libMesh
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Attributes | List of all members
libMesh::TransientRBConstruction Class Reference

This class is part of the rbOOmit framework. More...

#include <transient_rb_construction.h>

Inheritance diagram for libMesh::TransientRBConstruction:
[legend]

Public Types

typedef TransientRBConstruction sys_type
 The type of system. More...
 
typedef TransientSystem< RBConstructionParent
 The type of the parent. More...
 
typedef Number(* ValueFunctionPointer) (const Point &p, const Parameters &Parameters, const std::string &sys_name, const std::string &unknown_name)
 Projects arbitrary functions onto the current solution. More...
 
typedef Gradient(* GradientFunctionPointer) (const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name)
 
typedef std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> >::iterator vectors_iterator
 Vector iterator typedefs. More...
 
typedef std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> >::const_iterator const_vectors_iterator
 
typedef std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> >::iterator matrices_iterator
 Matrix iterator typedefs. More...
 
typedef std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> >::const_iterator const_matrices_iterator
 

Public Member Functions

 TransientRBConstruction (EquationSystems &es, const std::string &name, const unsigned int number)
 Constructor. More...
 
 TransientRBConstruction (TransientRBConstruction &&)=default
 Special functions. More...
 
 TransientRBConstruction (const TransientRBConstruction &)=delete
 
TransientRBConstructionoperator= (const TransientRBConstruction &)=delete
 
TransientRBConstructionoperator= (TransientRBConstruction &&)=delete
 
virtual ~TransientRBConstruction ()
 
virtual void clear () override
 Clear all the data structures associated with the system. More...
 
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. More...
 
virtual Real truth_solve (int write_interval) override
 Perform a truth solve at the current parameter. More...
 
virtual Real train_reduced_basis (const bool resize_rb_eval_data=true) override
 Train the reduced basis. More...
 
virtual void process_parameters_file (const std::string &parameters_filename) override
 Read in the parameters from file and set up the system accordingly. More...
 
virtual void print_info () const override
 Print out info that describes the current setup of this RBConstruction. More...
 
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. More...
 
virtual void assemble_all_affine_operators () override
 Assemble and store all the affine operators. More...
 
virtual void assemble_misc_matrices () override
 Override to assemble the L2 matrix as well. More...
 
void assemble_L2_matrix (SparseMatrix< Number > *input_matrix, bool apply_dirichlet_bc=true)
 Assemble the L2 matrix. More...
 
void assemble_mass_matrix (SparseMatrix< Number > *input_matrix)
 Assemble the mass matrix at the current parameter and store it in input_matrix. More...
 
void add_scaled_mass_matrix (Number scalar, SparseMatrix< Number > *input_matrix)
 Add the scaled mass matrix (assembled for the current parameter) to input_matrix. More...
 
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. More...
 
void set_L2_assembly (ElemAssembly &L2_assembly_in)
 Set the L2 object. More...
 
ElemAssemblyget_L2_assembly ()
 
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. More...
 
SparseMatrix< Number > * get_M_q (unsigned int q)
 Get a pointer to M_q. More...
 
SparseMatrix< Number > * get_non_dirichlet_M_q (unsigned int q)
 Get a pointer to non_dirichlet_M_q. More...
 
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. More...
 
virtual void truth_assembly () override
 Assemble the truth system in the transient linear case. More...
 
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 transient case. More...
 
void set_max_truth_solves (int max_truth_solves_in)
 
Real get_POD_tol () const
 Get/set POD_tol. More...
 
void set_POD_tol (const Real POD_tol_in)
 
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. More...
 
virtual void load_rb_solution () override
 Load the RB solution from the current time-level into the libMesh solution vector. More...
 
const NumericVector< Number > & get_error_temporal_data ()
 Get the column of temporal_data corresponding to the current time level. More...
 
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 each projection in RB_initial_condition_matrix. More...
 
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. More...
 
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. More...
 
sys_typesystem ()
 
virtual std::string system_type () const override
 
Number old_solution (const dof_id_type global_dof_number) const
 
Number older_solution (const dof_id_type global_dof_number) const
 
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 rhs. More...
 
void set_rb_evaluation (RBEvaluation &rb_eval_in)
 Set the RBEvaluation object. More...
 
RBEvaluationget_rb_evaluation ()
 Get a reference to the RBEvaluation object. More...
 
const RBEvaluationget_rb_evaluation () const
 
bool is_rb_eval_initialized () const
 
RBThetaExpansionget_rb_theta_expansion ()
 Get a reference to the RBThetaExpansion object that that belongs to rb_eval. More...
 
const RBThetaExpansionget_rb_theta_expansion () const
 
void set_rb_assembly_expansion (RBAssemblyExpansion &rb_assembly_expansion_in)
 Set the rb_assembly_expansion object. More...
 
RBAssemblyExpansionget_rb_assembly_expansion ()
 
Real train_reduced_basis_with_greedy (const bool resize_rb_eval_data)
 Train the reduced basis using the "Greedy algorithm.". More...
 
void enrich_basis_from_rhs_terms (const bool resize_rb_eval_data=true)
 This function computes one basis function for each rhs term. More...
 
void train_reduced_basis_with_POD ()
 Train the reduced basis using Proper Orthogonal Decomposition (POD). More...
 
virtual Real compute_max_error_bound ()
 (i) Compute the a posteriori error bound for each set of parameters in the training set, (ii) set current_parameters to the parameters that maximize the error bound, and (iii) return the maximum error bound. More...
 
const RBParametersget_greedy_parameter (unsigned int i)
 Return the parameters chosen during the i^th step of the Greedy algorithm. More...
 
void set_rel_training_tolerance (Real new_training_tolerance)
 Get/set the relative tolerance for the basis training. More...
 
Real get_rel_training_tolerance () const
 
void set_abs_training_tolerance (Real new_training_tolerance)
 Get/set the absolute tolerance for the basis training. More...
 
Real get_abs_training_tolerance () const
 
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. More...
 
bool get_normalize_rb_bound_in_greedy () const
 
virtual bool is_serial_training_type (const std::string &RB_training_type_in)
 
void set_RB_training_type (const std::string &RB_training_type_in)
 Get/set the string that determines the training type. More...
 
const std::string & get_RB_training_type () const
 
unsigned int get_Nmax () const
 Get/set Nmax, the maximum number of RB functions we are willing to compute. More...
 
virtual void set_Nmax (unsigned int Nmax)
 
virtual void load_basis_function (unsigned int i)
 Load the i^th RB function into the RBConstruction solution vector. More...
 
Real compute_residual_dual_norm_slow (const unsigned int N)
 The slow (but simple, non-error prone) way to compute the residual dual norm. More...
 
SparseMatrix< Number > * get_inner_product_matrix ()
 Get a pointer to inner_product_matrix. More...
 
const SparseMatrix< Number > * get_inner_product_matrix () const
 
SparseMatrix< Number > * get_non_dirichlet_inner_product_matrix ()
 Get the non-Dirichlet (or more generally no-constraints) version of the inner-product matrix. More...
 
const SparseMatrix< Number > * get_non_dirichlet_inner_product_matrix () const
 
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 with constraints. More...
 
const SparseMatrix< Number > * get_non_dirichlet_inner_product_matrix_if_avail () const
 
SparseMatrix< Number > * get_Aq (unsigned int q)
 Get a pointer to Aq. More...
 
SparseMatrix< Number > * get_non_dirichlet_Aq (unsigned int q)
 Get a pointer to non_dirichlet_Aq. More...
 
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. More...
 
NumericVector< Number > * get_Fq (unsigned int q)
 Get a pointer to Fq. More...
 
NumericVector< Number > * get_non_dirichlet_Fq (unsigned int q)
 Get a pointer to non-Dirichlet Fq. More...
 
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. More...
 
NumericVector< Number > * get_output_vector (unsigned int n, unsigned int q_l)
 Get a pointer to the n^th output. More...
 
NumericVector< Number > * get_non_dirichlet_output_vector (unsigned int n, unsigned int q_l)
 Get a pointer to non-Dirichlet output vector. More...
 
virtual void get_all_vectors (std::map< std::string, NumericVector< Number > *> &all_vectors)
 Get a map that stores pointers to all of the vectors. More...
 
virtual void get_output_vectors (std::map< std::string, NumericVector< Number > *> &all_vectors)
 Get a map that stores pointers to all of the vectors. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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 training computation. More...
 
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. More...
 
void print_basis_function_orthogonality () const
 Print out a matrix that shows the orthogonality of the RB basis functions. More...
 
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 algorithm. More...
 
void set_inner_product_assembly (ElemAssembly &inner_product_assembly_in)
 Set the rb_assembly_expansion object. More...
 
ElemAssemblyget_inner_product_assembly ()
 
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. More...
 
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. More...
 
virtual bool check_if_zero_truth_solve () const
 
void set_convergence_assertion_flag (bool flag)
 Setter for the flag determining if convergence should be checked after each solve. More...
 
bool get_preevaluate_thetas_flag () const
 Get/set flag to pre-evaluate the theta functions. More...
 
void set_preevaluate_thetas_flag (bool flag)
 
void set_quiet_mode (bool quiet_mode_in)
 Set the quiet_mode flag. More...
 
bool is_quiet () const
 Is the system in quiet mode? More...
 
void set_normalize_solution_snapshots (bool value)
 Set the boolean option that indicates if we normalization solution snapshots or not. More...
 
numeric_index_type get_n_training_samples () const
 Get the number of global training samples. More...
 
numeric_index_type get_local_n_training_samples () const
 Get the total number of training samples local to this processor. More...
 
numeric_index_type get_first_local_training_index () const
 Get the first local index of the training parameters. More...
 
numeric_index_type get_last_local_training_index () const
 Get the last local index of the training parameters. More...
 
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 should be used and whether or not we want the parameters to be scaled logarithmically. More...
 
virtual void load_training_set (const std::map< std::string, std::vector< RBParameter >> &new_training_set)
 Overwrite the training parameters with new_training_set. More...
 
void set_training_parameter_values (const std::string &param_name, const std::vector< RBParameter > &values)
 Overwrite the local training samples for param_name using values. More...
 
void broadcast_parameters (const unsigned int proc_id)
 Broadcasts parameters from processor proc_id to all processors. More...
 
void set_training_random_seed (int seed)
 Set the seed that is used to randomly generate training parameters. More...
 
void set_deterministic_training_parameter_name (const std::string &name)
 In some cases we only want to allow discrete parameter values, instead of parameters that may take any value in a specified interval. More...
 
const std::string & get_deterministic_training_parameter_name () const
 Get the name of the parameter that we will generate deterministic training parameters for. More...
 
virtual void reinit () override
 Reinitializes the member data fields associated with the system, so that, e.g., assemble() may be used. More...
 
virtual void assemble () override
 Prepares matrix and _dof_map for matrix assembly. More...
 
virtual void restrict_solve_to (const SystemSubset *subset, const SubsetSolveMode subset_solve_mode=SUBSET_ZERO) override
 After calling this method, any solve will be limited to the given subset. More...
 
virtual void solve () override
 Assembles & solves the linear system A*x=b. More...
 
virtual LinearSolver< Number > * get_linear_solver () const override
 
virtual void assembly (bool get_residual, bool get_jacobian, bool apply_heterogeneous_constraints=false, bool apply_no_constraints=false) override
 Assembles a residual in rhs and/or a jacobian in matrix, as requested. More...
 
unsigned int n_linear_iterations () const
 
Real final_linear_residual () const
 
void attach_shell_matrix (ShellMatrix< Number > *shell_matrix)
 This function enables the user to provide a shell matrix, i.e. More...
 
void detach_shell_matrix ()
 Detaches a shell matrix. More...
 
ShellMatrix< Number > * get_shell_matrix ()
 
virtual void create_static_condensation () override
 Request that static condensation be performed for this system. More...
 
virtual void disable_cache () override
 Avoids use of any cached data that might affect any solve result. More...
 
virtual std::pair< unsigned int, Realget_linear_solve_parameters () const
 
virtual void release_linear_solver (LinearSolver< Number > *) const
 Currently a no-op. More...
 
virtual void assemble_residual_derivatives (const ParameterVector &parameters) override
 Residual parameter derivative function. More...
 
virtual std::pair< unsigned int, Realsensitivity_solve (const ParameterVector &parameters) override
 Assembles & solves the linear system(s) (dR/du)*u_p = -dR/dp, for those parameters contained within parameters. More...
 
virtual std::pair< unsigned int, Realweighted_sensitivity_solve (const ParameterVector &parameters, const ParameterVector &weights) override
 Assembles & solves the linear system(s) (dR/du)*u_w = sum(w_p*-dR/dp), for those parameters p contained within parameters weighted by the values w_p found within weights. More...
 
virtual std::pair< unsigned int, Realadjoint_solve (const QoISet &qoi_indices=QoISet()) override
 Assembles & solves the linear system (dR/du)^T*z = dq/du, for those quantities of interest q specified by qoi_indices. More...
 
virtual std::pair< unsigned int, Realweighted_sensitivity_adjoint_solve (const ParameterVector &parameters, const ParameterVector &weights, const QoISet &qoi_indices=QoISet()) override
 Assembles & solves the linear system(s) (dR/du)^T*z_w = sum(w_p*(d^2q/dudp - d^2R/dudp*z)), for those parameters p contained within parameters, weighted by the values w_p found within weights. More...
 
virtual void adjoint_qoi_parameter_sensitivity (const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities) override
 Solves for the derivative of each of the system's quantities of interest q in qoi[qoi_indices] with respect to each parameter in parameters, placing the result for qoi i and parameter j into sensitivities[i][j]. More...
 
virtual void forward_qoi_parameter_sensitivity (const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities) override
 Solves for the derivative of each of the system's quantities of interest q in qoi[qoi_indices] with respect to each parameter in parameters, placing the result for qoi i and parameter j into sensitivities[i][j]. More...
 
virtual void qoi_parameter_hessian (const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &hessian) override
 For each of the system's quantities of interest q in qoi[qoi_indices], and for a vector of parameters p, the parameter sensitivity Hessian H_ij is defined as H_ij = (d^2 q)/(d p_i d p_j) This Hessian is the output of this method, where for each q_i, H_jk is stored in hessian.second_derivative(i,j,k). More...
 
virtual void qoi_parameter_hessian_vector_product (const QoISet &qoi_indices, const ParameterVector &parameters, const ParameterVector &vector, SensitivityData &product) override
 For each of the system's quantities of interest q in qoi[qoi_indices], and for a vector of parameters p, the parameter sensitivity Hessian H_ij is defined as H_ij = (d^2 q)/(d p_i d p_j) The Hessian-vector product, for a vector v_k in parameter space, is S_j = H_jk v_k This product is the output of this method, where for each q_i, S_j is stored in sensitivities[i][j]. More...
 
const SparseMatrix< Number > & get_system_matrix () const
 
SparseMatrix< Number > & get_system_matrix ()
 
StaticCondensationget_static_condensation ()
 
virtual void assemble_qoi (const QoISet &qoi_indices=QoISet()) override
 Prepares qoi for quantity of interest assembly, then calls user qoi function. More...
 
virtual void assemble_qoi_derivative (const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true) override
 Prepares adjoint_rhs for quantity of interest derivative assembly, then calls user qoi derivative function. More...
 
void init ()
 Initializes degrees of freedom on the current mesh. More...
 
virtual void reinit_constraints ()
 Reinitializes the constraints for this system. More...
 
virtual void reinit_mesh ()
 Reinitializes the system with a new mesh. More...
 
bool is_initialized () const
 
virtual void update ()
 Update the local values to reflect the solution on neighboring processors. More...
 
bool is_adjoint_already_solved () const
 Accessor for the adjoint_already_solved boolean. More...
 
void set_adjoint_already_solved (bool setting)
 Setter for the adjoint_already_solved boolean. More...
 
virtual void qoi_parameter_sensitivity (const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
 Solves for the derivative of each of the system's quantities of interest q in qoi[qoi_indices] with respect to each parameter in parameters, placing the result for qoi i and parameter j into sensitivities[i][j]. More...
 
virtual bool compare (const System &other_system, const Real threshold, const bool verbose) const
 
const std::string & name () const
 
void project_solution (FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr) const
 Projects arbitrary functions onto the current solution. More...
 
void project_solution (FEMFunctionBase< Number > *f, FEMFunctionBase< Gradient > *g=nullptr) const
 Projects arbitrary functions onto the current solution. More...
 
void project_solution (ValueFunctionPointer fptr, GradientFunctionPointer gptr, const Parameters &parameters) const
 This method projects an arbitrary function onto the solution via L2 projections and nodal interpolations on each element. More...
 
void project_vector (NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
 Projects arbitrary functions onto a vector of degree of freedom values for the current system. More...
 
void project_vector (NumericVector< Number > &new_vector, FEMFunctionBase< Number > *f, FEMFunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
 Projects arbitrary functions onto a vector of degree of freedom values for the current system. More...
 
void project_vector (ValueFunctionPointer fptr, GradientFunctionPointer gptr, const Parameters &parameters, NumericVector< Number > &new_vector, int is_adjoint=-1) const
 Projects arbitrary functions onto a vector of degree of freedom values for the current system. More...
 
void boundary_project_solution (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr)
 Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system. More...
 
void boundary_project_solution (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, ValueFunctionPointer fptr, GradientFunctionPointer gptr, const Parameters &parameters)
 Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system. More...
 
void boundary_project_vector (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
 Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system. More...
 
void boundary_project_vector (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, ValueFunctionPointer fptr, GradientFunctionPointer gptr, const Parameters &parameters, NumericVector< Number > &new_vector, int is_adjoint=-1) const
 Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system. More...
 
unsigned int number () const
 
void update_global_solution (std::vector< Number > &global_soln) const
 Fill the input vector global_soln so that it contains the global solution on all processors. More...
 
void update_global_solution (std::vector< Number > &global_soln, const processor_id_type dest_proc) const
 Fill the input vector global_soln so that it contains the global solution on processor dest_proc. More...
 
const MeshBaseget_mesh () const
 
MeshBaseget_mesh ()
 
const DofMapget_dof_map () const
 
DofMapget_dof_map ()
 
const EquationSystemsget_equation_systems () const
 
EquationSystemsget_equation_systems ()
 
bool active () const
 
void activate ()
 Activates the system. More...
 
void deactivate ()
 Deactivates the system. More...
 
void set_basic_system_only ()
 Sets the system to be "basic only": i.e. More...
 
vectors_iterator vectors_begin ()
 Beginning of vectors container. More...
 
const_vectors_iterator vectors_begin () const
 Beginning of vectors container. More...
 
vectors_iterator vectors_end ()
 End of vectors container. More...
 
const_vectors_iterator vectors_end () const
 End of vectors container. More...
 
matrices_iterator matrices_begin ()
 Beginning of matrices container. More...
 
const_matrices_iterator matrices_begin () const
 Beginning of matrices container. More...
 
matrices_iterator matrices_end ()
 End of matrices container. More...
 
const_matrices_iterator matrices_end () const
 End of matrices container. More...
 
NumericVector< Number > & add_vector (std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
 Adds the additional vector vec_name to this system. More...
 
void remove_vector (std::string_view vec_name)
 Removes the additional vector vec_name from this system. More...
 
bool & project_solution_on_reinit (void)
 Tells the System whether or not to project the solution vector onto new grids when the system is reinitialized. More...
 
bool have_vector (std::string_view vec_name) const
 
const NumericVector< Number > * request_vector (std::string_view vec_name) const
 
NumericVector< Number > * request_vector (std::string_view vec_name)
 
const NumericVector< Number > * request_vector (const unsigned int vec_num) const
 
NumericVector< Number > * request_vector (const unsigned int vec_num)
 
const NumericVector< Number > & get_vector (std::string_view vec_name) const
 
NumericVector< Number > & get_vector (std::string_view vec_name)
 
const NumericVector< Number > & get_vector (const unsigned int vec_num) const
 
NumericVector< Number > & get_vector (const unsigned int vec_num)
 
const std::string & vector_name (const unsigned int vec_num) const
 
const std::string & vector_name (const NumericVector< Number > &vec_reference) const
 
void set_vector_as_adjoint (const std::string &vec_name, int qoi_num)
 Allows one to set the QoI index controlling whether the vector identified by vec_name represents a solution from the adjoint (qoi_num >= 0) or primal (qoi_num == -1) space. More...
 
int vector_is_adjoint (std::string_view vec_name) const
 
void set_vector_preservation (const std::string &vec_name, bool preserve)
 Allows one to set the boolean controlling whether the vector identified by vec_name should be "preserved": projected to new meshes, saved, etc. More...
 
bool vector_preservation (std::string_view vec_name) const
 
NumericVector< Number > & add_adjoint_solution (unsigned int i=0)
 
NumericVector< Number > & get_adjoint_solution (unsigned int i=0)
 
const NumericVector< Number > & get_adjoint_solution (unsigned int i=0) const
 
NumericVector< Number > & add_sensitivity_solution (unsigned int i=0)
 
NumericVector< Number > & get_sensitivity_solution (unsigned int i=0)
 
const NumericVector< Number > & get_sensitivity_solution (unsigned int i=0) const
 
NumericVector< Number > & add_weighted_sensitivity_adjoint_solution (unsigned int i=0)
 
NumericVector< Number > & get_weighted_sensitivity_adjoint_solution (unsigned int i=0)
 
const NumericVector< Number > & get_weighted_sensitivity_adjoint_solution (unsigned int i=0) const
 
NumericVector< Number > & add_weighted_sensitivity_solution ()
 
NumericVector< Number > & get_weighted_sensitivity_solution ()
 
const NumericVector< Number > & get_weighted_sensitivity_solution () const
 
NumericVector< Number > & add_adjoint_rhs (unsigned int i=0)
 
NumericVector< Number > & get_adjoint_rhs (unsigned int i=0)
 
const NumericVector< Number > & get_adjoint_rhs (unsigned int i=0) const
 
NumericVector< Number > & add_sensitivity_rhs (unsigned int i=0)
 
NumericVector< Number > & get_sensitivity_rhs (unsigned int i=0)
 
const NumericVector< Number > & get_sensitivity_rhs (unsigned int i=0) const
 
unsigned int n_vectors () const
 
unsigned int n_matrices () const
 
unsigned int n_vars () const
 
unsigned int n_variable_groups () const
 
unsigned int n_components () const
 
dof_id_type n_dofs () const
 
dof_id_type n_active_dofs () const
 
dof_id_type n_constrained_dofs () const
 
dof_id_type n_local_constrained_dofs () const
 
dof_id_type n_local_dofs () const
 
unsigned int add_variable (std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
 Adds the variable var to the list of variables for this system. More...
 
unsigned int add_variable (std::string_view var, const Order order=FIRST, const FEFamily=LAGRANGE, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
 Adds the variable var to the list of variables for this system. More...
 
unsigned int add_variables (const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
 Adds the variable var to the list of variables for this system. More...
 
unsigned int add_variables (const std::vector< std::string > &vars, const Order order=FIRST, const FEFamily=LAGRANGE, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
 Adds the variable var to the list of variables for this system. More...
 
const Variablevariable (unsigned int var) const
 Return a constant reference to Variable var. More...
 
const VariableGroupvariable_group (unsigned int vg) const
 Return a constant reference to VariableGroup vg. More...
 
bool has_variable (std::string_view var) const
 
const std::string & variable_name (const unsigned int i) const
 
unsigned int variable_number (std::string_view var) const
 
void get_all_variable_numbers (std::vector< unsigned int > &all_variable_numbers) const
 Fills all_variable_numbers with all the variable numbers for the variables that have been added to this system. More...
 
unsigned int variable_scalar_number (std::string_view var, unsigned int component) const
 
unsigned int variable_scalar_number (unsigned int var_num, unsigned int component) const
 
const FETypevariable_type (const unsigned int i) const
 
const FETypevariable_type (std::string_view var) const
 
bool identify_variable_groups () const
 
void identify_variable_groups (const bool)
 Toggle automatic VariableGroup identification. More...
 
Real calculate_norm (const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=nullptr) const
 
Real calculate_norm (const NumericVector< Number > &v, const SystemNorm &norm, std::set< unsigned int > *skip_dimensions=nullptr) const
 
void read_header (Xdr &io, std::string_view version, const bool read_header=true, const bool read_additional_data=true, const bool read_legacy_format=false)
 Reads the basic data header for this System. More...
 
void read_legacy_data (Xdr &io, const bool read_additional_data=true)
 Reads additional data, namely vectors, for this System. More...
 
template<typename ValType >
void read_serialized_data (Xdr &io, const bool read_additional_data=true)
 Reads additional data, namely vectors, for this System. More...
 
void read_serialized_data (Xdr &io, const bool read_additional_data=true)
 Non-templated version for backward compatibility. More...
 
template<typename InValType >
std::size_t read_serialized_vectors (Xdr &io, const std::vector< NumericVector< Number > *> &vectors) const
 Read a number of identically distributed vectors. More...
 
std::size_t read_serialized_vectors (Xdr &io, const std::vector< NumericVector< Number > *> &vectors) const
 Non-templated version for backward compatibility. More...
 
template<typename InValType >
void read_parallel_data (Xdr &io, const bool read_additional_data)
 Reads additional data, namely vectors, for this System. More...
 
void read_parallel_data (Xdr &io, const bool read_additional_data)
 Non-templated version for backward compatibility. More...
 
void write_header (Xdr &io, std::string_view version, const bool write_additional_data) const
 Writes the basic data header for this System. More...
 
void write_serialized_data (Xdr &io, const bool write_additional_data=true) const
 Writes additional data, namely vectors, for this System. More...
 
std::size_t write_serialized_vectors (Xdr &io, const std::vector< const NumericVector< Number > *> &vectors) const
 Serialize & write a number of identically distributed vectors. More...
 
void write_parallel_data (Xdr &io, const bool write_additional_data) const
 Writes additional data, namely vectors, for this System. More...
 
std::string get_info () const
 
void attach_init_function (void fptr(EquationSystems &es, const std::string &name))
 Register a user function to use in initializing the system. More...
 
void attach_init_object (Initialization &init)
 Register a user class to use to initialize the system. More...
 
void attach_assemble_function (void fptr(EquationSystems &es, const std::string &name))
 Register a user function to use in assembling the system matrix and RHS. More...
 
void attach_assemble_object (Assembly &assemble)
 Register a user object to use in assembling the system matrix and RHS. More...
 
void attach_constraint_function (void fptr(EquationSystems &es, const std::string &name))
 Register a user function for imposing constraints. More...
 
void attach_constraint_object (Constraint &constrain)
 Register a user object for imposing constraints. More...
 
bool has_constraint_object () const
 
Constraintget_constraint_object ()
 Return the user object for imposing constraints. More...
 
void attach_QOI_function (void fptr(EquationSystems &es, const std::string &name, const QoISet &qoi_indices))
 Register a user function for evaluating the quantities of interest, whose values should be placed in System::qoi. More...
 
void attach_QOI_object (QOI &qoi)
 Register a user object for evaluating the quantities of interest, whose values should be placed in System::qoi. More...
 
void attach_QOI_derivative (void fptr(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints))
 Register a user function for evaluating derivatives of a quantity of interest with respect to test functions, whose values should be placed in System::rhs. More...
 
void attach_QOI_derivative_object (QOIDerivative &qoi_derivative)
 Register a user object for evaluating derivatives of a quantity of interest with respect to test functions, whose values should be placed in System::rhs. More...
 
virtual void user_initialization ()
 Calls user's attached initialization function, or is overridden by the user in derived classes. More...
 
virtual void user_assembly ()
 Calls user's attached assembly function, or is overridden by the user in derived classes. More...
 
virtual void user_constrain ()
 Calls user's attached constraint function, or is overridden by the user in derived classes. More...
 
virtual void user_QOI (const QoISet &qoi_indices)
 Calls user's attached quantity of interest function, or is overridden by the user in derived classes. More...
 
virtual void user_QOI_derivative (const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true)
 Calls user's attached quantity of interest derivative function, or is overridden by the user in derived classes. More...
 
virtual void restrict_vectors ()
 Restrict vectors after the mesh has coarsened. More...
 
virtual void prolong_vectors ()
 Prolong vectors after the mesh has refined. More...
 
Number current_solution (const dof_id_type global_dof_number) const
 
unsigned int n_qois () const
 Number of currently active quantities of interest. More...
 
void init_qois (unsigned int n_qois)
 Accessors for qoi and qoi_error_estimates vectors. More...
 
void set_qoi (unsigned int qoi_index, Number qoi_value)
 
void set_qoi (std::vector< Number > new_qoi)
 
Number get_qoi_value (unsigned int qoi_index) const
 
std::vector< Numberget_qoi_values () const
 Returns a copy of qoi, not a reference. More...
 
void set_qoi_error_estimate (unsigned int qoi_index, Number qoi_error_estimate)
 
Number get_qoi_error_estimate_value (unsigned int qoi_index) const
 
Number point_value (unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
 
Number point_value (unsigned int var, const Point &p, const Elem &e, const NumericVector< Number > *sol=nullptr) const
 
Number point_value (unsigned int var, const Point &p, const Elem *e) const
 Calls the version of point_value() which takes a reference. More...
 
Number point_value (unsigned int var, const Point &p, const NumericVector< Number > *sol) const
 Calls the parallel version of point_value(). More...
 
Gradient point_gradient (unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
 
Gradient point_gradient (unsigned int var, const Point &p, const Elem &e, const NumericVector< Number > *sol=nullptr) const
 
Gradient point_gradient (unsigned int var, const Point &p, const Elem *e) const
 Calls the version of point_gradient() which takes a reference. More...
 
Gradient point_gradient (unsigned int var, const Point &p, const NumericVector< Number > *sol) const
 Calls the parallel version of point_gradient(). More...
 
Tensor point_hessian (unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
 
Tensor point_hessian (unsigned int var, const Point &p, const Elem &e, const NumericVector< Number > *sol=nullptr) const
 
Tensor point_hessian (unsigned int var, const Point &p, const Elem *e) const
 Calls the version of point_hessian() which takes a reference. More...
 
Tensor point_hessian (unsigned int var, const Point &p, const NumericVector< Number > *sol) const
 Calls the parallel version of point_hessian(). More...
 
void local_dof_indices (const unsigned int var, std::set< dof_id_type > &var_indices) const
 Fills the std::set with the degrees of freedom on the local processor corresponding the the variable number passed in. More...
 
void zero_variable (NumericVector< Number > &v, unsigned int var_num) const
 Zeroes all dofs in v that correspond to variable number var_num. More...
 
bool get_project_with_constraints ()
 Setter and getter functions for project_with_constraints boolean. More...
 
void set_project_with_constraints (bool _project_with_constraints)
 
bool & hide_output ()
 
void projection_matrix (SparseMatrix< Number > &proj_mat) const
 This method creates a projection matrix which corresponds to the operation of project_vector between old and new solution spaces. More...
 
SparseMatrix< Number > & add_matrix (std::string_view mat_name, ParallelType type=PARALLEL, MatrixBuildType mat_build_type=MatrixBuildType::AUTOMATIC)
 Adds the additional matrix mat_name to this system. More...
 
template<template< typename > class>
SparseMatrix< Number > & add_matrix (std::string_view mat_name, ParallelType=PARALLEL)
 Adds the additional matrix mat_name to this system. More...
 
SparseMatrix< Number > & add_matrix (std::string_view mat_name, std::unique_ptr< SparseMatrix< Number >> matrix, ParallelType type=PARALLEL)
 Adds the additional matrix mat_name to this system. More...
 
void remove_matrix (std::string_view mat_name)
 Removes the additional matrix mat_name from this system. More...
 
bool have_matrix (std::string_view mat_name) const
 
const SparseMatrix< Number > * request_matrix (std::string_view mat_name) const
 
SparseMatrix< Number > * request_matrix (std::string_view mat_name)
 
const SparseMatrix< Number > & get_matrix (std::string_view mat_name) const
 
SparseMatrix< Number > & get_matrix (std::string_view mat_name)
 
void prefer_hash_table_matrix_assembly (bool preference)
 Sets whether to use hash table matrix assembly if the matrix sub-classes support it. More...
 
void prefix_with_name (bool value)
 Instructs this system to prefix solve options with its name for solvers that leverage prefixes. More...
 
bool prefix_with_name () const
 
std::string prefix () const
 
bool has_static_condensation () const
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 
void initialize_parameters (const RBParameters &mu_min_in, const RBParameters &mu_max_in, const std::map< std::string, std::vector< Real >> &discrete_parameter_values)
 Initialize the parameter ranges and set current_parameters. More...
 
void initialize_parameters (const RBParametrized &rb_parametrized)
 Initialize the parameter ranges and set current_parameters. More...
 
unsigned int get_n_params () const
 Get the number of parameters. More...
 
unsigned int get_n_continuous_params () const
 Get the number of continuous parameters. More...
 
unsigned int get_n_discrete_params () const
 Get the number of discrete parameters. More...
 
std::set< std::string > get_parameter_names () const
 Get a set that stores the parameter names. More...
 
const RBParametersget_parameters () const
 Get the current parameters. More...
 
bool set_parameters (const RBParameters &params)
 Set the current parameters to params The parameters are checked for validity; an error is thrown if the number of parameters or samples is different than expected. More...
 
const RBParametersget_parameters_min () const
 Get an RBParameters object that specifies the minimum allowable value for each parameter. More...
 
const RBParametersget_parameters_max () const
 Get an RBParameters object that specifies the maximum allowable value for each parameter. More...
 
Real get_parameter_min (const std::string &param_name) const
 Get minimum allowable value of parameter param_name. More...
 
Real get_parameter_max (const std::string &param_name) const
 Get maximum allowable value of parameter param_name. More...
 
void print_parameters () const
 Print the current parameters. More...
 
void write_parameter_data_to_files (const std::string &continuous_param_file_name, const std::string &discrete_param_file_name, const bool write_binary_data)
 Write out the parameter ranges to files. More...
 
void read_parameter_data_from_files (const std::string &continuous_param_file_name, const std::string &discrete_param_file_name, const bool read_binary_data)
 Read in the parameter ranges from files. More...
 
bool is_discrete_parameter (const std::string &mu_name) const
 Is parameter mu_name discrete? More...
 
const std::map< std::string, std::vector< Real > > & get_discrete_parameter_values () const
 Get a const reference to the discrete parameter values. More...
 
void print_discrete_parameter_values () const
 Print out all the discrete parameter values. More...
 
Real get_delta_t () const
 Get/set delta_t, the time-step size. More...
 
void set_delta_t (const Real delta_t_in)
 
Real get_euler_theta () const
 Get/set euler_theta, parameter that determines the temporal discretization. More...
 
void set_euler_theta (const Real euler_theta_in)
 
unsigned int get_time_step () const
 Get/set the current time-step. More...
 
void set_time_step (const unsigned int k)
 
unsigned int get_n_time_steps () const
 Get/set the total number of time-steps. More...
 
void set_n_time_steps (const unsigned int K)
 
Real get_control (const unsigned int k) const
 Get/set the RHS control. More...
 
void set_control (const std::vector< Real > &control)
 
void process_temporal_parameters_file (const std::string &parameters_filename)
 Read in and initialize parameters from parameters_filename. More...
 
void pull_temporal_discretization_data (RBTemporalDiscretization &other)
 Pull the temporal discretization data from other. More...
 

Static Public Member Functions

static void print_info (std::ostream &out_stream=libMesh::out)
 Prints the reference information, by default to libMesh::out. More...
 
static void print_info (std::ostream &out_stream=libMesh::out)
 Prints the reference information, by default to libMesh::out. More...
 
static std::unique_ptr< DirichletBoundarybuild_zero_dirichlet_boundary_object ()
 It's helpful to be able to generate a DirichletBoundary that stores a ZeroFunction in order to impose Dirichlet boundary conditions. More...
 
static std::pair< std::size_t, std::size_t > generate_training_parameters_random (const Parallel::Communicator &communicator, const std::map< std::string, bool > &log_param_scale, std::map< std::string, std::vector< RBParameter >> &local_training_parameters_in, const unsigned int n_global_training_samples_in, const RBParameters &min_parameters, const RBParameters &max_parameters, const int training_parameters_random_seed=-1, const bool serial_training_set=false)
 Static helper function for generating a randomized set of parameters. More...
 
static std::pair< std::size_t, std::size_t > generate_training_parameters_deterministic (const Parallel::Communicator &communicator, const std::map< std::string, bool > &log_param_scale, std::map< std::string, std::vector< RBParameter >> &local_training_parameters_in, const unsigned int n_global_training_samples_in, const RBParameters &min_parameters, const RBParameters &max_parameters, const bool serial_training_set=false)
 Static helper function for generating a deterministic set of parameters. More...
 
static std::string get_info ()
 Gets a string containing the reference information. More...
 
static std::string get_info ()
 Gets a string containing the reference information. More...
 
static unsigned int n_objects ()
 Prints the number of outstanding (created, but not yet destroyed) objects. More...
 
static unsigned int n_objects ()
 Prints the number of outstanding (created, but not yet destroyed) objects. More...
 
static void enable_print_counter_info ()
 Methods to enable/disable the reference counter output from print_info() More...
 
static void enable_print_counter_info ()
 Methods to enable/disable the reference counter output from print_info() More...
 
static void disable_print_counter_info ()
 
static void disable_print_counter_info ()
 
static Real get_closest_value (Real value, const std::vector< Real > &list_of_values)
 

Public Attributes

std::unique_ptr< SparseMatrix< Number > > L2_matrix
 The L2 matrix. More...
 
std::unique_ptr< SparseMatrix< Number > > non_dirichlet_L2_matrix
 The L2 matrix without Dirichlet conditions enforced. More...
 
std::vector< std::unique_ptr< SparseMatrix< Number > > > M_q_vector
 Vector storing the Q_m matrices from the mass operator. More...
 
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 conditions enforced. More...
 
std::vector< std::vector< Number > > truth_outputs_all_k
 The truth outputs for all time-levels from the most recent truth_solve. More...
 
bool nonzero_initialization
 Boolean flag to indicate whether we are using a non-zero initialization. More...
 
bool compute_truth_projection_error
 Boolean flag that indicates whether we will compute the projection error for the truth solution into the RB space (at every time level). More...
 
std::string init_filename
 The filename of the file containing the initial condition projected onto the truth mesh. More...
 
NumericVector< Number > * old_local_solution
 All the values I need to compute my contribution to the simulation at hand. More...
 
NumericVector< Number > * older_local_solution
 All the values I need to compute my contribution to the simulation at hand. More...
 
std::vector< Realtraining_error_bounds
 Vector storing the values of the error bound for each parameter in the training set — the parameter giving the largest error bound is chosen for the next snapshot in the Greedy basis training. More...
 
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 the system matrix is set to inner_product_matrix. More...
 
LinearSolver< Number > * extra_linear_solver
 Also, we store a pointer to an extra linear solver. More...
 
std::unique_ptr< SparseMatrix< Number > > inner_product_matrix
 The inner product matrix. More...
 
std::vector< Numbertruth_outputs
 Vector storing the truth output values from the most recent truth solve. More...
 
std::vector< std::vector< Number > > output_dual_innerprods
 The vector storing the dual norm inner product terms for each output. More...
 
std::vector< std::unique_ptr< NumericVector< Number > > > Fq_representor
 Vector storing the residual representors associated with the right-hand side. More...
 
std::vector< NumberFq_representor_innerprods
 Vectors storing the residual representor inner products to be used in computing the residuals online. More...
 
bool skip_residual_in_train_reduced_basis
 Boolean flag to indicate if we skip residual calculations in train_reduced_basis. More...
 
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. More...
 
bool impose_internal_fluxes
 Boolean flag to indicate whether we impose "fluxes" (i.e. More...
 
bool skip_degenerate_sides
 In some cases meshes are intentionally created with degenerate sides as a way to represent, say, triangles using a hex-only mesh. More...
 
bool compute_RB_inner_product
 Boolean flag to indicate whether we compute the RB_inner_product_matrix. More...
 
bool store_non_dirichlet_operators
 Boolean flag to indicate whether we store a second copy of each affine operator and vector which does not have Dirichlet bcs enforced. More...
 
bool store_untransformed_basis
 Boolean flag to indicate whether we store a second copy of the basis without constraints or dof transformations applied to it. More...
 
bool use_empty_rb_solve_in_greedy
 A boolean flag to indicate whether or not we initialize the Greedy algorithm by performing rb_solves on the training set with an "empty" (i.e. More...
 
bool Fq_representor_innerprods_computed
 A boolean flag to indicate whether or not the Fq representor norms have already been computed — used to make sure that we don't recompute them unnecessarily. More...
 
SparseMatrix< Number > * matrix
 The system matrix. More...
 
bool zero_out_matrix_and_rhs
 By default, the system will zero out the matrix and the right hand side. More...
 
std::unique_ptr< LinearSolver< Number > > linear_solver
 This class handles all the details of interfacing with various linear algebra packages like PETSc or LASPACK. More...
 
NumericVector< Number > * rhs
 The system matrix. More...
 
Parameters parameters
 Parameters for the system. If a parameter is not provided, it should be retrieved from the EquationSystems. More...
 
bool assemble_before_solve
 Flag which tells the system to whether or not to call the user assembly function during each call to solve(). More...
 
bool use_fixed_solution
 A boolean to be set to true by systems using elem_fixed_solution, for optional use by e.g. More...
 
int extra_quadrature_order
 A member int that can be employed to indicate increased or reduced quadrature order. More...
 
std::unique_ptr< NumericVector< Number > > solution
 Data structure to hold solution values. More...
 
std::unique_ptr< NumericVector< Number > > current_local_solution
 All the values I need to compute my contribution to the simulation at hand. More...
 
Real time
 For time-dependent problems, this is the time t at the beginning of the current timestep. More...
 
bool verbose_mode
 Public boolean to toggle verbose mode. More...
 

Protected Types

typedef std::map< std::string, std::pair< unsigned int, unsigned int > > Counts
 Data structure to log the information. More...
 
typedef std::map< std::string, std::pair< unsigned int, unsigned int > > Counts
 Data structure to log the information. More...
 

Protected Member Functions

virtual void allocate_data_structures () override
 Helper function that actually allocates all the data structures required by this class. More...
 
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. More...
 
virtual void initialize_truth ()
 This function imposes a truth initial condition, defaults to zero initial condition if the flag nonzero_initialization is true. More...
 
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. More...
 
void add_IC_to_RB_space ()
 Initialize RB space by adding the truth initial condition as the first RB basis function. More...
 
virtual void enrich_RB_space () override
 Add a new basis functions to the RB space. More...
 
virtual void update_system () override
 Update the system after enriching the RB space. More...
 
virtual void update_RB_system_matrices () override
 Compute the reduced basis matrices for the current basis. More...
 
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. More...
 
Number set_error_temporal_data ()
 Set column k (i.e. More...
 
virtual void re_update () override
 Re-update the local values when the mesh has changed. More...
 
virtual std::unique_ptr< DGFEMContextbuild_context ()
 Builds a DGFEMContext object with enough information to do evaluations on each element. More...
 
void update_greedy_param_list ()
 Update the list of Greedily chosen parameters with current_parameters. More...
 
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 routines, then adds the scaled result to input_matrix and/or input_vector. More...
 
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 assembled into their global counterparts. More...
 
virtual void post_process_truth_solution ()
 Similarly, provide an opportunity to post-process the truth solution after the solve is complete. More...
 
virtual void set_context_solution_vec (NumericVector< Number > &vec)
 Set current_local_solution = vec so that we can access vec from FEMContext during assembly. More...
 
virtual void assemble_all_affine_vectors ()
 Assemble and store the affine RHS vectors. More...
 
virtual void assemble_all_output_vectors ()
 Assemble and store the output vectors. More...
 
virtual void compute_output_dual_innerprods ()
 Compute and store the dual norm of each output functional. More...
 
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. More...
 
virtual Real get_RB_error_bound ()
 
virtual void init_context (FEMContext &)
 Initialize the FEMContext prior to performing an element loop. More...
 
bool get_convergence_assertion_flag () const
 Getter for the flag determining if convergence should be checked after each solve. More...
 
void check_convergence (LinearSolver< Number > &input_solver)
 Check if the linear solver reports convergence. More...
 
unsigned int get_current_training_parameter_index () const
 Get/set the current training parameter index. More...
 
void set_current_training_parameter_index (unsigned int index)
 
const std::vector< Number > & get_evaluated_thetas (unsigned int training_parameter_index) const
 Return the evaluated theta functions at the given training parameter index. More...
 
virtual void preevaluate_thetas ()
 
void reset_preevaluate_thetas_completed ()
 Reset the _preevaluate_thetas_completed flag to false. More...
 
virtual void init_data ()
 Initializes the member data fields associated with the system, so that, e.g., assemble() may be used. More...
 
RBParameters get_params_from_training_set (unsigned int global_index)
 Return the RBParameters in index global_index of the global training set. More...
 
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. More...
 
virtual void set_params_from_training_set_and_broadcast (unsigned int global_index)
 Load the specified training parameter and then broadcast to all processors. More...
 
virtual void add_matrices () override
 Adds the system matrix. More...
 
template<typename T >
void setup_static_condensation_preconditioner (T &solver)
 Sets up the static condensation preconditioner for the supplied solver. More...
 
void project_vector (NumericVector< Number > &, int is_adjoint=-1) const
 Projects the vector defined on the old mesh onto the new mesh. More...
 
void project_vector (const NumericVector< Number > &, NumericVector< Number > &, int is_adjoint=-1) const
 Projects the vector defined on the old mesh onto the new mesh. More...
 
virtual void init_matrices ()
 Initializes the matrices associated with this system. More...
 
bool can_add_matrices () const
 
void solve_for_unconstrained_dofs (NumericVector< Number > &, int is_adjoint=-1) const
 
virtual bool condense_constrained_dofs () const
 Whether this object should condense out constrained degrees of freedom. More...
 
void increment_constructor_count (const std::string &name) noexcept
 Increments the construction counter. More...
 
void increment_constructor_count (const std::string &name) noexcept
 Increments the construction counter. More...
 
void increment_destructor_count (const std::string &name) noexcept
 Increments the destruction counter. More...
 
void increment_destructor_count (const std::string &name) noexcept
 Increments the destruction counter. More...
 

Static Protected Member Functions

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 all processors. More...
 

Protected Attributes

Real POD_tol
 If positive, this tolerance determines the number of POD modes we add to the space on a call to enrich_RB_space(). More...
 
int max_truth_solves
 Maximum number of truth solves in the POD-Greedy. More...
 
ElemAssemblyL2_assembly
 Function pointer for assembling the L2 matrix. More...
 
DenseVector< NumberRB_ic_proj_rhs_all_N
 The vector that stores the right-hand side for the initial condition projections. More...
 
unsigned int Nmax
 Maximum number of reduced basis functions we are willing to use. More...
 
unsigned int delta_N
 The number of basis functions that we add at each greedy step. More...
 
bool output_dual_innerprods_computed
 A boolean flag to indicate whether or not the output dual norms have already been computed — used to make sure that we don't recompute them unnecessarily. More...
 
bool assert_convergence
 A boolean flag to indicate whether to check for proper convergence after each solve. More...
 
bool quiet_mode
 Flag to indicate whether we print out extra information during the Offline stage. More...
 
bool serial_training_set
 This boolean flag indicates whether or not the training set should be the same on all processors. More...
 
bool _normalize_solution_snapshots
 Set this boolean to true if we want to normalize solution snapshots used in training to have norm of 1. More...
 
std::unique_ptr< NumericVector< Number > > inner_product_storage_vector
 We keep an extra temporary vector that is useful for performing inner products (avoids unnecessary memory allocation/deallocation). More...
 
unsigned int _n_linear_iterations
 The number of linear iterations required to solve the linear system Ax=b. More...
 
Real _final_linear_residual
 The final residual for the linear system Ax=b. More...
 
ShellMatrix< Number > * _shell_matrix
 User supplies shell matrix or nullptr if no shell matrix is used. More...
 
const SystemSubset_subset
 The current subset on which to solve (or nullptr if none). More...
 
SubsetSolveMode _subset_solve_mode
 If restrict-solve-to-subset mode is active, this member decides what happens with the dofs outside the subset. More...
 
const Parallel::Communicator_communicator
 

Static Protected Attributes

static Counts _counts
 Actually holds the data. More...
 
static Counts _counts
 Actually holds the data. More...
 
static Threads::atomic< unsigned int_n_objects
 The number of objects. More...
 
static Threads::atomic< unsigned int_n_objects
 The number of objects. More...
 
static Threads::spin_mutex _mutex
 Mutual exclusion object to enable thread-safe reference counting. More...
 
static Threads::spin_mutex _mutex
 Mutual exclusion object to enable thread-safe reference counting. More...
 
static bool _enable_print_counter = true
 Flag to control whether reference count information is printed when print_info is called. More...
 
static bool _enable_print_counter = true
 Flag to control whether reference count information is printed when print_info is called. More...
 

Private Attributes

std::vector< std::unique_ptr< NumericVector< Number > > > temporal_data
 Dense matrix to store the data that we use for the temporal POD. More...
 

Detailed Description

This class is part of the rbOOmit framework.

TransientRBConstruction extends RBConstruction to add functionality relevant in the time-dependent case.

We can handle time controls on the RHS as h(t)*f(x, \( \mu \)). See Martin Grepl's thesis for more details.

Author
David J. Knezevic
Date
2009

Definition at line 48 of file transient_rb_construction.h.

Member Typedef Documentation

◆ const_matrices_iterator

typedef std::map<std::string, std::unique_ptr<SparseMatrix<Number> >, std::less<> >::const_iterator libMesh::System::const_matrices_iterator
inherited

Definition at line 784 of file system.h.

◆ const_vectors_iterator

typedef std::map<std::string, std::unique_ptr<NumericVector<Number> >, std::less<> >::const_iterator libMesh::System::const_vectors_iterator
inherited

Definition at line 758 of file system.h.

◆ Counts [1/2]

typedef std::map<std::string, std::pair<unsigned int, unsigned int> > libMesh::ReferenceCounter::Counts
protectedinherited

Data structure to log the information.

The log is identified by the class name.

Definition at line 119 of file reference_counter.h.

◆ Counts [2/2]

typedef std::map<std::string, std::pair<unsigned int, unsigned int> > libMesh::ReferenceCounter::Counts
protectedinherited

Data structure to log the information.

The log is identified by the class name.

Definition at line 119 of file reference_counter.h.

◆ GradientFunctionPointer

typedef Gradient(* libMesh::System::GradientFunctionPointer) (const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name)
inherited

Definition at line 541 of file system.h.

◆ matrices_iterator

typedef std::map<std::string, std::unique_ptr<SparseMatrix<Number> >, std::less<> >::iterator libMesh::System::matrices_iterator
inherited

Matrix iterator typedefs.

Definition at line 783 of file system.h.

◆ Parent

The type of the parent.

Definition at line 79 of file transient_rb_construction.h.

◆ sys_type

The type of system.

Definition at line 74 of file transient_rb_construction.h.

◆ ValueFunctionPointer

typedef Number(* libMesh::System::ValueFunctionPointer) (const Point &p, const Parameters &Parameters, const std::string &sys_name, const std::string &unknown_name)
inherited

Projects arbitrary functions onto the current solution.

The function value fptr and its gradient gptr are represented by function pointers. A gradient gptr is only required/used for projecting onto finite element spaces with continuous derivatives.

Definition at line 537 of file system.h.

◆ vectors_iterator

typedef std::map<std::string, std::unique_ptr<NumericVector<Number> >, std::less<> >::iterator libMesh::System::vectors_iterator
inherited

Vector iterator typedefs.

Definition at line 757 of file system.h.

Constructor & Destructor Documentation

◆ TransientRBConstruction() [1/3]

TransientRBConstruction::TransientRBConstruction ( EquationSystems es,
const std::string &  name,
const unsigned int  number 
)

Constructor.

Optionally initializes required data structures.

Definition at line 61 of file transient_rb_construction.C.

References libMesh::RBConstruction::compute_RB_inner_product, and libMesh::RBConstruction::exit_on_repeated_greedy_parameters.

64  : Parent(es, name_in, number_in),
69  init_filename(""),
70  POD_tol(-1.),
71  max_truth_solves(-1),
72  L2_assembly(nullptr)
73 {
74  // Indicate that we need to compute the RB
75  // inner product matrix in this case
77 
78  // We should not necessarily exit the greedy due to repeated parameters in
79  // the transient case
81 }
std::unique_ptr< SparseMatrix< Number > > L2_matrix
The L2 matrix.
int max_truth_solves
Maximum number of truth solves in the POD-Greedy.
bool compute_RB_inner_product
Boolean flag to indicate whether we compute the RB_inner_product_matrix.
TransientSystem< RBConstruction > Parent
The type of the parent.
Real POD_tol
If positive, this tolerance determines the number of POD modes we add to the space on a call to enric...
std::string init_filename
The filename of the file containing the initial condition projected onto the truth mesh...
static std::unique_ptr< SparseMatrix< Number > > 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.
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.
ElemAssembly * L2_assembly
Function pointer for assembling the L2 matrix.
bool compute_truth_projection_error
Boolean flag that indicates whether we will compute the projection error for the truth solution into ...
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...

◆ TransientRBConstruction() [2/3]

libMesh::TransientRBConstruction::TransientRBConstruction ( TransientRBConstruction &&  )
default

Special functions.

  • This class has the same restrictions/defaults as its base class.
  • Destructor is defaulted out-of-line

◆ TransientRBConstruction() [3/3]

libMesh::TransientRBConstruction::TransientRBConstruction ( const TransientRBConstruction )
delete

◆ ~TransientRBConstruction()

TransientRBConstruction::~TransientRBConstruction ( )
virtualdefault

Member Function Documentation

◆ activate()

void libMesh::System::activate ( )
inlineinherited

Activates the system.

Only active systems are solved.

Definition at line 2398 of file system.h.

References libMesh::System::_active.

2399 {
2400  _active = true;
2401 }
bool _active
Flag stating if the system is active or not.
Definition: system.h:2222

◆ active()

bool libMesh::System::active ( ) const
inlineinherited
Returns
true if the system is active, false otherwise. An active system will be solved.

Definition at line 2390 of file system.h.

References libMesh::System::_active.

2391 {
2392  return _active;
2393 }
bool _active
Flag stating if the system is active or not.
Definition: system.h:2222

◆ add_adjoint_rhs()

NumericVector< Number > & libMesh::System::add_adjoint_rhs ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's adjoint rhs vectors, by default the one corresponding to the first qoi. Creates the vector if it doesn't already exist.

Definition at line 1297 of file system.C.

References libMesh::System::add_vector().

Referenced by libMesh::ExplicitSystem::assemble_qoi_derivative(), and libMesh::FEMSystem::assemble_qoi_derivative().

1298 {
1299  std::ostringstream adjoint_rhs_name;
1300  adjoint_rhs_name << "adjoint_rhs" << i;
1301 
1302  return this->add_vector(adjoint_rhs_name.str(), false);
1303 }
NumericVector< Number > & add_vector(std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Adds the additional vector vec_name to this system.
Definition: system.C:768

◆ add_adjoint_solution()

NumericVector< Number > & libMesh::System::add_adjoint_solution ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's adjoint solution vectors, by default the one corresponding to the first qoi. Creates the vector if it doesn't already exist.

Definition at line 1233 of file system.C.

References libMesh::System::add_vector(), and libMesh::System::set_vector_as_adjoint().

Referenced by libMesh::ImplicitSystem::adjoint_solve().

1234 {
1235  std::ostringstream adjoint_name;
1236  adjoint_name << "adjoint_solution" << i;
1237 
1238  NumericVector<Number> & returnval = this->add_vector(adjoint_name.str());
1239  this->set_vector_as_adjoint(adjoint_name.str(), i);
1240  return returnval;
1241 }
void set_vector_as_adjoint(const std::string &vec_name, int qoi_num)
Allows one to set the QoI index controlling whether the vector identified by vec_name represents a so...
Definition: system.C:1160
NumericVector< Number > & add_vector(std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Adds the additional vector vec_name to this system.
Definition: system.C:768
template class LIBMESH_EXPORT NumericVector< Number >

◆ add_IC_to_RB_space()

void TransientRBConstruction::add_IC_to_RB_space ( )
protected

Initialize RB space by adding the truth initial condition as the first RB basis function.

Definition at line 725 of file transient_rb_construction.C.

References libMesh::RBEvaluation::basis_functions, libMesh::ParallelObject::comm(), libMesh::NumericVector< T >::dot(), libMesh::RBEvaluation::get_basis_function(), libMesh::RBConstruction::get_delta_N(), libMesh::RBConstruction::get_non_dirichlet_inner_product_matrix_if_avail(), libMesh::RBConstruction::get_rb_evaluation(), libMesh::NumericVector< T >::init(), initialize_truth(), libMesh::RBConstructionBase< LinearImplicitSystem >::inner_product_storage_vector, libMesh::libmesh_real(), libMesh::System::n_dofs(), libMesh::System::n_local_dofs(), nonzero_initialization, libMesh::PARALLEL, libMesh::Real, libMesh::NumericVector< T >::scale(), set_delta_N(), libMesh::System::solution, update_system(), and libMesh::SparseMatrix< T >::vector_mult().

726 {
727  LOG_SCOPE("add_IC_to_RB_space()", "TransientRBConstruction");
728 
729  libmesh_error_msg_if(get_rb_evaluation().get_n_basis_functions() > 0,
730  "Error: Should not call TransientRBConstruction::add_IC_to_RB_space() "
731  "on a system that already contains basis functions.");
732 
733  libmesh_error_msg_if(!nonzero_initialization,
734  "Error: Should not call TransientRBConstruction::add_IC_to_RB_space() "
735  "when nonzero_initialization==false.");
736 
738 
739  // load the new basis function into the basis_functions vector.
741  NumericVector<Number> & current_bf = get_rb_evaluation().get_basis_function(get_rb_evaluation().get_n_basis_functions()-1);
742  current_bf.init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
743  current_bf = *solution;
744 
745  // We can just set the norm to 1.
747 
748  Real current_bf_norm = libmesh_real(std::sqrt( current_bf.dot(*inner_product_storage_vector) ));
749  current_bf.scale(1./current_bf_norm);
750 
751  unsigned int saved_delta_N = get_delta_N();
752  set_delta_N(1);
753  update_system();
754  set_delta_N(saved_delta_N);
755 }
T libmesh_real(T a)
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...
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...
const Parallel::Communicator & comm() const
dof_id_type n_local_dofs() const
Definition: system.C:158
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.
dof_id_type n_dofs() const
Definition: system.C:121
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...
NumericVector< Number > & get_basis_function(unsigned int i)
Get a reference to the i^th basis function.
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
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...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
SparseMatrix< Number > * get_non_dirichlet_inner_product_matrix_if_avail()
Get the non-Dirichlet inner-product matrix if it&#39;s available, otherwise get the inner-product matrix ...
static std::unique_ptr< NumericVector< Number > > 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...
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.
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.
template class LIBMESH_EXPORT NumericVector< Number >
virtual void update_system() override
Update the system after enriching the RB space.

◆ add_matrices()

void libMesh::ImplicitSystem::add_matrices ( )
overrideprotectedvirtualinherited

Adds the system matrix.

Reimplemented from libMesh::System.

Definition at line 109 of file implicit_system.C.

References libMesh::System::add_matrices(), libMesh::System::add_matrix(), libMesh::libmesh_assert(), libMesh::ImplicitSystem::matrix, and libMesh::System::n_matrices().

110 {
112 
113  // Possible that we cleared the _matrices but
114  // forgot to update the matrix pointer?
115  if (this->n_matrices() == 0)
116  matrix = nullptr;
117 
118  // Only need to add the matrix if it isn't there
119  // already!
120  if (matrix == nullptr)
121  matrix = &(this->add_matrix ("System Matrix"));
122 
124 }
virtual void add_matrices()
Insertion point for adding matrices in derived classes before init_matrices() is called.
Definition: system.h:1964
libmesh_assert(ctx)
unsigned int n_matrices() const
Definition: system.h:2699
SparseMatrix< Number > * matrix
The system matrix.
SparseMatrix< Number > & add_matrix(std::string_view mat_name, ParallelType type=PARALLEL, MatrixBuildType mat_build_type=MatrixBuildType::AUTOMATIC)
Adds the additional matrix mat_name to this system.
Definition: system.C:1010

◆ add_matrix() [1/3]

SparseMatrix< Number > & libMesh::System::add_matrix ( std::string_view  mat_name,
ParallelType  type = PARALLEL,
MatrixBuildType  mat_build_type = MatrixBuildType::AUTOMATIC 
)
inherited

Adds the additional matrix mat_name to this system.

Only allowed prior to assemble(). All additional matrices have the same sparsity pattern as the matrix used during solution. When not System but the user wants to initialize the main/system matrix, then all the additional matrices, if existent, have to be initialized by the user, too.

This non-template method will add a derived matrix type corresponding to the solver package. If the user wishes to specify the matrix type to add, use the templated add_matrix method instead

Parameters
mat_nameA name for the matrix
typeThe serial/parallel/ghosted type of the matrix
mat_build_typeThe matrix type to build

Definition at line 1010 of file system.C.

References libMesh::System::_matrices, libMesh::System::_matrix_types, libMesh::SparseMatrix< T >::build(), libMesh::ParallelObject::comm(), libMesh::default_solver_package(), libMesh::DIAGONAL, libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::DofMap::get_static_condensation(), libMesh::System::has_static_condensation(), libMesh::if(), libMesh::System::late_matrix_init(), and libMesh::libmesh_assert().

Referenced by libMesh::ImplicitSystem::add_matrices(), libMesh::EigenSystem::add_matrices(), alternative_fe_assembly(), libMesh::ClawSystem::assemble_boundary_condition_matrices(), libMesh::ImplicitSystem::create_static_condensation_system_matrix(), form_matrixA(), libMesh::EigenTimeSolver::init(), main(), and libMesh::NewmarkSystem::NewmarkSystem().

1013 {
1014  parallel_object_only();
1015 
1016  libmesh_assert(this->comm().verify(std::string(mat_name)));
1017  libmesh_assert(this->comm().verify(int(type)));
1018  libmesh_assert(this->comm().verify(int(mat_build_type)));
1019 
1020  // Return the matrix if it is already there.
1021  if (auto it = this->_matrices.find(mat_name);
1022  it != this->_matrices.end())
1023  return *it->second;
1024 
1025  // Otherwise build the matrix to return.
1026  std::unique_ptr<SparseMatrix<Number>> matrix;
1027  if (this->has_static_condensation())
1028  {
1029  if (mat_build_type == MatrixBuildType::DIAGONAL)
1030  libmesh_error_msg(
1031  "We do not currently support static condensation of the diagonal matrix type");
1032  matrix = std::make_unique<StaticCondensation>(this->get_mesh(),
1033  *this,
1034  this->get_dof_map(),
1036  }
1037  else
1039  auto & mat = *matrix;
1040 
1041  _matrices.emplace(mat_name, std::move(matrix));
1042 
1043  _matrix_types.emplace(mat_name, type);
1044 
1045  // Initialize it first if we've already initialized the others.
1046  this->late_matrix_init(mat, type);
1047 
1048  return mat;
1049 }
const Parallel::Communicator & comm() const
bool has_static_condensation() const
Definition: system.C:2871
const MeshBase & get_mesh() const
Definition: system.h:2358
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.
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
Some systems need an arbitrary number of matrices.
Definition: system.h:2247
SolverPackage default_solver_package()
Definition: libmesh.C:1117
StaticCondensationDofMap & get_static_condensation()
Definition: dof_map.h:2689
libmesh_assert(ctx)
std::map< std::string, ParallelType, std::less<> > _matrix_types
Holds the types of the matrices.
Definition: system.h:2252
template class LIBMESH_EXPORT SparseMatrix< Number >
const DofMap & get_dof_map() const
Definition: system.h:2374
void late_matrix_init(SparseMatrix< Number > &mat, ParallelType type)
Helper function to keep DofMap forward declarable in system.h.
Definition: system.C:1076

◆ add_matrix() [2/3]

template<template< typename > class MatrixType>
SparseMatrix< Number > & libMesh::System::add_matrix ( std::string_view  mat_name,
ParallelType  type = PARALLEL 
)
inlineinherited

Adds the additional matrix mat_name to this system.

Only allowed prior to assemble(). All additional matrices have the same sparsity pattern as the matrix used during solution. When not System but the user wants to initialize the main/system matrix, then all the additional matrices, if existent, have to be initialized by the user, too.

This method will create add a derived matrix of type MatrixType<Number>. One can use the non-templated add_matrix method to add a matrix corresponding to the default solver package

Parameters
mat_nameA name for the matrix
typeThe serial/parallel/ghosted type of the matrix

Definition at line 2707 of file system.h.

References libMesh::System::_matrices, libMesh::System::_matrix_types, and libMesh::System::late_matrix_init().

2709 {
2710  // Return the matrix if it is already there.
2711  auto it = this->_matrices.find(mat_name);
2712  if (it != this->_matrices.end())
2713  return *it->second;
2714 
2715  // Otherwise build the matrix to return.
2716  auto pr = _matrices.emplace(mat_name, std::make_unique<MatrixType<Number>>(this->comm()));
2717  _matrix_types.emplace(mat_name, type);
2718 
2719  SparseMatrix<Number> & mat = *(pr.first->second);
2720 
2721  // Initialize it first if we've already initialized the others.
2722  this->late_matrix_init(mat, type);
2723 
2724  return mat;
2725 }
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
Some systems need an arbitrary number of matrices.
Definition: system.h:2247
std::map< std::string, ParallelType, std::less<> > _matrix_types
Holds the types of the matrices.
Definition: system.h:2252
template class LIBMESH_EXPORT SparseMatrix< Number >
void late_matrix_init(SparseMatrix< Number > &mat, ParallelType type)
Helper function to keep DofMap forward declarable in system.h.
Definition: system.C:1076

◆ add_matrix() [3/3]

SparseMatrix< Number > & libMesh::System::add_matrix ( std::string_view  mat_name,
std::unique_ptr< SparseMatrix< Number >>  matrix,
ParallelType  type = PARALLEL 
)
inherited

Adds the additional matrix mat_name to this system.

Only allowed prior to assemble(). All additional matrices have the same sparsity pattern as the matrix used during solution. When not System but the user wants to initialize the main/system matrix, then all the additional matrices, if existent, have to be initialized by the user, too.

Parameters
mat_nameA name for the matrix
matrixThe matrix we are handing over the System for ownership
typeThe serial/parallel/ghosted type of the matrix

Definition at line 1053 of file system.C.

References libMesh::System::_matrices, libMesh::System::_matrix_types, libMesh::ParallelObject::comm(), libMesh::System::late_matrix_init(), and libMesh::libmesh_assert().

1056 {
1057  parallel_object_only();
1058 
1059  libmesh_assert(this->comm().verify(std::string(mat_name)));
1060  libmesh_assert(this->comm().verify(int(type)));
1061 
1062  auto [it, inserted] = _matrices.emplace(mat_name, std::move(matrix));
1063  libmesh_error_msg_if(!inserted,
1064  "Tried to add '" << mat_name << "' but the matrix already exists");
1065 
1066  _matrix_types.emplace(mat_name, type);
1067 
1068  SparseMatrix<Number> & mat = *(it->second);
1069 
1070  // Initialize it first if we've already initialized the others.
1071  this->late_matrix_init(mat, type);
1072 
1073  return mat;
1074 }
const Parallel::Communicator & comm() const
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
Some systems need an arbitrary number of matrices.
Definition: system.h:2247
libmesh_assert(ctx)
std::map< std::string, ParallelType, std::less<> > _matrix_types
Holds the types of the matrices.
Definition: system.h:2252
template class LIBMESH_EXPORT SparseMatrix< Number >
void late_matrix_init(SparseMatrix< Number > &mat, ParallelType type)
Helper function to keep DofMap forward declarable in system.h.
Definition: system.C:1076

◆ add_scaled_Aq()

void libMesh::RBConstruction::add_scaled_Aq ( Number  scalar,
unsigned int  q_a,
SparseMatrix< Number > *  input_matrix,
bool  symmetrize 
)
inherited

Add the scaled q^th affine matrix to input_matrix.

If symmetrize==true, then we symmetrize Aq before adding it.

Definition at line 1046 of file rb_construction.C.

References libMesh::SparseMatrix< T >::add(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::SparseMatrix< T >::close(), libMesh::RBAssemblyExpansion::get_A_assembly(), libMesh::RBConstruction::get_Aq(), libMesh::RBConstruction::get_rb_theta_expansion(), and libMesh::RBConstruction::rb_assembly_expansion.

Referenced by libMesh::RBSCMConstruction::add_scaled_symm_Aq().

1050 {
1051  LOG_SCOPE("add_scaled_Aq()", "RBConstruction");
1052 
1053  libmesh_error_msg_if(q_a >= get_rb_theta_expansion().get_n_A_terms(),
1054  "Error: We must have q < Q_a in add_scaled_Aq.");
1055 
1056  if (!symmetrize)
1057  {
1058  input_matrix->add(scalar, *get_Aq(q_a));
1059  input_matrix->close();
1060  }
1061  else
1062  {
1065  input_matrix,
1066  nullptr,
1067  symmetrize);
1068  }
1069 }
SparseMatrix< Number > * get_Aq(unsigned int q)
Get a pointer to Aq.
virtual void add(const numeric_index_type i, const numeric_index_type j, const T value)=0
Add value to the element (i,j).
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
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 close()=0
Calls the SparseMatrix&#39;s internal assembly routines, ensuring that the values are consistent across p...
ElemAssembly & get_A_assembly(unsigned int q)
Return a reference to the specified A_assembly object.
RBAssemblyExpansion * rb_assembly_expansion
This member holds the (parameter independent) assembly functors that define the "affine expansion" of...

◆ add_scaled_mass_matrix()

void TransientRBConstruction::add_scaled_mass_matrix ( Number  scalar,
SparseMatrix< Number > *  input_matrix 
)

Add the scaled mass matrix (assembled for the current parameter) to input_matrix.

Definition at line 362 of file transient_rb_construction.C.

References libMesh::SparseMatrix< T >::add(), libMesh::TransientRBThetaExpansion::eval_M_theta(), get_M_q(), libMesh::TransientRBThetaExpansion::get_n_M_terms(), libMesh::RBParametrized::get_parameters(), and libMesh::RBConstruction::get_rb_theta_expansion().

Referenced by assemble_mass_matrix(), and truth_assembly().

363 {
364  const RBParameters & mu = get_parameters();
365 
366  TransientRBThetaExpansion & trans_theta_expansion =
367  cast_ref<TransientRBThetaExpansion &>(get_rb_theta_expansion());
368 
369  const unsigned int Q_m = trans_theta_expansion.get_n_M_terms();
370 
371  for (unsigned int q=0; q<Q_m; q++)
372  input_matrix->add(scalar * trans_theta_expansion.eval_M_theta(q,mu), *get_M_q(q));
373 }
SparseMatrix< Number > * get_M_q(unsigned int q)
Get a pointer to M_q.
virtual void add(const numeric_index_type i, const numeric_index_type j, const T value)=0
Add value to the element (i,j).
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
const RBParameters & get_parameters() const
Get the current parameters.

◆ add_scaled_matrix_and_vector()

void libMesh::RBConstruction::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 
)
protectedinherited

This function loops over the mesh and applies the specified interior and/or boundary assembly routines, then adds the scaled result to input_matrix and/or input_vector.

If symmetrize==true then we assemble the symmetric part of the matrix, 0.5*(A + A^T)

Definition at line 631 of file rb_construction.C.

References libMesh::DofMap::_dof_coupling, libMesh::SparseMatrix< T >::add_matrix(), libMesh::NumericVector< T >::add_vector(), libMesh::FEAbstract::attach_quadrature_rule(), libMesh::ElemAssembly::boundary_assembly(), libMesh::RBConstruction::build_context(), libMesh::NumericVector< T >::close(), libMesh::SparseMatrix< T >::close(), libMesh::ParallelObject::comm(), libMesh::DofMap::constrain_element_matrix_and_vector(), libMesh::FEType::default_quadrature_rule(), libMesh::DGFEMContext::dg_terms_are_active(), libMesh::DenseMatrix< T >::el(), libMesh::FEMContext::elem_fe_reinit(), libMesh::DiffContext::get_dof_indices(), libMesh::System::get_dof_map(), libMesh::FEMContext::get_elem(), libMesh::DGFEMContext::get_elem_elem_jacobian(), libMesh::DiffContext::get_elem_jacobian(), libMesh::DGFEMContext::get_elem_neighbor_jacobian(), libMesh::DiffContext::get_elem_residual(), libMesh::FEMContext::get_element_fe(), libMesh::FEAbstract::get_fe_type(), libMesh::System::get_mesh(), libMesh::DGFEMContext::get_neighbor_dof_indices(), libMesh::DGFEMContext::get_neighbor_elem_jacobian(), libMesh::DGFEMContext::get_neighbor_neighbor_jacobian(), libMesh::ElemAssembly::get_nodal_values(), libMesh::FEMContext::get_side(), libMesh::DenseMatrix< T >::get_transpose(), libMesh::RBConstruction::impose_internal_fluxes, libMesh::RBConstruction::init_context(), libMesh::ElemAssembly::interior_assembly(), libMesh::Tri3Subdivision::is_ghost(), libMesh::DenseMatrixBase< T >::m(), TIMPI::Communicator::max(), mesh, libMesh::DenseMatrixBase< T >::n(), libMesh::Elem::n_sides(), libMesh::System::n_vars(), libMesh::Elem::neighbor_ptr(), libMesh::NODEELEM, libMesh::RBConstruction::post_process_elem_matrix_and_vector(), libMesh::FEMContext::pre_fe_reinit(), libMesh::DofObject::processor_id(), TIMPI::Communicator::rank(), libMesh::FEMContext::side, libMesh::DGFEMContext::side_fe_reinit(), libMesh::Elem::side_ptr(), libMesh::RBConstruction::skip_degenerate_sides, libMesh::TRI3SUBDIVISION, and libMesh::MeshTools::volume().

Referenced by libMesh::RBConstruction::add_scaled_Aq(), libMesh::RBConstruction::assemble_all_output_vectors(), libMesh::RBConstruction::assemble_Aq_matrix(), libMesh::RBConstruction::assemble_Fq_vector(), libMesh::RBConstruction::assemble_inner_product_matrix(), assemble_L2_matrix(), and assemble_Mq_matrix().

637 {
638  LOG_SCOPE("add_scaled_matrix_and_vector()", "RBConstruction");
639 
640  bool assemble_matrix = (input_matrix != nullptr);
641  bool assemble_vector = (input_vector != nullptr);
642 
643  if (!assemble_matrix && !assemble_vector)
644  return;
645 
646  const MeshBase & mesh = this->get_mesh();
647 
648  // First add any node-based terms (e.g. point loads)
649 
650  // Make a std::set of all the nodes that are in 1 or more
651  // nodesets. We only want to call get_nodal_values() once per Node
652  // per ElemAssembly object, regardless of how many nodesets it
653  // appears in.
654  std::set<dof_id_type> nodes_with_nodesets;
655  for (const auto & t : mesh.get_boundary_info().build_node_list())
656  nodes_with_nodesets.insert(std::get<0>(t));
657 
658  // It's possible for the node assembly loop below to throw an
659  // exception on one (or some subset) of the processors. In that
660  // case, we stop assembling on the processor(s) that threw and let
661  // the other processors finish assembly. Then we synchronize to
662  // check whether an exception was thrown on _any_ processor, and if
663  // so, re-throw it on _all_ processors.
664  int nodal_assembly_threw = 0;
665 
666  libmesh_try
667  {
668 
669  for (const auto & id : nodes_with_nodesets)
670  {
671  const Node & node = mesh.node_ref(id);
672 
673  // If node is on this processor, then all dofs on node are too
674  // so we can do the add below safely
675  if (node.processor_id() == this->comm().rank())
676  {
677  // Get the values to add to the rhs vector
678  std::vector<dof_id_type> nodal_dof_indices;
679  DenseMatrix<Number> nodal_matrix;
680  DenseVector<Number> nodal_rhs;
681  elem_assembly->get_nodal_values(nodal_dof_indices,
682  nodal_matrix,
683  nodal_rhs,
684  *this,
685  node);
686 
687  // Perform any required user-defined postprocessing on
688  // the matrix and rhs.
689  //
690  // TODO: We need to postprocess node matrices and vectors
691  // in some cases (e.g. when rotations are applied to
692  // nodes), but since we don't have a FEMContext at this
693  // point we would need to have a different interface
694  // taking the DenseMatrix, DenseVector, and probably the
695  // current node that we are on...
696  // this->post_process_elem_matrix_and_vector(nodal_matrix, nodal_rhs);
697 
698  if (!nodal_dof_indices.empty())
699  {
700  if (apply_dof_constraints)
701  {
702  // Apply constraints, e.g. Dirichlet and periodic constraints
704  nodal_matrix,
705  nodal_rhs,
706  nodal_dof_indices,
707  /*asymmetric_constraint_rows*/ false);
708  }
709 
710  // Scale and add to global matrix and/or vector
711  nodal_matrix *= scalar;
712  nodal_rhs *= scalar;
713 
714  if (assemble_vector)
715  input_vector->add_vector(nodal_rhs, nodal_dof_indices);
716 
717  if (assemble_matrix)
718  input_matrix->add_matrix(nodal_matrix, nodal_dof_indices);
719  }
720  }
721  }
722  } // libmesh_try
723  libmesh_catch(...)
724  {
725  nodal_assembly_threw = 1;
726  }
727 
728  // Check for exceptions on any procs and if there is one, re-throw
729  // it on all procs.
730  this->comm().max(nodal_assembly_threw);
731 
732  if (nodal_assembly_threw)
733  libmesh_error_msg("Error during assembly in RBConstruction::add_scaled_matrix_and_vector()");
734 
735  std::unique_ptr<DGFEMContext> c = this->build_context();
736  DGFEMContext & context = cast_ref<DGFEMContext &>(*c);
737 
738  this->init_context(context);
739 
740  // It's possible for the assembly loop below to throw an exception
741  // on one (or some subset) of the processors. This can happen when
742  // e.g. the mesh contains one or more elements with negative
743  // Jacobian. In that case, we stop assembling on the processor(s)
744  // that threw and let the other processors finish assembly. Then we
745  // synchronize to check whether an exception was thrown on _any_
746  // processor, and if so, re-throw it on _all_ processors. This way,
747  // we make it easier for callers to handle exceptions in parallel
748  // during assembly: they can simply assume that the code either
749  // throws on all procs or on no procs.
750  int assembly_threw = 0;
751 
752  libmesh_try
753  {
754 
755  for (const auto & elem : mesh.active_local_element_ptr_range())
756  {
757  const ElemType elemtype = elem->type();
758 
759  if(elemtype == NODEELEM)
760  {
761  // We assume that we do not perform any assembly directly on
762  // NodeElems, so we skip the assembly calls.
763 
764  // However, in a spline basis with Dirichlet constraints on
765  // spline nodes, a constrained matrix has to take those
766  // nodes into account.
767  if (!apply_dof_constraints)
768  continue;
769  }
770 
771  // Subdivision elements need special care:
772  // - skip ghost elements
773  // - init special quadrature rule
774  std::unique_ptr<QBase> qrule;
775  if (elemtype == TRI3SUBDIVISION)
776  {
777  const Tri3Subdivision * gh_elem = static_cast<const Tri3Subdivision *> (elem);
778  if (gh_elem->is_ghost())
779  continue ;
780  // A Gauss quadrature rule for numerical integration.
781  // For subdivision shell elements, a single Gauss point per
782  // element is sufficient, hence we use extraorder = 0.
783  const int extraorder = 0;
784  FEBase * elem_fe = nullptr;
785  context.get_element_fe( 0, elem_fe );
786 
787  qrule = elem_fe->get_fe_type().default_quadrature_rule (2, extraorder);
788 
789  // Tell the finite element object to use our quadrature rule.
790  elem_fe->attach_quadrature_rule (qrule.get());
791  }
792 
793  context.pre_fe_reinit(*this, elem);
794 
795  // Do nothing in case there are no dof_indices on the current element
796  if ( context.get_dof_indices().empty() )
797  continue;
798 
799  context.elem_fe_reinit();
800 
801  if (elemtype != NODEELEM)
802  {
803  elem_assembly->interior_assembly(context);
804 
805  const unsigned char n_sides = context.get_elem().n_sides();
806  for (context.side = 0; context.side != n_sides; ++context.side)
807  {
808  // May not need to apply fluxes on non-boundary elements
809  if ((context.get_elem().neighbor_ptr(context.get_side()) != nullptr) && !impose_internal_fluxes)
810  continue;
811 
812  // skip degenerate sides with zero area
813  if( (context.get_elem().side_ptr(context.get_side())->volume() <= 0.) && skip_degenerate_sides)
814  continue;
815 
816  context.side_fe_reinit();
817  elem_assembly->boundary_assembly(context);
818 
819  if (context.dg_terms_are_active())
820  {
821  input_matrix->add_matrix (context.get_elem_elem_jacobian(),
822  context.get_dof_indices(),
823  context.get_dof_indices());
824 
825  input_matrix->add_matrix (context.get_elem_neighbor_jacobian(),
826  context.get_dof_indices(),
827  context.get_neighbor_dof_indices());
828 
829  input_matrix->add_matrix (context.get_neighbor_elem_jacobian(),
830  context.get_neighbor_dof_indices(),
831  context.get_dof_indices());
832 
833  input_matrix->add_matrix (context.get_neighbor_neighbor_jacobian(),
834  context.get_neighbor_dof_indices(),
835  context.get_neighbor_dof_indices());
836  }
837  }
838  }
839 
840  // Do any required user post-processing before symmetrizing and/or applying
841  // constraints.
842  //
843  // We only do this if apply_dof_constraints is true because we want to be
844  // able to set apply_dof_constraints=false in order to obtain a matrix
845  // A with no dof constraints or dof transformations, as opposed to C^T A C,
846  // which includes constraints and/or dof transformations. Here C refers to
847  // the matrix that imposes dof constraints and transformations on the
848  // solution u.
849  //
850  // Matrices such as A are what we store in our "non_dirichlet" operators, and
851  // they are useful for computing terms such as (C u_i)^T A (C u_j) (e.g. see
852  // update_RB_system_matrices()), where C u is the result of a "truth_solve",
853  // which includes calls to both enforce_constraints_exactly() and
854  // post_process_truth_solution(). If we use C^T A C to compute these terms then
855  // we would "double apply" the matrix C, which can give incorrect results.
856  if (apply_dof_constraints)
858 
859  // Need to symmetrize before imposing
860  // periodic constraints
861  if (assemble_matrix && symmetrize)
862  {
863  DenseMatrix<Number> Ke_transpose;
864  context.get_elem_jacobian().get_transpose(Ke_transpose);
865  context.get_elem_jacobian() += Ke_transpose;
866  context.get_elem_jacobian() *= 0.5;
867  }
868 
869  // As discussed above, we can set apply_dof_constraints=false to
870  // get A instead of C^T A C
871  if (apply_dof_constraints)
872  {
873  // Apply constraints, e.g. Dirichlet and periodic constraints
875  (context.get_elem_jacobian(),
876  context.get_elem_residual(),
877  context.get_dof_indices(),
878  /*asymmetric_constraint_rows*/ false );
879  }
880 
881  // Scale and add to global matrix and/or vector
882  context.get_elem_jacobian() *= scalar;
883  context.get_elem_residual() *= scalar;
884 
885  if (assemble_matrix)
886  {
887 
888  CouplingMatrix * coupling_matrix = get_dof_map()._dof_coupling;
889  if (!coupling_matrix)
890  {
891  // If we haven't defined a _dof_coupling matrix then just add
892  // the whole matrix
893  input_matrix->add_matrix (context.get_elem_jacobian(),
894  context.get_dof_indices() );
895  }
896  else
897  {
898  // Otherwise we should only add the relevant submatrices
899  for (unsigned int var1=0; var1<n_vars(); var1++)
900  {
901  ConstCouplingRow ccr(var1, *coupling_matrix);
902  for (const auto & var2 : ccr)
903  {
904  unsigned int sub_m = context.get_elem_jacobian( var1, var2 ).m();
905  unsigned int sub_n = context.get_elem_jacobian( var1, var2 ).n();
906  DenseMatrix<Number> sub_jac(sub_m, sub_n);
907  for (unsigned int row=0; row<sub_m; row++)
908  for (unsigned int col=0; col<sub_n; col++)
909  {
910  sub_jac(row,col) = context.get_elem_jacobian( var1, var2 ).el(row,col);
911  }
912  input_matrix->add_matrix (sub_jac,
913  context.get_dof_indices(var1),
914  context.get_dof_indices(var2) );
915  }
916  }
917  }
918 
919  }
920 
921  if (assemble_vector)
922  input_vector->add_vector (context.get_elem_residual(),
923  context.get_dof_indices() );
924  } // end for (elem)
925 
926  } // libmesh_try
927  libmesh_catch(...)
928  {
929  assembly_threw = 1;
930  }
931 
932  // Note: regardless of whether any procs threw during assembly (and
933  // thus didn't finish assembling), we should not leave the matrix
934  // and vector in an inconsistent state, since it may be possible to
935  // recover from the exception. Therefore, we close them now. The
936  // assumption here is that the nature of the exception does not
937  // prevent the matrix and vector from still being assembled (albeit
938  // with incomplete data).
939  if (assemble_matrix)
940  input_matrix->close();
941  if (assemble_vector)
942  input_vector->close();
943 
944  // Check for exceptions on any procs and if there is one, re-throw
945  // it on all procs.
946  this->comm().max(assembly_threw);
947 
948  if (assembly_threw)
949  libmesh_error_msg("Error during assembly in RBConstruction::add_scaled_matrix_and_vector()");
950 }
ElemType
Defines an enum for geometric element types.
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...
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.
Definition: dof_map.h:2330
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]...
MeshBase & mesh
processor_id_type rank() const
const Parallel::Communicator & comm() const
bool skip_degenerate_sides
In some cases meshes are intentionally created with degenerate sides as a way to represent, say, triangles using a hex-only mesh.
virtual std::unique_ptr< DGFEMContext > build_context()
Builds a DGFEMContext object with enough information to do evaluations on each element.
const MeshBase & get_mesh() const
Definition: system.h:2358
virtual void init_context(FEMContext &)
Initialize the FEMContext prior to performing an element loop.
bool impose_internal_fluxes
Boolean flag to indicate whether we impose "fluxes" (i.e.
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.
CouplingMatrix * _dof_coupling
Degree of freedom coupling.
Definition: dof_map.h:1613
FEGenericBase< Real > FEBase
Real volume(const MeshBase &mesh, unsigned int dim=libMesh::invalid_uint)
Find the total volume of a mesh (interpreting that as area for dim = 2, or total arc length for dim =...
Definition: mesh_tools.C:985
virtual void close()=0
Calls the NumericVector&#39;s internal assembly routines, ensuring that the values are consistent across ...
virtual void close()=0
Calls the SparseMatrix&#39;s internal assembly routines, ensuring that the values are consistent across p...
void max(const T &r, T &o, Request &req) const
unsigned int n_vars() const
Definition: system.h:2430
const DofMap & get_dof_map() const
Definition: system.h:2374

◆ add_sensitivity_rhs()

NumericVector< Number > & libMesh::System::add_sensitivity_rhs ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's sensitivity rhs vectors, by default the one corresponding to the first parameter. Creates the vector if it doesn't already exist.

Definition at line 1327 of file system.C.

References libMesh::System::add_vector().

Referenced by libMesh::ImplicitSystem::assemble_residual_derivatives().

1328 {
1329  std::ostringstream sensitivity_rhs_name;
1330  sensitivity_rhs_name << "sensitivity_rhs" << i;
1331 
1332  return this->add_vector(sensitivity_rhs_name.str(), false);
1333 }
NumericVector< Number > & add_vector(std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Adds the additional vector vec_name to this system.
Definition: system.C:768

◆ add_sensitivity_solution()

NumericVector< Number > & libMesh::System::add_sensitivity_solution ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's solution sensitivity vectors, by default the one corresponding to the first parameter. Creates the vector if it doesn't already exist.

Definition at line 1182 of file system.C.

References libMesh::System::add_vector().

Referenced by libMesh::ImplicitSystem::sensitivity_solve().

1183 {
1184  std::ostringstream sensitivity_name;
1185  sensitivity_name << "sensitivity_solution" << i;
1186 
1187  return this->add_vector(sensitivity_name.str());
1188 }
NumericVector< Number > & add_vector(std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Adds the additional vector vec_name to this system.
Definition: system.C:768

◆ add_variable() [1/2]

unsigned int libMesh::System::add_variable ( std::string_view  var,
const FEType type,
const std::set< subdomain_id_type > *const  active_subdomains = nullptr 
)
inherited

Adds the variable var to the list of variables for this system.

If active_subdomains is either nullptr (the default) or points to an empty set, then it will be assumed that var has no subdomain restrictions

Returns
The index number for the new variable.

Definition at line 1357 of file system.C.

References libMesh::System::_variable_groups, libMesh::System::_variable_numbers, libMesh::System::_variables, libMesh::Variable::active_subdomains(), libMesh::System::add_variables(), libMesh::ParallelObject::comm(), libMesh::System::identify_variable_groups(), libMesh::Variable::implicitly_active(), libMesh::System::is_initialized(), libMesh::libmesh_assert(), libMesh::make_range(), libMesh::System::n_variable_groups(), libMesh::System::n_vars(), libMesh::System::variable(), libMesh::System::variable_name(), and libMesh::System::variable_type().

Referenced by libMesh::DifferentiableSystem::add_second_order_dot_vars(), libMesh::System::add_variable(), assemble_and_solve(), OverlappingTestBase::init(), SolidSystem::init_data(), CurlCurlSystem::init_data(), SimpleEIMConstruction::init_data(), libMesh::VariationalSmootherSystem::init_data(), libMesh::AdvectionSystem::init_data(), HeatSystem::init_data(), SimpleRBConstruction::init_data(), NonManifoldCouplingTestBase::init_es(), main(), libMesh::ErrorVector::plot_error(), libMesh::System::read_header(), RationalMapTest< elem_type >::setUp(), SlitMeshRefinedSystemTest::setUp(), FETestBase< order, family, elem_type, 1 >::setUp(), WriteVecAndScalar::setupTests(), SystemsTest::simpleSetup(), MultiEvaluablePredTest::test(), ConstraintOperatorTest::test1DCoarseningNewNodes(), ConstraintOperatorTest::test1DCoarseningOperator(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), MeshFunctionTest::test_subdomain_id_sets(), SystemsTest::testAssemblyWithDgFemContext(), DofMapTest::testBadElemFECombo(), EquationSystemsTest::testBadVarNames(), SystemsTest::testBlockRestrictedVarNDofs(), SystemsTest::testBoundaryProjectCube(), DofMapTest::testConstraintLoopDetection(), MeshInputTest::testCopyElementSolutionImpl(), MeshInputTest::testCopyElementVectorImpl(), MeshInputTest::testCopyNodalSolutionImpl(), ConstraintOperatorTest::testCoreform(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), SystemsTest::testDofCouplingWithVarGroups(), DofMapTest::testDofOwner(), MeshInputTest::testDynaReadPatch(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), MeshAssignTest::testMeshMoveAssign(), PeriodicBCTest::testPeriodicBC(), EquationSystemsTest::testPostInitAddElem(), EquationSystemsTest::testPostInitAddRealSystem(), SystemsTest::testProjectCubeWithMeshFunction(), MeshInputTest::testProjectionRegression(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), InfFERadialTest::testRefinement(), EquationSystemsTest::testRefineThenReinitPreserveFlags(), EquationSystemsTest::testReinitWithNodeElem(), EquationSystemsTest::testRepartitionThenReinit(), EquationSystemsTest::testSelectivePRefine(), SystemsTest::testSetSystemParameterOverEquationSystem(), BoundaryInfoTest::testShellFaceConstraints(), MeshInputTest::testSingleElementImpl(), WriteVecAndScalar::testWriteExodus(), and WriteVecAndScalar::testWriteNemesis().

1360 {
1361  parallel_object_only(); // Not strictly needed, but the only safe way to keep in sync
1362 
1363  libmesh_assert(this->comm().verify(std::string(var)));
1364  libmesh_assert(this->comm().verify(type));
1365  libmesh_assert(this->comm().verify((active_subdomains == nullptr)));
1366 
1367  if (active_subdomains)
1368  libmesh_assert(this->comm().verify(active_subdomains->size()));
1369 
1370  // Make sure the variable isn't there already
1371  // or if it is, that it's the type we want
1372  for (auto v : make_range(this->n_vars()))
1373  if (this->variable_name(v) == var)
1374  {
1375  if (this->variable_type(v) == type)
1376  {
1377  // Check whether the existing variable's active subdomains also matches
1378  // the incoming variable's active subdomains. If they don't match, then
1379  // either it is an error by the user or the user is trying to change the
1380  // subdomain restriction after the variable has already been added, which
1381  // is not supported.
1382  const Variable & existing_var = this->variable(v);
1383 
1384  // Check whether active_subdomains is not provided/empty and the existing_var is implicitly_active()
1385  bool check1 = (!active_subdomains || active_subdomains->empty()) && existing_var.implicitly_active();
1386 
1387  // Check if the provided active_subdomains is equal to the existing_var's active_subdomains
1388  bool check2 = (active_subdomains && (*active_subdomains == existing_var.active_subdomains()));
1389 
1390  // If either of these checks passed, then we already have this variable
1391  if (check1 || check2)
1392  return _variables[v].number();
1393  }
1394 
1395  libmesh_error_msg("ERROR: incompatible variable " << var << " has already been added for this system!");
1396  }
1397 
1398  libmesh_assert(!this->is_initialized());
1399 
1400  if (this->n_variable_groups())
1401  {
1402  // Optimize for VariableGroups here - if the user is adding multiple
1403  // variables of the same FEType and subdomain restriction, catch
1404  // that here and add them as members of the same VariableGroup.
1405  //
1406  // start by setting this flag to whatever the user has requested
1407  // and then consider the conditions which should negate it.
1408  bool should_be_in_vg = this->identify_variable_groups();
1409 
1410  VariableGroup & vg(_variable_groups.back());
1411 
1412  // get a pointer to their subdomain restriction, if any.
1413  const std::set<subdomain_id_type> * const
1414  their_active_subdomains (vg.implicitly_active() ?
1415  nullptr : &vg.active_subdomains());
1416 
1417  // Different types?
1418  if (vg.type() != type)
1419  should_be_in_vg = false;
1420 
1421  // they are restricted, we aren't?
1422  if (their_active_subdomains &&
1423  (!active_subdomains || (active_subdomains && active_subdomains->empty())))
1424  should_be_in_vg = false;
1425 
1426  // they aren't restricted, we are?
1427  if (!their_active_subdomains && (active_subdomains && !active_subdomains->empty()))
1428  should_be_in_vg = false;
1429 
1430  if (their_active_subdomains && active_subdomains)
1431  // restricted to different sets?
1432  if (*their_active_subdomains != *active_subdomains)
1433  should_be_in_vg = false;
1434 
1435  // OK, after all that, append the variable to the vg if none of the conditions
1436  // were violated
1437  if (should_be_in_vg)
1438  {
1439  const unsigned int curr_n_vars = this->n_vars();
1440 
1441  std::string varstr(var);
1442 
1443  _variable_numbers[varstr] = curr_n_vars;
1444  vg.append (std::move(varstr));
1445  _variables.push_back(vg(vg.n_variables()-1));
1446 
1447  return curr_n_vars;
1448  }
1449  }
1450 
1451  // otherwise, fall back to adding a single variable group
1452  return this->add_variables (std::vector<std::string>(1, std::string(var)),
1453  type,
1454  active_subdomains);
1455 }
unsigned int add_variables(const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system.
Definition: system.C:1471
bool is_initialized() const
Definition: system.h:2414
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2458
unsigned int n_variable_groups() const
Definition: system.h:2438
const Parallel::Communicator & comm() const
std::vector< Variable > _variables
The Variable in this System.
Definition: system.h:2206
std::vector< VariableGroup > _variable_groups
The VariableGroup in this System.
Definition: system.h:2211
libmesh_assert(ctx)
const std::string & variable_name(const unsigned int i) const
Definition: system.h:2478
bool identify_variable_groups() const
Definition: system.h:2526
const FEType & variable_type(const unsigned int i) const
Definition: system.h:2508
std::map< std::string, unsigned int, std::less<> > _variable_numbers
The variable numbers corresponding to user-specified names, useful for name-based lookups...
Definition: system.h:2217
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...
Definition: int_range.h:140
unsigned int n_vars() const
Definition: system.h:2430

◆ add_variable() [2/2]

unsigned int libMesh::System::add_variable ( std::string_view  var,
const Order  order = FIRST,
const FEFamily  family = LAGRANGE,
const std::set< subdomain_id_type > *const  active_subdomains = nullptr 
)
inherited

Adds the variable var to the list of variables for this system.

Same as before, but assumes LAGRANGE as default value for FEType.family. If active_subdomains is either nullptr (the default) or points to an empty set, then it will be assumed that var has no subdomain restrictions

Definition at line 1459 of file system.C.

References libMesh::System::add_variable().

1463 {
1464  return this->add_variable(var,
1465  FEType(order, family),
1466  active_subdomains);
1467 }
unsigned int add_variable(std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system.
Definition: system.C:1357

◆ add_variables() [1/2]

unsigned int libMesh::System::add_variables ( const std::vector< std::string > &  vars,
const FEType type,
const std::set< subdomain_id_type > *const  active_subdomains = nullptr 
)
inherited

Adds the variable var to the list of variables for this system.

If active_subdomains is either nullptr (the default) or points to an empty set, then it will be assumed that var has no subdomain restrictions

Returns
The index number for the new variable.

Definition at line 1471 of file system.C.

References libMesh::System::_variable_groups, libMesh::System::_variable_numbers, libMesh::System::_variables, libMesh::ParallelObject::comm(), libMesh::System::identify_variable_groups(), libMesh::System::is_initialized(), libMesh::libmesh_assert(), libMesh::make_range(), libMesh::System::n_components(), libMesh::System::n_variable_groups(), libMesh::System::n_vars(), libMesh::System::variable_name(), and libMesh::System::variable_type().

Referenced by libMesh::System::add_variable(), libMesh::System::add_variables(), and SystemsTest::test100KVariables().

1474 {
1475  parallel_object_only(); // Not strictly needed, but the only safe way to keep in sync
1476 
1477  libmesh_assert(!this->is_initialized());
1478 
1479  libmesh_assert(this->comm().verify(vars.size()));
1480  libmesh_assert(this->comm().verify(type));
1481  libmesh_assert(this->comm().verify((active_subdomains == nullptr)));
1482 
1483  if (active_subdomains)
1484  libmesh_assert(this->comm().verify(active_subdomains->size()));
1485 
1486  // Make sure the variable isn't there already
1487  // or if it is, that it's the type we want
1488  for (auto ovar : vars)
1489  {
1490  libmesh_assert(this->comm().verify(ovar));
1491 
1492  for (auto v : make_range(this->n_vars()))
1493  if (this->variable_name(v) == ovar)
1494  {
1495  if (this->variable_type(v) == type)
1496  return _variables[v].number();
1497 
1498  libmesh_error_msg("ERROR: incompatible variable " << ovar << " has already been added for this system!");
1499  }
1500  }
1501 
1502  if (this->n_variable_groups())
1503  {
1504  // Optimize for VariableGroups here - if the user is adding multiple
1505  // variables of the same FEType and subdomain restriction, catch
1506  // that here and add them as members of the same VariableGroup.
1507  //
1508  // start by setting this flag to whatever the user has requested
1509  // and then consider the conditions which should negate it.
1510  bool should_be_in_vg = this->identify_variable_groups();
1511 
1512  VariableGroup & vg(_variable_groups.back());
1513 
1514  // get a pointer to their subdomain restriction, if any.
1515  const std::set<subdomain_id_type> * const
1516  their_active_subdomains (vg.implicitly_active() ?
1517  nullptr : &vg.active_subdomains());
1518 
1519  // Different types?
1520  if (vg.type() != type)
1521  should_be_in_vg = false;
1522 
1523  // they are restricted, we aren't?
1524  if (their_active_subdomains &&
1525  (!active_subdomains || (active_subdomains && active_subdomains->empty())))
1526  should_be_in_vg = false;
1527 
1528  // they aren't restricted, we are?
1529  if (!their_active_subdomains && (active_subdomains && !active_subdomains->empty()))
1530  should_be_in_vg = false;
1531 
1532  if (their_active_subdomains && active_subdomains)
1533  // restricted to different sets?
1534  if (*their_active_subdomains != *active_subdomains)
1535  should_be_in_vg = false;
1536 
1537  // If after all that none of the conditions were violated,
1538  // append the variables to the vg and we're done
1539  if (should_be_in_vg)
1540  {
1541  unsigned int curr_n_vars = this->n_vars();
1542 
1543  for (auto ovar : vars)
1544  {
1545  curr_n_vars = this->n_vars();
1546 
1547  vg.append (ovar);
1548 
1549  _variables.push_back(vg(vg.n_variables()-1));
1550  _variable_numbers[ovar] = curr_n_vars;
1551  }
1552  return curr_n_vars;
1553  }
1554  }
1555 
1556  const unsigned int curr_n_vars = this->n_vars();
1557 
1558  const unsigned int next_first_component = this->n_components();
1559 
1560  // We weren't able to add to an existing variable group, so
1561  // add a new variable group to the list
1562  _variable_groups.push_back((active_subdomains == nullptr) ?
1563  VariableGroup(this, vars, curr_n_vars,
1564  next_first_component, type) :
1565  VariableGroup(this, vars, curr_n_vars,
1566  next_first_component, type, *active_subdomains));
1567 
1568  const VariableGroup & vg (_variable_groups.back());
1569 
1570  // Add each component of the group individually
1571  for (auto v : make_range(vars.size()))
1572  {
1573  _variables.push_back (vg(v));
1574  _variable_numbers[vars[v]] = curr_n_vars+v;
1575  }
1576 
1577  libmesh_assert_equal_to ((curr_n_vars+vars.size()), this->n_vars());
1578 
1579  // BSK - Defer this now to System::init_data() so we can detect
1580  // VariableGroups 12/28/2012
1581  // // Add the variable group to the _dof_map
1582  // _dof_map->add_variable_group (vg);
1583 
1584  // Return the number of the new variable
1585  return cast_int<unsigned int>(curr_n_vars+vars.size()-1);
1586 }
bool is_initialized() const
Definition: system.h:2414
unsigned int n_components() const
Definition: system.h:2446
unsigned int n_variable_groups() const
Definition: system.h:2438
const Parallel::Communicator & comm() const
std::vector< Variable > _variables
The Variable in this System.
Definition: system.h:2206
std::vector< VariableGroup > _variable_groups
The VariableGroup in this System.
Definition: system.h:2211
libmesh_assert(ctx)
const std::string & variable_name(const unsigned int i) const
Definition: system.h:2478
bool identify_variable_groups() const
Definition: system.h:2526
const FEType & variable_type(const unsigned int i) const
Definition: system.h:2508
std::map< std::string, unsigned int, std::less<> > _variable_numbers
The variable numbers corresponding to user-specified names, useful for name-based lookups...
Definition: system.h:2217
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...
Definition: int_range.h:140
unsigned int n_vars() const
Definition: system.h:2430

◆ add_variables() [2/2]

unsigned int libMesh::System::add_variables ( const std::vector< std::string > &  vars,
const Order  order = FIRST,
const FEFamily  family = LAGRANGE,
const std::set< subdomain_id_type > *const  active_subdomains = nullptr 
)
inherited

Adds the variable var to the list of variables for this system.

Same as before, but assumes LAGRANGE as default value for FEType.family. If active_subdomains is either nullptr (the default) or points to an empty set, then it will be assumed that var has no subdomain restrictions

Definition at line 1590 of file system.C.

References libMesh::System::add_variables().

1594 {
1595  return this->add_variables(vars,
1596  FEType(order, family),
1597  active_subdomains);
1598 }
unsigned int add_variables(const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system.
Definition: system.C:1471

◆ add_vector()

NumericVector< Number > & libMesh::System::add_vector ( std::string_view  vec_name,
const bool  projections = true,
const ParallelType  type = PARALLEL 
)
inherited

Adds the additional vector vec_name to this system.

All the additional vectors are similarly distributed, like the solution, and initialized to zero.

By default vectors added by add_vector are projected to changed grids by reinit(). To zero them instead (more efficient), pass "false" as the second argument

If the vector already exists, the existing vector is returned. after any upgrade to the projections or type has been made. We only handle upgrades (projections false->true, or type PARALLEL->GHOSTED) in this fashion, not downgrades, on the theory that if two codes have differing needs we want to support the union of those needs, not the intersection. Downgrades can only be accomplished manually, via set_vector_preservation() or by setting a vector type() and re-initializing.

Definition at line 768 of file system.C.

References libMesh::System::_dof_map, libMesh::System::_is_initialized, libMesh::System::_vector_is_adjoint, libMesh::System::_vector_projections, libMesh::System::_vectors, libMesh::NumericVector< T >::build(), libMesh::NumericVector< T >::close(), libMesh::NumericVector< T >::closed(), libMesh::ParallelObject::comm(), libMesh::default_solver_package(), libMesh::GHOSTED, libMesh::NumericVector< T >::initialized(), libMesh::libmesh_assert(), libMesh::System::n_dofs(), libMesh::System::n_local_dofs(), libMesh::ParallelObject::n_processors(), libMesh::PARALLEL, libMesh::SERIAL, libMesh::NumericVector< T >::set_type(), libMesh::NumericVector< T >::swap(), and libMesh::NumericVector< T >::type().

Referenced by libMesh::System::add_adjoint_rhs(), libMesh::System::add_adjoint_solution(), libMesh::System::add_sensitivity_rhs(), libMesh::System::add_sensitivity_solution(), libMesh::ExplicitSystem::add_system_rhs(), libMesh::System::add_weighted_sensitivity_adjoint_solution(), libMesh::System::add_weighted_sensitivity_solution(), alternative_fe_assembly(), libMesh::AdjointRefinementEstimator::estimate_error(), fe_assembly(), form_functionA(), form_functionB(), libMesh::SecondOrderUnsteadySolver::init(), libMesh::UnsteadySolver::init(), libMesh::UnsteadySolver::init_adjoints(), libMesh::TimeSolver::init_adjoints(), libMesh::OptimizationSystem::init_data(), libMesh::ContinuationSystem::init_data(), main(), libMesh::NewmarkSystem::NewmarkSystem(), libMesh::System::read_header(), libMesh::FrequencySystem::set_frequencies(), libMesh::FrequencySystem::set_frequencies_by_range(), libMesh::FrequencySystem::set_frequencies_by_steps(), SystemsTest::testAddVectorProjChange(), SystemsTest::testAddVectorTypeChange(), SystemsTest::testPostInitAddVector(), and SystemsTest::testPostInitAddVectorTypeChange().

771 {
772  parallel_object_only();
773 
774  libmesh_assert(this->comm().verify(std::string(vec_name)));
775  libmesh_assert(this->comm().verify(int(type)));
776  libmesh_assert(this->comm().verify(projections));
777 
778  // Return the vector if it is already there.
779  if (auto it = this->_vectors.find(vec_name);
780  it != this->_vectors.end())
781  {
782  // If the projection setting has *upgraded*, change it.
783  if (projections) // only do expensive lookup if needed
784  libmesh_map_find(_vector_projections, vec_name) = projections;
785 
786  NumericVector<Number> & vec = *it->second;
787 
788  // If we're in serial, our vectors are effectively SERIAL, so
789  // we'll ignore any type setting. If we're in parallel, we
790  // might have a type change to deal with.
791 
792  if (this->n_processors() > 1)
793  {
794  // If the type setting has changed in a way we can't
795  // perceive as an upgrade or a downgrade, scream.
796  libmesh_assert_equal_to(type == SERIAL,
797  vec.type() == SERIAL);
798 
799  // If the type setting has *upgraded*, change it.
800  if (type == GHOSTED && vec.type() == PARALLEL)
801  {
802  // A *really* late upgrade is expensive, but better not
803  // to risk zeroing data.
804  if (vec.initialized())
805  {
806  if (!vec.closed())
807  vec.close();
808 
809  // Ideally we'd move parallel coefficients and then
810  // add ghosted coefficients, but copy and swap is
811  // simpler. If anyone actually ever uses this case
812  // for real we can look into optimizing it.
813  auto new_vec = NumericVector<Number>::build(this->comm());
814 #ifdef LIBMESH_ENABLE_GHOSTED
815  new_vec->init (this->n_dofs(), this->n_local_dofs(),
816  _dof_map->get_send_list(), /*fast=*/false,
817  GHOSTED);
818 #else
819  libmesh_error_msg("Cannot initialize ghosted vectors when they are not enabled.");
820 #endif
821 
822  *new_vec = vec;
823  vec.swap(*new_vec);
824  }
825  else
826  // The PARALLEL vec is not yet initialized, so we can
827  // just "upgrade" it to GHOSTED.
828  vec.set_type(type);
829  }
830  }
831 
832  // Any upgrades are done; we're happy here.
833  return vec;
834  }
835 
836  // Otherwise, build the vector. The following emplace() is
837  // guaranteed to succeed because, if we made it here, we don't
838  // already have a vector named "vec_name". We pass the user's
839  // requested ParallelType directly to NumericVector::build() so
840  // that, even if the vector is not initialized now, it will get the
841  // right type when it is initialized later.
842  auto pr =
843  _vectors.emplace(vec_name,
846  type));
847  auto buf = pr.first->second.get();
848  _vector_projections.emplace(vec_name, projections);
849 
850  // Vectors are primal by default
851  _vector_is_adjoint.emplace(vec_name, -1);
852 
853  // Initialize it if necessary
854  if (_is_initialized)
855  {
856  if (type == GHOSTED)
857  {
858 #ifdef LIBMESH_ENABLE_GHOSTED
859  buf->init (this->n_dofs(), this->n_local_dofs(),
860  _dof_map->get_send_list(), /*fast=*/false,
861  GHOSTED);
862 #else
863  libmesh_error_msg("Cannot initialize ghosted vectors when they are not enabled.");
864 #endif
865  }
866  else
867  buf->init (this->n_dofs(), this->n_local_dofs(), false, type);
868  }
869 
870  return *buf;
871 }
bool _is_initialized
true when additional vectors and variables do not require immediate initialization, false otherwise.
Definition: system.h:2276
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:2179
const Parallel::Communicator & comm() const
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2230
dof_id_type n_local_dofs() const
Definition: system.C:158
dof_id_type n_dofs() const
Definition: system.C:121
SolverPackage default_solver_package()
Definition: libmesh.C:1117
processor_id_type n_processors() const
std::map< std::string, int, std::less<> > _vector_is_adjoint
Holds non-negative if a vector by that name should be projected using adjoint constraints/BCs, -1 if primal.
Definition: system.h:2242
libmesh_assert(ctx)
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...
template class LIBMESH_EXPORT NumericVector< Number >
std::map< std::string, bool, std::less<> > _vector_projections
Holds true if a vector by that name should be projected onto a changed grid, false if it should be ze...
Definition: system.h:2236

◆ add_weighted_sensitivity_adjoint_solution()

NumericVector< Number > & libMesh::System::add_weighted_sensitivity_adjoint_solution ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's weighted sensitivity adjoint solution vectors, by default the one corresponding to the first qoi. Creates the vector if it doesn't already exist.

Definition at line 1265 of file system.C.

References libMesh::System::add_vector(), and libMesh::System::set_vector_as_adjoint().

Referenced by libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().

1266 {
1267  std::ostringstream adjoint_name;
1268  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
1269 
1270  NumericVector<Number> & returnval = this->add_vector(adjoint_name.str());
1271  this->set_vector_as_adjoint(adjoint_name.str(), i);
1272  return returnval;
1273 }
void set_vector_as_adjoint(const std::string &vec_name, int qoi_num)
Allows one to set the QoI index controlling whether the vector identified by vec_name represents a so...
Definition: system.C:1160
NumericVector< Number > & add_vector(std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Adds the additional vector vec_name to this system.
Definition: system.C:768
template class LIBMESH_EXPORT NumericVector< Number >

◆ add_weighted_sensitivity_solution()

NumericVector< Number > & libMesh::System::add_weighted_sensitivity_solution ( )
inherited
Returns
A reference to the solution of the last weighted sensitivity solve Creates the vector if it doesn't already exist.

Definition at line 1212 of file system.C.

References libMesh::System::add_vector().

Referenced by libMesh::ImplicitSystem::weighted_sensitivity_solve().

1213 {
1214  return this->add_vector("weighted_sensitivity_solution");
1215 }
NumericVector< Number > & add_vector(std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Adds the additional vector vec_name to this system.
Definition: system.C:768

◆ adjoint_qoi_parameter_sensitivity()

void libMesh::ImplicitSystem::adjoint_qoi_parameter_sensitivity ( const QoISet qoi_indices,
const ParameterVector parameters,
SensitivityData sensitivities 
)
overridevirtualinherited

Solves for the derivative of each of the system's quantities of interest q in qoi[qoi_indices] with respect to each parameter in parameters, placing the result for qoi i and parameter j into sensitivities[i][j].

Uses adjoint_solve() and the adjoint sensitivity method.

Currently uses finite differenced derivatives (partial q / partial p) and (partial R / partial p).

Reimplemented from libMesh::System.

Definition at line 513 of file implicit_system.C.

References libMesh::ImplicitSystem::adjoint_solve(), libMesh::SensitivityData::allocate_data(), libMesh::ExplicitSystem::assemble_qoi(), libMesh::ImplicitSystem::assemble_residual_derivatives(), libMesh::NumericVector< T >::dot(), libMesh::System::get_qoi_values(), libMesh::System::get_sensitivity_rhs(), libMesh::QoISet::has_index(), libMesh::System::is_adjoint_already_solved(), libMesh::System::n_qois(), libMesh::Real, libMesh::ParameterVector::size(), and libMesh::TOLERANCE.

Referenced by libMesh::UnsteadySolver::integrate_adjoint_sensitivity(), and main().

516 {
517  ParameterVector & parameters_vec =
518  const_cast<ParameterVector &>(parameters_in);
519 
520  const unsigned int Np = cast_int<unsigned int>
521  (parameters_vec.size());
522  const unsigned int Nq = this->n_qois();
523 
524  // An introduction to the problem:
525  //
526  // Residual R(u(p),p) = 0
527  // partial R / partial u = J = system matrix
528  //
529  // This implies that:
530  // d/dp(R) = 0
531  // (partial R / partial p) +
532  // (partial R / partial u) * (partial u / partial p) = 0
533 
534  // We first do an adjoint solve:
535  // J^T * z = (partial q / partial u)
536  // if we haven't already or dont have an initial condition for the adjoint
537  if (!this->is_adjoint_already_solved())
538  {
539  this->adjoint_solve(qoi_indices);
540  }
541 
542  this->assemble_residual_derivatives(parameters_in);
543 
544  // Get ready to fill in sensitivities:
545  sensitivities.allocate_data(qoi_indices, *this, parameters_vec);
546 
547  // We use the identities:
548  // dq/dp = (partial q / partial p) + (partial q / partial u) *
549  // (partial u / partial p)
550  // dq/dp = (partial q / partial p) + (J^T * z) *
551  // (partial u / partial p)
552  // dq/dp = (partial q / partial p) + z * J *
553  // (partial u / partial p)
554 
555  // Leading to our final formula:
556  // dq/dp = (partial q / partial p) - z * (partial R / partial p)
557 
558  // In the case of adjoints with heterogenous Dirichlet boundary
559  // function phi, where
560  // q := S(u) - R(u,phi)
561  // the final formula works out to:
562  // dq/dp = (partial S / partial p) - z * (partial R / partial p)
563  // Because we currently have no direct access to
564  // (partial S / partial p), we use the identity
565  // (partial S / partial p) = (partial q / partial p) +
566  // phi * (partial R / partial p)
567  // to derive an equivalent equation:
568  // dq/dp = (partial q / partial p) - (z-phi) * (partial R / partial p)
569 
570  // Since z-phi degrees of freedom are zero for constrained indices,
571  // we can use the same constrained -(partial R / partial p) that we
572  // use for forward sensitivity solves, taking into account the
573  // differing sign convention.
574  //
575  // Since that vector is constrained, its constrained indices are
576  // zero, so its product with phi is zero, so we can neglect the
577  // evaluation of phi terms.
578 
579  for (unsigned int j=0; j != Np; ++j)
580  {
581  // We currently get partial derivatives via central differencing
582 
583  // (partial q / partial p) ~= (q(p+dp)-q(p-dp))/(2*dp)
584  // (partial R / partial p) ~= (rhs(p+dp) - rhs(p-dp))/(2*dp)
585 
586  Number old_parameter = *parameters_vec[j];
587 
588  const Real delta_p =
589  TOLERANCE * std::max(std::abs(old_parameter), 1e-3);
590 
591  *parameters_vec[j] = old_parameter - delta_p;
592  this->assemble_qoi(qoi_indices);
593  const std::vector<Number> qoi_minus = this->get_qoi_values();
594 
595  NumericVector<Number> & neg_partialR_partialp = this->get_sensitivity_rhs(j);
596 
597  *parameters_vec[j] = old_parameter + delta_p;
598  this->assemble_qoi(qoi_indices);
599  const std::vector<Number> qoi_plus = this->get_qoi_values();
600 
601  std::vector<Number> partialq_partialp(Nq, 0);
602  for (unsigned int i=0; i != Nq; ++i)
603  if (qoi_indices.has_index(i))
604  partialq_partialp[i] = (qoi_plus[i] - qoi_minus[i]) / (2.*delta_p);
605 
606  // Don't leave the parameter changed
607  *parameters_vec[j] = old_parameter;
608 
609  for (unsigned int i=0; i != Nq; ++i)
610  if (qoi_indices.has_index(i))
611  sensitivities[i][j] = partialq_partialp[i] +
612  neg_partialR_partialp.dot(this->get_adjoint_solution(i));
613  }
614 
615  // All parameters_vec have been reset.
616  // Reset the original qoi.
617 
618  this->assemble_qoi(qoi_indices);
619 }
static constexpr Real TOLERANCE
unsigned int n_qois() const
Number of currently active quantities of interest.
Definition: system.h:2621
NumericVector< Number > & get_sensitivity_rhs(unsigned int i=0)
Definition: system.C:1337
virtual std::pair< unsigned int, Real > adjoint_solve(const QoISet &qoi_indices=QoISet()) override
Assembles & solves the linear system (dR/du)^T*z = dq/du, for those quantities of interest q specifie...
bool is_adjoint_already_solved() const
Accessor for the adjoint_already_solved boolean.
Definition: system.h:409
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void assemble_qoi(const QoISet &qoi_indices=QoISet()) override
Prepares qoi for quantity of interest assembly, then calls user qoi function.
virtual void assemble_residual_derivatives(const ParameterVector &parameters) override
Residual parameter derivative function.
template class LIBMESH_EXPORT NumericVector< Number >
std::vector< Number > get_qoi_values() const
Returns a copy of qoi, not a reference.
Definition: system.C:2393

◆ adjoint_solve()

std::pair< unsigned int, Real > libMesh::ImplicitSystem::adjoint_solve ( const QoISet qoi_indices = QoISet())
overridevirtualinherited

Assembles & solves the linear system (dR/du)^T*z = dq/du, for those quantities of interest q specified by qoi_indices.

Leave qoi_indices empty to solve all adjoint problems.

Returns
A pair with the total number of linear iterations performed and the (sum of the) final residual norms

Reimplemented from libMesh::System.

Reimplemented in libMesh::DifferentiableSystem.

Definition at line 192 of file implicit_system.C.

References libMesh::System::add_adjoint_solution(), libMesh::LinearSolver< T >::adjoint_solve(), libMesh::System::assemble_before_solve, libMesh::ExplicitSystem::assemble_qoi_derivative(), libMesh::ImplicitSystem::assembly(), libMesh::DofMap::enforce_adjoint_constraints_exactly(), libMesh::System::get_adjoint_rhs(), libMesh::System::get_adjoint_solution(), libMesh::System::get_dof_map(), libMesh::ImplicitSystem::get_linear_solve_parameters(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::QoISet::has_index(), libMesh::make_range(), libMesh::ImplicitSystem::matrix, and libMesh::System::n_qois().

Referenced by libMesh::ImplicitSystem::adjoint_qoi_parameter_sensitivity(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ImplicitSystem::qoi_parameter_hessian(), and libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product().

193 {
194  // Log how long the linear solve takes.
195  LOG_SCOPE("adjoint_solve()", "ImplicitSystem");
196 
197  if (this->assemble_before_solve)
198  // Assemble the linear system
199  this->assembly (/* get_residual = */ false,
200  /* get_jacobian = */ true);
201 
202  // The adjoint problem is linear
203  LinearSolver<Number> * solver = this->get_linear_solver();
204 
205  // Reset and build the RHS from the QOI derivative
206  this->assemble_qoi_derivative(qoi_indices,
207  /* include_liftfunc = */ false,
208  /* apply_constraints = */ true);
209 
210  // Our iteration counts and residuals will be sums of the individual
211  // results
212  std::pair<unsigned int, Real> solver_params =
214  std::pair<unsigned int, Real> totalrval = std::make_pair(0,0.0);
215 
216  for (auto i : make_range(this->n_qois()))
217  if (qoi_indices.has_index(i))
218  {
219  const std::pair<unsigned int, Real> rval =
220  solver->adjoint_solve (*matrix, this->add_adjoint_solution(i),
221  this->get_adjoint_rhs(i),
222  double(solver_params.second),
223  solver_params.first);
224 
225  totalrval.first += rval.first;
226  totalrval.second += rval.second;
227  }
228 
229  // The linear solver may not have fit our constraints exactly
230 #ifdef LIBMESH_ENABLE_CONSTRAINTS
231  for (auto i : make_range(this->n_qois()))
232  if (qoi_indices.has_index(i))
234  (this->get_adjoint_solution(i), i);
235 #endif
236 
237  return totalrval;
238 }
NumericVector< Number > & add_adjoint_solution(unsigned int i=0)
Definition: system.C:1233
virtual std::pair< unsigned int, Real > get_linear_solve_parameters() const
unsigned int n_qois() const
Number of currently active quantities of interest.
Definition: system.h:2621
virtual LinearSolver< Number > * get_linear_solver() const
void enforce_adjoint_constraints_exactly(NumericVector< Number > &v, unsigned int q) const
Heterogeneously constrains the numeric vector v, which represents an adjoint solution defined on the ...
Definition: dof_map.h:2354
virtual void assembly(bool, bool, bool=false, bool=false)
Assembles a residual in rhs and/or a jacobian in matrix, as requested.
template class LIBMESH_EXPORT LinearSolver< Number >
SparseMatrix< Number > * matrix
The system matrix.
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...
Definition: int_range.h:140
virtual void assemble_qoi_derivative(const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true) override
Prepares adjoint_rhs for quantity of interest derivative assembly, then calls user qoi derivative fun...
NumericVector< Number > & get_adjoint_solution(unsigned int i=0)
Definition: system.C:1245
bool assemble_before_solve
Flag which tells the system to whether or not to call the user assembly function during each call to ...
Definition: system.h:1547
const DofMap & get_dof_map() const
Definition: system.h:2374
NumericVector< Number > & get_adjoint_rhs(unsigned int i=0)
Definition: system.C:1307

◆ allocate_data_structures()

void TransientRBConstruction::allocate_data_structures ( )
overrideprotectedvirtual

Helper function that actually allocates all the data structures required by this class.

Reimplemented from libMesh::RBConstruction.

Definition at line 179 of file transient_rb_construction.C.

References libMesh::RBConstruction::allocate_data_structures(), libMesh::DofMap::attach_matrix(), libMesh::SparseMatrix< T >::build(), libMesh::NumericVector< T >::build(), libMesh::ParallelObject::comm(), libMesh::System::get_dof_map(), libMesh::TransientRBThetaExpansion::get_n_M_terms(), libMesh::RBThetaExpansion::get_n_outputs(), libMesh::RBTemporalDiscretization::get_n_time_steps(), libMesh::RBConstruction::get_rb_theta_expansion(), L2_matrix, M_q_vector, libMesh::System::n_dofs(), libMesh::System::n_local_dofs(), libMesh::RBConstruction::Nmax, non_dirichlet_L2_matrix, non_dirichlet_M_q_vector, libMesh::PARALLEL, RB_ic_proj_rhs_all_N, libMesh::DenseVector< T >::resize(), libMesh::RBConstruction::store_non_dirichlet_operators, temporal_data, and truth_outputs_all_k.

180 {
182 
183  TransientRBThetaExpansion & trans_theta_expansion =
184  cast_ref<TransientRBThetaExpansion &>(get_rb_theta_expansion());
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();
187 
188  // Resize and allocate vectors for storing mesh-dependent data
189  const unsigned int n_time_levels = get_n_time_steps()+1;
190  temporal_data.resize(n_time_levels);
191 
192  // Resize vectors for storing mesh-dependent data but only
193  // initialize if initialize_mesh_dependent_data == true
194  M_q_vector.resize(Q_m);
195 
196  // Only initialize the mass matrices if we
197  // are not in single-matrix mode
198  {
199  DofMap & dof_map = this->get_dof_map();
200 
201  dof_map.attach_matrix(*L2_matrix);
202  L2_matrix->init();
203  L2_matrix->zero();
204 
205  for (unsigned int q=0; q<Q_m; q++)
206  {
207  // Initialize the memory for the matrices
209  dof_map.attach_matrix(*M_q_vector[q]);
210  M_q_vector[q]->init();
211  M_q_vector[q]->zero();
212  }
213 
214  // We also need to initialize a second set of non-Dirichlet operators
216  {
217  dof_map.attach_matrix(*non_dirichlet_L2_matrix);
218  non_dirichlet_L2_matrix->init();
219  non_dirichlet_L2_matrix->zero();
220 
221  non_dirichlet_M_q_vector.resize(Q_m);
222  for (unsigned int q=0; q<Q_m; q++)
223  {
224  // Initialize the memory for the matrices
226  dof_map.attach_matrix(*non_dirichlet_M_q_vector[q]);
227  non_dirichlet_M_q_vector[q]->init();
228  non_dirichlet_M_q_vector[q]->zero();
229  }
230  }
231  }
232 
233  for (unsigned int i=0; i<n_time_levels; i++)
234  {
236  temporal_data[i]->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
237  }
238 
239  // and the truth output vectors
240  truth_outputs_all_k.resize(n_outputs);
241  for (unsigned int n=0; n<n_outputs; n++)
242  {
243  truth_outputs_all_k[n].resize(n_time_levels);
244  }
245 
246  // This vector is for storing rhs entries for
247  // computing the projection of the initial condition
248  // into the RB space
250 }
std::unique_ptr< SparseMatrix< Number > > L2_matrix
The L2 matrix.
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...
void resize(const unsigned int n)
Resize the vector.
Definition: dense_vector.h:396
const Parallel::Communicator & comm() const
std::vector< std::vector< Number > > truth_outputs_all_k
The truth outputs for all time-levels from the most recent truth_solve.
dof_id_type n_local_dofs() const
Definition: system.C:158
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.
dof_id_type n_dofs() const
Definition: system.C:121
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
std::unique_ptr< SparseMatrix< Number > > non_dirichlet_L2_matrix
The L2 matrix without Dirichlet conditions enforced.
bool store_non_dirichlet_operators
Boolean flag to indicate whether we store a second copy of each affine operator and vector which does...
std::vector< std::unique_ptr< NumericVector< Number > > > temporal_data
Dense matrix to store the data that we use for the temporal POD.
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...
unsigned int get_n_time_steps() const
Get/set the total number of time-steps.
std::vector< std::unique_ptr< SparseMatrix< Number > > > M_q_vector
Vector storing the Q_m matrices from the mass operator.
const DofMap & get_dof_map() const
Definition: system.h:2374
virtual void allocate_data_structures()
Helper function that actually allocates all the data structures required by this class.
unsigned int Nmax
Maximum number of reduced basis functions we are willing to use.
DenseVector< Number > RB_ic_proj_rhs_all_N
The vector that stores the right-hand side for the initial condition projections. ...

◆ assemble()

virtual void libMesh::LinearImplicitSystem::assemble ( )
inlineoverridevirtualinherited

Prepares matrix and _dof_map for matrix assembly.

Does not actually assemble anything. For matrix assembly, use the assemble() in derived classes. Should be overridden in derived classes.

Reimplemented from libMesh::ImplicitSystem.

Reimplemented in libMesh::FrequencySystem, and libMesh::NewmarkSystem.

Definition at line 115 of file linear_implicit_system.h.

References libMesh::ImplicitSystem::assemble().

Referenced by libMesh::NewmarkSystem::assemble(), libMesh::FrequencySystem::assemble(), libMesh::LinearImplicitSystem::assembly(), and libMesh::LinearImplicitSystem::solve().

virtual void assemble() override
Prepares matrix and rhs for system assembly, then calls user assembly function.

◆ assemble_affine_expansion()

void TransientRBConstruction::assemble_affine_expansion ( bool  skip_matrix_assembly,
bool  skip_vector_assembly 
)
overrideprotectedvirtual

Override assemble_affine_expansion to also initialize RB_ic_proj_rhs_all_N, if necessary.

Reimplemented from libMesh::RBConstruction.

Definition at line 252 of file transient_rb_construction.C.

References libMesh::RBConstruction::assemble_affine_expansion(), libMesh::NumericVector< T >::build(), libMesh::ParallelObject::comm(), libMesh::DenseVector< T >::dot(), libMesh::RBEvaluation::get_n_basis_functions(), libMesh::RBConstruction::get_rb_evaluation(), initialize_truth(), L2_matrix, libMesh::System::n_dofs(), libMesh::System::n_local_dofs(), libMesh::PARALLEL, RB_ic_proj_rhs_all_N, and libMesh::System::solution.

254 {
255  // Call parent's assembly functions
256  Parent::assemble_affine_expansion(skip_matrix_assembly, skip_vector_assembly);
257 
258  // Now update RB_ic_proj_rhs_all_N if necessary.
259  // This allows us to compute the L2 projection
260  // of the initial condition into the RB space
261  // so that we can continue to enrich a given RB
262  // space.
263  if (get_rb_evaluation().get_n_basis_functions() > 0)
264  {
265  // Load the initial condition into the solution vector
267 
268  std::unique_ptr<NumericVector<Number>> temp1 = NumericVector<Number>::build(this->comm());
269  temp1->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
270 
271  // First compute the right-hand side vector for the L2 projection
272  L2_matrix->vector_mult(*temp1, *solution);
273 
274  for (unsigned int i=0; i<get_rb_evaluation().get_n_basis_functions(); i++)
275  {
276  RB_ic_proj_rhs_all_N(i) = temp1->dot(get_rb_evaluation().get_basis_function(i));
277  }
278  }
279 }
std::unique_ptr< SparseMatrix< Number > > L2_matrix
The L2 matrix.
virtual void initialize_truth()
This function imposes a truth initial condition, defaults to zero initial condition if the flag nonze...
const Parallel::Communicator & comm() const
dof_id_type n_local_dofs() const
Definition: system.C:158
dof_id_type n_dofs() const
Definition: system.C:121
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
CompareTypes< T, T2 >::supertype dot(const DenseVector< T2 > &vec) const
Definition: dense_vector.h:492
virtual unsigned int get_n_basis_functions() const
Get the current number of basis functions.
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...
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.
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. ...

◆ assemble_all_affine_operators()

void TransientRBConstruction::assemble_all_affine_operators ( )
overridevirtual

Assemble and store all the affine operators.

Override to assemble the mass matrix operators.

Reimplemented from libMesh::RBConstruction.

Definition at line 485 of file transient_rb_construction.C.

References libMesh::RBConstruction::assemble_all_affine_operators(), assemble_Mq_matrix(), get_M_q(), libMesh::TransientRBThetaExpansion::get_n_M_terms(), get_non_dirichlet_M_q(), libMesh::RBConstruction::get_rb_theta_expansion(), and libMesh::RBConstruction::store_non_dirichlet_operators.

486 {
488 
489  TransientRBThetaExpansion & trans_theta_expansion =
490  cast_ref<TransientRBThetaExpansion &>(get_rb_theta_expansion());
491 
492  for (unsigned int q=0; q<trans_theta_expansion.get_n_M_terms(); q++)
494 
496  {
497  for (unsigned int q=0; q<trans_theta_expansion.get_n_M_terms(); q++)
499  }
500 }
SparseMatrix< Number > * get_M_q(unsigned int q)
Get a pointer to M_q.
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
bool store_non_dirichlet_operators
Boolean flag to indicate whether we store a second copy of each affine operator and vector which does...
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.
SparseMatrix< Number > * get_non_dirichlet_M_q(unsigned int q)
Get a pointer to non_dirichlet_M_q.
virtual void assemble_all_affine_operators()
Assemble and store all Q_a affine operators as well as the inner-product matrix.

◆ assemble_all_affine_vectors()

void libMesh::RBConstruction::assemble_all_affine_vectors ( )
protectedvirtualinherited

Assemble and store the affine RHS vectors.

Definition at line 1103 of file rb_construction.C.

References libMesh::RBConstruction::assemble_Fq_vector(), libMesh::RBConstruction::get_Fq(), libMesh::RBThetaExpansion::get_n_F_terms(), libMesh::RBConstruction::get_non_dirichlet_Fq(), libMesh::RBConstruction::get_rb_theta_expansion(), libMesh::out, and libMesh::RBConstruction::store_non_dirichlet_operators.

Referenced by libMesh::RBConstruction::assemble_affine_expansion().

1104 {
1105  for (unsigned int q_f=0; q_f<get_rb_theta_expansion().get_n_F_terms(); q_f++)
1106  {
1107  libMesh::out << "Assembling affine vector " << (q_f+1) << " of "
1108  << get_rb_theta_expansion().get_n_F_terms() << std::endl;
1109  assemble_Fq_vector(q_f, get_Fq(q_f));
1110  }
1111 
1113  {
1114  for (unsigned int q_f=0; q_f<get_rb_theta_expansion().get_n_F_terms(); q_f++)
1115  {
1116  libMesh::out << "Assembling non-Dirichlet affine vector " << (q_f+1) << " of "
1117  << get_rb_theta_expansion().get_n_F_terms() << std::endl;
1118  assemble_Fq_vector(q_f, get_non_dirichlet_Fq(q_f), false);
1119  }
1120  }
1121 
1122 }
unsigned int get_n_F_terms() const
Get Q_f, the number of terms in the affine expansion for the right-hand side.
NumericVector< Number > * get_Fq(unsigned int q)
Get a pointer to Fq.
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
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.
NumericVector< Number > * get_non_dirichlet_Fq(unsigned int q)
Get a pointer to non-Dirichlet Fq.
bool store_non_dirichlet_operators
Boolean flag to indicate whether we store a second copy of each affine operator and vector which does...
OStreamProxy out

◆ assemble_all_output_vectors()

void libMesh::RBConstruction::assemble_all_output_vectors ( )
protectedvirtualinherited

Assemble and store the output vectors.

Definition at line 1141 of file rb_construction.C.

References libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::RBThetaExpansion::get_n_output_terms(), libMesh::RBThetaExpansion::get_n_outputs(), libMesh::RBConstruction::get_non_dirichlet_output_vector(), libMesh::RBAssemblyExpansion::get_output_assembly(), libMesh::RBConstruction::get_output_vector(), libMesh::RBConstruction::get_rb_theta_expansion(), libMesh::out, libMesh::RBConstruction::rb_assembly_expansion, libMesh::RBConstruction::store_non_dirichlet_operators, and libMesh::NumericVector< T >::zero().

Referenced by libMesh::RBConstruction::assemble_affine_expansion().

1142 {
1143  for (unsigned int n=0; n<get_rb_theta_expansion().get_n_outputs(); n++)
1144  for (unsigned int q_l=0; q_l<get_rb_theta_expansion().get_n_output_terms(n); q_l++)
1145  {
1146  libMesh::out << "Assembling output vector, (" << (n+1) << "," << (q_l+1)
1147  << ") of (" << get_rb_theta_expansion().get_n_outputs()
1148  << "," << get_rb_theta_expansion().get_n_output_terms(n) << ")"
1149  << std::endl;
1150  get_output_vector(n, q_l)->zero();
1152  nullptr,
1153  get_output_vector(n,q_l),
1154  false, /* symmetrize */
1155  true /* apply_dof_constraints */);
1156  }
1157 
1159  {
1160  for (unsigned int n=0; n<get_rb_theta_expansion().get_n_outputs(); n++)
1161  for (unsigned int q_l=0; q_l<get_rb_theta_expansion().get_n_output_terms(n); q_l++)
1162  {
1163  libMesh::out << "Assembling non-Dirichlet output vector, (" << (n+1) << "," << (q_l+1)
1164  << ") of (" << get_rb_theta_expansion().get_n_outputs()
1165  << "," << get_rb_theta_expansion().get_n_output_terms(n) << ")"
1166  << std::endl;
1169  nullptr,
1171  false, /* symmetrize */
1172  false /* apply_dof_constraints */);
1173  }
1174  }
1175 }
ElemAssembly & get_output_assembly(unsigned int output_index, unsigned int q_l)
Return a reference to the specified output assembly object.
unsigned int get_n_outputs() const
Get n_outputs, the number output functionals.
virtual void zero()=0
Set all entries to zero.
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
void add_scaled_matrix_and_vector(Number scalar, ElemAssembly *elem_assembly, SparseMatrix< Number > *input_matrix, NumericVector< Number > *input_vector, bool symmetrize=false, bool apply_dof_constraints=true)
This function loops over the mesh and applies the specified interior and/or boundary assembly routine...
bool store_non_dirichlet_operators
Boolean flag to indicate whether we store a second copy of each affine operator and vector which does...
unsigned int get_n_output_terms(unsigned int output_index) const
Get the number of affine terms associated with the specified output.
OStreamProxy out
RBAssemblyExpansion * rb_assembly_expansion
This member holds the (parameter independent) assembly functors that define the "affine expansion" of...
NumericVector< Number > * get_output_vector(unsigned int n, unsigned int q_l)
Get a pointer to the n^th output.
NumericVector< Number > * get_non_dirichlet_output_vector(unsigned int n, unsigned int q_l)
Get a pointer to non-Dirichlet output vector.

◆ assemble_Aq_matrix()

void libMesh::RBConstruction::assemble_Aq_matrix ( unsigned int  q,
SparseMatrix< Number > *  input_matrix,
bool  apply_dof_constraints = true 
)
inherited

Assemble the q^th affine matrix and store it in input_matrix.

Definition at line 1029 of file rb_construction.C.

References libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::RBAssemblyExpansion::get_A_assembly(), libMesh::RBConstruction::get_rb_theta_expansion(), libMesh::RBConstruction::rb_assembly_expansion, and libMesh::SparseMatrix< T >::zero().

Referenced by libMesh::RBConstruction::assemble_all_affine_operators().

1032 {
1033  libmesh_error_msg_if(q >= get_rb_theta_expansion().get_n_A_terms(),
1034  "Error: We must have q < Q_a in assemble_Aq_matrix.");
1035 
1036  input_matrix->zero();
1037 
1040  input_matrix,
1041  nullptr,
1042  false, /* symmetrize */
1043  apply_dof_constraints);
1044 }
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
virtual void zero()=0
Set all entries to 0.
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...
ElemAssembly & get_A_assembly(unsigned int q)
Return a reference to the specified A_assembly object.
RBAssemblyExpansion * rb_assembly_expansion
This member holds the (parameter independent) assembly functors that define the "affine expansion" of...

◆ assemble_Fq_vector()

void libMesh::RBConstruction::assemble_Fq_vector ( unsigned int  q,
NumericVector< Number > *  input_vector,
bool  apply_dof_constraints = true 
)
inherited

Assemble the q^th affine vector and store it in input_matrix.

Definition at line 1124 of file rb_construction.C.

References libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::RBAssemblyExpansion::get_F_assembly(), libMesh::RBConstruction::get_rb_theta_expansion(), libMesh::RBConstruction::rb_assembly_expansion, and libMesh::NumericVector< T >::zero().

Referenced by libMesh::RBConstruction::assemble_all_affine_vectors().

1127 {
1128  libmesh_error_msg_if(q >= get_rb_theta_expansion().get_n_F_terms(),
1129  "Error: We must have q < Q_f in assemble_Fq_vector.");
1130 
1131  input_vector->zero();
1132 
1135  nullptr,
1136  input_vector,
1137  false, /* symmetrize */
1138  apply_dof_constraints /* apply_dof_constraints */);
1139 }
ElemAssembly & get_F_assembly(unsigned int q)
Return a reference to the specified F_assembly object.
virtual void zero()=0
Set all entries to zero.
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
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...
RBAssemblyExpansion * rb_assembly_expansion
This member holds the (parameter independent) assembly functors that define the "affine expansion" of...

◆ assemble_inner_product_matrix()

void libMesh::RBConstruction::assemble_inner_product_matrix ( SparseMatrix< Number > *  input_matrix,
bool  apply_dof_constraints = true 
)
inherited

Assemble the inner product matrix and store it in input_matrix.

Definition at line 996 of file rb_construction.C.

References libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::RBConstruction::energy_inner_product_coeffs, libMesh::RBAssemblyExpansion::get_A_assembly(), libMesh::RBThetaExpansion::get_n_A_terms(), libMesh::RBConstruction::get_rb_theta_expansion(), libMesh::RBConstruction::inner_product_assembly, libMesh::RBConstruction::rb_assembly_expansion, libMesh::RBConstruction::use_energy_inner_product, and libMesh::SparseMatrix< T >::zero().

Referenced by libMesh::RBConstruction::assemble_misc_matrices().

998 {
999  input_matrix->zero();
1000 
1002  {
1005  input_matrix,
1006  nullptr,
1007  false, /* symmetrize */
1008  apply_dof_constraints);
1009  }
1010  else
1011  {
1012  libmesh_error_msg_if(energy_inner_product_coeffs.size() != get_rb_theta_expansion().get_n_A_terms(),
1013  "Error: invalid number of entries in energy_inner_product_coeffs.");
1014 
1015  // We symmetrize below so that we may use the energy inner-product even in cases
1016  // where the A_q are not symmetric.
1017  for (unsigned int q_a=0; q_a<get_rb_theta_expansion().get_n_A_terms(); q_a++)
1018  {
1021  input_matrix,
1022  nullptr,
1023  true, /* symmetrize */
1024  apply_dof_constraints);
1025  }
1026  }
1027 }
unsigned int get_n_A_terms() const
Get Q_a, the number of terms in the affine expansion for the bilinear form.
std::vector< Number > energy_inner_product_coeffs
We may optionally want to use the "energy inner-product" rather than the inner-product assembly speci...
bool use_energy_inner_product
Boolean to indicate whether we&#39;re using the energy inner-product.
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
virtual void zero()=0
Set all entries to 0.
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...
ElemAssembly * inner_product_assembly
Pointer to inner product assembly.
ElemAssembly & get_A_assembly(unsigned int q)
Return a reference to the specified A_assembly object.
RBAssemblyExpansion * rb_assembly_expansion
This member holds the (parameter independent) assembly functors that define the "affine expansion" of...

◆ assemble_L2_matrix()

void TransientRBConstruction::assemble_L2_matrix ( SparseMatrix< Number > *  input_matrix,
bool  apply_dirichlet_bc = true 
)

Assemble the L2 matrix.

Definition at line 345 of file transient_rb_construction.C.

References libMesh::RBConstruction::add_scaled_matrix_and_vector(), L2_assembly, and libMesh::SparseMatrix< T >::zero().

Referenced by assemble_misc_matrices().

346 {
347  input_matrix->zero();
349  L2_assembly,
350  input_matrix,
351  nullptr,
352  false, /* symmetrize */
353  apply_dirichlet_bc);
354 }
virtual void zero()=0
Set all entries to 0.
ElemAssembly * L2_assembly
Function pointer for assembling the L2 matrix.
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...

◆ assemble_mass_matrix()

void TransientRBConstruction::assemble_mass_matrix ( SparseMatrix< Number > *  input_matrix)

Assemble the mass matrix at the current parameter and store it in input_matrix.

Definition at line 356 of file transient_rb_construction.C.

References add_scaled_mass_matrix(), and libMesh::SparseMatrix< T >::zero().

357 {
358  input_matrix->zero();
359  add_scaled_mass_matrix(1., input_matrix);
360 }
virtual void zero()=0
Set all entries to 0.
void add_scaled_mass_matrix(Number scalar, SparseMatrix< Number > *input_matrix)
Add the scaled mass matrix (assembled for the current parameter) to input_matrix. ...

◆ assemble_misc_matrices()

void TransientRBConstruction::assemble_misc_matrices ( )
overridevirtual

Override to assemble the L2 matrix as well.

Reimplemented from libMesh::RBConstruction.

Definition at line 502 of file transient_rb_construction.C.

References assemble_L2_matrix(), libMesh::RBConstruction::assemble_misc_matrices(), L2_matrix, non_dirichlet_L2_matrix, libMesh::out, and libMesh::RBConstruction::store_non_dirichlet_operators.

503 {
504  libMesh::out << "Assembling L2 matrix" << std::endl;
506 
508  {
509  libMesh::out << "Assembling non-Dirichlet L2 matrix" << std::endl;
510  assemble_L2_matrix(non_dirichlet_L2_matrix.get(), /* apply_dirichlet_bc = */ false);
511  }
512 
514 }
std::unique_ptr< SparseMatrix< Number > > L2_matrix
The L2 matrix.
void assemble_L2_matrix(SparseMatrix< Number > *input_matrix, bool apply_dirichlet_bc=true)
Assemble the L2 matrix.
std::unique_ptr< SparseMatrix< Number > > non_dirichlet_L2_matrix
The L2 matrix without Dirichlet conditions enforced.
bool store_non_dirichlet_operators
Boolean flag to indicate whether we store a second copy of each affine operator and vector which does...
OStreamProxy out
virtual void assemble_misc_matrices()
Assemble and store all the inner-product matrix, the constraint matrix (for constrained problems) and...

◆ assemble_Mq_matrix()

void TransientRBConstruction::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.

Definition at line 465 of file transient_rb_construction.C.

References libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::TransientRBThetaExpansion::get_n_M_terms(), libMesh::RBConstruction::get_rb_assembly_expansion(), libMesh::RBConstruction::get_rb_theta_expansion(), and libMesh::SparseMatrix< T >::zero().

Referenced by assemble_all_affine_operators().

466 {
467  TransientRBThetaExpansion & trans_theta_expansion =
468  cast_ref<TransientRBThetaExpansion &>(get_rb_theta_expansion());
469 
470  TransientRBAssemblyExpansion & trans_assembly_expansion =
471  cast_ref<TransientRBAssemblyExpansion &>(get_rb_assembly_expansion());
472 
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.");
475 
476  input_matrix->zero();
478  &trans_assembly_expansion.get_M_assembly(q),
479  input_matrix,
480  nullptr,
481  false, /* symmetrize */
482  apply_dirichlet_bc);
483 }
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
virtual void zero()=0
Set all entries to 0.
RBAssemblyExpansion & get_rb_assembly_expansion()
void add_scaled_matrix_and_vector(Number scalar, ElemAssembly *elem_assembly, SparseMatrix< Number > *input_matrix, NumericVector< Number > *input_vector, bool symmetrize=false, bool apply_dof_constraints=true)
This function loops over the mesh and applies the specified interior and/or boundary assembly routine...

◆ assemble_qoi()

void libMesh::ExplicitSystem::assemble_qoi ( const QoISet qoi_indices = QoISet())
overridevirtualinherited

Prepares qoi for quantity of interest assembly, then calls user qoi function.

Can be overridden in derived classes.

Reimplemented from libMesh::System.

Reimplemented in libMesh::FEMSystem.

Definition at line 54 of file explicit_system.C.

References libMesh::System::assemble_qoi(), libMesh::QoISet::has_index(), libMesh::make_range(), libMesh::System::n_qois(), and libMesh::System::set_qoi().

Referenced by libMesh::ImplicitSystem::adjoint_qoi_parameter_sensitivity(), libMesh::ImplicitSystem::forward_qoi_parameter_sensitivity(), libMesh::Euler2Solver::integrate_qoi_timestep(), libMesh::EulerSolver::integrate_qoi_timestep(), libMesh::SteadySolver::integrate_qoi_timestep(), libMesh::ImplicitSystem::qoi_parameter_hessian(), and libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product().

55 {
56  // The user quantity of interest assembly gets to expect to
57  // accumulate on initially zero values
58  for (auto i : make_range(this->n_qois()))
59  if (qoi_indices.has_index(i))
60  this->set_qoi(i, 0);
61 
62  Parent::assemble_qoi (qoi_indices);
63 }
unsigned int n_qois() const
Number of currently active quantities of interest.
Definition: system.h:2621
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...
Definition: int_range.h:140
void set_qoi(unsigned int qoi_index, Number qoi_value)
Definition: system.C:2378
virtual void assemble_qoi(const QoISet &qoi_indices=QoISet())
Calls user qoi function.
Definition: system.C:577

◆ assemble_qoi_derivative()

void libMesh::ExplicitSystem::assemble_qoi_derivative ( const QoISet qoi_indices = QoISet(),
bool  include_liftfunc = true,
bool  apply_constraints = true 
)
overridevirtualinherited

Prepares adjoint_rhs for quantity of interest derivative assembly, then calls user qoi derivative function.

Can be overridden in derived classes.

Reimplemented from libMesh::System.

Reimplemented in libMesh::FEMSystem.

Definition at line 67 of file explicit_system.C.

References libMesh::System::add_adjoint_rhs(), libMesh::System::assemble_qoi_derivative(), libMesh::QoISet::has_index(), libMesh::make_range(), libMesh::System::n_qois(), and libMesh::NumericVector< T >::zero().

Referenced by libMesh::ImplicitSystem::adjoint_solve(), libMesh::ImplicitSystem::forward_qoi_parameter_sensitivity(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), and libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().

70 {
71  // The user quantity of interest derivative assembly gets to expect
72  // to accumulate on initially zero vectors
73  for (auto i : make_range(this->n_qois()))
74  if (qoi_indices.has_index(i))
75  this->add_adjoint_rhs(i).zero();
76 
77  Parent::assemble_qoi_derivative (qoi_indices, include_liftfunc,
78  apply_constraints);
79 }
unsigned int n_qois() const
Number of currently active quantities of interest.
Definition: system.h:2621
virtual void assemble_qoi_derivative(const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true)
Calls user qoi derivative function.
Definition: system.C:588
virtual void zero()=0
Set all entries to zero.
NumericVector< Number > & add_adjoint_rhs(unsigned int i=0)
Definition: system.C:1297
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...
Definition: int_range.h:140

◆ assemble_residual_derivatives()

void libMesh::ImplicitSystem::assemble_residual_derivatives ( const ParameterVector parameters)
overridevirtualinherited

Residual parameter derivative function.

Uses finite differences by default.

This will assemble the sensitivity rhs vectors to hold -(partial R / partial p_i), making them ready to solve the forward sensitivity equation.

Can be overridden in derived classes.

Reimplemented from libMesh::System.

Definition at line 470 of file implicit_system.C.

References libMesh::System::add_sensitivity_rhs(), libMesh::ImplicitSystem::assembly(), libMesh::NumericVector< T >::close(), libMesh::Real, libMesh::ExplicitSystem::rhs, libMesh::ParameterVector::size(), and libMesh::TOLERANCE.

Referenced by libMesh::ImplicitSystem::adjoint_qoi_parameter_sensitivity(), and libMesh::ImplicitSystem::sensitivity_solve().

471 {
472  ParameterVector & parameters_vec =
473  const_cast<ParameterVector &>(parameters_in);
474 
475  const unsigned int Np = cast_int<unsigned int>
476  (parameters_vec.size());
477 
478  for (unsigned int p=0; p != Np; ++p)
479  {
480  NumericVector<Number> & sensitivity_rhs = this->add_sensitivity_rhs(p);
481 
482  // Approximate -(partial R / partial p) by
483  // (R(p-dp) - R(p+dp)) / (2*dp)
484 
485  Number old_parameter = *parameters_vec[p];
486 
487  const Real delta_p =
488  TOLERANCE * std::max(std::abs(old_parameter), 1e-3);
489 
490  *parameters_vec[p] -= delta_p;
491 
492  // this->assembly(true, false, true);
493  this->assembly(true, false, false);
494  this->rhs->close();
495  sensitivity_rhs = *this->rhs;
496 
497  *parameters_vec[p] = old_parameter + delta_p;
498 
499  // this->assembly(true, false, true);
500  this->assembly(true, false, false);
501  this->rhs->close();
502 
503  sensitivity_rhs -= *this->rhs;
504  sensitivity_rhs /= (2*delta_p);
505  sensitivity_rhs.close();
506 
507  *parameters_vec[p] = old_parameter;
508  }
509 }
static constexpr Real TOLERANCE
NumericVector< Number > * rhs
The system matrix.
NumericVector< Number > & add_sensitivity_rhs(unsigned int i=0)
Definition: system.C:1327
virtual void assembly(bool, bool, bool=false, bool=false)
Assembles a residual in rhs and/or a jacobian in matrix, as requested.
virtual void close()=0
Calls the NumericVector&#39;s internal assembly routines, ensuring that the values are consistent across ...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
template class LIBMESH_EXPORT NumericVector< Number >

◆ assembly()

void libMesh::LinearImplicitSystem::assembly ( bool  get_residual,
bool  get_jacobian,
bool  apply_heterogeneous_constraints = false,
bool  apply_no_constraints = false 
)
overridevirtualinherited

Assembles a residual in rhs and/or a jacobian in matrix, as requested.

Reimplemented from libMesh::ImplicitSystem.

Definition at line 363 of file linear_implicit_system.C.

References libMesh::NumericVector< T >::add_vector(), libMesh::LinearImplicitSystem::assemble(), libMesh::NumericVector< T >::close(), libMesh::SparseMatrix< T >::close(), libMesh::ImplicitSystem::matrix, libMesh::ExplicitSystem::rhs, and libMesh::System::solution.

367 {
368  // Residual R(u(p),p) := A(p)*u(p) - b(p)
369  // partial R / partial u = A
370 
371  this->assemble();
372  this->rhs->close();
373  this->matrix->close();
374 
375  *(this->rhs) *= -1.0;
376  this->rhs->add_vector(*this->solution, *this->matrix);
377 }
virtual void assemble() override
Prepares matrix and _dof_map for matrix assembly.
virtual void add_vector(const T *v, const std::vector< numeric_index_type > &dof_indices)
Computes , where v is a pointer and each dof_indices[i] specifies where to add value v[i]...
NumericVector< Number > * rhs
The system matrix.
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
virtual void close()=0
Calls the NumericVector&#39;s internal assembly routines, ensuring that the values are consistent across ...
virtual void close()=0
Calls the SparseMatrix&#39;s internal assembly routines, ensuring that the values are consistent across p...
SparseMatrix< Number > * matrix
The system matrix.

◆ attach_assemble_function()

void libMesh::System::attach_assemble_function ( void   fptrEquationSystems &es, const std::string &name)
inherited

Register a user function to use in assembling the system matrix and RHS.

Definition at line 2161 of file system.C.

References libMesh::System::_assemble_system_function, libMesh::System::_assemble_system_object, fptr(), and libMesh::libmesh_assert().

Referenced by assemble_and_solve(), main(), ConstraintOperatorTest::test1DCoarseningNewNodes(), ConstraintOperatorTest::test1DCoarseningOperator(), SystemsTest::testAssemblyWithDgFemContext(), ConstraintOperatorTest::testCoreform(), SystemsTest::testDofCouplingWithVarGroups(), and PeriodicBCTest::testPeriodicBC().

2163 {
2165 
2166  if (_assemble_system_object != nullptr)
2167  {
2168  libmesh_warning("WARNING: Cannot specify both assembly function and object!");
2169 
2170  _assemble_system_object = nullptr;
2171  }
2172 
2174 }
Assembly * _assemble_system_object
Object that assembles the system.
Definition: system.h:2136
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:80
libmesh_assert(ctx)
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Function that assembles the system.
Definition: system.h:2130

◆ attach_assemble_object()

void libMesh::System::attach_assemble_object ( System::Assembly assemble_in)
inherited

Register a user object to use in assembling the system matrix and RHS.

Definition at line 2178 of file system.C.

References libMesh::System::_assemble_system_function, and libMesh::System::_assemble_system_object.

Referenced by main().

2179 {
2180  if (_assemble_system_function != nullptr)
2181  {
2182  libmesh_warning("WARNING: Cannot specify both assembly object and function!");
2183 
2184  _assemble_system_function = nullptr;
2185  }
2186 
2187  _assemble_system_object = &assemble_in;
2188 }
Assembly * _assemble_system_object
Object that assembles the system.
Definition: system.h:2136
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Function that assembles the system.
Definition: system.h:2130

◆ attach_constraint_function()

void libMesh::System::attach_constraint_function ( void   fptrEquationSystems &es, const std::string &name)
inherited

Register a user function for imposing constraints.

Definition at line 2192 of file system.C.

References libMesh::System::_constrain_system_function, libMesh::System::_constrain_system_object, fptr(), and libMesh::libmesh_assert().

2194 {
2196 
2197  if (_constrain_system_object != nullptr)
2198  {
2199  libmesh_warning("WARNING: Cannot specify both constraint function and object!");
2200 
2201  _constrain_system_object = nullptr;
2202  }
2203 
2205 }
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Function to impose constraints.
Definition: system.h:2141
Constraint * _constrain_system_object
Object that constrains the system.
Definition: system.h:2147
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:80
libmesh_assert(ctx)

◆ attach_constraint_object()

void libMesh::System::attach_constraint_object ( System::Constraint constrain)
inherited

Register a user object for imposing constraints.

Definition at line 2209 of file system.C.

References libMesh::System::_constrain_system_function, and libMesh::System::_constrain_system_object.

Referenced by libMesh::VariationalMeshSmoother::smooth(), and DofMapTest::testConstraintLoopDetection().

2210 {
2211  if (_constrain_system_function != nullptr)
2212  {
2213  libmesh_warning("WARNING: Cannot specify both constraint object and function!");
2214 
2215  _constrain_system_function = nullptr;
2216  }
2217 
2218  _constrain_system_object = &constrain;
2219 }
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Function to impose constraints.
Definition: system.h:2141
Constraint * _constrain_system_object
Object that constrains the system.
Definition: system.h:2147

◆ attach_init_function()

void libMesh::System::attach_init_function ( void   fptrEquationSystems &es, const std::string &name)
inherited

Register a user function to use in initializing the system.

Definition at line 2130 of file system.C.

References libMesh::System::_init_system_function, libMesh::System::_init_system_object, fptr(), and libMesh::libmesh_assert().

Referenced by main().

2132 {
2134 
2135  if (_init_system_object != nullptr)
2136  {
2137  libmesh_warning("WARNING: Cannot specify both initialization function and object!");
2138 
2139  _init_system_object = nullptr;
2140  }
2141 
2143 }
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:80
libmesh_assert(ctx)
Initialization * _init_system_object
Object that initializes the system.
Definition: system.h:2125
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Function that initializes the system.
Definition: system.h:2119

◆ attach_init_object()

void libMesh::System::attach_init_object ( System::Initialization init_in)
inherited

Register a user class to use to initialize the system.

Note
This is exclusive with the attach_init_function.

Definition at line 2147 of file system.C.

References libMesh::System::_init_system_function, and libMesh::System::_init_system_object.

2148 {
2149  if (_init_system_function != nullptr)
2150  {
2151  libmesh_warning("WARNING: Cannot specify both initialization object and function!");
2152 
2153  _init_system_function = nullptr;
2154  }
2155 
2156  _init_system_object = &init_in;
2157 }
Initialization * _init_system_object
Object that initializes the system.
Definition: system.h:2125
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Function that initializes the system.
Definition: system.h:2119

◆ attach_QOI_derivative()

void libMesh::System::attach_QOI_derivative ( void   fptrEquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
inherited

Register a user function for evaluating derivatives of a quantity of interest with respect to test functions, whose values should be placed in System::rhs.

Definition at line 2266 of file system.C.

References libMesh::System::_qoi_evaluate_derivative_function, libMesh::System::_qoi_evaluate_derivative_object, fptr(), and libMesh::libmesh_assert().

2268 {
2270 
2271  if (_qoi_evaluate_derivative_object != nullptr)
2272  {
2273  libmesh_warning("WARNING: Cannot specify both QOI derivative function and object!");
2274 
2276  }
2277 
2279 }
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:80
QOIDerivative * _qoi_evaluate_derivative_object
Object to compute derivatives of quantities of interest.
Definition: system.h:2173
libmesh_assert(ctx)
void(* _qoi_evaluate_derivative_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
Function to evaluate quantity of interest derivative.
Definition: system.h:2164

◆ attach_QOI_derivative_object()

void libMesh::System::attach_QOI_derivative_object ( QOIDerivative qoi_derivative)
inherited

Register a user object for evaluating derivatives of a quantity of interest with respect to test functions, whose values should be placed in System::rhs.

Definition at line 2283 of file system.C.

References libMesh::System::_qoi_evaluate_derivative_function, and libMesh::System::_qoi_evaluate_derivative_object.

2284 {
2285  if (_qoi_evaluate_derivative_function != nullptr)
2286  {
2287  libmesh_warning("WARNING: Cannot specify both QOI derivative object and function!");
2288 
2290  }
2291 
2292  _qoi_evaluate_derivative_object = &qoi_derivative;
2293 }
QOIDerivative * _qoi_evaluate_derivative_object
Object to compute derivatives of quantities of interest.
Definition: system.h:2173
void(* _qoi_evaluate_derivative_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
Function to evaluate quantity of interest derivative.
Definition: system.h:2164

◆ attach_QOI_function()

void libMesh::System::attach_QOI_function ( void   fptrEquationSystems &es, const std::string &name, const QoISet &qoi_indices)
inherited

Register a user function for evaluating the quantities of interest, whose values should be placed in System::qoi.

Definition at line 2234 of file system.C.

References libMesh::System::_qoi_evaluate_function, libMesh::System::_qoi_evaluate_object, fptr(), and libMesh::libmesh_assert().

2237 {
2239 
2240  if (_qoi_evaluate_object != nullptr)
2241  {
2242  libmesh_warning("WARNING: Cannot specify both QOI function and object!");
2243 
2244  _qoi_evaluate_object = nullptr;
2245  }
2246 
2248 }
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Function to evaluate quantity of interest.
Definition: system.h:2152
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:80
libmesh_assert(ctx)
QOI * _qoi_evaluate_object
Object to compute quantities of interest.
Definition: system.h:2159

◆ attach_QOI_object()

void libMesh::System::attach_QOI_object ( QOI qoi)
inherited

Register a user object for evaluating the quantities of interest, whose values should be placed in System::qoi.

Definition at line 2252 of file system.C.

References libMesh::System::_qoi_evaluate_function, and libMesh::System::_qoi_evaluate_object.

2253 {
2254  if (_qoi_evaluate_function != nullptr)
2255  {
2256  libmesh_warning("WARNING: Cannot specify both QOI object and function!");
2257 
2258  _qoi_evaluate_function = nullptr;
2259  }
2260 
2261  _qoi_evaluate_object = &qoi_in;
2262 }
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Function to evaluate quantity of interest.
Definition: system.h:2152
QOI * _qoi_evaluate_object
Object to compute quantities of interest.
Definition: system.h:2159

◆ attach_shell_matrix()

void libMesh::LinearImplicitSystem::attach_shell_matrix ( ShellMatrix< Number > *  shell_matrix)
inherited

This function enables the user to provide a shell matrix, i.e.

a matrix that is not stored element-wise, but as a function. When you register your shell matrix using this function, calling solve() will no longer use the matrix member but the registered shell matrix instead. You can reset this behaviour to its original state by supplying a nullptr to this function.

Definition at line 161 of file linear_implicit_system.C.

References libMesh::LinearImplicitSystem::_shell_matrix.

Referenced by libMesh::LinearImplicitSystem::detach_shell_matrix(), and main().

162 {
163  _shell_matrix = shell_matrix;
164 }
ShellMatrix< Number > * _shell_matrix
User supplies shell matrix or nullptr if no shell matrix is used.

◆ boundary_project_solution() [1/2]

void libMesh::System::boundary_project_solution ( const std::set< boundary_id_type > &  b,
const std::vector< unsigned int > &  variables,
FunctionBase< Number > *  f,
FunctionBase< Gradient > *  g = nullptr 
)
inherited

Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system.

This method projects an arbitrary boundary function onto the solution via L2 projections and nodal interpolations on each element.

Only degrees of freedom which affect the function's trace on a boundary in the set b are affected. Only degrees of freedom associated with the variables listed in the vector variables are projected. The function value f and its gradient g are user-provided cloneable functors. A gradient g is only required/used for projecting onto finite element spaces with continuous derivatives.

Definition at line 1253 of file system_projection.C.

Referenced by SystemsTest::testBoundaryProjectCube().

1257 {
1258  this->boundary_project_vector(b, variables, *solution, f, g);
1259 
1260  solution->localize(*current_local_solution);
1261 }
void boundary_project_vector(const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
Projects arbitrary boundary functions onto a vector of degree of freedom values for the current syste...
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Definition: system.h:1605

◆ boundary_project_solution() [2/2]

void libMesh::System::boundary_project_solution ( const std::set< boundary_id_type > &  b,
const std::vector< unsigned int > &  variables,
ValueFunctionPointer  fptr,
GradientFunctionPointer  gptr,
const Parameters parameters 
)
inherited

Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system.

This method projects components of an arbitrary boundary function onto the solution via L2 projections and nodal interpolations on each element.

Only degrees of freedom which affect the function's trace on a boundary in the set b are affected. Only degrees of freedom associated with the variables listed in the vector variables are projected. The function value fptr and its gradient gptr are represented by function pointers. A gradient gptr is only required/used for projecting onto finite element spaces with continuous derivatives.

Definition at line 1236 of file system_projection.C.

References fptr(), and gptr().

1241 {
1242  WrappedFunction<Number> f(*this, fptr, &function_parameters);
1243  WrappedFunction<Gradient> g(*this, gptr, &function_parameters);
1244  this->boundary_project_solution(b, variables, &f, &g);
1245 }
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:80
Gradient gptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:95
void boundary_project_solution(const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr)
Projects arbitrary boundary functions onto a vector of degree of freedom values for the current syste...

◆ boundary_project_vector() [1/2]

void libMesh::System::boundary_project_vector ( const std::set< boundary_id_type > &  b,
const std::vector< unsigned int > &  variables,
NumericVector< Number > &  new_vector,
FunctionBase< Number > *  f,
FunctionBase< Gradient > *  g = nullptr,
int  is_adjoint = -1 
) const
inherited

Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system.

This method projects an arbitrary function via L2 projections and nodal interpolations on each element.

Only degrees of freedom which affect the function's trace on a boundary in the set b are affected. Only degrees of freedom associated with the variables listed in the vector variables are projected. The function value f and its gradient g are user-provided cloneable functors. A gradient g is only required/used for projecting onto finite element spaces with continuous derivatives.

Constrain the new vector using the requested adjoint rather than primal constraints if is_adjoint is non-negative.

Definition at line 1289 of file system_projection.C.

References libMesh::NumericVector< T >::close(), libMesh::libmesh_ignore(), and libMesh::Threads::parallel_for().

1295 {
1296  LOG_SCOPE ("boundary_project_vector()", "System");
1297 
1299  (ConstElemRange (this->get_mesh().active_local_elements_begin(),
1300  this->get_mesh().active_local_elements_end() ),
1301  BoundaryProjectSolution(b, variables, *this, f, g,
1303  new_vector)
1304  );
1305 
1306  // We don't do SCALAR dofs when just projecting the boundary, so
1307  // we're done here.
1308 
1309  new_vector.close();
1310 
1311 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1312  if (is_adjoint == -1)
1313  this->get_dof_map().enforce_constraints_exactly(*this, &new_vector);
1314  else if (is_adjoint >= 0)
1316  is_adjoint);
1317 #else
1318  libmesh_ignore(is_adjoint);
1319 #endif
1320 }
void parallel_for(const Range &range, const Body &body)
Execute the provided function object in parallel on the specified range.
Definition: threads_none.h:73
const EquationSystems & get_equation_systems() const
Definition: system.h:721
Parameters parameters
Parameters for the system. If a parameter is not provided, it should be retrieved from the EquationSy...
Definition: system.h:1526
const MeshBase & get_mesh() const
Definition: system.h:2358
StoredRange< MeshBase::const_element_iterator, const Elem * > ConstElemRange
Definition: elem_range.h:34
void enforce_adjoint_constraints_exactly(NumericVector< Number > &v, unsigned int q) const
Heterogeneously constrains the numeric vector v, which represents an adjoint solution defined on the ...
Definition: dof_map.h:2354
void libmesh_ignore(const Args &...)
virtual void close()=0
Calls the NumericVector&#39;s internal assembly routines, ensuring that the values are consistent across ...
const DofMap & get_dof_map() const
Definition: system.h:2374
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. ...
Definition: dof_map.h:2350

◆ boundary_project_vector() [2/2]

void libMesh::System::boundary_project_vector ( const std::set< boundary_id_type > &  b,
const std::vector< unsigned int > &  variables,
ValueFunctionPointer  fptr,
GradientFunctionPointer  gptr,
const Parameters parameters,
NumericVector< Number > &  new_vector,
int  is_adjoint = -1 
) const
inherited

Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system.

This method projects an arbitrary boundary function via L2 projections and nodal interpolations on each element.

Only degrees of freedom which affect the function's trace on a boundary in the set b are affected. Only degrees of freedom associated with the variables listed in the vector variables are projected. The function value fptr and its gradient gptr are represented by function pointers. A gradient gptr is only required/used for projecting onto finite element spaces with continuous derivatives.

Constrain the new vector using the requested adjoint rather than primal constraints if is_adjoint is non-negative.

Definition at line 1271 of file system_projection.C.

References fptr(), and gptr().

1278 {
1279  WrappedFunction<Number> f(*this, fptr, &function_parameters);
1280  WrappedFunction<Gradient> g(*this, gptr, &function_parameters);
1281  this->boundary_project_vector(b, variables, new_vector, &f, &g,
1282  is_adjoint);
1283 }
void boundary_project_vector(const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
Projects arbitrary boundary functions onto a vector of degree of freedom values for the current syste...
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:80
Gradient gptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:95

◆ broadcast_parameters()

void libMesh::RBConstructionBase< LinearImplicitSystem >::broadcast_parameters ( const unsigned int  proc_id)
inherited

Broadcasts parameters from processor proc_id to all processors.

This broadcasts the RBParameters object from .get_parameters(), and then sets it on all processors with .set_parameters().

Definition at line 720 of file rb_construction_base.C.

Referenced by libMesh::RBConstruction::compute_max_error_bound().

721 {
722  libmesh_assert_less (proc_id, this->n_processors());
723 
724  // create a copy of the current parameters
725  RBParameters current_parameters = get_parameters();
726  libmesh_error_msg_if(current_parameters.n_samples()!=1,
727  "Only single-sample RBParameter objects can be broadcast.");
728 
729  // Serialize the current_parameters to current_parameters_vector in order to broadcast.
730  // We handle multiple samples and vector values.
731  // However, the vector values are assumed to remain the same size across samples.
732  const std::size_t nparams = current_parameters.n_parameters();
733  const std::size_t nsamples = current_parameters.n_samples();
734 
735  // First we get the sizes of all the parameter value vectors.
736  std::vector<std::size_t> param_value_sizes;
737  param_value_sizes.reserve(nparams);
738  for (const auto & pr : current_parameters)
739  param_value_sizes.push_back(pr.second[0].size());
740 
741  // Broadcast the sizes vector and reserve memory.
742  this->comm().broadcast(param_value_sizes, proc_id);
743  std::size_t buffsize = std::accumulate(param_value_sizes.cbegin(), param_value_sizes.cend(), 0ul);
744  std::vector<Real> serialized_parameters;
745  serialized_parameters.reserve(buffsize);
746 
747  // Then we serialize the parameters/sample/value vectors into a single vector.
748  for (const auto & pr : current_parameters)
749  {
750  for (const auto sample_idx : make_range(nsamples))
751  serialized_parameters.insert(serialized_parameters.end(),
752  pr.second[sample_idx].cbegin(),
753  pr.second[sample_idx].cend());
754  }
755 
756  // Do the broadcasts.
757  this->comm().broadcast(serialized_parameters, proc_id);
758 
759  // Deserialize into the copy of the RBParameters object.
760  std::size_t param_idx = 0;
761  auto val_idx = serialized_parameters.cbegin();
762  for (const auto & pr : current_parameters)
763  {
764  const std::size_t param_value_size = param_value_sizes[param_idx];
765  for (const auto sample_idx: make_range(nsamples))
766  {
767  auto end_val_idx = std::next(val_idx,param_value_size);
768  RBParameter sample_val(val_idx, end_val_idx);
769  current_parameters.set_value(pr.first, sample_idx, sample_val);
770  val_idx = end_val_idx;
771  }
772  ++param_idx;
773  }
774 
775  // Overwrite the parameters globally.
776  set_parameters(current_parameters);
777 }
const Parallel::Communicator & comm() const
processor_id_type n_processors() const
std::vector< Real > RBParameter
Typedef for an individual RB parameter.
Definition: rb_parameters.h:39
const RBParameters & get_parameters() const
Get the current parameters.
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
bool set_parameters(const RBParameters &params)
Set the current parameters to params The parameters are checked for validity; an error is thrown if t...
static const unsigned int next[3]
A lookup table for the increment modulo 3 operation, for iterating through the three nodes per elemen...
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...
Definition: int_range.h:140

◆ build_context()

std::unique_ptr< DGFEMContext > libMesh::RBConstruction::build_context ( )
protectedvirtualinherited

Builds a DGFEMContext object with enough information to do evaluations on each element.

We use DGFEMContext since it allows for both DG and continuous Galerkin formulations.

Definition at line 626 of file rb_construction.C.

Referenced by libMesh::RBConstruction::add_scaled_matrix_and_vector().

627 {
628  return std::make_unique<DGFEMContext>(*this);
629 }

◆ build_zero_dirichlet_boundary_object()

std::unique_ptr< DirichletBoundary > libMesh::RBConstruction::build_zero_dirichlet_boundary_object ( )
staticinherited

It's helpful to be able to generate a DirichletBoundary that stores a ZeroFunction in order to impose Dirichlet boundary conditions.

Definition at line 2495 of file rb_construction.C.

Referenced by SimpleRBConstruction::init_data().

2496 {
2497  ZeroFunction<> zf;
2498 
2499  std::set<boundary_id_type> dirichlet_ids;
2500  std::vector<unsigned int> variables;
2501 
2502  // The DirichletBoundary constructor clones zf, so it's OK that zf is only in local scope
2503  return std::make_unique<DirichletBoundary>(dirichlet_ids, variables, &zf);
2504 }

◆ calculate_norm() [1/2]

Real libMesh::System::calculate_norm ( const NumericVector< Number > &  v,
unsigned int  var,
FEMNormType  norm_type,
std::set< unsigned int > *  skip_dimensions = nullptr 
) const
inherited
Returns
A norm of variable var in the vector v, in the specified norm (e.g. L2, L_INF, H1)

Definition at line 1724 of file system.C.

References libMesh::DISCRETE_L1, libMesh::DISCRETE_L2, libMesh::DISCRETE_L_INF, libMesh::System::discrete_var_norm(), libMesh::L2, libMesh::System::n_vars(), and libMesh::Real.

Referenced by libMesh::TwostepTimeSolver::adjoint_solve(), libMesh::AdaptiveTimeSolver::calculate_norm(), libMesh::UnsteadySolver::du(), main(), output_norms(), ConstraintOperatorTest::testCoreform(), and MeshInputTest::testProjectionRegression().

1728 {
1729  //short circuit to save time
1730  if (norm_type == DISCRETE_L1 ||
1731  norm_type == DISCRETE_L2 ||
1732  norm_type == DISCRETE_L_INF)
1733  return discrete_var_norm(v,var,norm_type);
1734 
1735  // Not a discrete norm
1736  std::vector<FEMNormType> norms(this->n_vars(), L2);
1737  std::vector<Real> weights(this->n_vars(), 0.0);
1738  norms[var] = norm_type;
1739  weights[var] = 1.0;
1740  Real val = this->calculate_norm(v, SystemNorm(norms, weights), skip_dimensions);
1741  return val;
1742 }
Real calculate_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=nullptr) const
Definition: system.C:1724
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Real discrete_var_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type) const
Finds the discrete norm for the entries in the vector corresponding to Dofs associated with var...
Definition: system.C:1705
unsigned int n_vars() const
Definition: system.h:2430

◆ calculate_norm() [2/2]

Real libMesh::System::calculate_norm ( const NumericVector< Number > &  v,
const SystemNorm norm,
std::set< unsigned int > *  skip_dimensions = nullptr 
) const
inherited
Returns
A norm of the vector v, using component_norm and component_scale to choose and weight the norms of each variable.

Definition at line 1746 of file system.C.

References libMesh::System::_dof_map, libMesh::System::_mesh, libMesh::FEGenericBase< OutputType >::build(), libMesh::NumericVector< T >::build(), libMesh::ParallelObject::comm(), libMesh::FEType::default_quadrature_rule(), dim, libMesh::DISCRETE_L1, libMesh::DISCRETE_L2, libMesh::DISCRETE_L_INF, libMesh::System::discrete_var_norm(), libMesh::DofMap::dof_indices(), libMesh::MeshBase::elem_dimensions(), libMesh::Utility::enum_to_string(), libMesh::FEInterface::field_type(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::GHOSTED, libMesh::H1, libMesh::H1_SEMINORM, libMesh::H2, libMesh::H2_SEMINORM, libMesh::L1, libMesh::NumericVector< T >::l1_norm(), libMesh::L2, libMesh::NumericVector< T >::l2_norm(), libMesh::L_INF, libMesh::libmesh_assert(), libMesh::NumericVector< T >::linfty_norm(), libMesh::NumericVector< T >::local_size(), libMesh::NumericVector< T >::localize(), libMesh::make_range(), TIMPI::Communicator::max(), libMesh::System::n_vars(), libMesh::TensorTools::norm(), libMesh::TensorTools::norm_sq(), libMesh::Real, libMesh::NumericVector< T >::size(), TIMPI::Communicator::sum(), libMesh::TYPE_SCALAR, libMesh::TYPE_VECTOR, libMesh::DofMap::variable_type(), libMesh::W1_INF_SEMINORM, libMesh::W2_INF_SEMINORM, and libMesh::SystemNorm::weight().

1749 {
1750  // This function must be run on all processors at once
1751  parallel_object_only();
1752 
1753  LOG_SCOPE ("calculate_norm()", "System");
1754 
1755  // Zero the norm before summation
1756  Real v_norm = 0.;
1757 
1758  if (norm.is_discrete())
1759  {
1760  //Check to see if all weights are 1.0 and all types are equal
1761  FEMNormType norm_type0 = norm.type(0);
1762  unsigned int check_var = 0, check_end = this->n_vars();
1763  for (; check_var != check_end; ++check_var)
1764  if ((norm.weight(check_var) != 1.0) || (norm.type(check_var) != norm_type0))
1765  break;
1766 
1767  //All weights were 1.0 so just do the full vector discrete norm
1768  if (check_var == this->n_vars())
1769  {
1770  if (norm_type0 == DISCRETE_L1)
1771  return v.l1_norm();
1772  if (norm_type0 == DISCRETE_L2)
1773  return v.l2_norm();
1774  if (norm_type0 == DISCRETE_L_INF)
1775  return v.linfty_norm();
1776  else
1777  libmesh_error_msg("Invalid norm_type0 = " << Utility::enum_to_string(norm_type0));
1778  }
1779 
1780  for (auto var : make_range(this->n_vars()))
1781  {
1782  // Skip any variables we don't need to integrate
1783  if (norm.weight(var) == 0.0)
1784  continue;
1785 
1786  v_norm += norm.weight(var) * discrete_var_norm(v, var, norm.type(var));
1787  }
1788 
1789  return v_norm;
1790  }
1791 
1792  // Localize the potentially parallel vector
1793  std::unique_ptr<NumericVector<Number>> local_v = NumericVector<Number>::build(this->comm());
1794  local_v->init(v.size(), v.local_size(), _dof_map->get_send_list(),
1795  true, GHOSTED);
1796  v.localize (*local_v, _dof_map->get_send_list());
1797 
1798  // I'm not sure how best to mix Hilbert norms on some variables (for
1799  // which we'll want to square then sum then square root) with norms
1800  // like L_inf (for which we'll just want to take an absolute value
1801  // and then sum).
1802  bool using_hilbert_norm = true,
1803  using_nonhilbert_norm = true;
1804 
1805  // Loop over all variables
1806  for (auto var : make_range(this->n_vars()))
1807  {
1808  // Skip any variables we don't need to integrate
1809  Real norm_weight_sq = norm.weight_sq(var);
1810  if (norm_weight_sq == 0.0)
1811  continue;
1812  Real norm_weight = norm.weight(var);
1813 
1814  // Check for unimplemented norms (rather than just returning 0).
1815  FEMNormType norm_type = norm.type(var);
1816  if ((norm_type==H1) ||
1817  (norm_type==H2) ||
1818  (norm_type==L2) ||
1819  (norm_type==H1_SEMINORM) ||
1820  (norm_type==H2_SEMINORM))
1821  {
1822  if (!using_hilbert_norm)
1823  libmesh_not_implemented();
1824  using_nonhilbert_norm = false;
1825  }
1826  else if ((norm_type==L1) ||
1827  (norm_type==L_INF) ||
1828  (norm_type==W1_INF_SEMINORM) ||
1829  (norm_type==W2_INF_SEMINORM))
1830  {
1831  if (!using_nonhilbert_norm)
1832  libmesh_not_implemented();
1833  using_hilbert_norm = false;
1834  }
1835  else
1836  libmesh_not_implemented();
1837 
1838  const FEType & fe_type = this->get_dof_map().variable_type(var);
1839 
1840  // Allow space for dims 0-3, and for both scalar and vector
1841  // elements, even if we don't use them all
1842  std::vector<std::unique_ptr<FEBase>> fe_ptrs(4);
1843  std::vector<std::unique_ptr<FEVectorBase>> vec_fe_ptrs(4);
1844  std::vector<std::unique_ptr<QBase>> q_rules(4);
1845 
1846  const std::set<unsigned char> & elem_dims = _mesh.elem_dimensions();
1847 
1848  // Prepare finite elements for each dimension present in the mesh
1849  for (const auto & dim : elem_dims)
1850  {
1851  if (skip_dimensions && skip_dimensions->find(dim) != skip_dimensions->end())
1852  continue;
1853 
1854  // Construct quadrature and finite element objects
1855  q_rules[dim] = fe_type.default_quadrature_rule (dim);
1856 
1857  const FEFieldType field_type = FEInterface::field_type(fe_type);
1858  if (field_type == TYPE_SCALAR)
1859  {
1860  fe_ptrs[dim] = FEBase::build(dim, fe_type);
1861  fe_ptrs[dim]->attach_quadrature_rule (q_rules[dim].get());
1862  }
1863  else
1864  {
1865  vec_fe_ptrs[dim] = FEVectorBase::build(dim, fe_type);
1866  vec_fe_ptrs[dim]->attach_quadrature_rule (q_rules[dim].get());
1867  libmesh_assert_equal_to(field_type, TYPE_VECTOR);
1868  }
1869 
1870  }
1871 
1872  std::vector<dof_id_type> dof_indices;
1873 
1874  // Begin the loop over the elements
1875  for (const auto & elem : this->get_mesh().active_local_element_ptr_range())
1876  {
1877  const unsigned int dim = elem->dim();
1878 
1879  // One way for implementing this would be to exchange the fe with the FEInterface- class.
1880  // However, it needs to be discussed whether integral-norms make sense for infinite elements.
1881  // or in which sense they could make sense.
1882  if (elem->infinite() )
1883  libmesh_not_implemented();
1884 
1885  if (skip_dimensions && skip_dimensions->find(dim) != skip_dimensions->end())
1886  continue;
1887 
1888  QBase * qrule = q_rules[dim].get();
1889  libmesh_assert(qrule);
1890 
1891  this->get_dof_map().dof_indices (elem, dof_indices, var);
1892 
1893  auto element_calculation = [&dof_indices, &elem,
1894  norm_type, norm_weight, norm_weight_sq, &qrule,
1895  &local_v, &v_norm](auto & fe) {
1896  typedef typename std::remove_reference<decltype(fe)>::type::OutputShape OutputShape;
1897  typedef typename TensorTools::MakeNumber<OutputShape>::type OutputNumberShape;
1898  typedef typename std::remove_reference<decltype(fe)>::type::OutputGradient OutputGradient;
1899  typedef typename TensorTools::MakeNumber<OutputGradient>::type OutputNumberGradient;
1900 
1901  const std::vector<Real> & JxW = fe.get_JxW();
1902  const std::vector<std::vector<OutputShape>> * phi = nullptr;
1903  if (norm_type == H1 ||
1904  norm_type == H2 ||
1905  norm_type == L2 ||
1906  norm_type == L1 ||
1907  norm_type == L_INF)
1908  phi = &(fe.get_phi());
1909 
1910  const std::vector<std::vector<OutputGradient>> * dphi = nullptr;
1911  if (norm_type == H1 ||
1912  norm_type == H2 ||
1913  norm_type == H1_SEMINORM ||
1914  norm_type == W1_INF_SEMINORM)
1915  dphi = &(fe.get_dphi());
1916 
1917 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1918  typedef typename std::remove_reference<decltype(fe)>::type::OutputTensor OutputTensor;
1919 
1920  const std::vector<std::vector<OutputTensor>> * d2phi = nullptr;
1921  if (norm_type == H2 ||
1922  norm_type == H2_SEMINORM ||
1923  norm_type == W2_INF_SEMINORM)
1924  d2phi = &(fe.get_d2phi());
1925 #endif
1926 
1927  fe.reinit (elem);
1928 
1929  const unsigned int n_qp = qrule->n_points();
1930 
1931  const unsigned int n_sf = cast_int<unsigned int>
1932  (dof_indices.size());
1933 
1934  // Begin the loop over the Quadrature points.
1935  for (unsigned int qp=0; qp<n_qp; qp++)
1936  {
1937  if (norm_type == L1)
1938  {
1939  OutputNumberShape u_h = 0.;
1940  for (unsigned int i=0; i != n_sf; ++i)
1941  u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
1942  v_norm += norm_weight *
1943  JxW[qp] * TensorTools::norm(u_h);
1944  }
1945 
1946  if (norm_type == L_INF)
1947  {
1948  OutputNumberShape u_h = 0.;
1949  for (unsigned int i=0; i != n_sf; ++i)
1950  u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
1951  v_norm = std::max(v_norm, norm_weight * TensorTools::norm(u_h));
1952  }
1953 
1954  if (norm_type == H1 ||
1955  norm_type == H2 ||
1956  norm_type == L2)
1957  {
1958  OutputNumberShape u_h = 0.;
1959  for (unsigned int i=0; i != n_sf; ++i)
1960  u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
1961  v_norm += norm_weight_sq *
1962  JxW[qp] * TensorTools::norm_sq(u_h);
1963  }
1964 
1965  if (norm_type == H1 ||
1966  norm_type == H2 ||
1967  norm_type == H1_SEMINORM)
1968  {
1969  OutputNumberGradient grad_u_h;
1970  for (unsigned int i=0; i != n_sf; ++i)
1971  grad_u_h.add_scaled((*dphi)[i][qp], (*local_v)(dof_indices[i]));
1972  v_norm += norm_weight_sq *
1973  JxW[qp] * grad_u_h.norm_sq();
1974  }
1975 
1976  if (norm_type == W1_INF_SEMINORM)
1977  {
1978  OutputNumberGradient grad_u_h;
1979  for (unsigned int i=0; i != n_sf; ++i)
1980  grad_u_h.add_scaled((*dphi)[i][qp], (*local_v)(dof_indices[i]));
1981  v_norm = std::max(v_norm, norm_weight * grad_u_h.norm());
1982  }
1983 
1984 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1985  typedef typename TensorTools::MakeNumber<OutputTensor>::type OutputNumberTensor;
1986 
1987  if (norm_type == H2 ||
1988  norm_type == H2_SEMINORM)
1989  {
1990  OutputNumberTensor hess_u_h;
1991  for (unsigned int i=0; i != n_sf; ++i)
1992  hess_u_h.add_scaled((*d2phi)[i][qp], (*local_v)(dof_indices[i]));
1993  v_norm += norm_weight_sq *
1994  JxW[qp] * hess_u_h.norm_sq();
1995  }
1996 
1997  if (norm_type == W2_INF_SEMINORM)
1998  {
1999  OutputNumberTensor hess_u_h;
2000  for (unsigned int i=0; i != n_sf; ++i)
2001  hess_u_h.add_scaled((*d2phi)[i][qp], (*local_v)(dof_indices[i]));
2002  v_norm = std::max(v_norm, norm_weight * hess_u_h.norm());
2003  }
2004 #endif
2005  }
2006  };
2007 
2008  FEBase * scalar_fe = fe_ptrs[dim].get();
2009  FEVectorBase * vec_fe = vec_fe_ptrs[dim].get();
2010 
2011  if (scalar_fe)
2012  {
2013  libmesh_assert(!vec_fe);
2014  element_calculation(*scalar_fe);
2015  }
2016 
2017  if (vec_fe)
2018  {
2019  libmesh_assert(!scalar_fe);
2020  element_calculation(*vec_fe);
2021  }
2022  }
2023  }
2024 
2025  if (using_hilbert_norm)
2026  {
2027  this->comm().sum(v_norm);
2028  v_norm = std::sqrt(v_norm);
2029  }
2030  else
2031  {
2032  this->comm().max(v_norm);
2033  }
2034 
2035  return v_norm;
2036 }
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Definition: dof_map.C:2164
unsigned int dim
virtual numeric_index_type size() const =0
const FEType & variable_type(const unsigned int c) const
Definition: dof_map.h:2220
void sum(T &r) const
static FEFieldType field_type(const FEType &fe_type)
FEMNormType
defines an enum for norms defined on vectors of finite element coefficients
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:2179
const Parallel::Communicator & comm() const
FEGenericBase< RealGradient > FEVectorBase
Definition: fe_base.h:818
const MeshBase & get_mesh() const
Definition: system.h:2358
virtual Real l2_norm() const =0
static std::unique_ptr< FEGenericBase > build(const unsigned int dim, const FEType &type)
Builds a specific finite element type.
libmesh_assert(ctx)
const std::set< unsigned char > & elem_dimensions() const
Definition: mesh_base.h:282
auto norm(const T &a) -> decltype(std::abs(a))
Definition: tensor_tools.h:74
FEGenericBase< Real > FEBase
virtual Real l1_norm() const =0
std::string enum_to_string(const T e)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void max(const T &r, T &o, Request &req) const
auto norm_sq(const T &a) -> decltype(std::norm(a))
Definition: tensor_tools.h:104
virtual numeric_index_type local_size() const =0
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...
Definition: int_range.h:140
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...
Real discrete_var_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type) const
Finds the discrete norm for the entries in the vector corresponding to Dofs associated with var...
Definition: system.C:1705
unsigned int n_vars() const
Definition: system.h:2430
const DofMap & get_dof_map() const
Definition: system.h:2374
MeshBase & _mesh
Constant reference to the mesh data structure used for the simulation.
Definition: system.h:2191
virtual Real linfty_norm() const =0
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.
FEFieldType
defines an enum for finite element field types - i.e.

◆ can_add_matrices()

bool libMesh::System::can_add_matrices ( ) const
inlineprotectedinherited
Returns
Whether or not matrices can still be added without expensive per-matrix initialization.

Definition at line 1975 of file system.h.

References libMesh::System::_matrices_initialized.

Referenced by libMesh::EigenSystem::set_eigenproblem_type().

1975 { return !_matrices_initialized; }
bool _matrices_initialized
false when additional matrices being added require initialization, true otherwise.
Definition: system.h:2257

◆ check_convergence()

void libMesh::RBConstruction::check_convergence ( LinearSolver< Number > &  input_solver)
protectedinherited

Check if the linear solver reports convergence.

Throw an error when that is not the case.

Definition at line 2704 of file rb_construction.C.

References libMesh::LinearSolver< T >::get_converged_reason().

Referenced by libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::enrich_basis_from_rhs_terms(), truth_solve(), libMesh::RBConstruction::truth_solve(), update_residual_terms(), and libMesh::RBConstruction::update_residual_terms().

2705 {
2707 
2708  conv_flag = input_solver.get_converged_reason();
2709 
2710  libmesh_error_msg_if(conv_flag < 0, "Convergence error. Error id: " << conv_flag);
2711 }
LinearConvergenceReason
Linear solver convergence flags (taken from the PETSc flags).
virtual LinearConvergenceReason get_converged_reason() const =0

◆ check_if_zero_truth_solve()

bool libMesh::RBConstruction::check_if_zero_truth_solve ( ) const
virtualinherited
Returns
true if the most recent truth solve gave a zero solution.

Definition at line 457 of file rb_construction.C.

References libMesh::System::solution.

Referenced by libMesh::RBConstruction::train_reduced_basis_with_greedy().

458 {
459  return (solution->l2_norm() == 0.);
460 }
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593

◆ clear()

void TransientRBConstruction::clear ( )
overridevirtual

Clear all the data structures associated with the system.

Reimplemented from libMesh::TransientSystem< RBConstruction >.

Definition at line 85 of file transient_rb_construction.C.

References libMesh::TransientSystem< RBConstruction >::clear(), M_q_vector, non_dirichlet_M_q_vector, libMesh::RBConstruction::store_non_dirichlet_operators, and temporal_data.

86 {
87  Parent::clear();
88 
89  // clear the mass matrices
90  M_q_vector.clear();
91 
94 
95  // clear the temporal_data
96  temporal_data.clear();
97 }
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...
bool store_non_dirichlet_operators
Boolean flag to indicate whether we store a second copy of each affine operator and vector which does...
std::vector< std::unique_ptr< NumericVector< Number > > > temporal_data
Dense matrix to store the data that we use for the temporal POD.
virtual void clear() override
Clear all the data structures associated with the system.
std::vector< std::unique_ptr< SparseMatrix< Number > > > M_q_vector
Vector storing the Q_m matrices from the mass operator.

◆ comm()

const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inlineinherited
Returns
A reference to the Parallel::Communicator object used by this mesh.

Definition at line 97 of file parallel_object.h.

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_tao_equality_constraints(), libMesh::__libmesh_tao_equality_constraints_jacobian(), libMesh::__libmesh_tao_gradient(), libMesh::__libmesh_tao_hessian(), libMesh::__libmesh_tao_inequality_constraints(), libMesh::__libmesh_tao_inequality_constraints_jacobian(), libMesh::__libmesh_tao_objective(), libMesh::MeshRefinement::_coarsen_elements(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::Partitioner::_find_global_index_by_pid_map(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< libMesh::Number >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_mult(), libMesh::SlepcEigenSolver< libMesh::Number >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_mult_add(), libMesh::MeshRefinement::_refine_elements(), libMesh::MeshRefinement::_smooth_flags(), libMesh::DofMap::add_constraints_to_send_list(), add_cube_convex_hull_to_mesh(), libMesh::PetscDMWrapper::add_dofs_helper(), libMesh::PetscDMWrapper::add_dofs_to_section(), add_IC_to_RB_space(), libMesh::RBEIMEvaluation::add_interpolation_data(), libMesh::CondensedEigenSystem::add_matrices(), libMesh::EigenSystem::add_matrices(), libMesh::System::add_matrix(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::System::add_variable(), libMesh::System::add_variables(), libMesh::System::add_vector(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::DofMap::allgather_recursive_constraints(), allocate_data_structures(), libMesh::RBConstruction::allocate_data_structures(), assemble_affine_expansion(), libMesh::AdvectionSystem::assemble_claw_rhs(), libMesh::FEMSystem::assemble_qoi(), libMesh::Nemesis_IO::assert_symmetric_cmaps(), libMesh::MeshCommunication::assign_global_indices(), libMesh::Partitioner::assign_partitioning(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::Partitioner::build_graph(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::PetscDMWrapper::build_section(), libMesh::PetscDMWrapper::build_sf(), libMesh::MeshBase::cache_elem_data(), libMesh::System::calculate_norm(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_max_error_bound(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), libMesh::RBSCMConstruction::compute_SCM_bounds_on_training_set(), libMesh::DofMap::computed_sparsity_already(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ContinuationSystem::ContinuationSystem(), libMesh::MeshBase::copy_constraint_rows(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::CondensedEigenSystem::copy_super_to_sub(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::MeshTools::create_bounding_box(), libMesh::DofMap::create_dof_constraints(), libMesh::MeshTools::create_nodal_bounding_box(), libMesh::MeshRefinement::create_parent_error_vector(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::MeshTools::create_subdomain_bounding_box(), libMesh::PetscMatrix< T >::create_submatrix_nosort(), create_wrapped_function(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::RBEIMEvaluation::distribute_bfs(), DMlibMeshFunction(), DMlibMeshJacobian(), DMlibMeshSetSystem_libMesh(), DMVariableBounds_libMesh(), libMesh::DTKSolutionTransfer::DTKSolutionTransfer(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_interiors(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_nodes(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_sides(), enrich_RB_space(), libMesh::EpetraVector< T >::EpetraVector(), AssembleOptimization::equality_constraints(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_error_tolerance(), libMesh::MeshRefinement::flag_elements_by_mean_stddev(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::RBEIMEvaluation::gather_bfs(), libMesh::DofMap::gather_constraints(), libMesh::MeshfreeInterpolation::gather_remote_data(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::RBEIMEvaluation::get_eim_basis_function_node_value(), libMesh::RBEIMEvaluation::get_eim_basis_function_side_value(), libMesh::RBEIMEvaluation::get_eim_basis_function_value(), libMesh::MeshBase::get_info(), libMesh::System::get_info(), libMesh::DofMap::get_info(), libMesh::RBEIMEvaluation::get_interior_basis_functions_as_vecs(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::RBEIMConstruction::get_max_abs_value(), libMesh::RBEIMConstruction::get_node_max_abs_value(), libMesh::RBEIMEvaluation::get_parametrized_function_node_value(), libMesh::RBEIMEvaluation::get_parametrized_function_side_value(), libMesh::RBEIMEvaluation::get_parametrized_function_value(), libMesh::RBEIMConstruction::get_random_point(), AssembleOptimization::inequality_constraints(), AssembleOptimization::inequality_constraints_jacobian(), libMesh::LocationMap< T >::init(), libMesh::TimeSolver::init(), libMesh::StaticCondensation::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::AdvectionSystem::init_data(), libMesh::ClawSystem::init_data(), libMesh::PetscDMWrapper::init_petscdm(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::RBEIMConstruction::initialize_parametrized_functions_in_training_set(), libMesh::RBEIMConstruction::inner_product(), integrate_function(), libMesh::MeshTools::libmesh_assert_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_equal_connectivity(), libMesh::MeshTools::libmesh_assert_equal_points(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_constraint_rows(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_flags(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_p_levels(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshTools::libmesh_assert_valid_unique_ids(), libMesh::libmesh_petsc_linesearch_shellfunc(), libMesh::libmesh_petsc_preconditioner_apply(), libMesh::libmesh_petsc_recalculate_monitor(), libMesh::libmesh_petsc_snes_fd_residual(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_mffd_interface(), libMesh::libmesh_petsc_snes_mffd_residual(), libMesh::libmesh_petsc_snes_postcheck(), libMesh::libmesh_petsc_snes_precheck(), libMesh::libmesh_petsc_snes_residual(), libMesh::libmesh_petsc_snes_residual_helper(), libMesh::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::limit_overrefined_boundary(), libMesh::MeshRefinement::limit_underrefined_boundary(), libMesh::LinearImplicitSystem::LinearImplicitSystem(), main(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshCommunication::make_elems_parallel_consistent(), libMesh::MeshRefinement::make_flags_parallel_consistent(), libMesh::MeshCommunication::make_new_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_new_nodes_parallel_consistent(), libMesh::MeshCommunication::make_node_bcids_parallel_consistent(), libMesh::MeshCommunication::make_node_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_unique_ids_parallel_consistent(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::MeshCommunication::make_p_levels_parallel_consistent(), libMesh::MeshRefinement::make_refinement_compatible(), mass_matrix_scaled_matvec(), libMesh::FEMSystem::mesh_position_set(), libMesh::TriangulatorInterface::MeshedHole::MeshedHole(), LinearElasticityWithContact::move_mesh(), libMesh::DistributedMesh::n_active_elem(), libMesh::MeshTools::n_active_levels(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::MeshTools::n_connected_components(), libMesh::DofMap::n_constrained_dofs(), libMesh::MeshBase::n_constraint_rows(), libMesh::DofMap::n_dofs(), libMesh::DofMap::n_dofs_per_processor(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::CondensedEigenSystem::n_global_non_condensed_dofs(), libMesh::MeshTools::n_levels(), MixedOrderTest::n_neighbor_links(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::SparsityPattern::Build::n_nonzeros(), libMesh::MeshTools::n_p_levels(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::RBEIMEvaluation::node_distribute_bfs(), libMesh::RBEIMEvaluation::node_gather_bfs(), libMesh::RBEIMConstruction::node_inner_product(), libMesh::MeshBase::operator==(), libMesh::DistributedMesh::parallel_max_elem_id(), libMesh::DistributedMesh::parallel_max_node_id(), libMesh::ReplicatedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_n_elem(), libMesh::DistributedMesh::parallel_n_nodes(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::BoundaryInfo::parallel_sync_node_ids(), libMesh::BoundaryInfo::parallel_sync_side_ids(), libMesh::MeshTools::paranoid_n_levels(), libMesh::Partitioner::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::petsc_auto_fieldsplit(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::MeshBase::print_constraint_rows(), libMesh::DofMap::print_dof_constraints(), libMesh::DofMap::process_mesh_constraint_rows(), libMesh::Partitioner::processor_pairs_to_interface_nodes(), libMesh::InterMeshProjection::project_system_vectors(), FEMParameters::read(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::EquationSystems::read(), libMesh::ExodusII_IO::read_header(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::System::read_header(), libMesh::RBEIMEvaluation::read_in_interior_basis_functions(), libMesh::RBEIMEvaluation::read_in_node_basis_functions(), libMesh::RBEIMEvaluation::read_in_side_basis_functions(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::System::read_legacy_data(), read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::Nemesis_IO_Helper::read_var_names_impl(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::SimplexRefiner::refine_via_edges(), libMesh::StaticCondensationDofMap::reinit(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::DistributedMesh::renumber_nodes_and_elements(), LinearElasticityWithContact::residual_and_jacobian(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), scale_mesh_and_plot(), libMesh::DofMap::scatter_constraints(), libMesh::CheckpointIO::select_split_config(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::send_and_insert_dof_values(), set_error_temporal_data(), libMesh::Partitioner::set_interface_node_processor_ids_BFS(), libMesh::Partitioner::set_interface_node_processor_ids_linear(), libMesh::Partitioner::set_interface_node_processor_ids_petscpartitioner(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Partitioner::set_parent_processor_ids(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::PetscDiffSolver::setup_petsc_data(), libMesh::RBEIMEvaluation::side_distribute_bfs(), libMesh::RBEIMEvaluation::side_gather_bfs(), libMesh::RBEIMConstruction::side_inner_product(), libMesh::Partitioner::single_partition(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::VariationalMeshSmoother::smooth(), libMesh::ClawSystem::solve_conservation_law(), libMesh::split_mesh(), libMesh::RBEIMConstruction::store_eim_solutions_for_training_set(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), ConstraintOperatorTest::test1DCoarseningNewNodes(), ConstraintOperatorTest::test1DCoarseningOperator(), libMesh::MeshRefinement::test_level_one(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), libMesh::MeshRefinement::test_unflagged(), DofMapTest::testBadElemFECombo(), SystemsTest::testBlockRestrictedVarNDofs(), BoundaryInfoTest::testBoundaryOnChildrenErrors(), VolumeTest::testC0PolygonMethods(), VolumeTest::testC0PolyhedronMethods(), ConstraintOperatorTest::testCoreform(), ConnectedComponentsTest::testEdge(), MeshInputTest::testExodusIGASidesets(), MeshTriangulationTest::testFoundCenters(), PointLocatorTest::testLocator(), BoundaryInfoTest::testMesh(), PointLocatorTest::testPlanar(), MeshTriangulationTest::testPoly2TriRefinementBase(), SystemsTest::testProjectCubeWithMeshFunction(), BoundaryInfoTest::testRenumber(), CheckpointIOTest::testSplitter(), MeshInputTest::testTetgenIO(), MeshTriangulationTest::testTriangulatorInterp(), MeshTriangulationTest::testTriangulatorMeshedHoles(), MeshTriangulationTest::testTriangulatorRoundHole(), libMesh::MeshTools::total_weight(), libMesh::RBConstruction::train_reduced_basis_with_POD(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::Poly2TriTriangulator::triangulate(), truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::MeshRefinement::uniformly_coarsen(), update_current_local_solution(), update_RB_initial_condition_all_N(), update_RB_system_matrices(), libMesh::RBConstruction::update_RB_system_matrices(), update_residual_terms(), libMesh::RBConstruction::update_residual_terms(), libMesh::MeshTools::volume(), libMesh::STLIO::write(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::VTKIO::write_nodal_data(), libMesh::RBEIMEvaluation::write_out_interior_basis_functions(), libMesh::RBEIMEvaluation::write_out_node_basis_functions(), libMesh::RBEIMEvaluation::write_out_side_basis_functions(), libMesh::RBEvaluation::write_out_vectors(), write_riesz_representors_to_files(), libMesh::RBConstruction::write_riesz_representors_to_files(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::RBDataSerialization::RBEvaluationSerialization::write_to_file(), libMesh::RBDataSerialization::TransientRBEvaluationSerialization::write_to_file(), libMesh::RBDataSerialization::RBEIMEvaluationSerialization::write_to_file(), and libMesh::RBDataSerialization::RBSCMEvaluationSerialization::write_to_file().

98  { return _communicator; }
const Parallel::Communicator & _communicator

◆ compare()

bool libMesh::System::compare ( const System other_system,
const Real  threshold,
const bool  verbose 
) const
virtualinherited
Returns
true when the other system contains identical data, up to the given threshold. Outputs some diagnostic info when verbose is set.

Definition at line 618 of file system.C.

References libMesh::System::_is_initialized, libMesh::System::_sys_name, libMesh::System::_vectors, libMesh::System::get_vector(), libMesh::libmesh_assert(), libMesh::System::n_vectors(), libMesh::System::name(), libMesh::out, and libMesh::System::solution.

621 {
622  // we do not care for matrices, but for vectors
624  libmesh_assert (other_system._is_initialized);
625 
626  if (verbose)
627  {
628  libMesh::out << " Systems \"" << _sys_name << "\"" << std::endl;
629  libMesh::out << " comparing matrices not supported." << std::endl;
630  libMesh::out << " comparing names...";
631  }
632 
633  // compare the name: 0 means identical
634  const int name_result = _sys_name.compare(other_system.name());
635  if (verbose)
636  {
637  if (name_result == 0)
638  libMesh::out << " identical." << std::endl;
639  else
640  libMesh::out << " names not identical." << std::endl;
641  libMesh::out << " comparing solution vector...";
642  }
643 
644 
645  // compare the solution: -1 means identical
646  const int solu_result = solution->compare (*other_system.solution.get(),
647  threshold);
648 
649  if (verbose)
650  {
651  if (solu_result == -1)
652  libMesh::out << " identical up to threshold." << std::endl;
653  else
654  libMesh::out << " first difference occurred at index = "
655  << solu_result << "." << std::endl;
656  }
657 
658 
659  // safety check, whether we handle at least the same number
660  // of vectors
661  std::vector<int> ov_result;
662 
663  if (this->n_vectors() != other_system.n_vectors())
664  {
665  if (verbose)
666  {
667  libMesh::out << " Fatal difference. This system handles "
668  << this->n_vectors() << " add'l vectors," << std::endl
669  << " while the other system handles "
670  << other_system.n_vectors()
671  << " add'l vectors." << std::endl
672  << " Aborting comparison." << std::endl;
673  }
674  return false;
675  }
676  else if (this->n_vectors() == 0)
677  {
678  // there are no additional vectors...
679  ov_result.clear ();
680  }
681  else
682  {
683  // compare other vectors
684  for (auto & [vec_name, vec] : _vectors)
685  {
686  if (verbose)
687  libMesh::out << " comparing vector \""
688  << vec_name << "\" ...";
689 
690  // assume they have the same name
691  const NumericVector<Number> & other_system_vector =
692  other_system.get_vector(vec_name);
693 
694  ov_result.push_back(vec->compare(other_system_vector, threshold));
695 
696  if (verbose)
697  {
698  if (ov_result[ov_result.size()-1] == -1)
699  libMesh::out << " identical up to threshold." << std::endl;
700  else
701  libMesh::out << " first difference occurred at" << std::endl
702  << " index = " << ov_result[ov_result.size()-1] << "." << std::endl;
703  }
704  }
705  } // finished comparing additional vectors
706 
707 
708  bool overall_result;
709 
710  // sum up the results
711  if ((name_result==0) && (solu_result==-1))
712  {
713  if (ov_result.size()==0)
714  overall_result = true;
715  else
716  {
717  bool ov_identical;
718  unsigned int n = 0;
719  do
720  {
721  ov_identical = (ov_result[n]==-1);
722  n++;
723  }
724  while (ov_identical && n<ov_result.size());
725  overall_result = ov_identical;
726  }
727  }
728  else
729  overall_result = false;
730 
731  if (verbose)
732  {
733  libMesh::out << " finished comparisons, ";
734  if (overall_result)
735  libMesh::out << "found no differences." << std::endl << std::endl;
736  else
737  libMesh::out << "found differences." << std::endl << std::endl;
738  }
739 
740  return overall_result;
741 }
bool _is_initialized
true when additional vectors and variables do not require immediate initialization, false otherwise.
Definition: system.h:2276
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2230
unsigned int n_vectors() const
Definition: system.h:2558
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
libmesh_assert(ctx)
OStreamProxy out
const std::string _sys_name
A name associated with this system.
Definition: system.h:2196
template class LIBMESH_EXPORT NumericVector< Number >

◆ compute_Fq_representor_innerprods()

void libMesh::RBConstruction::compute_Fq_representor_innerprods ( bool  compute_inner_products = true)
protectedvirtualinherited

Compute the terms that are combined ‘online’ to determine the dual norm of the residual.

Here we compute the terms associated with the right-hand side. These terms are basis independent, hence we separate them from the rest of the calculations that are done in update_residual_terms. By default, inner product terms are also computed, but you can turn this feature off e.g. if you are already reading in that data from files.

Definition at line 2170 of file rb_construction.C.

References libMesh::NumericVector< T >::add(), libMesh::RBConstruction::assert_convergence, libMesh::NumericVector< T >::build(), libMesh::RBConstruction::check_convergence(), libMesh::ParallelObject::comm(), libMesh::LinearImplicitSystem::final_linear_residual(), libMesh::RBConstruction::Fq_representor, libMesh::RBEvaluation::Fq_representor_innerprods, libMesh::RBConstruction::Fq_representor_innerprods, libMesh::RBConstruction::Fq_representor_innerprods_computed, libMesh::RBConstruction::get_Fq(), libMesh::RBThetaExpansion::get_n_F_terms(), libMesh::RBConstruction::get_non_dirichlet_inner_product_matrix_if_avail(), libMesh::RBConstruction::get_rb_evaluation(), libMesh::RBConstruction::get_rb_theta_expansion(), libMesh::Utility::get_timestamp(), libMesh::RBConstruction::inner_product_matrix, libMesh::RBConstruction::inner_product_solver, libMesh::RBConstructionBase< LinearImplicitSystem >::inner_product_storage_vector, libMesh::RBConstructionBase< LinearImplicitSystem >::is_quiet(), libMesh::libmesh_assert(), libMesh::System::n_dofs(), libMesh::LinearImplicitSystem::n_linear_iterations(), libMesh::System::n_local_dofs(), libMesh::out, libMesh::PARALLEL, libMesh::ExplicitSystem::rhs, libMesh::System::solution, libMesh::RBConstruction::solve_for_matrix_and_rhs(), libMesh::SparseMatrix< T >::vector_mult(), and libMesh::NumericVector< T >::zero().

Referenced by libMesh::RBConstruction::recompute_all_residual_terms(), and libMesh::RBConstruction::train_reduced_basis_with_greedy().

2171 {
2172 
2173  // Skip calculations if we've already computed the Fq_representors
2175  {
2176  // Only log if we get to here
2177  LOG_SCOPE("compute_Fq_representor_innerprods()", "RBConstruction");
2178 
2179  for (unsigned int q_f=0; q_f<get_rb_theta_expansion().get_n_F_terms(); q_f++)
2180  {
2181  if (!Fq_representor[q_f])
2182  {
2184  Fq_representor[q_f]->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
2185  }
2186 
2187  libmesh_assert(Fq_representor[q_f]->size() == this->n_dofs() &&
2188  Fq_representor[q_f]->local_size() == this->n_local_dofs() );
2189 
2190  rhs->zero();
2191  rhs->add(1., *get_Fq(q_f));
2192 
2193  if (!is_quiet())
2194  libMesh::out << "Starting solve q_f=" << q_f
2195  << " in RBConstruction::update_residual_terms() at "
2196  << Utility::get_timestamp() << std::endl;
2197 
2199 
2200  if (assert_convergence)
2202 
2203  if (!is_quiet())
2204  {
2205  libMesh::out << "Finished solve q_f=" << q_f
2206  << " in RBConstruction::update_residual_terms() at "
2207  << Utility::get_timestamp() << std::endl;
2208 
2210  << " iterations, final residual "
2211  << this->final_linear_residual() << std::endl;
2212  }
2213 
2214  *Fq_representor[q_f] = *solution;
2215  }
2216 
2217  if (compute_inner_products)
2218  {
2219  unsigned int q=0;
2220 
2221  for (unsigned int q_f1=0; q_f1<get_rb_theta_expansion().get_n_F_terms(); q_f1++)
2222  {
2224 
2225  for (unsigned int q_f2=q_f1; q_f2<get_rb_theta_expansion().get_n_F_terms(); q_f2++)
2226  {
2228 
2229  q++;
2230  }
2231  }
2232  } // end if (compute_inner_products)
2233 
2235  }
2236 
2238 }
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 > > > Fq_representor
Vector storing the residual representors associated with the right-hand side.
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.
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...
std::string get_timestamp()
Definition: timestamp.C:37
NumericVector< Number > * rhs
The system matrix.
const Parallel::Communicator & comm() const
bool is_quiet() const
Is the system in quiet mode?
std::unique_ptr< SparseMatrix< Number > > inner_product_matrix
The inner product matrix.
NumericVector< Number > * get_Fq(unsigned int q)
Get a pointer to Fq.
dof_id_type n_local_dofs() const
Definition: system.C:158
std::vector< Number > Fq_representor_innerprods
Vectors storing the residual representor inner products to be used in computing the residuals online...
dof_id_type n_dofs() const
Definition: system.C:121
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 solve_for_matrix_and_rhs(LinearSolver< Number > &input_solver, SparseMatrix< Number > &input_matrix, NumericVector< Number > &input_rhs)
Assembles & solves the linear system A*x=b for the specified matrix input_matrix and right-hand side ...
bool Fq_representor_innerprods_computed
A boolean flag to indicate whether or not the Fq representor norms have already been computed — used...
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
unsigned int n_linear_iterations() const
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
libmesh_assert(ctx)
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...
OStreamProxy out
SparseMatrix< Number > * get_non_dirichlet_inner_product_matrix_if_avail()
Get the non-Dirichlet inner-product matrix if it&#39;s available, otherwise get the inner-product 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...
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.
virtual void add(const numeric_index_type i, const T value)=0
Adds value to the vector entry specified by i.

◆ compute_max_error_bound()

Real libMesh::RBConstruction::compute_max_error_bound ( )
virtualinherited

(i) Compute the a posteriori error bound for each set of parameters in the training set, (ii) set current_parameters to the parameters that maximize the error bound, and (iii) return the maximum error bound.

Definition at line 1817 of file rb_construction.C.

References libMesh::RBConstructionBase< LinearImplicitSystem >::broadcast_parameters(), libMesh::ParallelObject::comm(), libMesh::RBConstructionBase< LinearImplicitSystem >::get_first_local_training_index(), libMesh::RBConstructionBase< LinearImplicitSystem >::get_global_max_error_pair(), libMesh::RBConstructionBase< LinearImplicitSystem >::get_last_local_training_index(), libMesh::RBConstructionBase< LinearImplicitSystem >::get_local_n_training_samples(), libMesh::RBParametrized::get_n_params(), libMesh::RBConstruction::get_preevaluate_thetas_flag(), libMesh::RBConstruction::get_RB_error_bound(), libMesh::RBConstruction::get_rb_evaluation(), libMesh::ParallelObject::processor_id(), libMesh::Real, libMesh::RBConstructionBase< LinearImplicitSystem >::serial_training_set, libMesh::RBConstruction::set_current_training_parameter_index(), libMesh::RBConstructionBase< LinearImplicitSystem >::set_params_from_training_set(), TIMPI::Communicator::sum(), and libMesh::RBConstruction::training_error_bounds.

Referenced by libMesh::RBConstruction::train_reduced_basis_with_greedy().

1818 {
1819  LOG_SCOPE("compute_max_error_bound()", "RBConstruction");
1820 
1821  // Treat the case with no parameters in a special way
1822  if (get_n_params() == 0)
1823  {
1824  Real max_val;
1825  if (std::numeric_limits<Real>::has_infinity)
1826  {
1827  max_val = std::numeric_limits<Real>::infinity();
1828  }
1829  else
1830  {
1831  max_val = std::numeric_limits<Real>::max();
1832  }
1833 
1834  // Make sure we do at least one solve, but otherwise return a zero error bound
1835  // when we have no parameters
1836  return (get_rb_evaluation().get_n_basis_functions() == 0) ? max_val : 0.;
1837  }
1838 
1840 
1841  // keep track of the maximum error
1842  unsigned int max_err_index = 0;
1843  Real max_err = 0.;
1844 
1846  for (unsigned int i=0; i<get_local_n_training_samples(); i++)
1847  {
1848  // Load training parameter i, this is only loaded
1849  // locally since the RB solves are local.
1850  set_params_from_training_set( first_index+i );
1851 
1852  // In case we pre-evaluate the theta functions,
1853  // also keep track of the current training parameter index.
1855  set_current_training_parameter_index(first_index+i);
1856 
1857 
1859 
1860  if (training_error_bounds[i] > max_err)
1861  {
1862  max_err_index = i;
1863  max_err = training_error_bounds[i];
1864  }
1865  }
1866 
1867  std::pair<numeric_index_type, Real> error_pair(first_index+max_err_index, max_err);
1868  get_global_max_error_pair(this->comm(),error_pair);
1869 
1870  // If we have a serial training set (i.e. a training set that is the same on all processors)
1871  // just set the parameters on all processors
1872  if (serial_training_set)
1873  {
1874  set_params_from_training_set( error_pair.first );
1875  }
1876  // otherwise, broadcast the parameter that produced the maximum error
1877  else
1878  {
1879  unsigned int root_id=0;
1880  if ((get_first_local_training_index() <= error_pair.first) &&
1881  (error_pair.first < get_last_local_training_index()))
1882  {
1883  set_params_from_training_set( error_pair.first );
1884  root_id = this->processor_id();
1885  }
1886 
1887  this->comm().sum(root_id); // root_id is only non-zero on one processor
1888  broadcast_parameters(root_id);
1889  }
1890 
1891  return error_pair.second;
1892 }
numeric_index_type get_first_local_training_index() const
Get the first local index of the training parameters.
std::vector< Real > training_error_bounds
Vector storing the values of the error bound for each parameter in the training set — the parameter ...
void sum(T &r) const
const Parallel::Communicator & comm() const
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...
void broadcast_parameters(const unsigned int proc_id)
Broadcasts parameters from processor proc_id to all processors.
bool get_preevaluate_thetas_flag() const
Get/set flag to pre-evaluate the theta functions.
dof_id_type numeric_index_type
Definition: id_types.h:99
numeric_index_type get_last_local_training_index() const
Get the last 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.
virtual Real get_RB_error_bound()
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...
void set_current_training_parameter_index(unsigned int index)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
bool serial_training_set
This boolean flag indicates whether or not the training set should be the same on all processors...
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.
processor_id_type processor_id() const
unsigned int get_n_params() const
Get the number of parameters.

◆ compute_output_dual_innerprods()

void libMesh::RBConstruction::compute_output_dual_innerprods ( )
protectedvirtualinherited

Compute and store the dual norm of each output functional.

Definition at line 2075 of file rb_construction.C.

References libMesh::NumericVector< T >::add(), libMesh::RBConstruction::assert_convergence, libMesh::NumericVector< T >::build(), libMesh::RBConstruction::check_convergence(), libMesh::ParallelObject::comm(), libMesh::LinearImplicitSystem::final_linear_residual(), libMesh::LinearImplicitSystem::get_linear_solver(), libMesh::RBConstruction::get_matrix_for_output_dual_solves(), libMesh::RBThetaExpansion::get_n_output_terms(), libMesh::RBThetaExpansion::get_n_outputs(), libMesh::RBConstruction::get_output_vector(), libMesh::RBConstruction::get_rb_evaluation(), libMesh::RBConstruction::get_rb_theta_expansion(), libMesh::Utility::get_timestamp(), libMesh::RBConstructionBase< LinearImplicitSystem >::inner_product_storage_vector, libMesh::RBConstructionBase< LinearImplicitSystem >::is_quiet(), libMesh::ImplicitSystem::linear_solver, libMesh::System::n_dofs(), libMesh::LinearImplicitSystem::n_linear_iterations(), libMesh::System::n_local_dofs(), libMesh::out, libMesh::RBEvaluation::output_dual_innerprods, libMesh::RBConstruction::output_dual_innerprods, libMesh::RBConstruction::output_dual_innerprods_computed, libMesh::PARALLEL, libMesh::ExplicitSystem::rhs, libMesh::System::solution, libMesh::RBConstruction::solve_for_matrix_and_rhs(), libMesh::SparseMatrix< T >::vector_mult(), and libMesh::NumericVector< T >::zero().

Referenced by libMesh::RBConstruction::train_reduced_basis_with_greedy().

2076 {
2077  // Skip calculations if we've already computed the output dual norms
2079  {
2080  // Short circuit if we don't have any outputs
2081  if (get_rb_theta_expansion().get_n_outputs() == 0)
2082  {
2084  return;
2085  }
2086 
2087  // Only log if we get to here
2088  LOG_SCOPE("compute_output_dual_innerprods()", "RBConstruction");
2089 
2090  libMesh::out << "Compute output dual inner products" << std::endl;
2091 
2092  // Find out the largest value of Q_l
2093  unsigned int max_Q_l = 0;
2094  for (unsigned int n=0; n<get_rb_theta_expansion().get_n_outputs(); n++)
2095  max_Q_l = (get_rb_theta_expansion().get_n_output_terms(n) > max_Q_l) ? get_rb_theta_expansion().get_n_output_terms(n) : max_Q_l;
2096 
2097  std::vector<std::unique_ptr<NumericVector<Number>>> L_q_representor(max_Q_l);
2098  for (unsigned int q=0; q<max_Q_l; q++)
2099  {
2100  L_q_representor[q] = NumericVector<Number>::build(this->comm());
2101  L_q_representor[q]->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
2102  }
2103 
2104  for (unsigned int n=0; n<get_rb_theta_expansion().get_n_outputs(); n++)
2105  {
2106  for (unsigned int q_l=0; q_l<get_rb_theta_expansion().get_n_output_terms(n); q_l++)
2107  {
2108  rhs->zero();
2109  rhs->add(1., *get_output_vector(n,q_l));
2110 
2111  if (!is_quiet())
2112  libMesh::out << "Starting solve n=" << n << ", q_l=" << q_l
2113  << " in RBConstruction::compute_output_dual_innerprods() at "
2114  << Utility::get_timestamp() << std::endl;
2115 
2116  // Use the main linear solver here instead of the inner_product solver, since
2117  // get_matrix_for_output_dual_solves() may not return the inner product matrix.
2119 
2120  // We possibly perform multiple solves here with the same matrix, hence
2121  // set reuse_preconditioner(true) (and set it back to false again below
2122  // at the end of this function).
2123  linear_solver->reuse_preconditioner(true);
2124 
2125  if (assert_convergence)
2127 
2128  if (!is_quiet())
2129  {
2130  libMesh::out << "Finished solve n=" << n << ", q_l=" << q_l
2131  << " in RBConstruction::compute_output_dual_innerprods() at "
2132  << Utility::get_timestamp() << std::endl;
2133 
2135  << " iterations, final residual "
2136  << this->final_linear_residual() << std::endl;
2137  }
2138 
2139  *L_q_representor[q_l] = *solution;
2140  }
2141 
2142  unsigned int q=0;
2143  for (unsigned int q_l1=0; q_l1<get_rb_theta_expansion().get_n_output_terms(n); q_l1++)
2144  {
2146 
2147  for (unsigned int q_l2=q_l1; q_l2<get_rb_theta_expansion().get_n_output_terms(n); q_l2++)
2148  {
2149  output_dual_innerprods[n][q] = L_q_representor[q_l2]->dot(*inner_product_storage_vector);
2150  libMesh::out << "output_dual_innerprods[" << n << "][" << q << "] = " << output_dual_innerprods[n][q] << std::endl;
2151 
2152  q++;
2153  }
2154  }
2155  }
2156 
2157  // We may not need to use linear_solver again (e.g. this would happen if we use
2158  // extra_linear_solver for the truth_solves). As a result, let's clear linear_solver
2159  // to release any memory it may be taking up. If we do need it again, it will
2160  // be initialized when necessary.
2161  linear_solver->clear();
2162  linear_solver->reuse_preconditioner(false);
2163 
2165  }
2166 
2168 }
bool assert_convergence
A boolean flag to indicate whether to check for proper convergence after each solve.
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...
std::string get_timestamp()
Definition: timestamp.C:37
std::vector< std::vector< Number > > output_dual_innerprods
The vector storing the dual norm inner product terms for each output.
NumericVector< Number > * rhs
The system matrix.
const Parallel::Communicator & comm() const
bool is_quiet() const
Is the system in quiet mode?
std::vector< std::vector< Number > > output_dual_innerprods
The vector storing the dual norm inner product terms for each output.
virtual LinearSolver< Number > * get_linear_solver() const override
dof_id_type n_local_dofs() const
Definition: system.C:158
unsigned int get_n_outputs() const
Get n_outputs, the number output functionals.
dof_id_type n_dofs() const
Definition: system.C:121
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 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 ...
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
unsigned int n_linear_iterations() const
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
virtual SparseMatrix< Number > & get_matrix_for_output_dual_solves()
Return the matrix for the output residual dual norm solves.
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.
OStreamProxy out
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...
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 add(const numeric_index_type i, const T value)=0
Adds value to the vector entry specified by i.
std::unique_ptr< LinearSolver< Number > > linear_solver
This class handles all the details of interfacing with various linear algebra packages like PETSc or ...
bool output_dual_innerprods_computed
A boolean flag to indicate whether or not the output dual norms have already been computed — used to...

◆ compute_residual_dual_norm_slow()

Real libMesh::RBConstruction::compute_residual_dual_norm_slow ( const unsigned int  N)
inherited

The slow (but simple, non-error prone) way to compute the residual dual norm.

Useful for error checking.

Definition at line 2259 of file rb_construction.C.

References libMesh::RBConstruction::_untransformed_basis_functions, libMesh::SparseMatrix< T >::add(), libMesh::NumericVector< T >::add(), libMesh::NumericVector< T >::build(), libMesh::ParallelObject::comm(), libMesh::RBEvaluation::get_n_basis_functions(), libMesh::RBConstruction::get_non_dirichlet_inner_product_matrix_if_avail(), libMesh::RBConstruction::get_rb_evaluation(), libMesh::RBConstruction::inner_product_matrix, libMesh::RBConstruction::inner_product_solver, libMesh::RBConstructionBase< LinearImplicitSystem >::inner_product_storage_vector, libMesh::libmesh_real(), libMesh::ImplicitSystem::matrix, libMesh::System::n_dofs(), libMesh::System::n_local_dofs(), libMesh::PARALLEL, libMesh::ExplicitSystem::rhs, libMesh::System::solution, libMesh::RBConstruction::solve_for_matrix_and_rhs(), libMesh::RBConstruction::store_untransformed_basis, libMesh::RBConstruction::truth_assembly(), libMesh::SparseMatrix< T >::vector_mult(), and libMesh::SparseMatrix< T >::zero().

2260 {
2261  LOG_SCOPE("compute_residual_dual_norm_slow()", "RBConstruction");
2262 
2263  // Put the residual in rhs in order to compute the norm of the Riesz representor
2264  // Note that this only works in serial since otherwise each processor will
2265  // have a different parameter value during the Greedy training.
2266 
2267  std::unique_ptr<NumericVector<Number>> RB_sol = NumericVector<Number>::build(comm());
2268  RB_sol->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
2269 
2270  std::unique_ptr<NumericVector<Number>> temp = NumericVector<Number>::build(comm());
2271  temp->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
2272 
2274  {
2275  libmesh_assert_equal_to(_untransformed_basis_functions.size(), get_rb_evaluation().get_n_basis_functions());
2276  }
2277 
2278  for (unsigned int i=0; i<N; i++)
2279  {
2281  {
2282  RB_sol->add(get_rb_evaluation().RB_solution(i), get_rb_evaluation().get_basis_function(i));
2283  }
2284  else
2285  {
2286  RB_sol->add(get_rb_evaluation().RB_solution(i), *_untransformed_basis_functions[i]);
2287  }
2288  }
2289 
2290  this->truth_assembly();
2291  matrix->vector_mult(*temp, *RB_sol);
2292  rhs->add(-1., *temp);
2293 
2294  // Then solve to get the Reisz representor
2295  matrix->zero();
2297 
2300  Number slow_residual_norm_sq = solution->dot(*inner_product_storage_vector);
2301 
2302  return std::sqrt( libmesh_real(slow_residual_norm_sq) );
2303 }
T libmesh_real(T a)
virtual void truth_assembly()
Assemble the truth matrix and right-hand side for current_parameters.
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 vector_mult(NumericVector< T > &dest, const NumericVector< T > &arg) const
Multiplies the matrix by the NumericVector arg and stores the result in NumericVector dest...
NumericVector< Number > * rhs
The system matrix.
const Parallel::Communicator & comm() const
std::unique_ptr< SparseMatrix< Number > > inner_product_matrix
The inner product matrix.
dof_id_type n_local_dofs() const
Definition: system.C:158
dof_id_type n_dofs() const
Definition: system.C:121
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 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 void zero()=0
Set all entries to 0.
bool store_untransformed_basis
Boolean flag to indicate whether we store a second copy of the basis without constraints or dof trans...
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
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...
SparseMatrix< Number > * matrix
The system matrix.
virtual unsigned int get_n_basis_functions() const
Get the current number of basis functions.
SparseMatrix< Number > * get_non_dirichlet_inner_product_matrix_if_avail()
Get the non-Dirichlet inner-product matrix if it&#39;s available, otherwise get the inner-product 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...
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.
virtual void add(const numeric_index_type i, const T value)=0
Adds value to the vector entry specified by i.

◆ condense_constrained_dofs()

virtual bool libMesh::System::condense_constrained_dofs ( ) const
inlineprotectedvirtualinherited

Whether this object should condense out constrained degrees of freedom.

Reimplemented in libMesh::CondensedEigenSystem.

Definition at line 2013 of file system.h.

Referenced by libMesh::EigenSystem::init_matrices().

2013 { return false; }

◆ create_static_condensation()

void libMesh::LinearImplicitSystem::create_static_condensation ( )
overridevirtualinherited

Request that static condensation be performed for this system.

Reimplemented from libMesh::ImplicitSystem.

Definition at line 63 of file linear_implicit_system.C.

References libMesh::ImplicitSystem::create_static_condensation(), libMesh::ImplicitSystem::linear_solver, and libMesh::ImplicitSystem::setup_static_condensation_preconditioner().

64 {
67 }
virtual void create_static_condensation() override
Request that static condensation be performed for this system.
void setup_static_condensation_preconditioner(T &solver)
Sets up the static condensation preconditioner for the supplied solver.
std::unique_ptr< LinearSolver< Number > > linear_solver
This class handles all the details of interfacing with various linear algebra packages like PETSc or ...

◆ current_solution()

Number libMesh::System::current_solution ( const dof_id_type  global_dof_number) const
inherited
Returns
The current solution for the specified global DOF.

Definition at line 165 of file system.C.

References libMesh::System::_dof_map, and libMesh::System::current_local_solution.

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::HPCoarsenTest::add_projection(), compute_stresses(), LinearElasticityWithContact::compute_stresses(), LinearElasticity::compute_stresses(), LargeDeformationElasticity::compute_stresses(), libMesh::ExactErrorEstimator::estimate_error(), main(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::HPCoarsenTest::select_refinement(), SolidSystem::side_time_derivative(), libMesh::EnsightIO::write_scalar_ascii(), and libMesh::EnsightIO::write_vector_ascii().

166 {
167  // Check the sizes
168  libmesh_assert_less (global_dof_number, _dof_map->n_dofs());
169  libmesh_assert_less (global_dof_number, current_local_solution->size());
170 
171  return (*current_local_solution)(global_dof_number);
172 }
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:2179
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Definition: system.h:1605

◆ deactivate()

void libMesh::System::deactivate ( )
inlineinherited

Deactivates the system.

Only active systems are solved.

Definition at line 2406 of file system.h.

References libMesh::System::_active.

2407 {
2408  _active = false;
2409 }
bool _active
Flag stating if the system is active or not.
Definition: system.h:2222

◆ detach_shell_matrix()

void libMesh::LinearImplicitSystem::detach_shell_matrix ( )
inlineinherited

Detaches a shell matrix.

Same as attach_shell_matrix(nullptr).

Definition at line 176 of file linear_implicit_system.h.

References libMesh::LinearImplicitSystem::attach_shell_matrix().

Referenced by main().

176 { attach_shell_matrix(nullptr); }
void attach_shell_matrix(ShellMatrix< Number > *shell_matrix)
This function enables the user to provide a shell matrix, i.e.

◆ disable_cache()

void libMesh::ImplicitSystem::disable_cache ( )
overridevirtualinherited

Avoids use of any cached data that might affect any solve result.

Should be overridden in derived systems.

Reimplemented from libMesh::System.

Definition at line 128 of file implicit_system.C.

References libMesh::System::assemble_before_solve, libMesh::ImplicitSystem::get_linear_solver(), and libMesh::LinearSolver< T >::reuse_preconditioner().

Referenced by libMesh::DifferentiableSystem::pop_physics(), libMesh::DifferentiableSystem::push_physics(), and libMesh::DifferentiableSystem::swap_physics().

128  {
129  this->assemble_before_solve = true;
130  this->get_linear_solver()->reuse_preconditioner(false);
131 }
virtual LinearSolver< Number > * get_linear_solver() const
virtual void reuse_preconditioner(bool)
Set the same_preconditioner flag, which indicates if we reuse the same preconditioner for subsequent ...
bool assemble_before_solve
Flag which tells the system to whether or not to call the user assembly function during each call to ...
Definition: system.h:1547

◆ disable_print_counter_info() [1/2]

void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

Definition at line 100 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

101 {
102  _enable_print_counter = false;
103  return;
104 }
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called...

◆ disable_print_counter_info() [2/2]

void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

Definition at line 100 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

101 {
102  _enable_print_counter = false;
103  return;
104 }
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called...

◆ enable_print_counter_info() [1/2]

void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

Methods to enable/disable the reference counter output from print_info()

Definition at line 94 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

95 {
96  _enable_print_counter = true;
97  return;
98 }
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called...

◆ enable_print_counter_info() [2/2]

void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

Methods to enable/disable the reference counter output from print_info()

Definition at line 94 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

95 {
96  _enable_print_counter = true;
97  return;
98 }
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called...

◆ enrich_basis_from_rhs_terms()

void libMesh::RBConstruction::enrich_basis_from_rhs_terms ( const bool  resize_rb_eval_data = true)
inherited

This function computes one basis function for each rhs term.

This is useful in some cases since we can avoid doing a full greedy if we know that we do not have any "left-hand side" parameters, for example.

Definition at line 1315 of file rb_construction.C.

References libMesh::RBConstruction::assert_convergence, libMesh::RBConstruction::check_convergence(), libMesh::RBConstruction::enrich_RB_space(), libMesh::RBConstruction::extra_linear_solver, libMesh::System::get_equation_systems(), libMesh::RBConstruction::get_Fq(), libMesh::LinearImplicitSystem::get_linear_solver(), libMesh::System::get_mesh(), libMesh::RBThetaExpansion::get_n_F_terms(), libMesh::RBConstruction::get_Nmax(), libMesh::RBConstruction::get_rb_evaluation(), libMesh::RBConstruction::get_rb_theta_expansion(), libMesh::RBParametrized::initialize_parameters(), libMesh::NumericVector< T >::l2_norm(), libMesh::ImplicitSystem::matrix, libMesh::System::name(), libMesh::out, libMesh::RBConstruction::post_process_truth_solution(), libMesh::NumericVector< T >::print_matlab(), libMesh::RBEvaluation::resize_data_structures(), libMesh::ExplicitSystem::rhs, libMesh::RBConstruction::solve_for_matrix_and_rhs(), libMesh::RBConstruction::truth_assembly(), libMesh::RBConstruction::update_system(), and libMesh::ExodusII_IO::write_equation_systems().

1316 {
1317  LOG_SCOPE("enrich_basis_from_rhs_terms()", "RBConstruction");
1318 
1319  // initialize rb_eval's parameters
1321 
1322  // possibly resize data structures according to Nmax
1323  if (resize_rb_eval_data)
1324  {
1326  }
1327 
1328  libMesh::out << std::endl << "---- Enriching basis from rhs terms ----" << std::endl;
1329 
1330  truth_assembly();
1331 
1332  for (unsigned int q_f=0; q_f<get_rb_theta_expansion().get_n_F_terms(); q_f++)
1333  {
1334  libMesh::out << std::endl << "Performing truth solve with rhs from rhs term " << q_f << std::endl;
1335 
1336  *rhs = *get_Fq(q_f);
1337 
1338  if (rhs->l2_norm() == 0)
1339  {
1340  // Skip enrichment if the rhs is zero
1341  continue;
1342  }
1343 
1344  // truth_assembly assembles into matrix and rhs, so use those for the solve
1345  if (extra_linear_solver)
1346  {
1347  // If extra_linear_solver has been initialized, then we use it for the
1348  // truth solves.
1350 
1351  if (assert_convergence)
1353  }
1354  else
1355  {
1357 
1358  if (assert_convergence)
1360  }
1361 
1362  // Debugging: enable this code to print the rhs that was used in
1363  // the most recent truth solve to a uniquely-named file.
1364 #if 0
1365  {
1366  char temp_file[] = "truth_rhs_XXXXXX.dat";
1367  int fd = mkstemps(temp_file, 4);
1368  if (fd != -1)
1369  {
1370  libMesh::out << "Writing truth system rhs to file: " << temp_file << std::endl;
1371  rhs->print_matlab(std::string(temp_file));
1372  }
1373  }
1374 #endif // 0
1375 
1376  // Debugging: enable this code to print the most recent truth
1377  // solution to a uniquely-named file.
1378 #ifdef LIBMESH_HAVE_EXODUS_API
1379 #if 0
1380  {
1381  // Note: mkstemps creates a file and returns an open file descriptor to it.
1382  // The filename is created from a template which must have 6 'X' characters followed
1383  // by a suffix having the specified length (in this case 4, for ".exo").
1384  char temp_file[] = "truth_XXXXXX.exo";
1385  int fd = mkstemps(temp_file, 4);
1386  if (fd != -1)
1387  {
1388  libMesh::out << "Writing truth solution to file: " << temp_file << std::endl;
1389  ExodusII_IO exo_io(this->get_mesh());
1390  std::set<std::string> system_names = {this->name()};
1391  exo_io.write_equation_systems(std::string(temp_file),
1392  this->get_equation_systems(), &system_names);
1393  }
1394  }
1395 #endif // 0
1396 #endif // LIBMESH_HAVE_EXODUS_API
1397 
1398  // Call user-defined post-processing routines on the truth solution.
1400 
1401  // Add orthogonal part of the snapshot to the RB space
1402  libMesh::out << "Enriching the RB space" << std::endl;
1403  enrich_RB_space();
1404 
1405  update_system();
1406  }
1407 }
virtual void truth_assembly()
Assemble the truth matrix and right-hand side for current_parameters.
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 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.
const EquationSystems & get_equation_systems() const
Definition: system.h:721
NumericVector< Number > * rhs
The system matrix.
virtual LinearSolver< Number > * get_linear_solver() const override
NumericVector< Number > * get_Fq(unsigned int q)
Get a pointer to Fq.
const MeshBase & get_mesh() const
Definition: system.h:2358
LinearSolver< Number > * extra_linear_solver
Also, we store a pointer to an extra linear solver.
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 ...
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
virtual Real l2_norm() const =0
unsigned int get_Nmax() const
Get/set Nmax, the maximum number of RB functions we are willing to compute.
virtual void update_system()
Update the system after enriching the RB space; this calls a series of functions to update the system...
virtual void post_process_truth_solution()
Similarly, provide an opportunity to post-process the truth solution after the solve is complete...
virtual void print_matlab(const std::string &filename="") const
Print the contents of the vector in Matlab&#39;s sparse matrix format.
void check_convergence(LinearSolver< Number > &input_solver)
Check if the linear solver reports convergence.
OStreamProxy out
SparseMatrix< Number > * matrix
The system matrix.
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.
const std::string & name() const
Definition: system.h:2342
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.
virtual void enrich_RB_space()
Add a new basis function to the RB space.

◆ enrich_RB_space()

void TransientRBConstruction::enrich_RB_space ( )
overrideprotectedvirtual

Add a new basis functions to the RB space.

In the transient case we first perform a POD of the time-dependent "truth" and then add a certain number of POD modes to the reduced basis.

Reimplemented from libMesh::RBConstruction.

Definition at line 757 of file transient_rb_construction.C.

References libMesh::NumericVector< T >::add(), libMesh::RBEvaluation::basis_functions, libMesh::ParallelObject::comm(), libMesh::NumericVector< T >::dot(), libMesh::DenseMatrix< T >::el(), libMesh::RBEvaluation::get_basis_function(), libMesh::RBConstruction::get_delta_N(), libMesh::RBTemporalDiscretization::get_n_time_steps(), libMesh::RBConstruction::get_Nmax(), libMesh::RBConstruction::get_non_dirichlet_inner_product_matrix_if_avail(), libMesh::RBConstruction::get_rb_evaluation(), libMesh::NumericVector< T >::init(), libMesh::RBConstructionBase< LinearImplicitSystem >::inner_product_storage_vector, libMesh::libmesh_conj(), libMesh::System::n_dofs(), libMesh::System::n_local_dofs(), libMesh::out, libMesh::PARALLEL, POD_tol, libMesh::RBEvaluation::rb_solve(), libMesh::Real, libMesh::NumericVector< T >::scale(), set_delta_N(), libMesh::DenseMatrix< T >::svd(), temporal_data, update_system(), libMesh::SparseMatrix< T >::vector_mult(), and libMesh::NumericVector< T >::zero().

758 {
759  // Need SLEPc to get the POD eigenvalues
760  LOG_SCOPE("enrich_RB_space()", "TransientRBConstruction");
761 
762  // With the "method of snapshots", the size of
763  // the eigenproblem is determined by the number
764  // of time-steps (rather than the number of spatial dofs).
765  unsigned int n_snapshots = temporal_data.size();
766  DenseMatrix<Number> correlation_matrix(n_snapshots,n_snapshots);
767  for (unsigned int i=0; i<n_snapshots; i++)
768  {
771 
772  for (unsigned int j=0; j<=i; j++)
773  {
774  // Scale the inner products by the number of time-steps to normalize the
775  // POD energy norm appropriately
776  Number inner_prod = (temporal_data[j]->dot(*inner_product_storage_vector)) /
777  (Real)(get_n_time_steps()+1);
778 
779  correlation_matrix(i,j) = inner_prod;
780  if(i != j)
781  {
782  correlation_matrix(j,i) = libmesh_conj(inner_prod);
783  }
784  }
785  }
786 
787  // The POD can be formulated in terms of either the SVD or an eigenvalue problem.
788  // Here we use the SVD of the correlation matrix to obtain the POD eigenvalues and
789  // eigenvectors.
790  DenseVector<Real> sigma( n_snapshots );
791  DenseMatrix<Number> U( n_snapshots, n_snapshots );
792  DenseMatrix<Number> VT( n_snapshots, n_snapshots );
793  correlation_matrix.svd(sigma, U, VT );
794 
795  libMesh::out << std::endl << "POD singular values:" << std::endl;
796  for (unsigned int i=0; i<=1; i++)
797  {
798  libMesh::out << "singular value " << i << " = " << sigma(i) << std::endl;
799  }
800  libMesh::out << "..." << std::endl;
801  libMesh::out << "last singular value = " << sigma(n_snapshots-1) << std::endl;
802  libMesh::out << std::endl;
803 
804  // Now load the new basis functions
805  unsigned int j = 0;
806  while (true)
807  {
808  // load the new basis function into the basis_functions vector.
810  NumericVector<Number> & current_bf =
811  get_rb_evaluation().get_basis_function(get_rb_evaluation().get_n_basis_functions()-1);
812  current_bf.init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
813  current_bf.zero();
814 
815  // Perform the matrix multiplication of temporal data with
816  // the next POD eigenvector
817  for (unsigned int i=0; i<n_snapshots; i++)
818  {
819  current_bf.add( U.el(i,j), *temporal_data[i] );
820  }
821 
822  // We just set the norm to 1.
824 
825  Real current_bf_norm = std::abs( std::sqrt( current_bf.dot(*inner_product_storage_vector) ) );
826  current_bf.scale(1./current_bf_norm);
827 
828  // Increment j here since we use the incremented counter
829  // in the if clauses below
830  j++;
831 
832  // If positive POD_tol, we use it to determine the number of basis functions
833  // to add, and then break the loop when POD_tol is satisfied, or after Nmax
834  // basis functions have been added. Else we break the loop after delta_N
835  // (or Nmax) new basis functions.
836  if (POD_tol > 0.)
837  {
838  set_delta_N(1);
839 
840  // We need to define the updated RB system matrices before the RB solve
841  update_system();
842  Real error_bound = get_rb_evaluation().rb_solve(get_rb_evaluation().get_n_basis_functions());
843 
844  if ((error_bound <= POD_tol) || (get_rb_evaluation().get_n_basis_functions()==get_Nmax()))
845  {
846  set_delta_N(0);
847  break;
848  }
849  }
850  else
851  {
852  if (j == get_delta_N())
853  {
854  break;
855  }
856  else
857  if (get_rb_evaluation().get_n_basis_functions()==get_Nmax())
858  {
859  set_delta_N(j);
860  break;
861  }
862  }
863  }
864 }
T libmesh_conj(T a)
template class LIBMESH_EXPORT DenseVector< Real >
Definition: dense_vector.C:29
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...
std::vector< std::unique_ptr< NumericVector< Number > > > basis_functions
The libMesh vectors storing the finite element coefficients of the RB basis functions.
const Parallel::Communicator & comm() const
Real POD_tol
If positive, this tolerance determines the number of POD modes we add to the space on a call to enric...
dof_id_type n_local_dofs() const
Definition: system.C:158
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.
dof_id_type n_dofs() const
Definition: system.C:121
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...
unsigned int get_Nmax() const
Get/set Nmax, the maximum number of RB functions we are willing to compute.
NumericVector< Number > & get_basis_function(unsigned int i)
Get a reference to the i^th basis function.
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 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.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< std::unique_ptr< NumericVector< Number > > > temporal_data
Dense matrix to store the data that we use for the temporal POD.
OStreamProxy out
SparseMatrix< Number > * get_non_dirichlet_inner_product_matrix_if_avail()
Get the non-Dirichlet inner-product matrix if it&#39;s available, otherwise get the inner-product matrix ...
static std::unique_ptr< NumericVector< Number > > 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...
unsigned int get_n_time_steps() const
Get/set the total number of time-steps.
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.
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.
template class LIBMESH_EXPORT NumericVector< Number >
virtual void update_system() override
Update the system after enriching the RB space.

◆ final_linear_residual()

Real libMesh::LinearImplicitSystem::final_linear_residual ( ) const
inlineinherited

◆ forward_qoi_parameter_sensitivity()

void libMesh::ImplicitSystem::forward_qoi_parameter_sensitivity ( const QoISet qoi_indices,
const ParameterVector parameters,
SensitivityData sensitivities 
)
overridevirtualinherited

Solves for the derivative of each of the system's quantities of interest q in qoi[qoi_indices] with respect to each parameter in parameters, placing the result for qoi i and parameter j into sensitivities[i][j].

Uses the forward sensitivity method.

Currently uses finite differenced derivatives (partial q / partial p) and (partial R / partial p).

Reimplemented from libMesh::System.

Definition at line 623 of file implicit_system.C.

References libMesh::SensitivityData::allocate_data(), libMesh::ExplicitSystem::assemble_qoi(), libMesh::ExplicitSystem::assemble_qoi_derivative(), libMesh::ImplicitSystem::assembly(), libMesh::NumericVector< T >::close(), libMesh::SparseMatrix< T >::close(), libMesh::NumericVector< T >::dot(), libMesh::System::get_adjoint_rhs(), libMesh::System::get_qoi_values(), libMesh::System::get_sensitivity_solution(), libMesh::QoISet::has_index(), libMesh::make_range(), libMesh::ImplicitSystem::matrix, libMesh::System::n_qois(), libMesh::Real, libMesh::ExplicitSystem::rhs, libMesh::ImplicitSystem::sensitivity_solve(), libMesh::ParameterVector::size(), and libMesh::TOLERANCE.

Referenced by main().

626 {
627  ParameterVector & parameters_vec =
628  const_cast<ParameterVector &>(parameters_in);
629 
630  const unsigned int Np = cast_int<unsigned int>
631  (parameters_vec.size());
632  const unsigned int Nq = this->n_qois();
633 
634  // An introduction to the problem:
635  //
636  // Residual R(u(p),p) = 0
637  // partial R / partial u = J = system matrix
638  //
639  // This implies that:
640  // d/dp(R) = 0
641  // (partial R / partial p) +
642  // (partial R / partial u) * (partial u / partial p) = 0
643 
644  // We first solve for (partial u / partial p) for each parameter:
645  // J * (partial u / partial p) = - (partial R / partial p)
646 
647  this->sensitivity_solve(parameters_vec);
648 
649  // Get ready to fill in sensitivities:
650  sensitivities.allocate_data(qoi_indices, *this, parameters_vec);
651 
652  // We use the identity:
653  // dq/dp = (partial q / partial p) + (partial q / partial u) *
654  // (partial u / partial p)
655 
656  // We get (partial q / partial u) from the user
657  this->assemble_qoi_derivative(qoi_indices,
658  /* include_liftfunc = */ true,
659  /* apply_constraints = */ false);
660 
661  // We don't need these to be closed() in this function, but libMesh
662  // standard practice is to have them closed() by the time the
663  // function exits
664  for (auto i : make_range(this->n_qois()))
665  if (qoi_indices.has_index(i))
666  this->get_adjoint_rhs(i).close();
667 
668  for (unsigned int j=0; j != Np; ++j)
669  {
670  // We currently get partial derivatives via central differencing
671 
672  // (partial q / partial p) ~= (q(p+dp)-q(p-dp))/(2*dp)
673 
674  Number old_parameter = *parameters_vec[j];
675 
676  const Real delta_p =
677  TOLERANCE * std::max(std::abs(old_parameter), 1e-3);
678 
679  *parameters_vec[j] = old_parameter - delta_p;
680  this->assemble_qoi(qoi_indices);
681  const std::vector<Number> qoi_minus = this->get_qoi_values();
682 
683  *parameters_vec[j] = old_parameter + delta_p;
684  this->assemble_qoi(qoi_indices);
685  const std::vector<Number> qoi_plus = this->get_qoi_values();
686 
687  std::vector<Number> partialq_partialp(Nq, 0);
688  for (unsigned int i=0; i != Nq; ++i)
689  if (qoi_indices.has_index(i))
690  partialq_partialp[i] = (qoi_plus[i] - qoi_minus[i]) / (2.*delta_p);
691 
692  // Don't leave the parameter changed
693  *parameters_vec[j] = old_parameter;
694 
695  for (unsigned int i=0; i != Nq; ++i)
696  if (qoi_indices.has_index(i))
697  sensitivities[i][j] = partialq_partialp[i] +
698  this->get_adjoint_rhs(i).dot(this->get_sensitivity_solution(j));
699  }
700 
701  // All parameters_vec have been reset.
702  // We didn't cache the original rhs or matrix for memory reasons,
703  // but we can restore them to a state consistent solution -
704  // principle of least surprise.
705  this->assembly(true, true);
706  this->rhs->close();
707  this->matrix->close();
708  this->assemble_qoi(qoi_indices);
709 }
static constexpr Real TOLERANCE
unsigned int n_qois() const
Number of currently active quantities of interest.
Definition: system.h:2621
NumericVector< Number > & get_sensitivity_solution(unsigned int i=0)
Definition: system.C:1192
NumericVector< Number > * rhs
The system matrix.
virtual std::pair< unsigned int, Real > sensitivity_solve(const ParameterVector &parameters) override
Assembles & solves the linear system(s) (dR/du)*u_p = -dR/dp, for those parameters contained within p...
virtual T dot(const NumericVector< T > &v) const =0
virtual void assembly(bool, bool, bool=false, bool=false)
Assembles a residual in rhs and/or a jacobian in matrix, as requested.
virtual void close()=0
Calls the NumericVector&#39;s internal assembly routines, ensuring that the values are consistent across ...
virtual void close()=0
Calls the SparseMatrix&#39;s internal assembly routines, ensuring that the values are consistent across p...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
SparseMatrix< Number > * matrix
The system matrix.
virtual void assemble_qoi(const QoISet &qoi_indices=QoISet()) override
Prepares qoi for quantity of interest assembly, then calls user qoi function.
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...
Definition: int_range.h:140
virtual void assemble_qoi_derivative(const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true) override
Prepares adjoint_rhs for quantity of interest derivative assembly, then calls user qoi derivative fun...
std::vector< Number > get_qoi_values() const
Returns a copy of qoi, not a reference.
Definition: system.C:2393
NumericVector< Number > & get_adjoint_rhs(unsigned int i=0)
Definition: system.C:1307

◆ generate_training_parameters_deterministic()

std::pair< std::size_t, std::size_t > libMesh::RBConstructionBase< LinearImplicitSystem >::generate_training_parameters_deterministic ( const Parallel::Communicator communicator,
const std::map< std::string, bool > &  log_param_scale,
std::map< std::string, std::vector< RBParameter >> &  local_training_parameters_in,
const unsigned int  n_global_training_samples_in,
const RBParameters min_parameters,
const RBParameters max_parameters,
const bool  serial_training_set = false 
)
staticinherited

Static helper function for generating a deterministic set of parameters.

Only works with 1 or 2 parameters (as defined by the lengths of min/max parameters vectors), otherwise throws an error. The parameter n_global_training_samples_in is the total number of parameters to generate, and they will be split across all the processors (unless serial_training_set=true) in the local_training_parameters_in map.

Returns
a pair of {first_local_index,last_local_index}

Definition at line 572 of file rb_construction_base.C.

579 {
580  libmesh_assert_equal_to ( min_parameters.n_parameters(), max_parameters.n_parameters() );
581  const unsigned int num_params = min_parameters.n_parameters();
582 
583  if (num_params == 0)
584  return {0,0};
585 
586  if (num_params > 3)
587  libmesh_not_implemented_msg("ERROR: Deterministic training sample generation "
588  "not implemented for more than three parameters.");
589 
590  // TODO - we don't support vector-data here yet. This would only apply in the case where
591  // min or max are vector-valued, and all the generated points need to stay within those ranges.
592  // But typically we expect that if we're calling this function, we only have 1 min and 1 max,
593  // so the generated values are single-valued as well. The .get_value() calls will throw an error
594  // if this is not the case.
595 
596  // Reinitialize training_parameters_in (but don't remove existing keys!)
597  const auto &[n_local_training_samples, first_local_index] =
598  calculate_n_local_samples_and_index(communicator, n_global_training_samples_in,
600  const auto last_local_index = first_local_index + n_local_training_samples;
601  for (const auto & pr : min_parameters)
602  local_training_parameters_in[pr.first] = std::vector<RBParameter>(n_local_training_samples);
603 
604  // n_training_samples_per_param has 3 entries, but entries after "num_params"
605  // are unused so we just set their value to 1. We need to set it to 1 (rather
606  // than 0) so that we don't skip the inner part of the triply-nested loop over
607  // n_training_samples_per_param below.
608  std::vector<unsigned int> n_training_samples_per_param(3);
609  for (unsigned int param=0; param<3; param++)
610  {
611  if (param < num_params)
612  {
613  n_training_samples_per_param[param] =
614  static_cast<unsigned int>( std::round(std::pow(static_cast<Real>(n_global_training_samples_in), 1./num_params)) );
615  }
616  else
617  {
618  n_training_samples_per_param[param] = 1;
619  }
620  }
621 
622  {
623  // The current implementation assumes that we have the same number of
624  // samples in each parameter, so we check that n_training_samples_in
625  // is consistent with this assumption.
626  unsigned int total_samples_check = 1;
627  for (unsigned int n_samples : n_training_samples_per_param)
628  {
629  total_samples_check *= n_samples;
630  }
631 
632  libmesh_error_msg_if(total_samples_check != n_global_training_samples_in,
633  "Error: Number of training samples = "
634  << n_global_training_samples_in
635  << " does not enable a uniform grid of samples with "
636  << num_params << " parameters. Try "
637  << total_samples_check << " samples instead?");
638  }
639 
640  // First we make a list of training samples associated with each parameter,
641  // then we take a tensor product to obtain the final set of training samples.
642  std::vector<std::vector<Real>> training_samples_per_param(num_params);
643  {
644  unsigned int i = 0;
645  for (const auto & pr : min_parameters)
646  {
647  const std::string & param_name = pr.first;
648  const bool use_log_scaling = libmesh_map_find(log_param_scale, param_name);
649  Real min_param = min_parameters.get_value(param_name);
650  Real max_param = max_parameters.get_value(param_name);
651 
652  training_samples_per_param[i].resize(n_training_samples_per_param[i]);
653 
654  for (unsigned int j=0; j<n_training_samples_per_param[i]; j++)
655  {
656  // Generate log10 scaled training parameters
657  if (use_log_scaling)
658  {
659  Real epsilon = 1.e-6; // Prevent rounding errors triggering asserts
660  Real log_min = std::log10(min_param + epsilon);
661  Real log_range = std::log10( (max_param-epsilon) / (min_param+epsilon) );
662  Real step_size = log_range /
663  std::max((unsigned int)1,(n_training_samples_per_param[i]-1));
664 
665  if (j<(n_training_samples_per_param[i]-1))
666  {
667  training_samples_per_param[i][j] = std::pow(10., log_min + j*step_size );
668  }
669  else
670  {
671  // due to rounding error, the last parameter can be slightly
672  // bigger than max_parameters, hence snap back to the max
673  training_samples_per_param[i][j] = max_param;
674  }
675  }
676  else
677  {
678  // Generate linearly scaled training parameters
679  Real step_size = (max_param - min_param) /
680  std::max((unsigned int)1,(n_training_samples_per_param[i]-1));
681  training_samples_per_param[i][j] = j*step_size + min_param;
682  }
683 
684  }
685  i++;
686  }
687  }
688 
689  // Now load into training_samples_in
690  {
691  std::vector<unsigned int> indices(3);
692  unsigned int index_count = 0;
693  for (indices[0]=0; indices[0]<n_training_samples_per_param[0]; indices[0]++)
694  {
695  for (indices[1]=0; indices[1]<n_training_samples_per_param[1]; indices[1]++)
696  {
697  for (indices[2]=0; indices[2]<n_training_samples_per_param[2]; indices[2]++)
698  {
699  unsigned int param_count = 0;
700  for (const auto & pr : min_parameters)
701  {
702  std::vector<RBParameter> & training_vector =
703  libmesh_map_find(local_training_parameters_in, pr.first);
704  if (first_local_index <= index_count && index_count < last_local_index)
705  training_vector[index_count - first_local_index] =
706  {training_samples_per_param[param_count][indices[param_count]]};
707 
708  param_count++;
709  }
710  index_count++;
711  }
712  }
713  }
714  }
715  return {first_local_index, first_local_index+n_local_training_samples};
716 }
T pow(const T &x)
Definition: utility.h:328
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
bool serial_training_set
This boolean flag indicates whether or not the training set should be the same on all processors...

◆ generate_training_parameters_random()

std::pair< std::size_t, std::size_t > libMesh::RBConstructionBase< LinearImplicitSystem >::generate_training_parameters_random ( const Parallel::Communicator communicator,
const std::map< std::string, bool > &  log_param_scale,
std::map< std::string, std::vector< RBParameter >> &  local_training_parameters_in,
const unsigned int  n_global_training_samples_in,
const RBParameters min_parameters,
const RBParameters max_parameters,
const int  training_parameters_random_seed = -1,
const bool  serial_training_set = false 
)
staticinherited

Static helper function for generating a randomized set of parameters.

The parameter n_global_training_samples_in is the total number of parameters to generate, and they will be split across all the processors (unless serial_training_set=true) in the local_training_parameters_in map.

Returns
a pair of {first_local_index,last_local_index}

Definition at line 472 of file rb_construction_base.C.

480 {
481  const unsigned int num_params = min_parameters.n_parameters();
482  libmesh_error_msg_if(num_params!=max_parameters.n_parameters(),
483  "Number of parameters must be identical for min/max.");
484 
485  // Clear training_parameters_in
486  local_training_parameters_in.clear();
487 
488  if (num_params == 0)
489  return {0,0};
490 
491  if (training_parameters_random_seed < 0)
492  {
493  if (!serial_training_set)
494  {
495  // seed the random number generator with the system time
496  // and the processor ID so that the seed is different
497  // on different processors
498  std::srand( static_cast<unsigned>( std::time(0)*(1+communicator.rank()) ));
499  }
500  else
501  {
502  // seed the random number generator with the system time
503  // only so that the seed is the same on all processors
504  //
505  // Note that we broadcast the time on processor 0 to make
506  // sure all processors agree.
507  unsigned int current_time = static_cast<unsigned>( std::time(0) );
508  communicator.broadcast(current_time, 0);
509  std::srand(current_time);
510  }
511  }
512  else
513  {
514  if (!serial_training_set)
515  {
516  // seed the random number generator with the provided value
517  // and the processor ID so that the seed is different
518  // on different processors
519  std::srand( static_cast<unsigned>( training_parameters_random_seed*(1+communicator.rank()) ));
520  }
521  else
522  {
523  // seed the random number generator with the provided value
524  // so that the seed is the same on all processors
525  std::srand( static_cast<unsigned>( training_parameters_random_seed ));
526  }
527  }
528 
529  // TODO - we don't support vector-data here yet. This would only apply in the case where
530  // min or max are vector-valued, and all the generated points need to stay within those ranges.
531  // But typically we expect that if we're calling this function, we only have 1 min and 1 max,
532  // so the generated values are single-valued as well. The .get_value() calls will throw an error
533  // if this is not the case.
534 
535  // initialize training_parameters_in
536  const auto & [n_local_training_samples, first_local_index] =
537  calculate_n_local_samples_and_index(communicator, n_global_training_samples_in,
539  for (const auto & pr : min_parameters)
540  local_training_parameters_in[pr.first] = std::vector<RBParameter>(n_local_training_samples);
541 
542  // finally, set the values
543  for (auto & [param_name, sample_vector] : local_training_parameters_in)
544  {
545  for (auto i : make_range(n_local_training_samples))
546  {
547  Real random_number = static_cast<Real>(std::rand()) / RAND_MAX; // in range [0,1]
548 
549  // Generate log10 scaled training parameters
550  if (libmesh_map_find(log_param_scale, param_name))
551  {
552  Real log_min = std::log10(min_parameters.get_value(param_name));
553  Real log_range = std::log10(max_parameters.get_value(param_name) / min_parameters.get_value(param_name));
554 
555  sample_vector[i] = {std::pow(Real(10.), log_min + random_number*log_range )};
556  }
557  // Generate linearly scaled training parameters
558  else
559  {
560  sample_vector[i] = {
561  random_number * (max_parameters.get_value(param_name) -
562  min_parameters.get_value(param_name)) +
563  min_parameters.get_value(param_name)};
564  }
565  }
566  }
567  return {first_local_index, first_local_index+n_local_training_samples};
568 }
T pow(const T &x)
Definition: utility.h:328
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
DIE A HORRIBLE DEATH HERE typedef MPI_Comm communicator
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...
Definition: int_range.h:140
bool serial_training_set
This boolean flag indicates whether or not the training set should be the same on all processors...

◆ get_abs_training_tolerance()

Real libMesh::RBConstruction::get_abs_training_tolerance ( ) const
inlineinherited

◆ get_adjoint_rhs() [1/2]

NumericVector< Number > & libMesh::System::get_adjoint_rhs ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's adjoint rhs vectors, by default the one corresponding to the first qoi. This what the user's QoI derivative code should assemble when setting up an adjoint problem

Definition at line 1307 of file system.C.

References libMesh::System::get_vector().

Referenced by libMesh::ImplicitSystem::adjoint_solve(), libMesh::FEMSystem::assemble_qoi_derivative(), libMesh::ImplicitSystem::forward_qoi_parameter_sensitivity(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), and libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().

1308 {
1309  std::ostringstream adjoint_rhs_name;
1310  adjoint_rhs_name << "adjoint_rhs" << i;
1311 
1312  return this->get_vector(adjoint_rhs_name.str());
1313 }
const NumericVector< Number > & get_vector(std::string_view vec_name) const
Definition: system.C:943

◆ get_adjoint_rhs() [2/2]

const NumericVector< Number > & libMesh::System::get_adjoint_rhs ( unsigned int  i = 0) const
inherited
Returns
A reference to one of the system's adjoint rhs vectors, by default the one corresponding to the first qoi.

Definition at line 1317 of file system.C.

References libMesh::System::get_vector().

1318 {
1319  std::ostringstream adjoint_rhs_name;
1320  adjoint_rhs_name << "adjoint_rhs" << i;
1321 
1322  return this->get_vector(adjoint_rhs_name.str());
1323 }
const NumericVector< Number > & get_vector(std::string_view vec_name) const
Definition: system.C:943

◆ get_adjoint_solution() [1/2]

NumericVector< Number > & libMesh::System::get_adjoint_solution ( unsigned int  i = 0)
inherited

◆ get_adjoint_solution() [2/2]

const NumericVector< Number > & libMesh::System::get_adjoint_solution ( unsigned int  i = 0) const
inherited
Returns
A reference to one of the system's adjoint solution vectors, by default the one corresponding to the first qoi.

Definition at line 1255 of file system.C.

References libMesh::System::get_vector().

1256 {
1257  std::ostringstream adjoint_name;
1258  adjoint_name << "adjoint_solution" << i;
1259 
1260  return this->get_vector(adjoint_name.str());
1261 }
const NumericVector< Number > & get_vector(std::string_view vec_name) const
Definition: system.C:943

◆ get_all_matrices()

void TransientRBConstruction::get_all_matrices ( std::map< std::string, SparseMatrix< Number > *> &  all_matrices)
overridevirtual

Get a map that stores pointers to all of the matrices.

Reimplemented from libMesh::RBConstruction.

Definition at line 318 of file transient_rb_construction.C.

References libMesh::RBConstruction::get_all_matrices(), get_M_q(), libMesh::TransientRBThetaExpansion::get_n_M_terms(), get_non_dirichlet_M_q(), libMesh::RBConstruction::get_rb_theta_expansion(), L2_matrix, non_dirichlet_L2_matrix, and libMesh::RBConstruction::store_non_dirichlet_operators.

319 {
320  Parent::get_all_matrices(all_matrices);
321 
322  all_matrices["L2_matrix"] = L2_matrix.get();
323 
325  all_matrices["L2_matrix_non_dirichlet"] = non_dirichlet_L2_matrix.get();
326 
327  TransientRBThetaExpansion & trans_theta_expansion =
328  cast_ref<TransientRBThetaExpansion &>(get_rb_theta_expansion());
329  const unsigned int Q_m = trans_theta_expansion.get_n_M_terms();
330 
331  for (unsigned int q_m=0; q_m<Q_m; q_m++)
332  {
333  std::stringstream matrix_name;
334  matrix_name << "M" << q_m;
335  all_matrices[matrix_name.str()] = get_M_q(q_m);
336 
338  {
339  matrix_name << "_non_dirichlet";
340  all_matrices[matrix_name.str()] = get_non_dirichlet_M_q(q_m);
341  }
342  }
343 }
std::unique_ptr< SparseMatrix< Number > > L2_matrix
The L2 matrix.
virtual void get_all_matrices(std::map< std::string, SparseMatrix< Number > *> &all_matrices)
Get a map that stores pointers to all of the matrices.
SparseMatrix< Number > * get_M_q(unsigned int q)
Get a pointer to M_q.
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
std::unique_ptr< SparseMatrix< Number > > non_dirichlet_L2_matrix
The L2 matrix without Dirichlet conditions enforced.
bool store_non_dirichlet_operators
Boolean flag to indicate whether we store a second copy of each affine operator and vector which does...
SparseMatrix< Number > * get_non_dirichlet_M_q(unsigned int q)
Get a pointer to non_dirichlet_M_q.

◆ get_all_variable_numbers()

void libMesh::System::get_all_variable_numbers ( std::vector< unsigned int > &  all_variable_numbers) const
inherited

Fills all_variable_numbers with all the variable numbers for the variables that have been added to this system.

Definition at line 1617 of file system.C.

References libMesh::System::_variable_numbers, and libMesh::System::n_vars().

Referenced by MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), and SystemsTest::testProjectCubeWithMeshFunction().

1618 {
1619  all_variable_numbers.resize(n_vars());
1620 
1621  unsigned int count = 0;
1622  for (auto vn : _variable_numbers)
1623  all_variable_numbers[count++] = vn.second;
1624 }
std::map< std::string, unsigned int, std::less<> > _variable_numbers
The variable numbers corresponding to user-specified names, useful for name-based lookups...
Definition: system.h:2217
unsigned int n_vars() const
Definition: system.h:2430

◆ get_all_vectors()

void libMesh::RBConstruction::get_all_vectors ( std::map< std::string, NumericVector< Number > *> &  all_vectors)
virtualinherited

Get a map that stores pointers to all of the vectors.

Definition at line 2454 of file rb_construction.C.

References libMesh::RBConstruction::get_Fq(), libMesh::RBThetaExpansion::get_n_F_terms(), libMesh::RBConstruction::get_non_dirichlet_Fq(), libMesh::RBConstruction::get_output_vectors(), libMesh::RBConstruction::get_rb_theta_expansion(), and libMesh::RBConstruction::store_non_dirichlet_operators.

2455 {
2456  all_vectors.clear();
2457 
2458  get_output_vectors(all_vectors);
2459 
2460  for (unsigned int q_f=0; q_f<get_rb_theta_expansion().get_n_F_terms(); q_f++)
2461  {
2462  std::stringstream F_vector_name;
2463  F_vector_name << "F" << q_f;
2464  all_vectors[F_vector_name.str()] = get_Fq(q_f);
2465 
2467  {
2468  F_vector_name << "_non_dirichlet";
2469  all_vectors[F_vector_name.str()] = get_non_dirichlet_Fq(q_f);
2470  }
2471  }
2472 }
unsigned int get_n_F_terms() const
Get Q_f, the number of terms in the affine expansion for the right-hand side.
NumericVector< Number > * get_Fq(unsigned int q)
Get a pointer to Fq.
virtual void get_output_vectors(std::map< std::string, NumericVector< Number > *> &all_vectors)
Get a map that stores pointers to all of the vectors.
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
NumericVector< Number > * get_non_dirichlet_Fq(unsigned int q)
Get a pointer to non-Dirichlet Fq.
bool store_non_dirichlet_operators
Boolean flag to indicate whether we store a second copy of each affine operator and vector which does...

◆ get_Aq()

SparseMatrix< Number > * libMesh::RBConstruction::get_Aq ( unsigned int  q)
inherited

Get a pointer to Aq.

Definition at line 2351 of file rb_construction.C.

References libMesh::RBConstruction::Aq_vector, and libMesh::RBConstruction::get_rb_theta_expansion().

Referenced by libMesh::RBConstruction::add_scaled_Aq(), libMesh::RBConstruction::assemble_all_affine_operators(), libMesh::RBConstruction::get_all_matrices(), libMesh::RBConstruction::get_non_dirichlet_Aq_if_avail(), truth_assembly(), libMesh::RBConstruction::truth_assembly(), and libMesh::RBConstruction::update_residual_terms().

2352 {
2353  libmesh_error_msg_if(q >= get_rb_theta_expansion().get_n_A_terms(),
2354  "Error: We must have q < Q_a in get_Aq.");
2355 
2356  return Aq_vector[q].get();
2357 }
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
std::vector< std::unique_ptr< SparseMatrix< Number > > > Aq_vector
Vector storing the Q_a matrices from the affine expansion.

◆ get_closest_value()

Real libMesh::RBParametrized::get_closest_value ( Real  value,
const std::vector< Real > &  list_of_values 
)
staticinherited
Returns
The closest entry to value from list_of_values.

Definition at line 446 of file rb_parametrized.C.

References distance(), libMesh::Real, and value.

Referenced by libMesh::RBParametrized::is_value_in_list().

447 {
448  libmesh_error_msg_if(list_of_values.empty(), "Error: list_of_values is empty.");
449 
450  Real min_distance = std::numeric_limits<Real>::max();
451  Real closest_val = 0.;
452  for (const auto & current_value : list_of_values)
453  {
454  Real distance = std::abs(value - current_value);
455  if (distance < min_distance)
456  {
457  min_distance = distance;
458  closest_val = current_value;
459  }
460  }
461 
462  return closest_val;
463 }
Real distance(const Point &p)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const bool value
Definition: xdr_io.C:54

◆ get_constraint_object()

System::Constraint & libMesh::System::get_constraint_object ( )
inherited

Return the user object for imposing constraints.

Definition at line 2226 of file system.C.

References libMesh::System::_constrain_system_object.

2227 {
2228  libmesh_assert_msg(_constrain_system_object,"No constraint object available.");
2229  return *_constrain_system_object;
2230 }
Constraint * _constrain_system_object
Object that constrains the system.
Definition: system.h:2147

◆ get_control()

Real libMesh::RBTemporalDiscretization::get_control ( const unsigned int  k) const
inherited

Get/set the RHS control.

Definition at line 79 of file rb_temporal_discretization.C.

References libMesh::RBTemporalDiscretization::_control, and libMesh::RBTemporalDiscretization::get_n_time_steps().

Referenced by libMesh::TransientRBEvaluation::compute_residual_dual_norm(), libMesh::TransientRBEvaluation::rb_solve(), libMesh::TransientRBEvaluation::rb_solve_again(), and truth_assembly().

80 {
81  libmesh_assert_less_equal (k, get_n_time_steps());
82  return _control[k];
83 }
std::vector< Real > _control
The RHS control (scalar function of time).
unsigned int get_n_time_steps() const
Get/set the total number of time-steps.

◆ get_convergence_assertion_flag()

bool libMesh::RBConstruction::get_convergence_assertion_flag ( ) const
protectedinherited

Getter for the flag determining if convergence should be checked after each solve.

Definition at line 2713 of file rb_construction.C.

References libMesh::RBConstruction::assert_convergence.

2714 {
2715  return assert_convergence;
2716 }
bool assert_convergence
A boolean flag to indicate whether to check for proper convergence after each solve.

◆ get_current_training_parameter_index()

unsigned int libMesh::RBConstruction::get_current_training_parameter_index ( ) const
protectedinherited

Get/set the current training parameter index.

Definition at line 2733 of file rb_construction.C.

References libMesh::RBConstruction::_current_training_parameter_index.

Referenced by libMesh::RBConstruction::get_RB_error_bound().

2734 {
2736 }
unsigned int _current_training_parameter_index
The current training parameter index during reduced basis training.

◆ get_delta_N()

unsigned int libMesh::RBConstruction::get_delta_N ( ) const
inlineinherited

Get delta_N, the number of basis functions we add to the RB space per iteration of the greedy algorithm.

For steady-state systems, this should be 1, but can be more than 1 for time-dependent systems.

Definition at line 469 of file rb_construction.h.

References libMesh::RBConstruction::delta_N.

Referenced by add_IC_to_RB_space(), enrich_RB_space(), print_info(), update_system(), write_riesz_representors_to_files(), and libMesh::RBConstruction::write_riesz_representors_to_files().

469 { return delta_N; }
unsigned int delta_N
The number of basis functions that we add at each greedy step.

◆ get_delta_t()

Real libMesh::RBTemporalDiscretization::get_delta_t ( ) const
inherited

◆ get_deterministic_training_parameter_name()

const std::string& libMesh::RBConstructionBase< LinearImplicitSystem >::get_deterministic_training_parameter_name ( ) const
inherited

Get the name of the parameter that we will generate deterministic training parameters for.

◆ get_discrete_parameter_values()

const std::map< std::string, std::vector< Real > > & libMesh::RBParametrized::get_discrete_parameter_values ( ) const
inherited

Get a const reference to the discrete parameter values.

Definition at line 373 of file rb_parametrized.C.

References libMesh::RBParametrized::_discrete_parameter_values, and libMesh::RBParametrized::parameters_initialized.

Referenced by libMesh::RBDataSerialization::add_parameter_ranges_to_builder(), libMesh::RBParametrized::check_if_valid_params(), libMesh::RBParametrized::get_n_discrete_params(), libMesh::RBParametrized::initialize_parameters(), libMesh::RBParametrized::print_discrete_parameter_values(), and libMesh::RBParametrized::write_discrete_parameter_values_to_file().

374 {
375  libmesh_error_msg_if(!parameters_initialized, "Error: parameters not initialized in RBParametrized::get_discrete_parameter_values");
376 
378 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
std::map< std::string, std::vector< Real > > _discrete_parameter_values
Map that defines the allowable values of any discrete parameters.

◆ get_dof_map() [1/2]

const DofMap & libMesh::System::get_dof_map ( ) const
inlineinherited
Returns
A constant reference to this system's _dof_map.

Definition at line 2374 of file system.h.

References libMesh::System::_dof_map.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::DifferentiableSystem::add_dot_var_dirichlet_bcs(), libMesh::System::add_matrix(), libMesh::HPCoarsenTest::add_projection(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::AdaptiveTimeSolver::adjoint_advance_timestep(), libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::ImplicitSystem::adjoint_solve(), libMesh::NewmarkSolver::advance_timestep(), libMesh::AdaptiveTimeSolver::advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), libMesh::EquationSystems::allgather(), allocate_data_structures(), libMesh::RBConstruction::allocate_data_structures(), alternative_fe_assembly(), assemble(), LinearElasticity::assemble(), assemble_1D(), AssembleOptimization::assemble_A_and_F(), libMesh::ClawSystem::assemble_advection_matrices(), assemble_and_solve(), libMesh::ClawSystem::assemble_avg_coupling_matrices(), assemble_biharmonic(), libMesh::ClawSystem::assemble_boundary_condition_matrices(), assemble_divgrad(), assemble_elasticity(), assemble_ellipticdg(), assemble_func(), assemble_graddiv(), assemble_helmholtz(), libMesh::ClawSystem::assemble_jump_coupling_matrix(), assemble_laplace(), assemble_mass(), libMesh::ClawSystem::assemble_mass_matrix(), assemble_matrices(), assemble_matrix_and_rhs(), assemble_poisson(), assemble_SchroedingerEquation(), assemble_shell(), assemble_stokes(), assemble_wave(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::PetscDMWrapper::build_sf(), libMesh::System::calculate_norm(), compute_jacobian(), compute_residual(), compute_stresses(), LinearElasticityWithContact::compute_stresses(), LinearElasticity::compute_stresses(), LargeDeformationElasticity::compute_stresses(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), MyConstraint::constrain(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::Nemesis_IO::copy_elemental_solution(), libMesh::Nemesis_IO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), libMesh::CondensedEigenSystem::copy_sub_to_super(), libMesh::CondensedEigenSystem::copy_super_to_sub(), libMesh::System::create_static_condensation(), libMesh::ImplicitSystem::create_static_condensation_system_matrix(), create_wrapped_function(), DMCreateDomainDecomposition_libMesh(), DMCreateFieldDecomposition_libMesh(), DMlibMeshFunction(), DMlibMeshJacobian(), DMlibMeshSetSystem_libMesh(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), fe_assembly(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::find_dofs_to_send(), libMesh::VariationalSmootherConstraint::fix_node(), form_functionA(), form_functionB(), form_matrixA(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::System::get_info(), libMesh::System::has_static_condensation(), libMesh::SystemSubsetBySubdomain::init(), libMesh::SecondOrderUnsteadySolver::init_data(), libMesh::UnsteadySolver::init_data(), HeatSystem::init_data(), SimpleRBConstruction::init_data(), libMesh::ClawSystem::init_data(), LaplaceSystem::init_dirichlet_bcs(), NonManifoldCouplingTestBase::init_es(), libMesh::FEMContext::init_internal_data(), libMesh::EigenSystem::init_matrices(), libMesh::System::init_matrices(), libMesh::PetscDMWrapper::init_petscdm(), libMesh::CondensedEigenSystem::initialize_condensed_dofs(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), LaplaceYoung::jacobian(), LargeDeformationElasticity::jacobian(), libMesh::System::late_matrix_init(), libMesh::libmesh_petsc_snes_fd_residual(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_mffd_residual(), libMesh::libmesh_petsc_snes_residual(), libMesh::libmesh_petsc_snes_residual_helper(), libMesh::System::local_dof_indices(), AssembleOptimization::lower_and_upper_bounds(), main(), libMesh::DofMap::max_constraint_error(), LinearElasticityWithContact::move_mesh(), libMesh::DGFEMContext::neighbor_side_fe_reinit(), libMesh::UnsteadySolver::old_nonlinear_solution(), libMesh::SecondOrderUnsteadySolver::old_solution_accel(), libMesh::SecondOrderUnsteadySolver::old_solution_rate(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectSides::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectInteriors::operator()(), libMesh::RBSCMConstruction::perform_SCM_greedy(), periodic_bc_test_poisson(), libMesh::petsc_auto_fieldsplit(), libMesh::ErrorVector::plot_error(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::FEMContext::pre_fe_reinit(), libMesh::InterMeshProjection::project_system_vectors(), libMesh::System::re_update(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::SecondOrderUnsteadySolver::reinit(), libMesh::UnsteadySolver::reinit(), libMesh::System::reinit(), libMesh::System::reinit_constraints(), libMesh::EquationSystems::reinit_solutions(), LaplaceYoung::residual(), LargeDeformationElasticity::residual(), LinearElasticityWithContact::residual_and_jacobian(), libMesh::UnsteadySolver::retrieve_timestep(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), libMesh::HPCoarsenTest::select_refinement(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::RBConstruction::set_context_solution_vec(), libMesh::PetscDMWrapper::set_point_range_in_section(), set_system_parameters(), SlitMeshRefinedSystemTest::setUp(), FETestBase< order, family, elem_type, 1 >::setUp(), SolidSystem::side_time_derivative(), libMesh::NewtonSolver::solve(), libMesh::PetscDiffSolver::solve(), libMesh::EigenSystem::solve(), libMesh::RBConstruction::solve_for_matrix_and_rhs(), SystemsTest::test100KVariables(), ConstraintOperatorTest::test1DCoarseningNewNodes(), ConstraintOperatorTest::test1DCoarseningOperator(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), MeshFunctionTest::test_subdomain_id_sets(), SystemsTest::testBlockRestrictedVarNDofs(), DofMapTest::testConstraintLoopDetection(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), EquationSystemsTest::testDisableDefaultGhosting(), SystemsTest::testDofCouplingWithVarGroups(), DofMapTest::testDofOwner(), MeshInputTest::testDynaReadPatch(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), MeshAssignTest::testMeshMoveAssign(), PeriodicBCTest::testPeriodicBC(), SystemsTest::testPostInitAddVectorTypeChange(), SystemsTest::testProjectCubeWithMeshFunction(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), InfFERadialTest::testRefinement(), EquationSystemsTest::testSelectivePRefine(), BoundaryInfoTest::testShellFaceConstraints(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), libMesh::UnsteadySolver::update(), update_current_local_solution(), NonManifoldGhostingFunctorTest::verify_send_list_entries_helper(), libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve(), libMesh::ImplicitSystem::weighted_sensitivity_solve(), libMesh::Nemesis_IO_Helper::write_nodal_solution(), libMesh::System::write_parallel_data(), libMesh::EnsightIO::write_scalar_ascii(), libMesh::System::write_SCALAR_dofs(), libMesh::EnsightIO::write_vector_ascii(), and libMesh::RBConstruction::zero_constrained_dofs_on_vector().

2375 {
2376  return *_dof_map;
2377 }
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:2179

◆ get_dof_map() [2/2]

DofMap & libMesh::System::get_dof_map ( )
inlineinherited
Returns
A writable reference to this system's _dof_map.

Definition at line 2382 of file system.h.

References libMesh::System::_dof_map.

2383 {
2384  return *_dof_map;
2385 }
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:2179

◆ get_equation_systems() [1/2]

const EquationSystems& libMesh::System::get_equation_systems ( ) const
inlineinherited
Returns
A constant reference to this system's parent EquationSystems object.

Definition at line 721 of file system.h.

References libMesh::System::_equation_systems.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::RBSCMConstruction::add_scaled_symm_Aq(), libMesh::NewmarkSystem::clear(), libMesh::FrequencySystem::clear_all(), compute_jacobian(), compute_residual(), LinearElasticityWithContact::compute_stresses(), SolidSystem::element_time_derivative(), libMesh::RBConstruction::enrich_basis_from_rhs_terms(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::find_squared_element_error(), libMesh::ImplicitSystem::get_linear_solve_parameters(), SolidSystem::init_data(), HeatSystem::init_data(), libMesh::FrequencySystem::init_data(), LaplaceYoung::jacobian(), libMesh::RBSCMConstruction::load_matrix_B(), LinearElasticityWithContact::move_mesh(), libMesh::FrequencySystem::n_frequencies(), libMesh::RBSCMConstruction::perform_SCM_greedy(), libMesh::System::point_gradient(), libMesh::System::point_value(), libMesh::InterMeshProjection::project_system_vectors(), libMesh::StaticCondensationDofMap::reinit(), LaplaceYoung::residual(), LinearElasticityWithContact::residual_and_jacobian(), libMesh::FileHistoryData::retrieve_adjoint_solution(), libMesh::FileHistoryData::retrieve_primal_solution(), libMesh::FileHistoryData::rewrite_stored_solution(), SolidSystem::save_initial_mesh(), libMesh::FrequencySystem::set_current_frequency(), libMesh::FrequencySystem::set_frequencies(), libMesh::FrequencySystem::set_frequencies_by_range(), libMesh::FrequencySystem::set_frequencies_by_steps(), libMesh::NewmarkSystem::set_newmark_parameters(), libMesh::NonlinearImplicitSystem::set_solver_parameters(), SolidSystem::side_time_derivative(), libMesh::EigenSystem::solve(), libMesh::CondensedEigenSystem::solve(), libMesh::FrequencySystem::solve(), libMesh::ClawSystem::solve_conservation_law(), libMesh::RBConstruction::solve_for_matrix_and_rhs(), libMesh::EigenSystem::solve_helper(), libMesh::FileHistoryData::store_adjoint_solution(), libMesh::FileHistoryData::store_initial_solution(), libMesh::FileHistoryData::store_primal_solution(), MeshFunctionTest::test_p_level(), MeshFunctionTest::test_subdomain_id_sets(), MeshAssignTest::testMeshMoveAssign(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::DirectSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::DTKSolutionTransfer::transfer(), truth_solve(), libMesh::RBConstruction::truth_solve(), and libMesh::WrappedFunction< Output >::WrappedFunction().

721 { return _equation_systems; }
EquationSystems & _equation_systems
Constant reference to the EquationSystems object used for the simulation.
Definition: system.h:2185

◆ get_equation_systems() [2/2]

EquationSystems& libMesh::System::get_equation_systems ( )
inlineinherited
Returns
A reference to this system's parent EquationSystems object.

Definition at line 726 of file system.h.

References libMesh::System::_equation_systems.

726 { return _equation_systems; }
EquationSystems & _equation_systems
Constant reference to the EquationSystems object used for the simulation.
Definition: system.h:2185

◆ get_error_temporal_data()

const NumericVector< Number > & TransientRBConstruction::get_error_temporal_data ( )

Get the column of temporal_data corresponding to the current time level.

This gives access to the truth projection error data. If the RB basis is empty, then this corresponds to the truth solution data itself.

Definition at line 698 of file transient_rb_construction.C.

References libMesh::RBTemporalDiscretization::get_time_step(), and temporal_data.

699 {
700  LOG_SCOPE("get_error_temporal_data()", "TransientRBConstruction");
701 
702  const unsigned int time_step = get_time_step();
703 
704  return *temporal_data[time_step];
705 }
unsigned int get_time_step() const
Get/set the current time-step.
std::vector< std::unique_ptr< NumericVector< Number > > > temporal_data
Dense matrix to store the data that we use for the temporal POD.

◆ get_euler_theta()

Real libMesh::RBTemporalDiscretization::get_euler_theta ( ) const
inherited

◆ get_evaluated_thetas()

const std::vector< Number > & libMesh::RBConstruction::get_evaluated_thetas ( unsigned int  training_parameter_index) const
protectedinherited

Return the evaluated theta functions at the given training parameter index.

Definition at line 2744 of file rb_construction.C.

References libMesh::RBConstruction::_evaluated_thetas, libMesh::RBConstructionBase< LinearImplicitSystem >::get_first_local_training_index(), and libMesh::libmesh_assert().

Referenced by libMesh::RBConstruction::get_RB_error_bound().

2745 {
2746  const numeric_index_type first_index = get_first_local_training_index();
2747  libmesh_assert(training_parameter_index >= first_index);
2748 
2749  const numeric_index_type local_index = training_parameter_index - first_index;
2750  libmesh_assert(local_index < _evaluated_thetas.size());
2751 
2752  return _evaluated_thetas[local_index];
2753 }
numeric_index_type get_first_local_training_index() const
Get the first local index of the training parameters.
std::vector< std::vector< Number > > _evaluated_thetas
Storage of evaluated theta functions at a set of parameters.
dof_id_type numeric_index_type
Definition: id_types.h:99
libmesh_assert(ctx)

◆ get_first_local_training_index()

numeric_index_type libMesh::RBConstructionBase< LinearImplicitSystem >::get_first_local_training_index ( ) const
inherited

Get the first local index of the training parameters.

Definition at line 191 of file rb_construction_base.C.

Referenced by libMesh::RBConstruction::compute_max_error_bound(), libMesh::RBConstruction::get_evaluated_thetas(), and libMesh::RBConstruction::preevaluate_thetas().

192 {
193  libmesh_error_msg_if(!_training_parameters_initialized,
194  "Error: training parameters must first be initialized.");
195 
196  // First we check if there are no parameters here, and in that case we
197  // return 0 for a serial training set and comm().rank() for a parallel
198  // training set. This is consistent with get_n_training_samples(), and
199  // avoids accessing training_parameters.begin() when training_parameters
200  // is empty.
201  if (_training_parameters.empty())
202  {
204  return 0;
205  else
206  return this->comm().rank();
207  }
208 
209  return _first_local_index;
210 }
processor_id_type rank() const
const Parallel::Communicator & comm() const
numeric_index_type _first_local_index
The first sample-vector index from the global vector which is stored in the _training_parameters on t...
bool serial_training_set
This boolean flag indicates whether or not the training set should be the same on all processors...
std::map< std::string, std::vector< RBParameter > > _training_parameters
The training samples for each parameter.
bool _training_parameters_initialized
Boolean flag to indicate whether or not the parameter ranges have been initialized.

◆ get_Fq()

NumericVector< Number > * libMesh::RBConstruction::get_Fq ( unsigned int  q)
inherited

Get a pointer to Fq.

Definition at line 2380 of file rb_construction.C.

References libMesh::RBConstruction::Fq_vector, and libMesh::RBConstruction::get_rb_theta_expansion().

Referenced by libMesh::RBConstruction::assemble_all_affine_vectors(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::enrich_basis_from_rhs_terms(), libMesh::RBConstruction::get_all_vectors(), libMesh::RBConstruction::get_non_dirichlet_Fq_if_avail(), truth_assembly(), and libMesh::RBConstruction::truth_assembly().

2381 {
2382  libmesh_error_msg_if(q >= get_rb_theta_expansion().get_n_F_terms(),
2383  "Error: We must have q < Q_f in get_Fq.");
2384 
2385  return Fq_vector[q].get();
2386 }
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
std::vector< std::unique_ptr< NumericVector< Number > > > Fq_vector
Vector storing the Q_f vectors in the affine decomposition of the right-hand side.

◆ get_global_max_error_pair()

void libMesh::RBConstructionBase< LinearImplicitSystem >::get_global_max_error_pair ( const Parallel::Communicator communicator,
std::pair< numeric_index_type, Real > &  error_pair 
)
staticprotectedinherited

Static function to return the error pair (index,error) that is corresponds to the largest error on all processors.

Definition at line 134 of file rb_construction_base.C.

Referenced by libMesh::RBConstruction::compute_max_error_bound().

136 {
137  // Set error_pair.second to the maximum global value and also
138  // find which processor contains the maximum value
139  unsigned int proc_ID_index;
140  communicator.maxloc(error_pair.second, proc_ID_index);
141 
142  // Then broadcast error_pair.first from proc_ID_index
143  communicator.broadcast(error_pair.first, proc_ID_index);
144 }
DIE A HORRIBLE DEATH HERE typedef MPI_Comm communicator

◆ get_greedy_parameter()

const RBParameters & libMesh::RBConstruction::get_greedy_parameter ( unsigned int  i)
inherited

Return the parameters chosen during the i^th step of the Greedy algorithm.

Definition at line 1591 of file rb_construction.C.

References libMesh::RBConstruction::get_rb_evaluation(), and libMesh::RBEvaluation::greedy_param_list.

1592 {
1593  libmesh_error_msg_if(i >= get_rb_evaluation().greedy_param_list.size(),
1594  "Error: Argument in RBConstruction::get_greedy_parameter is too large.");
1595 
1597 }
std::vector< RBParameters > greedy_param_list
The list of parameters selected by the Greedy algorithm in generating the Reduced Basis associated wi...
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.

◆ get_info() [1/3]

std::string libMesh::ReferenceCounter::get_info ( )
staticinherited

Gets a string containing the reference information.

Definition at line 47 of file reference_counter.C.

References libMesh::ReferenceCounter::_counts, and libMesh::Quality::name().

Referenced by libMesh::ReferenceCounter::print_info().

48 {
49 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
50 
51  std::ostringstream oss;
52 
53  oss << '\n'
54  << " ---------------------------------------------------------------------------- \n"
55  << "| Reference count information |\n"
56  << " ---------------------------------------------------------------------------- \n";
57 
58  for (const auto & [name, cd] : _counts)
59  oss << "| " << name << " reference count information:\n"
60  << "| Creations: " << cd.first << '\n'
61  << "| Destructions: " << cd.second << '\n';
62 
63  oss << " ---------------------------------------------------------------------------- \n";
64 
65  return oss.str();
66 
67 #else
68 
69  return "";
70 
71 #endif
72 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
static Counts _counts
Actually holds the data.

◆ get_info() [2/3]

std::string libMesh::ReferenceCounter::get_info ( )
staticinherited

Gets a string containing the reference information.

Definition at line 47 of file reference_counter.C.

References libMesh::ReferenceCounter::_counts, and libMesh::Quality::name().

Referenced by libMesh::ReferenceCounter::print_info().

48 {
49 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
50 
51  std::ostringstream oss;
52 
53  oss << '\n'
54  << " ---------------------------------------------------------------------------- \n"
55  << "| Reference count information |\n"
56  << " ---------------------------------------------------------------------------- \n";
57 
58  for (const auto & [name, cd] : _counts)
59  oss << "| " << name << " reference count information:\n"
60  << "| Creations: " << cd.first << '\n'
61  << "| Destructions: " << cd.second << '\n';
62 
63  oss << " ---------------------------------------------------------------------------- \n";
64 
65  return oss.str();
66 
67 #else
68 
69  return "";
70 
71 #endif
72 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
static Counts _counts
Actually holds the data.

◆ get_info() [3/3]

std::string libMesh::System::get_info ( ) const
inherited
Returns
A string containing information about the system.

Definition at line 2040 of file system.C.

References libMesh::ParallelObject::comm(), libMesh::FEType::family, libMesh::System::get_dof_map(), libMesh::DofMap::get_info(), libMesh::FEType::inf_map, libMesh::make_range(), TIMPI::Communicator::max(), libMesh::System::n_constrained_dofs(), libMesh::System::n_dofs(), libMesh::System::n_local_constrained_dofs(), libMesh::System::n_local_dofs(), libMesh::System::n_matrices(), libMesh::System::n_variable_groups(), libMesh::VariableGroup::n_variables(), libMesh::System::n_vectors(), libMesh::VariableGroup::name(), libMesh::System::name(), libMesh::System::number(), libMesh::FEType::order, libMesh::FEType::radial_family, libMesh::FEType::radial_order, libMesh::System::system_type(), libMesh::Variable::type(), libMesh::DofMap::variable_group(), and libMesh::System::variable_group().

2041 {
2042  std::ostringstream oss;
2043 
2044 
2045  const std::string & sys_name = this->name();
2046 
2047  oss << " System #" << this->number() << ", \"" << sys_name << "\"\n"
2048  << " Type \"" << this->system_type() << "\"\n"
2049  << " Variables=";
2050 
2051  for (auto vg : make_range(this->n_variable_groups()))
2052  {
2053  const VariableGroup & vg_description (this->variable_group(vg));
2054 
2055  if (vg_description.n_variables() > 1) oss << "{ ";
2056  for (auto vn : make_range(vg_description.n_variables()))
2057  oss << "\"" << vg_description.name(vn) << "\" ";
2058  if (vg_description.n_variables() > 1) oss << "} ";
2059  }
2060 
2061  oss << '\n';
2062 
2063  oss << " Finite Element Types=";
2064 #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
2065  for (auto vg : make_range(this->n_variable_groups()))
2066  oss << "\""
2067  << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().family)
2068  << "\" ";
2069 #else
2070  for (auto vg : make_range(this->n_variable_groups()))
2071  {
2072  oss << "\""
2073  << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().family)
2074  << "\", \""
2075  << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().radial_family)
2076  << "\" ";
2077  }
2078 
2079  oss << '\n' << " Infinite Element Mapping=";
2080  for (auto vg : make_range(this->n_variable_groups()))
2081  oss << "\""
2082  << Utility::enum_to_string<InfMapType>(this->get_dof_map().variable_group(vg).type().inf_map)
2083  << "\" ";
2084 #endif
2085 
2086  oss << '\n';
2087 
2088  oss << " Approximation Orders=";
2089  for (auto vg : make_range(this->n_variable_groups()))
2090  {
2091 #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
2092  oss << "\""
2093  << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().order)
2094  << "\" ";
2095 #else
2096  oss << "\""
2097  << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().order)
2098  << "\", \""
2099  << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().radial_order)
2100  << "\" ";
2101 #endif
2102  }
2103 
2104  oss << '\n';
2105 
2106  oss << " n_dofs()=" << this->n_dofs() << '\n';
2107  dof_id_type local_dofs = this->n_local_dofs();
2108  oss << " n_local_dofs()=" << local_dofs << '\n';
2109  this->comm().max(local_dofs);
2110  oss << " max(n_local_dofs())=" << local_dofs << '\n';
2111 #ifdef LIBMESH_ENABLE_CONSTRAINTS
2112  oss << " n_constrained_dofs()=" << this->n_constrained_dofs() << '\n';
2113  oss << " n_local_constrained_dofs()=" << this->n_local_constrained_dofs() << '\n';
2114  dof_id_type local_unconstrained_dofs = this->n_local_dofs() - this->n_local_constrained_dofs();
2115  this->comm().max(local_unconstrained_dofs);
2116  oss << " max(local unconstrained dofs)=" << local_unconstrained_dofs << '\n';
2117 #endif
2118 
2119  oss << " " << "n_vectors()=" << this->n_vectors() << '\n';
2120  oss << " " << "n_matrices()=" << this->n_matrices() << '\n';
2121  // oss << " " << "n_additional_matrices()=" << this->n_additional_matrices() << '\n';
2122 
2123  oss << this->get_dof_map().get_info();
2124 
2125  return oss.str();
2126 }
FEFamily family
The type of finite element.
Definition: fe_type.h:221
OrderWrapper radial_order
The approximation order in radial direction of the infinite element.
Definition: fe_type.h:254
unsigned int n_variable_groups() const
Definition: system.h:2438
const Parallel::Communicator & comm() const
OrderWrapper order
The approximation order of the element.
Definition: fe_type.h:215
dof_id_type n_local_dofs() const
Definition: system.C:158
std::string get_info() const
Gets summary info about the sparsity bandwidth and constraints.
Definition: dof_map.C:2925
dof_id_type n_dofs() const
Definition: system.C:121
unsigned int number() const
Definition: system.h:2350
unsigned int n_vectors() const
Definition: system.h:2558
const VariableGroup & variable_group(const unsigned int c) const
Definition: dof_map.h:2180
InfMapType inf_map
The coordinate mapping type of the infinite element.
Definition: fe_type.h:275
unsigned int n_matrices() const
Definition: system.h:2699
FEFamily radial_family
The type of approximation in radial direction.
Definition: fe_type.h:267
virtual std::string system_type() const
Definition: system.h:508
void max(const T &r, T &o, Request &req) const
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...
Definition: int_range.h:140
dof_id_type n_local_constrained_dofs() const
Definition: system.C:143
const std::string & name() const
Definition: system.h:2342
const DofMap & get_dof_map() const
Definition: system.h:2374
const VariableGroup & variable_group(unsigned int vg) const
Return a constant reference to VariableGroup vg.
Definition: system.h:2468
dof_id_type n_constrained_dofs() const
Definition: system.C:128
uint8_t dof_id_type
Definition: id_types.h:67
const FEType & type() const
Definition: variable.h:144

◆ get_inner_product_assembly()

ElemAssembly & libMesh::RBConstruction::get_inner_product_assembly ( )
inherited
Returns
A reference to the inner product assembly object

Definition at line 423 of file rb_construction.C.

References libMesh::RBConstruction::inner_product_assembly, and libMesh::RBConstruction::use_energy_inner_product.

424 {
425  libmesh_error_msg_if(use_energy_inner_product,
426  "Error: inner_product_assembly not available since we're using energy inner-product");
427 
428  libmesh_error_msg_if(!inner_product_assembly,
429  "Error: inner_product_assembly hasn't been initialized yet");
430 
431  return *inner_product_assembly;
432 }
bool use_energy_inner_product
Boolean to indicate whether we&#39;re using the energy inner-product.
ElemAssembly * inner_product_assembly
Pointer to inner product assembly.

◆ get_inner_product_matrix() [1/2]

SparseMatrix< Number > * libMesh::RBConstruction::get_inner_product_matrix ( )
inherited

Get a pointer to inner_product_matrix.

Accessing via this function, rather than directly through the class member allows us to do error checking (e.g. inner_product_matrix is not defined in low-memory mode).

Definition at line 2305 of file rb_construction.C.

References libMesh::RBConstruction::inner_product_matrix.

Referenced by libMesh::RBConstruction::get_all_matrices(), libMesh::RBConstruction::get_non_dirichlet_inner_product_matrix_if_avail(), and libMesh::RBSCMConstruction::load_matrix_B().

2306 {
2307  return inner_product_matrix.get();
2308 }
std::unique_ptr< SparseMatrix< Number > > inner_product_matrix
The inner product matrix.

◆ get_inner_product_matrix() [2/2]

const SparseMatrix< Number > * libMesh::RBConstruction::get_inner_product_matrix ( ) const
inherited

Definition at line 2310 of file rb_construction.C.

References libMesh::RBConstruction::inner_product_matrix.

2311 {
2312  return inner_product_matrix.get();
2313 }
std::unique_ptr< SparseMatrix< Number > > inner_product_matrix
The inner product matrix.

◆ get_L2_assembly()

ElemAssembly & TransientRBConstruction::get_L2_assembly ( )
Returns
A reference to the L2 assembly object

Definition at line 458 of file transient_rb_construction.C.

References L2_assembly.

459 {
460  libmesh_error_msg_if(!L2_assembly, "Error: L2_assembly hasn't been initialized yet");
461 
462  return *L2_assembly;
463 }
ElemAssembly * L2_assembly
Function pointer for assembling the L2 matrix.

◆ get_last_local_training_index()

numeric_index_type libMesh::RBConstructionBase< LinearImplicitSystem >::get_last_local_training_index ( ) const
inherited

Get the last local index of the training parameters.

Definition at line 213 of file rb_construction_base.C.

Referenced by libMesh::RBConstruction::compute_max_error_bound().

214 {
215  libmesh_error_msg_if(!_training_parameters_initialized,
216  "Error: training parameters must first be initialized.");
217 
218  if (_training_parameters.empty())
219  return 0;
220 
222 }
numeric_index_type _first_local_index
The first sample-vector index from the global vector which is stored in the _training_parameters on t...
std::map< std::string, std::vector< RBParameter > > _training_parameters
The training samples for each parameter.
bool _training_parameters_initialized
Boolean flag to indicate whether or not the parameter ranges have been initialized.

◆ get_linear_solve_parameters()

std::pair< unsigned int, Real > libMesh::ImplicitSystem::get_linear_solve_parameters ( ) const
virtualinherited
Returns
An integer corresponding to the upper iteration count limit and a Real corresponding to the convergence tolerance to be used in linear adjoint and/or sensitivity solves

Reimplemented in libMesh::NonlinearImplicitSystem, and libMesh::DifferentiableSystem.

Definition at line 1233 of file implicit_system.C.

References libMesh::Parameters::get(), libMesh::System::get_equation_systems(), libMesh::Parameters::have_parameter(), libMesh::EquationSystems::parameters, libMesh::System::parameters, and libMesh::Real.

Referenced by libMesh::ImplicitSystem::adjoint_solve(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::NonlinearImplicitSystem::set_solver_parameters(), libMesh::FrequencySystem::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve(), and libMesh::ImplicitSystem::weighted_sensitivity_solve().

1234 {
1235  return std::make_pair(
1236  parameters.have_parameter<unsigned int>("linear solver maximum iterations")
1237  ? parameters.get<unsigned int>("linear solver maximum iterations")
1238  : this->get_equation_systems().parameters.get<unsigned int>(
1239  "linear solver maximum iterations"),
1240  parameters.have_parameter<Real>("linear solver tolerance")
1241  ? parameters.get<Real>("linear solver tolerance")
1242  : this->get_equation_systems().parameters.get<Real>("linear solver tolerance"));
1243 }
bool have_parameter(std::string_view) const
Definition: parameters.h:395
const EquationSystems & get_equation_systems() const
Definition: system.h:721
Parameters parameters
Parameters for the system. If a parameter is not provided, it should be retrieved from the EquationSy...
Definition: system.h:1526
const T & get(std::string_view) const
Definition: parameters.h:426
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Parameters parameters
Data structure holding arbitrary parameters.

◆ get_linear_solver()

LinearSolver< Number > * libMesh::LinearImplicitSystem::get_linear_solver ( ) const
overridevirtualinherited
Returns
A pointer to a linear solver appropriate for use in adjoint and/or sensitivity solves

Reimplemented from libMesh::ImplicitSystem.

Definition at line 356 of file linear_implicit_system.C.

References libMesh::ImplicitSystem::linear_solver.

Referenced by libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::enrich_basis_from_rhs_terms(), libMesh::RBConstruction::initialize_rb_construction(), main(), SystemsTest::testDofCouplingWithVarGroups(), truth_solve(), and libMesh::RBConstruction::truth_solve().

357 {
358  return linear_solver.get();
359 }
std::unique_ptr< LinearSolver< Number > > linear_solver
This class handles all the details of interfacing with various linear algebra packages like PETSc or ...

◆ get_local_n_training_samples()

numeric_index_type libMesh::RBConstructionBase< LinearImplicitSystem >::get_local_n_training_samples ( ) const
inherited

Get the total number of training samples local to this processor.

Definition at line 175 of file rb_construction_base.C.

Referenced by libMesh::RBConstruction::compute_max_error_bound(), and libMesh::RBConstruction::preevaluate_thetas().

176 {
177  libmesh_error_msg_if(!_training_parameters_initialized,
178  "Error: training parameters must first be initialized.");
179 
180  // First we check if there are no parameters here, and in that case we
181  // return 1 for both serial and parallel training sets. This is consistent
182  // with get_n_training_samples(), and avoids accessing
183  // training_parameters.begin() when training_parameters is empty.
184  if (_training_parameters.empty())
185  return 1;
186 
188 }
std::map< std::string, std::vector< RBParameter > > _training_parameters
The training samples for each parameter.
bool _training_parameters_initialized
Boolean flag to indicate whether or not the parameter ranges have been initialized.

◆ get_M_q()

SparseMatrix< Number > * TransientRBConstruction::get_M_q ( unsigned int  q)

Get a pointer to M_q.

Definition at line 293 of file transient_rb_construction.C.

References libMesh::TransientRBThetaExpansion::get_n_M_terms(), libMesh::RBConstruction::get_rb_theta_expansion(), and M_q_vector.

Referenced by add_scaled_mass_matrix(), assemble_all_affine_operators(), get_all_matrices(), mass_matrix_scaled_matvec(), and update_RB_system_matrices().

294 {
295  TransientRBThetaExpansion & trans_theta_expansion =
296  cast_ref<TransientRBThetaExpansion &>(get_rb_theta_expansion());
297 
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.");
300 
301  return M_q_vector[q].get();
302 }
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
std::vector< std::unique_ptr< SparseMatrix< Number > > > M_q_vector
Vector storing the Q_m matrices from the mass operator.

◆ get_matrix() [1/2]

const SparseMatrix< Number > & libMesh::System::get_matrix ( std::string_view  mat_name) const
inherited
Returns
A const reference to this system's matrix named mat_name.

Definition at line 1124 of file system.C.

References libMesh::System::_matrices.

Referenced by add_M_C_K_helmholtz(), assemble(), assemble_helmholtz(), assemble_poisson(), libMesh::NewmarkSystem::compute_matrix(), libMesh::ImplicitSystem::get_system_matrix(), main(), libMesh::EigenTimeSolver::solve(), and libMesh::NewmarkSystem::update_rhs().

1125 {
1126  return *libmesh_map_find(_matrices, mat_name);
1127 }
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
Some systems need an arbitrary number of matrices.
Definition: system.h:2247

◆ get_matrix() [2/2]

SparseMatrix< Number > & libMesh::System::get_matrix ( std::string_view  mat_name)
inherited
Returns
A writable reference to this system's matrix named mat_name.

Definition at line 1131 of file system.C.

References libMesh::System::_matrices.

1132 {
1133  return *libmesh_map_find(_matrices, mat_name);
1134 }
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
Some systems need an arbitrary number of matrices.
Definition: system.h:2247

◆ get_matrix_for_output_dual_solves()

SparseMatrix< Number > & TransientRBConstruction::get_matrix_for_output_dual_solves ( )
overrideprotectedvirtual

Override to return the L2 product matrix for output dual norm solves for transient state problems.

Reimplemented from libMesh::RBConstruction.

Definition at line 879 of file transient_rb_construction.C.

References L2_matrix.

880 {
881  return *L2_matrix;
882 }
std::unique_ptr< SparseMatrix< Number > > L2_matrix
The L2 matrix.

◆ get_max_truth_solves()

int libMesh::TransientRBConstruction::get_max_truth_solves ( ) const
inline

Get/set max_truth_solves, the maximum number of RB truth solves we are willing to compute in the transient case.

Note
In the steady state case, max_truth_solves is not needed since it is equivalent to Nmax.

Definition at line 214 of file transient_rb_construction.h.

References max_truth_solves.

Referenced by greedy_termination_test().

214 { return max_truth_solves; }
int max_truth_solves
Maximum number of truth solves in the POD-Greedy.

◆ get_mesh() [1/2]

const MeshBase & libMesh::System::get_mesh ( ) const
inlineinherited
Returns
A constant reference to this systems's _mesh.

Definition at line 2358 of file system.h.

References libMesh::System::_mesh.

Referenced by libMesh::ExactSolution::_compute_error(), LinearElasticityWithContact::add_contact_edge_elements(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::System::add_matrix(), libMesh::HPCoarsenTest::add_projection(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), AssembleOptimization::assemble_A_and_F(), libMesh::ClawSystem::assemble_advection_matrices(), libMesh::ClawSystem::assemble_avg_coupling_matrices(), libMesh::ClawSystem::assemble_boundary_condition_matrices(), libMesh::ClawSystem::assemble_jump_coupling_matrix(), libMesh::ClawSystem::assemble_mass_matrix(), libMesh::FEMSystem::assemble_qoi(), libMesh::FEMSystem::assemble_qoi_derivative(), libMesh::VariationalSmootherSystem::assembly(), libMesh::FEMSystem::assembly(), AssemblyA0::boundary_assembly(), AssemblyA1::boundary_assembly(), AssemblyF0::boundary_assembly(), AssemblyF1::boundary_assembly(), AssemblyA2::boundary_assembly(), AssemblyF2::boundary_assembly(), libMesh::System::calculate_norm(), libMesh::VariationalSmootherSystem::compute_element_reference_volume(), compute_jacobian(), compute_residual(), LinearElasticityWithContact::compute_stresses(), libMesh::VariationalSmootherConstraint::constrain(), libMesh::System::create_static_condensation(), libMesh::ImplicitSystem::create_static_condensation_system_matrix(), libMesh::RBEIMEvaluation::distribute_bfs(), DMCreateDomainDecomposition_libMesh(), DMCreateFieldDecomposition_libMesh(), DMlibMeshSetSystem_libMesh(), SolidSystem::element_time_derivative(), HeatSystem::element_time_derivative(), libMesh::RBConstruction::enrich_basis_from_rhs_terms(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_interiors(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_sides(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::find_dofs_to_send(), libMesh::VariationalSmootherConstraint::fix_node(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::GenericProjector(), LinearElasticityWithContact::get_least_and_max_gap_function(), libMesh::SystemSubsetBySubdomain::init(), libMesh::RBEIMConstruction::init_context(), SolidSystem::init_data(), libMesh::VariationalSmootherSystem::init_data(), libMesh::System::init_data(), libMesh::System::init_matrices(), libMesh::PetscDMWrapper::init_petscdm(), LinearElasticityWithContact::initialize_contact_load_paths(), libMesh::RBEIMConstruction::initialize_qp_data(), libMesh::System::local_dof_indices(), libMesh::DofMap::max_constraint_error(), libMesh::FEMSystem::mesh_position_get(), libMesh::FEMSystem::mesh_position_set(), LinearElasticityWithContact::move_mesh(), libMesh::System::n_components(), libMesh::RBEIMEvaluation::node_distribute_bfs(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectVertices::operator()(), libMesh::petsc_auto_fieldsplit(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::FEMSystem::postprocess(), libMesh::RBParametrizedFunction::preevaluate_parametrized_function_on_mesh(), libMesh::RBParametrizedFunction::preevaluate_parametrized_function_on_mesh_sides(), libMesh::System::read_header(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::System::read_legacy_data(), libMesh::System::read_parallel_data(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::System::reinit(), LinearElasticityWithContact::residual_and_jacobian(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), SolidSystem::save_initial_mesh(), libMesh::HPSingularity::select_refinement(), libMesh::HPCoarsenTest::select_refinement(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::RBEIMEvaluation::side_distribute_bfs(), SolidSystem::side_time_derivative(), libMesh::PetscDiffSolver::solve(), libMesh::ClawSystem::solve_conservation_law(), MeshAssignTest::testMeshMoveAssign(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::BoundaryVolumeSolutionTransfer::transfer(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), libMesh::BoundaryVolumeSolutionTransfer::transfer_volume_boundary(), truth_solve(), libMesh::RBConstruction::truth_solve(), libMesh::System::write_header(), libMesh::RBEvaluation::write_out_vectors(), libMesh::System::write_parallel_data(), libMesh::System::write_serialized_vector(), libMesh::System::write_serialized_vectors(), and libMesh::System::zero_variable().

2359 {
2360  return _mesh;
2361 }
MeshBase & _mesh
Constant reference to the mesh data structure used for the simulation.
Definition: system.h:2191

◆ get_mesh() [2/2]

MeshBase & libMesh::System::get_mesh ( )
inlineinherited
Returns
A reference to this systems's _mesh.

Definition at line 2366 of file system.h.

References libMesh::System::_mesh.

2367 {
2368  return _mesh;
2369 }
MeshBase & _mesh
Constant reference to the mesh data structure used for the simulation.
Definition: system.h:2191

◆ get_n_continuous_params()

unsigned int libMesh::RBParametrized::get_n_continuous_params ( ) const
inherited

Get the number of continuous parameters.

Definition at line 112 of file rb_parametrized.C.

References libMesh::RBParametrized::get_n_discrete_params(), libMesh::RBParametrized::get_n_params(), libMesh::libmesh_assert(), and libMesh::RBParametrized::parameters_initialized.

Referenced by libMesh::RBDataSerialization::add_parameter_ranges_to_builder(), and libMesh::RBParametrized::write_parameter_ranges_to_file().

113 {
114  libmesh_error_msg_if(!parameters_initialized, "Error: parameters not initialized in RBParametrized::get_n_continuous_params");
115 
117 
118  return static_cast<unsigned int>(get_n_params() - get_n_discrete_params());
119 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
unsigned int get_n_discrete_params() const
Get the number of discrete parameters.
libmesh_assert(ctx)
unsigned int get_n_params() const
Get the number of parameters.

◆ get_n_discrete_params()

unsigned int libMesh::RBParametrized::get_n_discrete_params ( ) const
inherited

Get the number of discrete parameters.

Definition at line 121 of file rb_parametrized.C.

References libMesh::RBParametrized::get_discrete_parameter_values(), and libMesh::RBParametrized::parameters_initialized.

Referenced by libMesh::RBDataSerialization::add_parameter_ranges_to_builder(), libMesh::RBParametrized::get_n_continuous_params(), and libMesh::RBParametrized::write_discrete_parameter_values_to_file().

122 {
123  libmesh_error_msg_if(!parameters_initialized, "Error: parameters not initialized in RBParametrized::get_n_discrete_params");
124 
125  return cast_int<unsigned int>
127 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
const std::map< std::string, std::vector< Real > > & get_discrete_parameter_values() const
Get a const reference to the discrete parameter values.

◆ get_n_params()

unsigned int libMesh::RBParametrized::get_n_params ( ) const
inherited

Get the number of parameters.

Definition at line 103 of file rb_parametrized.C.

References libMesh::RBParameters::n_parameters(), libMesh::RBParametrized::parameters_initialized, libMesh::RBParametrized::parameters_max, and libMesh::RBParametrized::parameters_min.

Referenced by libMesh::RBParametrized::check_if_valid_params(), libMesh::RBEIMConstruction::compute_max_eim_error(), libMesh::RBConstruction::compute_max_error_bound(), libMesh::RBParametrized::get_n_continuous_params(), libMesh::RBSCMConstruction::print_info(), libMesh::RBEIMConstruction::print_info(), libMesh::RBConstruction::print_info(), libMesh::RBEIMEvaluation::set_eim_error_indicator_active(), and libMesh::RBConstruction::train_reduced_basis_with_POD().

104 {
105  libmesh_error_msg_if(!parameters_initialized, "Error: parameters not initialized in RBParametrized::get_n_params");
106 
107  libmesh_assert_equal_to ( parameters_min.n_parameters(), parameters_max.n_parameters() );
108 
109  return parameters_min.n_parameters();
110 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
RBParameters parameters_min
Vectors that define the ranges (min and max) for the parameters.
unsigned int n_parameters() const
Get the number of parameters that have been added.

◆ get_n_time_steps()

unsigned int libMesh::RBTemporalDiscretization::get_n_time_steps ( ) const
inherited

◆ get_n_training_samples()

numeric_index_type libMesh::RBConstructionBase< LinearImplicitSystem >::get_n_training_samples ( ) const
inherited

Get the number of global training samples.

Definition at line 153 of file rb_construction_base.C.

Referenced by libMesh::RBConstruction::print_info(), and libMesh::RBConstruction::train_reduced_basis_with_POD().

154 {
155  libmesh_error_msg_if(!_training_parameters_initialized,
156  "Error: training parameters must first be initialized.");
157 
158  // First we check if there are no parameters here, and in that case we
159  // return 1 since a single training sample is sufficient to generate an
160  // RB approximation if there are no parameters. Note that in parallel,
161  // and when we don't have a serial training set, set return comm().size()
162  // so that each processor is assigned a single (empty) training sample.
163  if (_training_parameters.empty())
164  {
166  return 1;
167  else
168  return this->comm().size();
169  }
170 
172 }
const Parallel::Communicator & comm() const
processor_id_type size() const
bool serial_training_set
This boolean flag indicates whether or not the training set should be the same on all processors...
std::map< std::string, std::vector< RBParameter > > _training_parameters
The training samples for each parameter.
bool _training_parameters_initialized
Boolean flag to indicate whether or not the parameter ranges have been initialized.

◆ get_Nmax()

unsigned int libMesh::RBConstruction::get_Nmax ( ) const
inlineinherited

Get/set Nmax, the maximum number of RB functions we are willing to compute.

Definition at line 253 of file rb_construction.h.

References libMesh::RBConstruction::Nmax.

Referenced by libMesh::RBConstruction::enrich_basis_from_rhs_terms(), enrich_RB_space(), libMesh::RBConstruction::greedy_termination_test(), libMesh::RBConstruction::train_reduced_basis_with_greedy(), and libMesh::RBConstruction::train_reduced_basis_with_POD().

253 { return Nmax; }
unsigned int Nmax
Maximum number of reduced basis functions we are willing to use.

◆ get_non_dirichlet_Aq()

SparseMatrix< Number > * libMesh::RBConstruction::get_non_dirichlet_Aq ( unsigned int  q)
inherited

Get a pointer to non_dirichlet_Aq.

Definition at line 2359 of file rb_construction.C.

References libMesh::RBConstruction::get_rb_theta_expansion(), libMesh::RBConstruction::non_dirichlet_Aq_vector, and libMesh::RBConstruction::store_non_dirichlet_operators.

Referenced by libMesh::RBConstruction::assemble_all_affine_operators(), libMesh::RBConstruction::get_all_matrices(), and libMesh::RBConstruction::get_non_dirichlet_Aq_if_avail().

2360 {
2361  libmesh_error_msg_if(!store_non_dirichlet_operators,
2362  "Error: Must have store_non_dirichlet_operators==true to access non_dirichlet_Aq.");
2363 
2364  libmesh_error_msg_if(q >= get_rb_theta_expansion().get_n_A_terms(),
2365  "Error: We must have q < Q_a in get_Aq.");
2366 
2367  return non_dirichlet_Aq_vector[q].get();
2368 }
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
bool store_non_dirichlet_operators
Boolean flag to indicate whether we store a second copy of each affine operator and vector which does...
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 ...

◆ get_non_dirichlet_Aq_if_avail()

SparseMatrix< Number > * libMesh::RBConstruction::get_non_dirichlet_Aq_if_avail ( unsigned int  q)
inherited

Get a pointer to non_dirichlet_Aq if it's available, otherwise get Aq.

Definition at line 2370 of file rb_construction.C.

References libMesh::RBConstruction::get_Aq(), libMesh::RBConstruction::get_non_dirichlet_Aq(), and libMesh::RBConstruction::store_non_dirichlet_operators.

Referenced by libMesh::RBConstruction::update_RB_system_matrices().

2371 {
2373  {
2374  return get_non_dirichlet_Aq(q);
2375  }
2376 
2377  return get_Aq(q);
2378 }
SparseMatrix< Number > * get_Aq(unsigned int q)
Get a pointer to Aq.
SparseMatrix< Number > * get_non_dirichlet_Aq(unsigned int q)
Get a pointer to non_dirichlet_Aq.
bool store_non_dirichlet_operators
Boolean flag to indicate whether we store a second copy of each affine operator and vector which does...

◆ get_non_dirichlet_Fq()

NumericVector< Number > * libMesh::RBConstruction::get_non_dirichlet_Fq ( unsigned int  q)
inherited

Get a pointer to non-Dirichlet Fq.

Definition at line 2388 of file rb_construction.C.

References libMesh::RBConstruction::get_rb_theta_expansion(), libMesh::RBConstruction::non_dirichlet_Fq_vector, and libMesh::RBConstruction::store_non_dirichlet_operators.

Referenced by libMesh::RBConstruction::assemble_all_affine_vectors(), libMesh::RBConstruction::get_all_vectors(), and libMesh::RBConstruction::get_non_dirichlet_Fq_if_avail().

2389 {
2390  libmesh_error_msg_if(!store_non_dirichlet_operators,
2391  "Error: Must have store_non_dirichlet_operators==true to access non_dirichlet_Fq.");
2392 
2393  libmesh_error_msg_if(q >= get_rb_theta_expansion().get_n_F_terms(),
2394  "Error: We must have q < Q_f in get_Fq.");
2395 
2396  return non_dirichlet_Fq_vector[q].get();
2397 }
std::vector< std::unique_ptr< NumericVector< Number > > > non_dirichlet_Fq_vector
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
bool store_non_dirichlet_operators
Boolean flag to indicate whether we store a second copy of each affine operator and vector which does...

◆ get_non_dirichlet_Fq_if_avail()

NumericVector< Number > * libMesh::RBConstruction::get_non_dirichlet_Fq_if_avail ( unsigned int  q)
inherited

Get a pointer to non_dirichlet_Fq if it's available, otherwise get Fq.

Definition at line 2399 of file rb_construction.C.

References libMesh::RBConstruction::get_Fq(), libMesh::RBConstruction::get_non_dirichlet_Fq(), and libMesh::RBConstruction::store_non_dirichlet_operators.

Referenced by libMesh::RBConstruction::update_RB_system_matrices().

2400 {
2402  {
2403  return get_non_dirichlet_Fq(q);
2404  }
2405 
2406  return get_Fq(q);
2407 }
NumericVector< Number > * get_Fq(unsigned int q)
Get a pointer to Fq.
NumericVector< Number > * get_non_dirichlet_Fq(unsigned int q)
Get a pointer to non-Dirichlet Fq.
bool store_non_dirichlet_operators
Boolean flag to indicate whether we store a second copy of each affine operator and vector which does...

◆ get_non_dirichlet_inner_product_matrix() [1/2]

SparseMatrix< Number > * libMesh::RBConstruction::get_non_dirichlet_inner_product_matrix ( )
inherited

Get the non-Dirichlet (or more generally no-constraints) version of the inner-product matrix.

This is useful for performing multiplications on vectors that already have constraints enforced.

Definition at line 2315 of file rb_construction.C.

References libMesh::RBConstruction::non_dirichlet_inner_product_matrix, and libMesh::RBConstruction::store_non_dirichlet_operators.

Referenced by libMesh::RBConstruction::get_all_matrices(), and libMesh::RBConstruction::get_non_dirichlet_inner_product_matrix_if_avail().

2316 {
2317  libmesh_error_msg_if(!store_non_dirichlet_operators,
2318  "Error: Must have store_non_dirichlet_operators==true to access non_dirichlet_inner_product_matrix.");
2319 
2321 }
std::unique_ptr< SparseMatrix< Number > > non_dirichlet_inner_product_matrix
bool store_non_dirichlet_operators
Boolean flag to indicate whether we store a second copy of each affine operator and vector which does...

◆ get_non_dirichlet_inner_product_matrix() [2/2]

const SparseMatrix< Number > * libMesh::RBConstruction::get_non_dirichlet_inner_product_matrix ( ) const
inherited

Definition at line 2323 of file rb_construction.C.

References libMesh::RBConstruction::non_dirichlet_inner_product_matrix, and libMesh::RBConstruction::store_non_dirichlet_operators.

2324 {
2325  libmesh_error_msg_if(!store_non_dirichlet_operators,
2326  "Error: Must have store_non_dirichlet_operators==true to access non_dirichlet_inner_product_matrix.");
2327 
2329 }
std::unique_ptr< SparseMatrix< Number > > non_dirichlet_inner_product_matrix
bool store_non_dirichlet_operators
Boolean flag to indicate whether we store a second copy of each affine operator and vector which does...

◆ get_non_dirichlet_inner_product_matrix_if_avail() [1/2]

SparseMatrix< Number > * libMesh::RBConstruction::get_non_dirichlet_inner_product_matrix_if_avail ( )
inherited

Get the non-Dirichlet inner-product matrix if it's available, otherwise get the inner-product matrix with constraints.

Definition at line 2331 of file rb_construction.C.

References libMesh::RBConstruction::get_inner_product_matrix(), libMesh::RBConstruction::get_non_dirichlet_inner_product_matrix(), and libMesh::RBConstruction::store_non_dirichlet_operators.

Referenced by add_IC_to_RB_space(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), enrich_RB_space(), libMesh::RBConstruction::enrich_RB_space(), libMesh::RBConstruction::print_basis_function_orthogonality(), set_error_temporal_data(), libMesh::RBConstruction::train_reduced_basis_with_POD(), libMesh::RBConstruction::truth_solve(), libMesh::RBConstruction::update_RB_system_matrices(), update_residual_terms(), and libMesh::RBConstruction::update_residual_terms().

2332 {
2334  {
2336  }
2337 
2338  return get_inner_product_matrix();
2339 }
SparseMatrix< Number > * get_non_dirichlet_inner_product_matrix()
Get the non-Dirichlet (or more generally no-constraints) version of the inner-product matrix...
SparseMatrix< Number > * get_inner_product_matrix()
Get a pointer to inner_product_matrix.
bool store_non_dirichlet_operators
Boolean flag to indicate whether we store a second copy of each affine operator and vector which does...

◆ get_non_dirichlet_inner_product_matrix_if_avail() [2/2]

const SparseMatrix< Number > * libMesh::RBConstruction::get_non_dirichlet_inner_product_matrix_if_avail ( ) const
inherited

Definition at line 2341 of file rb_construction.C.

References libMesh::RBConstruction::get_inner_product_matrix(), libMesh::RBConstruction::get_non_dirichlet_inner_product_matrix(), and libMesh::RBConstruction::store_non_dirichlet_operators.

2342 {
2344  {
2346  }
2347 
2348  return get_inner_product_matrix();
2349 }
SparseMatrix< Number > * get_non_dirichlet_inner_product_matrix()
Get the non-Dirichlet (or more generally no-constraints) version of the inner-product matrix...
SparseMatrix< Number > * get_inner_product_matrix()
Get a pointer to inner_product_matrix.
bool store_non_dirichlet_operators
Boolean flag to indicate whether we store a second copy of each affine operator and vector which does...

◆ get_non_dirichlet_M_q()

SparseMatrix< Number > * TransientRBConstruction::get_non_dirichlet_M_q ( unsigned int  q)

Get a pointer to non_dirichlet_M_q.

Definition at line 304 of file transient_rb_construction.C.

References libMesh::TransientRBThetaExpansion::get_n_M_terms(), libMesh::RBConstruction::get_rb_theta_expansion(), non_dirichlet_M_q_vector, and libMesh::RBConstruction::store_non_dirichlet_operators.

Referenced by assemble_all_affine_operators(), and get_all_matrices().

305 {
306  libmesh_error_msg_if(!store_non_dirichlet_operators,
307  "Error: Must have store_non_dirichlet_operators==true to access non_dirichlet_M_q.");
308 
309  TransientRBThetaExpansion & trans_theta_expansion =
310  cast_ref<TransientRBThetaExpansion &>(get_rb_theta_expansion());
311 
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.");
314 
315  return non_dirichlet_M_q_vector[q].get();
316 }
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...
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
bool store_non_dirichlet_operators
Boolean flag to indicate whether we store a second copy of each affine operator and vector which does...

◆ get_non_dirichlet_output_vector()

NumericVector< Number > * libMesh::RBConstruction::get_non_dirichlet_output_vector ( unsigned int  n,
unsigned int  q_l 
)
inherited

Get a pointer to non-Dirichlet output vector.

Definition at line 2419 of file rb_construction.C.

References libMesh::RBConstruction::get_rb_theta_expansion(), and libMesh::RBConstruction::non_dirichlet_outputs_vector.

Referenced by libMesh::RBConstruction::assemble_all_output_vectors(), and libMesh::RBConstruction::get_output_vectors().

2420 {
2421  libmesh_error_msg_if((n >= get_rb_theta_expansion().get_n_outputs()) ||
2422  (q_l >= get_rb_theta_expansion().get_n_output_terms(n)),
2423  "Error: We must have n < n_outputs and "
2424  "q_l < get_rb_theta_expansion().get_n_output_terms(n) in get_non_dirichlet_output_vector.");
2425 
2426  return non_dirichlet_outputs_vector[n][q_l].get();
2427 }
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
std::vector< std::vector< std::unique_ptr< NumericVector< Number > > > > non_dirichlet_outputs_vector

◆ get_normalize_rb_bound_in_greedy()

bool libMesh::RBConstruction::get_normalize_rb_bound_in_greedy ( ) const
inlineinherited

Definition at line 234 of file rb_construction.h.

References libMesh::RBConstruction::normalize_rb_bound_in_greedy.

Referenced by libMesh::RBConstruction::print_info().

bool normalize_rb_bound_in_greedy
This boolean indicates if we normalize the RB error in the greedy using RBEvaluation::get_error_bound...

◆ get_output_vector()

NumericVector< Number > * libMesh::RBConstruction::get_output_vector ( unsigned int  n,
unsigned int  q_l 
)
inherited

Get a pointer to the n^th output.

Definition at line 2409 of file rb_construction.C.

References libMesh::RBConstruction::get_rb_theta_expansion(), and libMesh::RBConstruction::outputs_vector.

Referenced by libMesh::RBConstruction::assemble_all_output_vectors(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::get_output_vectors(), truth_solve(), libMesh::RBConstruction::truth_solve(), and libMesh::RBConstruction::update_RB_system_matrices().

2410 {
2411  libmesh_error_msg_if((n >= get_rb_theta_expansion().get_n_outputs()) ||
2412  (q_l >= get_rb_theta_expansion().get_n_output_terms(n)),
2413  "Error: We must have n < n_outputs and "
2414  "q_l < get_rb_theta_expansion().get_n_output_terms(n) in get_output_vector.");
2415 
2416  return outputs_vector[n][q_l].get();
2417 }
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
std::vector< std::vector< std::unique_ptr< NumericVector< Number > > > > outputs_vector
The libMesh vectors that define the output functionals.

◆ get_output_vectors()

void libMesh::RBConstruction::get_output_vectors ( std::map< std::string, NumericVector< Number > *> &  all_vectors)
virtualinherited

Get a map that stores pointers to all of the vectors.

Definition at line 2474 of file rb_construction.C.

References libMesh::RBThetaExpansion::get_n_output_terms(), libMesh::RBThetaExpansion::get_n_outputs(), libMesh::RBConstruction::get_non_dirichlet_output_vector(), libMesh::RBConstruction::get_output_vector(), libMesh::RBConstruction::get_rb_theta_expansion(), and libMesh::RBConstruction::store_non_dirichlet_operators.

Referenced by libMesh::RBConstruction::get_all_vectors().

2475 {
2476  output_vectors.clear();
2477 
2478  for (unsigned int n=0; n<get_rb_theta_expansion().get_n_outputs(); n++)
2479  for (unsigned int q_l=0; q_l<get_rb_theta_expansion().get_n_output_terms(n); q_l++)
2480  {
2481  std::stringstream output_name;
2482  output_name << "output_" << n << "_"<< q_l;
2483  output_vectors[output_name.str()] = get_output_vector(n,q_l);
2484 
2486  {
2487  output_name << "_non_dirichlet";
2488  output_vectors[output_name.str()] = get_non_dirichlet_output_vector(n,q_l);
2489  }
2490  }
2491 }
unsigned int get_n_outputs() const
Get n_outputs, the number output functionals.
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
bool store_non_dirichlet_operators
Boolean flag to indicate whether we store a second copy of each affine operator and vector which does...
unsigned int get_n_output_terms(unsigned int output_index) const
Get the number of affine terms associated with the specified output.
NumericVector< Number > * get_output_vector(unsigned int n, unsigned int q_l)
Get a pointer to the n^th output.
NumericVector< Number > * get_non_dirichlet_output_vector(unsigned int n, unsigned int q_l)
Get a pointer to non-Dirichlet output vector.

◆ get_parameter_max()

Real libMesh::RBParametrized::get_parameter_max ( const std::string &  param_name) const
inherited

Get maximum allowable value of parameter param_name.

Definition at line 185 of file rb_parametrized.C.

References libMesh::RBParameters::get_value(), libMesh::RBParametrized::parameters_initialized, and libMesh::RBParametrized::parameters_max.

Referenced by libMesh::RBParametrized::check_if_valid_params(), libMesh::RBSCMConstruction::print_info(), libMesh::RBEIMConstruction::print_info(), and libMesh::RBConstruction::print_info().

186 {
187  libmesh_error_msg_if(!parameters_initialized, "Error: parameters not initialized in RBParametrized::get_parameter_max");
188 
189  return parameters_max.get_value(param_name);
190 }
Real get_value(const std::string &param_name) const
Get the value of the specified parameter, throw an error if it does not exist.
Definition: rb_parameters.C:65
bool parameters_initialized
Flag indicating whether the parameters have been initialized.

◆ get_parameter_min()

Real libMesh::RBParametrized::get_parameter_min ( const std::string &  param_name) const
inherited

Get minimum allowable value of parameter param_name.

Definition at line 178 of file rb_parametrized.C.

References libMesh::RBParameters::get_value(), libMesh::RBParametrized::parameters_initialized, and libMesh::RBParametrized::parameters_min.

Referenced by libMesh::RBParametrized::check_if_valid_params(), libMesh::RBSCMConstruction::print_info(), libMesh::RBEIMConstruction::print_info(), and libMesh::RBConstruction::print_info().

179 {
180  libmesh_error_msg_if(!parameters_initialized, "Error: parameters not initialized in RBParametrized::get_parameter_min");
181 
182  return parameters_min.get_value(param_name);
183 }
Real get_value(const std::string &param_name) const
Get the value of the specified parameter, throw an error if it does not exist.
Definition: rb_parameters.C:65
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
RBParameters parameters_min
Vectors that define the ranges (min and max) for the parameters.

◆ get_parameter_names()

std::set< std::string > libMesh::RBParametrized::get_parameter_names ( ) const
inherited

Get a set that stores the parameter names.

Deprecated:
to avoid making it too easy to create copies that in most circumstances aren't needed. If this functionality really is required, call get_parameters_min().get_parameters_map() and loop over the keys directly.

Definition at line 130 of file rb_parametrized.C.

References libMesh::RBParametrized::parameters_initialized, and libMesh::RBParametrized::parameters_min.

131 {
132  libmesh_deprecated();
133  libmesh_error_msg_if(!parameters_initialized, "Error: parameters not initialized in RBParametrized::get_parameter_names");
134 
135  std::set<std::string> parameter_names;
136  for (const auto & pr : parameters_min)
137  parameter_names.insert(pr.first);
138 
139  return parameter_names;
140 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
RBParameters parameters_min
Vectors that define the ranges (min and max) for the parameters.

◆ get_parameters()

const RBParameters & libMesh::RBParametrized::get_parameters ( ) const
inherited

Get the current parameters.

Definition at line 157 of file rb_parametrized.C.

References libMesh::RBParametrized::parameters, and libMesh::RBParametrized::parameters_initialized.

Referenced by add_scaled_mass_matrix(), libMesh::TransientRBEvaluation::cache_online_residual_terms(), libMesh::RBEvaluation::compute_residual_dual_norm(), libMesh::RBSCMConstruction::compute_SCM_bounds_on_training_set(), libMesh::RBSCMConstruction::enrich_C_J(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_interiors(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_nodes(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_sides(), libMesh::RBEvaluation::eval_output_dual_norm(), libMesh::RBSCMConstruction::evaluate_stability_constant(), libMesh::RBConstruction::get_RB_error_bound(), libMesh::RBSCMEvaluation::get_SCM_LB(), libMesh::RBSCMEvaluation::get_SCM_UB(), SimpleRBEvaluation::get_stability_lower_bound(), libMesh::RBConstruction::greedy_termination_test(), libMesh::RBEIMConstruction::initialize_parametrized_functions_in_training_set(), libMesh::RBSCMEvaluation::legacy_read_offline_data_from_files(), mass_matrix_scaled_matvec(), libMesh::RBConstruction::preevaluate_thetas(), libMesh::RBSCMConstruction::print_info(), libMesh::RBEIMConstruction::print_info(), libMesh::RBConstruction::print_info(), libMesh::RBParametrized::print_parameters(), libMesh::RBSCMConstruction::process_parameters_file(), libMesh::TransientRBEvaluation::rb_solve(), libMesh::RBEvaluation::rb_solve(), libMesh::RBSCMEvaluation::save_current_parameters(), libMesh::RBEIMConstruction::train_eim_approximation_with_greedy(), libMesh::RBEIMConstruction::train_eim_approximation_with_POD(), truth_assembly(), libMesh::RBConstruction::truth_assembly(), truth_solve(), libMesh::RBConstruction::truth_solve(), libMesh::TransientRBEvaluation::uncached_compute_residual_dual_norm(), and libMesh::RBConstruction::update_greedy_param_list().

158 {
159  libmesh_error_msg_if(!parameters_initialized, "Error: parameters not initialized in RBParametrized::get_parameters");
160 
161  return parameters;
162 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
RBParameters parameters
Vector storing the current parameters.

◆ get_parameters_max()

const RBParameters & libMesh::RBParametrized::get_parameters_max ( ) const
inherited

Get an RBParameters object that specifies the maximum allowable value for each parameter.

Definition at line 171 of file rb_parametrized.C.

References libMesh::RBParametrized::parameters_initialized, and libMesh::RBParametrized::parameters_max.

Referenced by libMesh::RBDataSerialization::add_parameter_ranges_to_builder(), libMesh::RBParametrized::initialize_parameters(), libMesh::RBSCMConstruction::process_parameters_file(), libMesh::RBEIMConstruction::set_rb_construction_parameters(), libMesh::RBConstruction::set_rb_construction_parameters(), and libMesh::RBParametrized::write_parameter_ranges_to_file().

172 {
173  libmesh_error_msg_if(!parameters_initialized, "Error: parameters not initialized in RBParametrized::get_parameters_max");
174 
175  return parameters_max;
176 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.

◆ get_parameters_min()

const RBParameters & libMesh::RBParametrized::get_parameters_min ( ) const
inherited

Get an RBParameters object that specifies the minimum allowable value for each parameter.

Definition at line 164 of file rb_parametrized.C.

References libMesh::RBParametrized::parameters_initialized, and libMesh::RBParametrized::parameters_min.

Referenced by libMesh::RBDataSerialization::add_parameter_ranges_to_builder(), libMesh::RBParametrized::initialize_parameters(), libMesh::RBSCMConstruction::process_parameters_file(), libMesh::RBEIMConstruction::set_rb_construction_parameters(), libMesh::RBConstruction::set_rb_construction_parameters(), and libMesh::RBParametrized::write_parameter_ranges_to_file().

165 {
166  libmesh_error_msg_if(!parameters_initialized, "Error: parameters not initialized in RBParametrized::get_parameters_min");
167 
168  return parameters_min;
169 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
RBParameters parameters_min
Vectors that define the ranges (min and max) for the parameters.

◆ get_params_from_training_set()

RBParameters libMesh::RBConstructionBase< LinearImplicitSystem >::get_params_from_training_set ( unsigned int  global_index)
protectedinherited

Return the RBParameters in index global_index of the global training set.

Why do we use an index here? RBParameters supports loading the full sample set. This seems probably unnecessary now to load individually. Maybe it's a memory issue?

Definition at line 231 of file rb_construction_base.C.

232 {
233  libmesh_error_msg_if(!_training_parameters_initialized,
234  "Error: training parameters must first be initialized.");
235 
236  // If the _training_parameters are empty, return an empty RBParameters.
237  // Otherwise, create a new RBParameters object from the single sample requested.
238  RBParameters params;
239  if (!_training_parameters.empty())
240  {
241  libmesh_error_msg_if((global_index < this->get_first_local_training_index()) ||
242  (global_index >= this->get_last_local_training_index()),
243  "Error: index "
244  << global_index
245  << " must be within range: "
247  << " - "
248  << this->get_last_local_training_index());
249 
250  const numeric_index_type local_index = global_index - get_first_local_training_index();
251  for (const auto & [param_name, sample_vector] : _training_parameters)
252  params.set_value(param_name, sample_vector[local_index]);
253 
254  // Copy all extra values into the new RBParameters.
255  // We assume that the samples may be indexed differently for extra parameters,
256  // so we don't just copy the local_index value.
257  const auto & mine = get_parameters();
258  for (const auto & [key, extra_sample_vector] :
259  as_range(mine.extra_begin(), mine.extra_end()))
260  {
261  for (const auto idx : index_range(extra_sample_vector))
262  params.set_extra_value(key, idx, extra_sample_vector[idx]);
263  }
264  }
265 
266  return params;
267 }
numeric_index_type get_first_local_training_index() const
Get the first local index of the training parameters.
dof_id_type numeric_index_type
Definition: id_types.h:99
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
Helper function that allows us to treat a homogenous pair as a range.
Definition: simple_range.h:57
numeric_index_type get_last_local_training_index() const
Get the last local index of the training parameters.
const RBParameters & get_parameters() const
Get the current parameters.
std::map< std::string, std::vector< RBParameter > > _training_parameters
The training samples for each parameter.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:117
bool _training_parameters_initialized
Boolean flag to indicate whether or not the parameter ranges have been initialized.
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)
A useful inline function which replaces the macros used previously.

◆ get_POD_tol()

Real libMesh::TransientRBConstruction::get_POD_tol ( ) const
inline

Get/set POD_tol.

Definition at line 220 of file transient_rb_construction.h.

References POD_tol.

Referenced by print_info().

220 { return POD_tol; }
Real POD_tol
If positive, this tolerance determines the number of POD modes we add to the space on a call to enric...

◆ get_preevaluate_thetas_flag()

bool libMesh::RBConstruction::get_preevaluate_thetas_flag ( ) const
inherited

Get/set flag to pre-evaluate the theta functions.

Definition at line 2723 of file rb_construction.C.

References libMesh::RBConstruction::_preevaluate_thetas_flag.

Referenced by libMesh::RBConstruction::compute_max_error_bound(), libMesh::RBConstruction::get_RB_error_bound(), and libMesh::RBConstruction::train_reduced_basis_with_greedy().

2724 {
2725  return _preevaluate_thetas_flag;
2726 }
bool _preevaluate_thetas_flag
Flag to indicate if we preevaluate the theta functions.

◆ get_project_with_constraints()

bool libMesh::System::get_project_with_constraints ( )
inlineinherited

Setter and getter functions for project_with_constraints boolean.

Definition at line 1795 of file system.h.

References libMesh::System::project_with_constraints.

Referenced by libMesh::AdjointRefinementEstimator::estimate_error().

1796  {
1797  return project_with_constraints;
1798  }
bool project_with_constraints
Do we want to apply constraints while projecting vectors ?
Definition: system.h:2319

◆ get_qoi_error_estimate_value()

Number libMesh::System::get_qoi_error_estimate_value ( unsigned int  qoi_index) const
inherited

Definition at line 2413 of file system.C.

References libMesh::libmesh_assert(), and libMesh::System::qoi_error_estimates.

Referenced by libMesh::TwostepTimeSolver::integrate_adjoint_refinement_error_estimate(), and main().

2414 {
2415  libmesh_assert(qoi_index < qoi_error_estimates.size());
2416  return qoi_error_estimates[qoi_index];
2417 }
libmesh_assert(ctx)
std::vector< Number > qoi_error_estimates
Vector to hold error estimates for qois, either from a steady state calculation, or from a single uns...
Definition: system.h:1639

◆ get_qoi_value()

Number libMesh::System::get_qoi_value ( unsigned int  qoi_index) const
inherited

◆ get_qoi_values()

std::vector< Number > libMesh::System::get_qoi_values ( ) const
inherited

Returns a copy of qoi, not a reference.

Definition at line 2393 of file system.C.

References libMesh::System::qoi.

Referenced by libMesh::ImplicitSystem::adjoint_qoi_parameter_sensitivity(), libMesh::FEMSystem::assemble_qoi(), libMesh::ImplicitSystem::forward_qoi_parameter_sensitivity(), libMesh::ImplicitSystem::qoi_parameter_hessian(), and libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product().

2394 {
2395  return this->qoi;
2396 }
std::vector< Number > qoi
Values of the quantities of interest.
Definition: system.h:1631

◆ get_rb_assembly_expansion()

RBAssemblyExpansion & libMesh::RBConstruction::get_rb_assembly_expansion ( )
inherited
Returns
A reference to the rb_assembly_expansion object

Definition at line 410 of file rb_construction.C.

References libMesh::RBConstruction::rb_assembly_expansion.

Referenced by assemble_Mq_matrix(), initialize_rb_construction(), and libMesh::RBConstruction::initialize_rb_construction().

411 {
412  libmesh_error_msg_if(!rb_assembly_expansion, "Error: RBAssemblyExpansion object hasn't been initialized yet");
413 
414  return *rb_assembly_expansion;
415 }
RBAssemblyExpansion * rb_assembly_expansion
This member holds the (parameter independent) assembly functors that define the "affine expansion" of...

◆ get_RB_error_bound()

Real libMesh::RBConstruction::get_RB_error_bound ( )
protectedvirtualinherited
Returns
The RB error bound for the current parameters.

Used in the Greedy algorithm to select the next parameter.

Definition at line 1768 of file rb_construction.C.

References libMesh::RBConstruction::abs_training_tolerance, libMesh::RBConstruction::get_current_training_parameter_index(), libMesh::RBEvaluation::get_error_bound_normalization(), libMesh::RBConstruction::get_evaluated_thetas(), libMesh::RBParametrized::get_parameters(), libMesh::RBConstruction::get_preevaluate_thetas_flag(), libMesh::RBConstruction::get_rb_evaluation(), libMesh::RBConstruction::normalize_rb_bound_in_greedy, libMesh::RBEvaluation::rb_solve(), libMesh::Real, and libMesh::RBParametrized::set_parameters().

Referenced by libMesh::RBConstruction::compute_max_error_bound().

1769 {
1771 
1772  Real error_bound = 0.;
1774  {
1775  // Obtain the pre-evaluated theta functions from the current training parameter index
1776  const auto & evaluated_thetas = get_evaluated_thetas(get_current_training_parameter_index());
1777  error_bound = get_rb_evaluation().rb_solve(get_rb_evaluation().get_n_basis_functions(),
1778  &evaluated_thetas);
1779  }
1780  else
1781  error_bound = get_rb_evaluation().rb_solve(get_rb_evaluation().get_n_basis_functions());
1782 
1783 
1785  {
1786  Real error_bound_normalization = get_rb_evaluation().get_error_bound_normalization();
1787 
1788  if ((error_bound < abs_training_tolerance) ||
1789  (error_bound_normalization < abs_training_tolerance))
1790  {
1791  // We don't want to normalize this error bound if the bound or the
1792  // normalization value are below the absolute tolerance. Hence do nothing
1793  // in this case.
1794  }
1795  else
1796  error_bound /= error_bound_normalization;
1797  }
1798 
1799  return error_bound;
1800 }
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_error_bound_normalization()
unsigned int get_current_training_parameter_index() const
Get/set the current training parameter index.
bool get_preevaluate_thetas_flag() const
Get/set flag to pre-evaluate the theta functions.
const std::vector< Number > & get_evaluated_thetas(unsigned int training_parameter_index) const
Return the evaluated theta functions at the given training parameter index.
const RBParameters & get_parameters() const
Get the current parameters.
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.
bool set_parameters(const RBParameters &params)
Set the current parameters to params The parameters are checked for validity; an error is thrown if t...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.

◆ get_rb_evaluation() [1/2]

RBEvaluation & libMesh::RBConstruction::get_rb_evaluation ( )
inherited

Get a reference to the RBEvaluation object.

Definition at line 175 of file rb_construction.C.

References libMesh::RBConstruction::rb_eval.

Referenced by add_IC_to_RB_space(), assemble_affine_expansion(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_max_error_bound(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), libMesh::RBConstruction::enrich_basis_from_rhs_terms(), enrich_RB_space(), libMesh::RBConstruction::enrich_RB_space(), libMesh::RBConstruction::get_greedy_parameter(), libMesh::RBConstruction::get_RB_error_bound(), libMesh::RBConstruction::get_rb_theta_expansion(), libMesh::RBConstruction::greedy_termination_test(), libMesh::RBConstruction::load_basis_function(), load_rb_solution(), libMesh::RBConstruction::load_rb_solution(), main(), libMesh::RBConstruction::preevaluate_thetas(), libMesh::RBConstruction::print_basis_function_orthogonality(), process_parameters_file(), read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::recompute_all_residual_terms(), set_error_temporal_data(), libMesh::RBConstruction::train_reduced_basis_with_greedy(), libMesh::RBConstruction::train_reduced_basis_with_POD(), libMesh::RBConstruction::update_greedy_param_list(), update_RB_initial_condition_all_N(), update_RB_system_matrices(), libMesh::RBConstruction::update_RB_system_matrices(), update_residual_terms(), libMesh::RBConstruction::update_residual_terms(), write_riesz_representors_to_files(), and libMesh::RBConstruction::write_riesz_representors_to_files().

176 {
177  libmesh_error_msg_if(!rb_eval, "Error: RBEvaluation object hasn't been initialized yet");
178 
179  return *rb_eval;
180 }
RBEvaluation * rb_eval
The current RBEvaluation object we are using to perform the Evaluation stage of the reduced basis met...

◆ get_rb_evaluation() [2/2]

const RBEvaluation & libMesh::RBConstruction::get_rb_evaluation ( ) const
inherited

Definition at line 182 of file rb_construction.C.

References libMesh::RBConstruction::rb_eval.

183 {
184  libmesh_error_msg_if(!rb_eval, "Error: RBEvaluation object hasn't been initialized yet");
185 
186  return *rb_eval;
187 }
RBEvaluation * rb_eval
The current RBEvaluation object we are using to perform the Evaluation stage of the reduced basis met...

◆ get_rb_theta_expansion() [1/2]

RBThetaExpansion & libMesh::RBConstruction::get_rb_theta_expansion ( )
inherited

Get a reference to the RBThetaExpansion object that that belongs to rb_eval.

Definition at line 194 of file rb_construction.C.

References libMesh::RBConstruction::get_rb_evaluation(), and libMesh::RBEvaluation::get_rb_theta_expansion().

Referenced by libMesh::RBConstruction::add_scaled_Aq(), add_scaled_mass_matrix(), allocate_data_structures(), libMesh::RBConstruction::allocate_data_structures(), assemble_all_affine_operators(), libMesh::RBConstruction::assemble_all_affine_operators(), libMesh::RBConstruction::assemble_all_affine_vectors(), libMesh::RBConstruction::assemble_all_output_vectors(), libMesh::RBConstruction::assemble_Aq_matrix(), libMesh::RBConstruction::assemble_Fq_vector(), libMesh::RBConstruction::assemble_inner_product_matrix(), assemble_Mq_matrix(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::enrich_basis_from_rhs_terms(), get_all_matrices(), libMesh::RBConstruction::get_all_matrices(), libMesh::RBConstruction::get_all_vectors(), libMesh::RBConstruction::get_Aq(), libMesh::RBConstruction::get_Fq(), get_M_q(), libMesh::RBConstruction::get_non_dirichlet_Aq(), libMesh::RBConstruction::get_non_dirichlet_Fq(), get_non_dirichlet_M_q(), libMesh::RBConstruction::get_non_dirichlet_output_vector(), libMesh::RBConstruction::get_output_vector(), libMesh::RBConstruction::get_output_vectors(), initialize_rb_construction(), libMesh::RBConstruction::initialize_rb_construction(), mass_matrix_scaled_matvec(), print_info(), libMesh::RBConstruction::print_info(), truth_assembly(), libMesh::RBConstruction::truth_assembly(), truth_solve(), libMesh::RBConstruction::truth_solve(), update_RB_system_matrices(), libMesh::RBConstruction::update_RB_system_matrices(), update_residual_terms(), and libMesh::RBConstruction::update_residual_terms().

195 {
197 }
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the rb_theta_expansion.
Definition: rb_evaluation.C:85

◆ get_rb_theta_expansion() [2/2]

const RBThetaExpansion & libMesh::RBConstruction::get_rb_theta_expansion ( ) const
inherited

Definition at line 199 of file rb_construction.C.

References libMesh::RBConstruction::get_rb_evaluation(), and libMesh::RBEvaluation::get_rb_theta_expansion().

200 {
202 }
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the rb_theta_expansion.
Definition: rb_evaluation.C:85

◆ get_RB_training_type()

const std::string & libMesh::RBConstruction::get_RB_training_type ( ) const
inherited

Definition at line 1682 of file rb_construction.C.

References libMesh::RBConstruction::RB_training_type.

Referenced by libMesh::RBConstruction::print_info(), train_reduced_basis(), and libMesh::RBConstruction::train_reduced_basis().

1683 {
1684  return RB_training_type;
1685 }
std::string RB_training_type
This string indicates the type of training that we will use.

◆ get_rel_training_tolerance()

Real libMesh::RBConstruction::get_rel_training_tolerance ( ) const
inlineinherited

Definition at line 220 of file rb_construction.h.

References libMesh::RBConstruction::rel_training_tolerance.

Referenced by libMesh::RBConstruction::print_info().

220 { return rel_training_tolerance; }
Real rel_training_tolerance
Relative and absolute tolerances for training reduced basis using the Greedy scheme.

◆ get_sensitivity_rhs() [1/2]

NumericVector< Number > & libMesh::System::get_sensitivity_rhs ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's sensitivity rhs vectors, by default the one corresponding to the first parameter. By default these vectors are built by the library, using finite differences, when assemble_residual_derivatives() is called.

When assembled, this vector should hold -(partial R / partial p_i)

Definition at line 1337 of file system.C.

References libMesh::System::get_vector().

Referenced by libMesh::ImplicitSystem::adjoint_qoi_parameter_sensitivity(), and libMesh::ImplicitSystem::sensitivity_solve().

1338 {
1339  std::ostringstream sensitivity_rhs_name;
1340  sensitivity_rhs_name << "sensitivity_rhs" << i;
1341 
1342  return this->get_vector(sensitivity_rhs_name.str());
1343 }
const NumericVector< Number > & get_vector(std::string_view vec_name) const
Definition: system.C:943

◆ get_sensitivity_rhs() [2/2]

const NumericVector< Number > & libMesh::System::get_sensitivity_rhs ( unsigned int  i = 0) const
inherited
Returns
A reference to one of the system's sensitivity rhs vectors, by default the one corresponding to the first parameter.

Definition at line 1347 of file system.C.

References libMesh::System::get_vector().

1348 {
1349  std::ostringstream sensitivity_rhs_name;
1350  sensitivity_rhs_name << "sensitivity_rhs" << i;
1351 
1352  return this->get_vector(sensitivity_rhs_name.str());
1353 }
const NumericVector< Number > & get_vector(std::string_view vec_name) const
Definition: system.C:943

◆ get_sensitivity_solution() [1/2]

NumericVector< Number > & libMesh::System::get_sensitivity_solution ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's solution sensitivity vectors, by default the one corresponding to the first parameter.

Definition at line 1192 of file system.C.

References libMesh::System::get_vector().

Referenced by libMesh::ImplicitSystem::forward_qoi_parameter_sensitivity(), libMesh::ImplicitSystem::qoi_parameter_hessian(), and libMesh::ImplicitSystem::sensitivity_solve().

1193 {
1194  std::ostringstream sensitivity_name;
1195  sensitivity_name << "sensitivity_solution" << i;
1196 
1197  return this->get_vector(sensitivity_name.str());
1198 }
const NumericVector< Number > & get_vector(std::string_view vec_name) const
Definition: system.C:943

◆ get_sensitivity_solution() [2/2]

const NumericVector< Number > & libMesh::System::get_sensitivity_solution ( unsigned int  i = 0) const
inherited
Returns
A reference to one of the system's solution sensitivity vectors, by default the one corresponding to the first parameter.

Definition at line 1202 of file system.C.

References libMesh::System::get_vector().

1203 {
1204  std::ostringstream sensitivity_name;
1205  sensitivity_name << "sensitivity_solution" << i;
1206 
1207  return this->get_vector(sensitivity_name.str());
1208 }
const NumericVector< Number > & get_vector(std::string_view vec_name) const
Definition: system.C:943

◆ get_shell_matrix()

ShellMatrix<Number>* libMesh::LinearImplicitSystem::get_shell_matrix ( )
inlineinherited
Returns
A pointer to the currently attached shell matrix, if any, otherwise nullptr.

Definition at line 182 of file linear_implicit_system.h.

References libMesh::LinearImplicitSystem::_shell_matrix.

182 { return _shell_matrix; }
ShellMatrix< Number > * _shell_matrix
User supplies shell matrix or nullptr if no shell matrix is used.

◆ get_static_condensation()

StaticCondensation & libMesh::ImplicitSystem::get_static_condensation ( )
inlineinherited
Returns
The static condensation system matrix

Definition at line 373 of file implicit_system.h.

References libMesh::ImplicitSystem::_sc_system_matrix, and libMesh::libmesh_assert().

Referenced by assemble_poisson().

374 {
376  return *_sc_system_matrix;
377 }
StaticCondensation * _sc_system_matrix
The system matrix for static condensation problems.
libmesh_assert(ctx)

◆ get_system_matrix() [1/2]

const SparseMatrix< Number > & libMesh::ImplicitSystem::get_system_matrix ( ) const
inherited

◆ get_system_matrix() [2/2]

SparseMatrix< Number > & libMesh::ImplicitSystem::get_system_matrix ( )
inherited
Returns
A reference to the system's primary matrix.

Definition at line 1270 of file implicit_system.C.

References libMesh::System::get_matrix(), libMesh::libmesh_assert(), and libMesh::ImplicitSystem::matrix.

1271 {
1273  libmesh_assert_equal_to(&get_matrix("System Matrix"), matrix);
1274  return *matrix;
1275 }
libmesh_assert(ctx)
SparseMatrix< Number > * matrix
The system matrix.
const SparseMatrix< Number > & get_matrix(std::string_view mat_name) const
Definition: system.C:1124

◆ get_time_step()

unsigned int libMesh::RBTemporalDiscretization::get_time_step ( ) const
inherited

◆ get_vector() [1/4]

const NumericVector< Number > & libMesh::System::get_vector ( std::string_view  vec_name) const
inherited
Returns
A const reference to this system's additional vector named vec_name. Access is only granted when the vector is already properly initialized.

Definition at line 943 of file system.C.

References libMesh::System::_vectors.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), add_M_C_K_helmholtz(), libMesh::AdaptiveTimeSolver::adjoint_advance_timestep(), libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::NewmarkSolver::advance_timestep(), libMesh::AdaptiveTimeSolver::advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), apply_initial(), assemble(), libMesh::System::compare(), libMesh::NewmarkSolver::compute_initial_accel(), libMesh::UnsteadySolver::du(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::System::get_adjoint_rhs(), libMesh::System::get_adjoint_solution(), libMesh::System::get_sensitivity_rhs(), libMesh::System::get_sensitivity_solution(), libMesh::System::get_weighted_sensitivity_adjoint_solution(), libMesh::System::get_weighted_sensitivity_solution(), libMesh::NewmarkSystem::initial_conditions(), AssembleOptimization::lower_and_upper_bounds(), main(), libMesh::NewmarkSolver::project_initial_accel(), libMesh::SecondOrderUnsteadySolver::project_initial_rate(), libMesh::InterMeshProjection::project_system_vectors(), libMesh::SecondOrderUnsteadySolver::reinit(), libMesh::UnsteadySolver::reinit(), libMesh::FileSolutionHistory::retrieve(), libMesh::UnsteadySolver::retrieve_timestep(), libMesh::MemoryHistoryData::retrieve_vectors(), libMesh::TwostepTimeSolver::solve(), libMesh::FrequencySystem::solve(), libMesh::UnsteadySolver::update(), libMesh::NewmarkSystem::update_rhs(), and libMesh::NewmarkSystem::update_u_v_a().

944 {
945  return *(libmesh_map_find(_vectors, vec_name));
946 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2230

◆ get_vector() [2/4]

NumericVector< Number > & libMesh::System::get_vector ( std::string_view  vec_name)
inherited
Returns
A writable reference to this system's additional vector named vec_name. Access is only granted when the vector is already properly initialized.

Definition at line 950 of file system.C.

References libMesh::System::_vectors.

951 {
952  return *(libmesh_map_find(_vectors, vec_name));
953 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2230

◆ get_vector() [3/4]

const NumericVector< Number > & libMesh::System::get_vector ( const unsigned int  vec_num) const
inherited
Returns
A const reference to this system's additional vector number vec_num (where the vectors are counted starting with 0).

Definition at line 957 of file system.C.

References libMesh::System::_vectors, and libMesh::System::vectors_begin().

958 {
959  // If we don't have that many vectors, throw an error
960  libmesh_assert_less(vec_num, _vectors.size());
961 
962  // Otherwise return a reference to the vec_num'th vector
963  auto it = vectors_begin();
964  std::advance(it, vec_num);
965  return *(it->second);
966 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2230
vectors_iterator vectors_begin()
Beginning of vectors container.
Definition: system.h:2564

◆ get_vector() [4/4]

NumericVector< Number > & libMesh::System::get_vector ( const unsigned int  vec_num)
inherited
Returns
A writable reference to this system's additional vector number vec_num (where the vectors are counted starting with 0).

Definition at line 970 of file system.C.

References libMesh::System::_vectors, and libMesh::System::vectors_begin().

971 {
972  // If we don't have that many vectors, throw an error
973  libmesh_assert_less(vec_num, _vectors.size());
974 
975  // Otherwise return a reference to the vec_num'th vector
976  auto it = vectors_begin();
977  std::advance(it, vec_num);
978  return *(it->second);
979 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2230
vectors_iterator vectors_begin()
Beginning of vectors container.
Definition: system.h:2564

◆ get_weighted_sensitivity_adjoint_solution() [1/2]

NumericVector< Number > & libMesh::System::get_weighted_sensitivity_adjoint_solution ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's weighted sensitivity adjoint solution vectors, by default the one corresponding to the first qoi.

Definition at line 1277 of file system.C.

References libMesh::System::get_vector().

Referenced by libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), and libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().

1278 {
1279  std::ostringstream adjoint_name;
1280  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
1281 
1282  return this->get_vector(adjoint_name.str());
1283 }
const NumericVector< Number > & get_vector(std::string_view vec_name) const
Definition: system.C:943

◆ get_weighted_sensitivity_adjoint_solution() [2/2]

const NumericVector< Number > & libMesh::System::get_weighted_sensitivity_adjoint_solution ( unsigned int  i = 0) const
inherited
Returns
A reference to one of the system's weighted sensitivity adjoint solution vectors, by default the one corresponding to the first qoi.

Definition at line 1287 of file system.C.

References libMesh::System::get_vector().

1288 {
1289  std::ostringstream adjoint_name;
1290  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
1291 
1292  return this->get_vector(adjoint_name.str());
1293 }
const NumericVector< Number > & get_vector(std::string_view vec_name) const
Definition: system.C:943

◆ get_weighted_sensitivity_solution() [1/2]

NumericVector< Number > & libMesh::System::get_weighted_sensitivity_solution ( )
inherited
Returns
A reference to the solution of the last weighted sensitivity solve

Definition at line 1219 of file system.C.

References libMesh::System::get_vector().

Referenced by libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), and libMesh::ImplicitSystem::weighted_sensitivity_solve().

1220 {
1221  return this->get_vector("weighted_sensitivity_solution");
1222 }
const NumericVector< Number > & get_vector(std::string_view vec_name) const
Definition: system.C:943

◆ get_weighted_sensitivity_solution() [2/2]

const NumericVector< Number > & libMesh::System::get_weighted_sensitivity_solution ( ) const
inherited
Returns
A reference to the solution of the last weighted sensitivity solve

Definition at line 1226 of file system.C.

References libMesh::System::get_vector().

1227 {
1228  return this->get_vector("weighted_sensitivity_solution");
1229 }
const NumericVector< Number > & get_vector(std::string_view vec_name) const
Definition: system.C:943

◆ greedy_termination_test()

bool TransientRBConstruction::greedy_termination_test ( Real  abs_greedy_error,
Real  initial_greedy_error,
int  count 
)
overridevirtual

Function that indicates when to terminate the Greedy basis training.

Reimplemented from libMesh::RBConstruction.

Definition at line 615 of file transient_rb_construction.C.

References get_max_truth_solves(), libMesh::RBConstruction::greedy_termination_test(), and libMesh::out.

618 {
619  if ((get_max_truth_solves()>0) && (count >= get_max_truth_solves()))
620  {
621  libMesh::out << "Maximum number of truth solves reached: max = "
622  << count << std::endl;
623  return true;
624  }
625 
626  return Parent::greedy_termination_test(abs_greedy_error, initial_greedy_error, count);
627 }
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.
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...
OStreamProxy out

◆ has_constraint_object()

bool libMesh::System::has_constraint_object ( ) const
inherited
Returns
true if there is a user-defined constraint object attached to this object, false otherwise. Calling System:: get_constraint_object() when there is no user-defined constraint object attached leads to either undefined behavior (dereferencing a nullptr) or an assert (in dbg mode) so you should call this function first unless you are sure there is a user-defined constraint object attached.

Definition at line 2221 of file system.C.

References libMesh::System::_constrain_system_object.

2222 {
2223  return _constrain_system_object != nullptr;
2224 }
Constraint * _constrain_system_object
Object that constrains the system.
Definition: system.h:2147

◆ has_static_condensation()

bool libMesh::System::has_static_condensation ( ) const
inherited
Returns
Whether this system will be statically condensed

Definition at line 2871 of file system.C.

References libMesh::System::get_dof_map(), and libMesh::DofMap::has_static_condensation().

Referenced by libMesh::System::add_matrix(), assemble_poisson(), libMesh::ImplicitSystem::ImplicitSystem(), libMesh::LinearImplicitSystem::LinearImplicitSystem(), and libMesh::NonlinearImplicitSystem::NonlinearImplicitSystem().

2872 {
2873  return this->get_dof_map().has_static_condensation();
2874 }
bool has_static_condensation() const
Checks whether we have static condensation.
Definition: dof_map.h:1668
const DofMap & get_dof_map() const
Definition: system.h:2374

◆ has_variable()

bool libMesh::System::has_variable ( std::string_view  var) const
inherited
Returns
true if a variable named var exists in this System

Definition at line 1602 of file system.C.

References libMesh::System::_variable_numbers.

Referenced by libMesh::GMVIO::copy_nodal_solution(), and main().

1603 {
1604  return _variable_numbers.count(var);
1605 }
std::map< std::string, unsigned int, std::less<> > _variable_numbers
The variable numbers corresponding to user-specified names, useful for name-based lookups...
Definition: system.h:2217

◆ have_matrix()

bool libMesh::System::have_matrix ( std::string_view  mat_name) const
inlineinherited
Returns
true if this System has a matrix associated with the given name, false otherwise.

Definition at line 1891 of file system.h.

References libMesh::System::_matrices.

Referenced by libMesh::EigenTimeSolver::init().

1891 { return _matrices.count(mat_name); }
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
Some systems need an arbitrary number of matrices.
Definition: system.h:2247

◆ have_vector()

bool libMesh::System::have_vector ( std::string_view  vec_name) const
inlineinherited
Returns
true if this System has a vector associated with the given name, false otherwise.

Definition at line 2550 of file system.h.

References libMesh::System::_vectors.

2551 {
2552  return (_vectors.count(vec_name));
2553 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2230

◆ hide_output()

bool& libMesh::System::hide_output ( )
inlineinherited
Returns
A writable reference to a boolean that determines if this system can be written to file or not. If set to true, then EquationSystems::write will ignore this system.

Definition at line 1810 of file system.h.

References libMesh::System::_hide_output.

1810 { return _hide_output; }
bool _hide_output
Are we allowed to write this system to file? If _hide_output is true, then EquationSystems::write wil...
Definition: system.h:2314

◆ identify_variable_groups() [1/2]

bool libMesh::System::identify_variable_groups ( ) const
inlineinherited
Returns
true when VariableGroup structures should be automatically identified, false otherwise.

Definition at line 2526 of file system.h.

References libMesh::System::_identify_variable_groups.

Referenced by libMesh::System::add_variable(), and libMesh::System::add_variables().

2527 {
2529 }
bool _identify_variable_groups
true when VariableGroup structures should be automatically identified, false otherwise.
Definition: system.h:2282

◆ identify_variable_groups() [2/2]

void libMesh::System::identify_variable_groups ( const bool  ivg)
inlineinherited

Toggle automatic VariableGroup identification.

Definition at line 2534 of file system.h.

References libMesh::System::_identify_variable_groups.

2535 {
2537 }
bool _identify_variable_groups
true when VariableGroup structures should be automatically identified, false otherwise.
Definition: system.h:2282

◆ increment_constructor_count() [1/2]

void libMesh::ReferenceCounter::increment_constructor_count ( const std::string &  name)
inlineprotectednoexceptinherited

Increments the construction counter.

Should be called in the constructor of any derived class that will be reference counted.

Definition at line 183 of file reference_counter.h.

References libMesh::err, libMesh::BasicOStreamProxy< charT, traits >::get(), libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::ReferenceCountedObject().

184 {
185  libmesh_try
186  {
187  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
188  std::pair<unsigned int, unsigned int> & p = _counts[name];
189  p.first++;
190  }
191  libmesh_catch (...)
192  {
193  auto stream = libMesh::err.get();
194  stream->exceptions(stream->goodbit); // stream must not throw
195  libMesh::err << "Encountered unrecoverable error while calling "
196  << "ReferenceCounter::increment_constructor_count() "
197  << "for a(n) " << name << " object." << std::endl;
198  std::terminate();
199  }
200 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
OStreamProxy err
static Counts _counts
Actually holds the data.
streamT * get()
Rather than implement every ostream/ios/ios_base function, we&#39;ll be lazy and make esoteric uses go th...
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.
Definition: threads.C:30

◆ increment_constructor_count() [2/2]

void libMesh::ReferenceCounter::increment_constructor_count ( const std::string &  name)
inlineprotectednoexceptinherited

Increments the construction counter.

Should be called in the constructor of any derived class that will be reference counted.

Definition at line 183 of file reference_counter.h.

References libMesh::err, libMesh::BasicOStreamProxy< charT, traits >::get(), libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::ReferenceCountedObject().

184 {
185  libmesh_try
186  {
187  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
188  std::pair<unsigned int, unsigned int> & p = _counts[name];
189  p.first++;
190  }
191  libmesh_catch (...)
192  {
193  auto stream = libMesh::err.get();
194  stream->exceptions(stream->goodbit); // stream must not throw
195  libMesh::err << "Encountered unrecoverable error while calling "
196  << "ReferenceCounter::increment_constructor_count() "
197  << "for a(n) " << name << " object." << std::endl;
198  std::terminate();
199  }
200 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
OStreamProxy err
static Counts _counts
Actually holds the data.
streamT * get()
Rather than implement every ostream/ios/ios_base function, we&#39;ll be lazy and make esoteric uses go th...
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.
Definition: threads.C:30

◆ increment_destructor_count() [1/2]

void libMesh::ReferenceCounter::increment_destructor_count ( const std::string &  name)
inlineprotectednoexceptinherited

Increments the destruction counter.

Should be called in the destructor of any derived class that will be reference counted.

Definition at line 207 of file reference_counter.h.

References libMesh::err, libMesh::BasicOStreamProxy< charT, traits >::get(), libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::~ReferenceCountedObject().

208 {
209  libmesh_try
210  {
211  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
212  std::pair<unsigned int, unsigned int> & p = _counts[name];
213  p.second++;
214  }
215  libmesh_catch (...)
216  {
217  auto stream = libMesh::err.get();
218  stream->exceptions(stream->goodbit); // stream must not throw
219  libMesh::err << "Encountered unrecoverable error while calling "
220  << "ReferenceCounter::increment_destructor_count() "
221  << "for a(n) " << name << " object." << std::endl;
222  std::terminate();
223  }
224 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
OStreamProxy err
static Counts _counts
Actually holds the data.
streamT * get()
Rather than implement every ostream/ios/ios_base function, we&#39;ll be lazy and make esoteric uses go th...
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.
Definition: threads.C:30

◆ increment_destructor_count() [2/2]

void libMesh::ReferenceCounter::increment_destructor_count ( const std::string &  name)
inlineprotectednoexceptinherited

Increments the destruction counter.

Should be called in the destructor of any derived class that will be reference counted.

Definition at line 207 of file reference_counter.h.

References libMesh::err, libMesh::BasicOStreamProxy< charT, traits >::get(), libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCountedObject< RBParametrized >::~ReferenceCountedObject().

208 {
209  libmesh_try
210  {
211  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
212  std::pair<unsigned int, unsigned int> & p = _counts[name];
213  p.second++;
214  }
215  libmesh_catch (...)
216  {
217  auto stream = libMesh::err.get();
218  stream->exceptions(stream->goodbit); // stream must not throw
219  libMesh::err << "Encountered unrecoverable error while calling "
220  << "ReferenceCounter::increment_destructor_count() "
221  << "for a(n) " << name << " object." << std::endl;
222  std::terminate();
223  }
224 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
OStreamProxy err
static Counts _counts
Actually holds the data.
streamT * get()
Rather than implement every ostream/ios/ios_base function, we&#39;ll be lazy and make esoteric uses go th...
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.
Definition: threads.C:30

◆ init()

void libMesh::System::init ( )
inherited

Initializes degrees of freedom on the current mesh.

Sets the

Definition at line 197 of file system.C.

References libMesh::System::is_initialized(), libMesh::libmesh_assert(), and libMesh::System::reinit_mesh().

Referenced by libMesh::StaticCondensationDofMap::reinit().

198 {
199  // Calling init() twice on the same system currently works evil
200  // magic, whether done directly or via EquationSystems::read()
201  libmesh_assert(!this->is_initialized());
202 
203  this->reinit_mesh();
204 }
bool is_initialized() const
Definition: system.h:2414
libmesh_assert(ctx)
virtual void reinit_mesh()
Reinitializes the system with a new mesh.
Definition: system.C:301

◆ init_context()

virtual void libMesh::RBConstruction::init_context ( FEMContext )
inlineprotectedvirtualinherited

Initialize the FEMContext prior to performing an element loop.

Reimplement this in derived classes in order to call FE::get_*() as the particular physics requires.

Reimplemented in SimpleRBConstruction, SimpleRBConstruction, SimpleRBConstruction, SimpleRBConstruction, SimpleRBConstruction, and ElasticityRBConstruction.

Definition at line 816 of file rb_construction.h.

Referenced by libMesh::RBConstruction::add_scaled_matrix_and_vector().

817  {
818  // Failing to rederive init_context() means your FE objects don't
819  // know what to compute.
820  libmesh_deprecated();
821  }

◆ init_data()

void libMesh::RBConstructionBase< LinearImplicitSystem >::init_data ( )
protectedvirtualinherited

Initializes the member data fields associated with the system, so that, e.g., assemble() may be used.

Reimplemented from libMesh::LinearImplicitSystem.

Reimplemented in SimpleRBConstruction, SimpleRBConstruction, SimpleRBConstruction, SimpleRBConstruction, SimpleRBConstruction, SimpleRBConstruction, and ElasticityRBConstruction.

Definition at line 123 of file rb_construction_base.C.

Referenced by SimpleRBConstruction::init_data().

124 {
125  Base::init_data();
126 
127  // Initialize the inner product storage vector, which is useful for
128  // storing intermediate results when evaluating inner products
130  inner_product_storage_vector->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
131 }
const Parallel::Communicator & comm() const
dof_id_type n_local_dofs() const
Definition: system.C:158
dof_id_type n_dofs() const
Definition: system.C:121
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...
static std::unique_ptr< NumericVector< Number > > 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...

◆ init_matrices()

void libMesh::System::init_matrices ( )
protectedvirtualinherited

Initializes the matrices associated with this system.

Reimplemented in libMesh::EigenSystem.

Definition at line 323 of file system.C.

References libMesh::System::_matrices, libMesh::System::_matrices_initialized, libMesh::System::_matrix_types, libMesh::System::_prefer_hash_table_matrix_assembly, libMesh::System::_require_sparsity_pattern, libMesh::DofMap::attach_matrix(), libMesh::DofMap::compute_sparsity(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::SparseMatrix< T >::initialized(), libMesh::DofMap::is_attached(), libMesh::libmesh_assert(), and libMesh::System::name().

Referenced by libMesh::System::init_data(), and libMesh::EigenSystem::init_matrices().

324 {
325  parallel_object_only();
326 
327  // No matrices to init
328  if (_matrices.empty())
329  {
330  // any future matrices to be added will need their own
331  // initialization
332  _matrices_initialized = true;
333 
334  return;
335  }
336 
337  // Check for quick return in case the first matrix
338  // (and by extension all the matrices) has already
339  // been initialized
340  if (_matrices.begin()->second->initialized())
341  {
343  return;
344  }
345 
346  _matrices_initialized = true;
347 
348  // Tell the matrices about the dof map, and vice versa
349  for (auto & pr : _matrices)
350  {
351  SparseMatrix<Number> & m = *(pr.second);
352  libmesh_assert (!m.initialized());
353 
354  // We want to allow repeated init() on systems, but we don't
355  // want to attach the same matrix to the DofMap twice
356  if (!this->get_dof_map().is_attached(m))
357  this->get_dof_map().attach_matrix(m);
358 
359  // If the user has already explicitly requested that this matrix use a hash table, then we
360  // always honor that
361  const bool use_hash =
362  pr.second->use_hash_table() ||
363  (this->_prefer_hash_table_matrix_assembly && pr.second->supports_hash_table());
364  pr.second->use_hash_table(use_hash);
365  // Make this call after we've determined whether the matrix is using a hash table
366  if (pr.second->require_sparsity_pattern())
367  this->_require_sparsity_pattern = true;
368  }
369 
370  // Compute the sparsity pattern for the current
371  // mesh and DOF distribution. This also updates
372  // additional matrices, \p DofMap now knows them
373  if (this->_require_sparsity_pattern)
374  this->get_dof_map().compute_sparsity(this->get_mesh());
375 
376  // Initialize matrices and set to zero
377  for (auto & [name, mat] : _matrices)
378  {
379  mat->init(_matrix_types[name]);
380  mat->zero();
381  }
382 }
bool is_attached(SparseMatrix< Number > &matrix)
Matrices should not be attached more than once.
Definition: dof_map.C:329
void attach_matrix(SparseMatrix< Number > &matrix)
Additional matrices may be attached to this DofMap.
Definition: dof_map.C:274
const MeshBase & get_mesh() const
Definition: system.h:2358
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
Some systems need an arbitrary number of matrices.
Definition: system.h:2247
bool _prefer_hash_table_matrix_assembly
Whether to use hash table matrix assembly if the matrix sub-classes support it.
Definition: system.h:2324
libmesh_assert(ctx)
std::map< std::string, ParallelType, std::less<> > _matrix_types
Holds the types of the matrices.
Definition: system.h:2252
template class LIBMESH_EXPORT SparseMatrix< Number >
bool _matrices_initialized
false when additional matrices being added require initialization, true otherwise.
Definition: system.h:2257
bool _require_sparsity_pattern
Whether any of our matrices require an initial sparsity pattern computation in order to determine pre...
Definition: system.h:2329
const std::string & name() const
Definition: system.h:2342
void compute_sparsity(const MeshBase &)
Computes the sparsity pattern for the matrices corresponding to proc_id and sends that data to Linear...
Definition: dof_map.C:1988
const DofMap & get_dof_map() const
Definition: system.h:2374

◆ init_qois()

void libMesh::System::init_qois ( unsigned int  n_qois)
inherited

Accessors for qoi and qoi_error_estimates vectors.

Definition at line 2371 of file system.C.

References libMesh::System::n_qois(), libMesh::System::qoi, and libMesh::System::qoi_error_estimates.

Referenced by CoupledSystemQoI::init_qoi_count(), LaplaceQoI::init_qoi_count(), and main().

2372 {
2373  qoi.resize(n_qois);
2374  qoi_error_estimates.resize(n_qois);
2375 }
unsigned int n_qois() const
Number of currently active quantities of interest.
Definition: system.h:2621
std::vector< Number > qoi
Values of the quantities of interest.
Definition: system.h:1631
std::vector< Number > qoi_error_estimates
Vector to hold error estimates for qois, either from a steady state calculation, or from a single uns...
Definition: system.h:1639

◆ initialize_parameters() [1/2]

void libMesh::RBParametrized::initialize_parameters ( const RBParameters mu_min_in,
const RBParameters mu_max_in,
const std::map< std::string, std::vector< Real >> &  discrete_parameter_values 
)
inherited

Initialize the parameter ranges and set current_parameters.

Parameter ranges are inclusive. The input min/max RBParameters should have exactly 1 sample each. Vector-valued samples are not currently supported for the min/max parameters or for discrete parameters.

Definition at line 53 of file rb_parametrized.C.

References libMesh::RBParametrized::_discrete_parameter_values, libMesh::RBParameters::begin_serialized(), libMesh::RBParameters::end_serialized(), libMesh::RBParameters::n_parameters(), libMesh::RBParameters::n_samples(), libMesh::Quality::name(), libMesh::RBParametrized::parameters_initialized, libMesh::RBParametrized::parameters_max, libMesh::RBParametrized::parameters_min, libMesh::Real, libMesh::RBParametrized::set_parameters(), and libMesh::RBParameters::set_value().

Referenced by libMesh::RBConstruction::enrich_basis_from_rhs_terms(), libMesh::RBParametrized::initialize_parameters(), libMesh::RBDataDeserialization::load_parameter_ranges(), libMesh::RBSCMConstruction::perform_SCM_greedy(), libMesh::RBSCMConstruction::process_parameters_file(), libMesh::RBParametrized::read_parameter_data_from_files(), libMesh::RBEIMConstruction::set_rb_construction_parameters(), libMesh::RBConstruction::set_rb_construction_parameters(), RBParametersTest::testRBParametrized(), libMesh::RBEIMConstruction::train_eim_approximation_with_greedy(), libMesh::RBEIMConstruction::train_eim_approximation_with_POD(), libMesh::RBConstruction::train_reduced_basis_with_greedy(), and libMesh::RBConstruction::train_reduced_basis_with_POD().

56 {
57  // Check that the min/max vectors have the same size.
58  libmesh_error_msg_if(mu_min_in.n_parameters() != mu_max_in.n_parameters(),
59  "Error: Invalid mu_min/mu_max in initialize_parameters(), different number of parameters.");
60  libmesh_error_msg_if(mu_min_in.n_samples() != 1 ||
61  mu_max_in.n_samples() != 1,
62  "Error: Invalid mu_min/mu_max in initialize_parameters(), only 1 sample supported.");
63 
64  // Ensure all the values are valid for min and max.
65  auto pr_min = mu_min_in.begin_serialized();
66  auto pr_max = mu_max_in.begin_serialized();
67  for (; pr_min != mu_min_in.end_serialized(); ++pr_min, ++pr_max)
68  libmesh_error_msg_if((*pr_min).second > (*pr_max).second,
69  "Error: Invalid mu_min/mu_max in RBParameters constructor.");
70 
71  parameters_min = mu_min_in;
72  parameters_max = mu_max_in;
73 
74  // Add in min/max values due to the discrete parameters
75  for (const auto & [name, vals] : discrete_parameter_values)
76  {
77  libmesh_error_msg_if(vals.empty(), "Error: List of discrete parameters for " << name << " is empty.");
78 
79  Real min_val = *std::min_element(vals.begin(), vals.end());
80  Real max_val = *std::max_element(vals.begin(), vals.end());
81 
82  libmesh_assert_less_equal(min_val, max_val);
83 
84  parameters_min.set_value(name, min_val);
85  parameters_max.set_value(name, max_val);
86  }
87 
88  _discrete_parameter_values = discrete_parameter_values;
89 
91 
92  // Initialize the current parameters to parameters_min
94 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
RBParameters parameters_min
Vectors that define the ranges (min and max) for the parameters.
std::map< std::string, std::vector< Real > > _discrete_parameter_values
Map that defines the allowable values of any discrete parameters.
bool set_parameters(const RBParameters &params)
Set the current parameters to params The parameters are checked for validity; an error is thrown if t...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void set_value(const std::string &param_name, Real value)
Set the value of the specified parameter.

◆ initialize_parameters() [2/2]

void libMesh::RBParametrized::initialize_parameters ( const RBParametrized rb_parametrized)
inherited

Initialize the parameter ranges and set current_parameters.

Definition at line 96 of file rb_parametrized.C.

References libMesh::RBParametrized::get_discrete_parameter_values(), libMesh::RBParametrized::get_parameters_max(), libMesh::RBParametrized::get_parameters_min(), and libMesh::RBParametrized::initialize_parameters().

97 {
98  initialize_parameters(rb_parametrized.get_parameters_min(),
99  rb_parametrized.get_parameters_max(),
100  rb_parametrized.get_discrete_parameter_values());
101 }
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.

◆ initialize_rb_construction()

void TransientRBConstruction::initialize_rb_construction ( bool  skip_matrix_assembly = false,
bool  skip_vector_assembly = false 
)
overridevirtual

Allocate all the data structures necessary for the construction stage of the RB method.

This function also performs matrix and vector assembly of the "truth" affine expansion.

Override to check that theta and assembly expansions are consistently sized.

Reimplemented from libMesh::RBConstruction.

Definition at line 99 of file transient_rb_construction.C.

References libMesh::TransientRBThetaExpansion::get_n_M_terms(), libMesh::RBConstruction::get_rb_assembly_expansion(), libMesh::RBConstruction::get_rb_theta_expansion(), and libMesh::RBConstruction::initialize_rb_construction().

101 {
102  // Check that the theta and assembly objects are consistently sized
103 #ifndef NDEBUG
104  TransientRBThetaExpansion & trans_theta_expansion =
105  cast_ref<TransientRBThetaExpansion &>(get_rb_theta_expansion());
106 
107  TransientRBAssemblyExpansion & trans_assembly_expansion =
108  cast_ref<TransientRBAssemblyExpansion &>(get_rb_assembly_expansion());
109 #endif
110  // This assert only gets called if DEBUG is on
111  libmesh_assert_equal_to (trans_theta_expansion.get_n_M_terms(), trans_assembly_expansion.get_n_M_terms());
112 
113  Parent::initialize_rb_construction(skip_matrix_assembly, skip_vector_assembly);
114 }
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.
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
RBAssemblyExpansion & get_rb_assembly_expansion()

◆ initialize_training_parameters()

void libMesh::RBConstructionBase< LinearImplicitSystem >::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 
)
virtualinherited

Initialize the parameter ranges and indicate whether deterministic or random training parameters should be used and whether or not we want the parameters to be scaled logarithmically.

n_global_training_samples is the total number of samples to generate, which will be distributed across all the processors.

Definition at line 292 of file rb_construction_base.C.

Referenced by libMesh::RBConstruction::set_rb_construction_parameters().

297 {
298  if (!is_quiet())
299  {
300  // Print out some info about the training set initialization
301  libMesh::out << "Initializing training parameters with "
302  << (deterministic ? "deterministic " : "random " )
303  << "training set..." << std::endl;
304 
305  for (const auto & pr : log_param_scale)
306  libMesh::out << "Parameter "
307  << pr.first
308  << ": log scaling = "
309  << pr.second
310  << std::endl;
311 
312  libMesh::out << std::endl;
313  }
314 
315  if (deterministic)
316  {
317  const auto [first_local_index, last_local_index] =
319  log_param_scale,
321  n_global_training_samples,
322  mu_min,
323  mu_max,
325  _first_local_index = first_local_index;
326  _n_local_training_samples = last_local_index-first_local_index;
327  }
328  else
329  {
330  // Generate random training samples for all parameters
331  const auto [first_local_index, last_local_index] =
333  log_param_scale,
335  n_global_training_samples,
336  mu_min,
337  mu_max,
340  _first_local_index = first_local_index;
341  _n_local_training_samples = last_local_index-first_local_index;
342  }
344 
345  if (!serial_training_set)
347 
348  // For each parameter that only allows discrete values, we "snap" to the nearest
349  // allowable discrete value
350  if (get_n_discrete_params() > 0)
351  {
352  for (auto & [param_name, sample_vector] : _training_parameters)
353  {
354  if (is_discrete_parameter(param_name))
355  {
356  const std::vector<Real> & discrete_values =
357  libmesh_map_find(get_discrete_parameter_values(), param_name);
358 
359  for (const auto sample_idx : index_range(sample_vector))
360  {
361  // Round all values to the closest discrete value.
362  std::vector<Real> discretized_vector(sample_vector[sample_idx].size());
363  std::transform(sample_vector[sample_idx].cbegin(),
364  sample_vector[sample_idx].cend(),
365  discretized_vector.begin(),
366  [&discrete_values](const Real & val) {
367  return get_closest_value(val, discrete_values);
368  });
369  sample_vector[sample_idx] = discretized_vector;
370  }
371  }
372  }
373  }
374 
376 }
static std::pair< std::size_t, std::size_t > generate_training_parameters_random(const Parallel::Communicator &communicator, const std::map< std::string, bool > &log_param_scale, std::map< std::string, std::vector< RBParameter >> &local_training_parameters_in, const unsigned int n_global_training_samples_in, const RBParameters &min_parameters, const RBParameters &max_parameters, const int training_parameters_random_seed=-1, const bool serial_training_set=false)
Static helper function for generating a randomized set of parameters.
static std::pair< std::size_t, std::size_t > generate_training_parameters_deterministic(const Parallel::Communicator &communicator, const std::map< std::string, bool > &log_param_scale, std::map< std::string, std::vector< RBParameter >> &local_training_parameters_in, const unsigned int n_global_training_samples_in, const RBParameters &min_parameters, const RBParameters &max_parameters, const bool serial_training_set=false)
Static helper function for generating a deterministic set of parameters.
void sum(T &r) const
const Parallel::Communicator & comm() const
bool is_quiet() const
Is the system in quiet mode?
static Real get_closest_value(Real value, const std::vector< Real > &list_of_values)
unsigned int get_n_discrete_params() const
Get the number of discrete parameters.
numeric_index_type _first_local_index
The first sample-vector index from the global vector which is stored in the _training_parameters on t...
const std::map< std::string, std::vector< Real > > & get_discrete_parameter_values() const
Get a const reference to the discrete parameter values.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
OStreamProxy out
bool serial_training_set
This boolean flag indicates whether or not the training set should be the same on all processors...
int _training_parameters_random_seed
If < 0, use std::time() * processor_id() to seed the random number generator for the training paramet...
std::map< std::string, std::vector< RBParameter > > _training_parameters
The training samples for each parameter.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:117
bool _training_parameters_initialized
Boolean flag to indicate whether or not the parameter ranges have been initialized.
bool is_discrete_parameter(const std::string &mu_name) const
Is parameter mu_name discrete?

◆ initialize_truth()

void TransientRBConstruction::initialize_truth ( )
protectedvirtual

This function imposes a truth initial condition, defaults to zero initial condition if the flag nonzero_initialization is true.

Definition at line 707 of file transient_rb_construction.C.

References init_filename, nonzero_initialization, libMesh::READ, libMesh::System::read_serialized_data(), libMesh::System::solution, and libMesh::System::update().

Referenced by add_IC_to_RB_space(), assemble_affine_expansion(), truth_solve(), and update_RB_initial_condition_all_N().

708 {
710  {
711  // Use System::read_serialized_data to read the initial condition
712  // into this->solution
713  Xdr IC_data(init_filename, READ);
714  read_serialized_data(IC_data, false);
715  }
716  else
717  {
718  // Otherwise zero out the solution as a default
719  this->solution->zero();
720  }
721  this->solution->close();
722  this->update();
723 }
std::string init_filename
The filename of the file containing the initial condition projected onto the truth mesh...
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
bool nonzero_initialization
Boolean flag to indicate whether we are using a non-zero initialization.
virtual void update()
Update the local values to reflect the solution on neighboring processors.
Definition: system.C:510
void read_serialized_data(Xdr &io, const bool read_additional_data=true)
Reads additional data, namely vectors, for this System.
Definition: system_io.C:680

◆ is_adjoint_already_solved()

bool libMesh::System::is_adjoint_already_solved ( ) const
inlineinherited

Accessor for the adjoint_already_solved boolean.

Definition at line 409 of file system.h.

References libMesh::System::adjoint_already_solved.

Referenced by libMesh::ImplicitSystem::adjoint_qoi_parameter_sensitivity(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ImplicitSystem::qoi_parameter_hessian(), and libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product().

410  { return adjoint_already_solved;}
bool adjoint_already_solved
Has the adjoint problem already been solved? If the user sets adjoint_already_solved to true...
Definition: system.h:2308

◆ is_discrete_parameter()

bool libMesh::RBParametrized::is_discrete_parameter ( const std::string &  mu_name) const
inherited

Is parameter mu_name discrete?

Definition at line 365 of file rb_parametrized.C.

References libMesh::RBParametrized::_discrete_parameter_values, and libMesh::RBParametrized::parameters_initialized.

Referenced by libMesh::RBDataSerialization::add_parameter_ranges_to_builder(), libMesh::RBEIMConstruction::print_info(), libMesh::RBConstruction::print_info(), and libMesh::RBParametrized::write_parameter_ranges_to_file().

366 {
367  libmesh_error_msg_if(!parameters_initialized,
368  "Error: parameters not initialized in RBParametrized::is_discrete_parameter");
369 
370  return _discrete_parameter_values.count(mu_name);
371 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
std::map< std::string, std::vector< Real > > _discrete_parameter_values
Map that defines the allowable values of any discrete parameters.

◆ is_initialized()

bool libMesh::System::is_initialized ( ) const
inlineinherited
Returns
true iff this system has been initialized.

Definition at line 2414 of file system.h.

References libMesh::System::_is_initialized.

Referenced by libMesh::System::add_variable(), libMesh::System::add_variables(), libMesh::System::init(), and libMesh::StaticCondensationDofMap::reinit().

2415 {
2416  return _is_initialized;
2417 }
bool _is_initialized
true when additional vectors and variables do not require immediate initialization, false otherwise.
Definition: system.h:2276

◆ is_quiet()

bool libMesh::RBConstructionBase< LinearImplicitSystem >::is_quiet ( ) const
inlineinherited

◆ is_rb_eval_initialized()

bool libMesh::RBConstruction::is_rb_eval_initialized ( ) const
inherited
Returns
true if rb_eval is initialized. False, otherwise.

Definition at line 189 of file rb_construction.C.

References libMesh::RBConstruction::rb_eval.

Referenced by print_info(), and libMesh::RBConstruction::print_info().

190 {
191  return (rb_eval != nullptr);
192 }
RBEvaluation * rb_eval
The current RBEvaluation object we are using to perform the Evaluation stage of the reduced basis met...

◆ is_serial_training_type()

bool libMesh::RBConstruction::is_serial_training_type ( const std::string &  RB_training_type_in)
virtualinherited
Returns
true if RB_training_type_in is a type of training that requires a serial training set. For example, POD training generally does require a serial training set.

Definition at line 1665 of file rb_construction.C.

Referenced by libMesh::RBConstruction::set_RB_training_type().

1666 {
1667  return (RB_training_type_in == "POD");
1668 }

◆ load_basis_function()

void libMesh::RBConstruction::load_basis_function ( unsigned int  i)
virtualinherited

Load the i^th RB function into the RBConstruction solution vector.

Definition at line 1692 of file rb_construction.C.

References libMesh::RBEvaluation::get_basis_function(), libMesh::RBConstruction::get_rb_evaluation(), libMesh::System::solution, and libMesh::System::update().

Referenced by main().

1693 {
1694  LOG_SCOPE("load_basis_function()", "RBConstruction");
1695 
1696  libmesh_assert_less (i, get_rb_evaluation().get_n_basis_functions());
1697 
1699 
1700  this->update();
1701 }
NumericVector< Number > & get_basis_function(unsigned int i)
Get a reference to the i^th basis function.
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
virtual void update()
Update the local values to reflect the solution on neighboring processors.
Definition: system.C:510
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.

◆ load_rb_solution()

void TransientRBConstruction::load_rb_solution ( )
overridevirtual

Load the RB solution from the current time-level into the libMesh solution vector.

Reimplemented from libMesh::RBConstruction.

Definition at line 884 of file transient_rb_construction.C.

References libMesh::RBEvaluation::get_n_basis_functions(), libMesh::RBConstruction::get_rb_evaluation(), libMesh::RBTemporalDiscretization::get_time_step(), libMesh::TransientRBEvaluation::RB_temporal_solution_data, libMesh::System::solution, and libMesh::System::update().

885 {
886  LOG_SCOPE("load_rb_solution()", "TransientRBConstruction");
887 
888  solution->zero();
889 
890  const unsigned int time_step = get_time_step();
891 
892  TransientRBEvaluation & trans_rb_eval = cast_ref<TransientRBEvaluation &>(get_rb_evaluation());
893  DenseVector<Number> RB_solution_vector_k = trans_rb_eval.RB_temporal_solution_data[time_step];
894 
895  libmesh_error_msg_if(RB_solution_vector_k.size() > get_rb_evaluation().get_n_basis_functions(),
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!");
901 
902  for (unsigned int i=0; i<RB_solution_vector_k.size(); i++)
903  solution->add(RB_solution_vector_k(i), get_rb_evaluation().get_basis_function(i));
904 
905  update();
906 }
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
unsigned int get_time_step() const
Get/set the current time-step.
virtual void update()
Update the local values to reflect the solution on neighboring processors.
Definition: system.C:510
virtual unsigned int get_n_basis_functions() const
Get the current number of basis functions.
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.

◆ load_training_set()

void libMesh::RBConstructionBase< LinearImplicitSystem >::load_training_set ( const std::map< std::string, std::vector< RBParameter >> &  new_training_set)
virtualinherited

Overwrite the training parameters with new_training_set.

This training set is assumed to contain only the samples local to this processor.

Definition at line 379 of file rb_construction_base.C.

Referenced by libMesh::RBConstruction::set_rb_construction_parameters().

380 {
381  // Make sure we're running this on all processors at the same time
382  libmesh_parallel_only(this->comm());
383 
384  // First, make sure that an initial training set has already been generated
385  libmesh_error_msg_if(!_training_parameters_initialized,
386  "Error: load_training_set cannot be used to initialize parameters");
387 
388  // Make sure that the training set has the correct number of parameters
389  const unsigned int n_params = get_n_params();
390  libmesh_error_msg_if(new_training_set.size() > n_params,
391  "Error: new_training_set should not have more than get_n_params() parameters.");
392 
393  // Check that (new_training_set.size() == get_n_params()) is the same on all processes so that
394  // we go into the same branch of the "if" statement below on all processes.
395  const bool size_matches = (new_training_set.size() == n_params);
396  libmesh_assert(this->comm().verify(size_matches));
397 
398  if (size_matches)
399  {
400  // If new_training_set stores values for all parameters, then we overwrite
401  // _training_parameters with new_training_set.
402 
403  // Get the number of local and global training parameters
404  _first_local_index = 0;
406  cast_int<numeric_index_type>(new_training_set.begin()->second.size());
408 
409  if (!serial_training_set)
410  {
411  this->comm().sum(_n_global_training_samples);
412 
413  // Set the first/last indices.
414  std::vector<numeric_index_type> local_sizes (this->n_processors(), 0);
415  local_sizes[this->processor_id()] = _n_local_training_samples;
416  this->comm().sum(local_sizes);
417 
418  // first_local_index is the sum of local_sizes
419  // for all processor ids less than ours
420  for (auto p : make_range(this->processor_id()))
421  _first_local_index += local_sizes[p];
422  }
423 
424  // Ensure that the parameters are the same.
425  for (const auto & pr : _training_parameters)
426  libmesh_error_msg_if(!new_training_set.count(pr.first),
427  "Parameters must be identical in order to overwrite dataset.");
428 
429  // Copy the values from the new_training_set to the internal training_parameters.
430  _training_parameters = new_training_set;
431  }
432  else
433  {
434  // If new_training_set stores values for a subset of the parameters, then we keep the
435  // length of training_parameters unchanged and overwrite the entries of the specified
436  // parameters from new_training_set. Note that we repeatedly loop over new_training_set
437  // to fill up the entire length of the sample_vector.
438  for (auto & [param_name, sample_vector]: _training_parameters)
439  {
440  if (new_training_set.count(param_name))
441  {
442  for (const auto i : make_range(get_local_n_training_samples()))
443  {
444  const unsigned int num_new_samples = libmesh_map_find(new_training_set,param_name).size();
445  libmesh_error_msg_if (num_new_samples==0, "new_training_set set should not be empty");
446 
447  const unsigned int new_training_set_index = i % num_new_samples;
448  sample_vector[i] = libmesh_map_find(new_training_set,param_name)[new_training_set_index];
449  }
450  }
451  }
452  }
453 }
void sum(T &r) const
const Parallel::Communicator & comm() const
numeric_index_type _first_local_index
The first sample-vector index from the global vector which is stored in the _training_parameters on t...
processor_id_type n_processors() const
numeric_index_type get_local_n_training_samples() const
Get the total number of training samples local to this processor.
libmesh_assert(ctx)
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...
Definition: int_range.h:140
bool serial_training_set
This boolean flag indicates whether or not the training set should be the same on all processors...
std::map< std::string, std::vector< RBParameter > > _training_parameters
The training samples for each parameter.
processor_id_type processor_id() const
unsigned int get_n_params() const
Get the number of parameters.
bool _training_parameters_initialized
Boolean flag to indicate whether or not the parameter ranges have been initialized.

◆ local_dof_indices()

void libMesh::System::local_dof_indices ( const unsigned int  var,
std::set< dof_id_type > &  var_indices 
) const
inherited

Fills the std::set with the degrees of freedom on the local processor corresponding the the variable number passed in.

Definition at line 1627 of file system.C.

References libMesh::DofMap::dof_indices(), libMesh::DofMapBase::end_dof(), libMesh::DofMapBase::first_dof(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), and libMesh::libmesh_assert().

Referenced by libMesh::System::discrete_var_norm(), SystemsTest::testBlockRestrictedVarNDofs(), and libMesh::DirectSolutionTransfer::transfer().

1629 {
1630  // Make sure the set is clear
1631  var_indices.clear();
1632 
1633  std::vector<dof_id_type> dof_indices;
1634 
1635  const dof_id_type
1636  first_local = this->get_dof_map().first_dof(),
1637  end_local = this->get_dof_map().end_dof();
1638 
1639  // Begin the loop over the elements
1640  for (const auto & elem : this->get_mesh().active_local_element_ptr_range())
1641  {
1642  this->get_dof_map().dof_indices (elem, dof_indices, var);
1643 
1644  for (dof_id_type dof : dof_indices)
1645  //If the dof is owned by the local processor
1646  if (first_local <= dof && dof < end_local)
1647  var_indices.insert(dof);
1648  }
1649 
1650  // we may have missed assigning DOFs to nodes that we own
1651  // but to which we have no connected elements matching our
1652  // variable restriction criterion. this will happen, for example,
1653  // if variable V is restricted to subdomain S. We may not own
1654  // any elements which live in S, but we may own nodes which are
1655  // *connected* to elements which do.
1656  for (const auto & node : this->get_mesh().local_node_ptr_range())
1657  {
1658  libmesh_assert(node);
1659  this->get_dof_map().dof_indices (node, dof_indices, var);
1660  for (auto dof : dof_indices)
1661  if (first_local <= dof && dof < end_local)
1662  var_indices.insert(dof);
1663  }
1664 }
dof_id_type end_dof(const processor_id_type proc) const
Definition: dof_map_base.h:191
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Definition: dof_map.C:2164
const MeshBase & get_mesh() const
Definition: system.h:2358
libmesh_assert(ctx)
dof_id_type first_dof(const processor_id_type proc) const
Definition: dof_map_base.h:185
const DofMap & get_dof_map() const
Definition: system.h:2374
uint8_t dof_id_type
Definition: id_types.h:67

◆ mass_matrix_scaled_matvec()

void TransientRBConstruction::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.

Definition at line 375 of file transient_rb_construction.C.

References libMesh::NumericVector< T >::add(), libMesh::NumericVector< T >::build(), libMesh::ParallelObject::comm(), libMesh::TransientRBThetaExpansion::eval_M_theta(), get_M_q(), libMesh::TransientRBThetaExpansion::get_n_M_terms(), libMesh::RBParametrized::get_parameters(), libMesh::RBConstruction::get_rb_theta_expansion(), libMesh::System::n_dofs(), libMesh::System::n_local_dofs(), libMesh::PARALLEL, libMesh::SparseMatrix< T >::vector_mult(), and libMesh::NumericVector< T >::zero().

Referenced by truth_assembly().

378 {
379  LOG_SCOPE("mass_matrix_scaled_matvec()", "TransientRBConstruction");
380 
381  dest.zero();
382 
383  const RBParameters & mu = get_parameters();
384 
385  TransientRBThetaExpansion & trans_theta_expansion =
386  cast_ref<TransientRBThetaExpansion &>(get_rb_theta_expansion());
387 
388  const unsigned int Q_m = trans_theta_expansion.get_n_M_terms();
389 
390  std::unique_ptr<NumericVector<Number>> temp_vec = NumericVector<Number>::build(this->comm());
391  temp_vec->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
392 
393  for (unsigned int q=0; q<Q_m; q++)
394  {
395  get_M_q(q)->vector_mult(*temp_vec, arg);
396  dest.add(scalar * trans_theta_expansion.eval_M_theta(q,mu), *temp_vec);
397  }
398 }
SparseMatrix< Number > * get_M_q(unsigned int q)
Get a pointer to M_q.
void vector_mult(NumericVector< T > &dest, const NumericVector< T > &arg) const
Multiplies the matrix by the NumericVector arg and stores the result in NumericVector dest...
const Parallel::Communicator & comm() const
dof_id_type n_local_dofs() const
Definition: system.C:158
dof_id_type n_dofs() const
Definition: system.C:121
virtual void zero()=0
Set all entries to zero.
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
const RBParameters & get_parameters() const
Get the current parameters.
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 add(const numeric_index_type i, const T value)=0
Adds value to the vector entry specified by i.

◆ matrices_begin() [1/2]

System::matrices_iterator libMesh::System::matrices_begin ( )
inlineinherited

Beginning of matrices container.

Definition at line 2588 of file system.h.

References libMesh::System::_matrices.

2589 {
2590  return _matrices.begin();
2591 }
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
Some systems need an arbitrary number of matrices.
Definition: system.h:2247

◆ matrices_begin() [2/2]

System::const_matrices_iterator libMesh::System::matrices_begin ( ) const
inlineinherited

Beginning of matrices container.

Definition at line 2594 of file system.h.

References libMesh::System::_matrices.

2595 {
2596  return _matrices.begin();
2597 }
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
Some systems need an arbitrary number of matrices.
Definition: system.h:2247

◆ matrices_end() [1/2]

System::matrices_iterator libMesh::System::matrices_end ( )
inlineinherited

End of matrices container.

Definition at line 2600 of file system.h.

References libMesh::System::_matrices.

2601 {
2602  return _matrices.end();
2603 }
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
Some systems need an arbitrary number of matrices.
Definition: system.h:2247

◆ matrices_end() [2/2]

System::const_matrices_iterator libMesh::System::matrices_end ( ) const
inlineinherited

End of matrices container.

Definition at line 2606 of file system.h.

References libMesh::System::_matrices.

2607 {
2608  return _matrices.end();
2609 }
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
Some systems need an arbitrary number of matrices.
Definition: system.h:2247

◆ n_active_dofs()

dof_id_type libMesh::System::n_active_dofs ( ) const
inlineinherited
Returns
The number of active degrees of freedom for this System.

Definition at line 2542 of file system.h.

References libMesh::System::n_constrained_dofs(), and libMesh::System::n_dofs().

2543 {
2544  return this->n_dofs() - this->n_constrained_dofs();
2545 }
dof_id_type n_dofs() const
Definition: system.C:121
dof_id_type n_constrained_dofs() const
Definition: system.C:128

◆ n_components()

unsigned int libMesh::System::n_components ( ) const
inlineinherited
Returns
The total number of scalar components in the system's variables. This will equal n_vars() in the case of all scalar-valued variables.

Definition at line 2446 of file system.h.

References libMesh::System::_variables, libMesh::Variable::first_scalar_number(), libMesh::System::get_mesh(), and libMesh::Variable::n_components().

Referenced by libMesh::System::add_variables().

2447 {
2448  if (_variables.empty())
2449  return 0;
2450 
2451  const Variable & last = _variables.back();
2452  return last.first_scalar_number() + last.n_components(this->get_mesh());
2453 }
std::vector< Variable > _variables
The Variable in this System.
Definition: system.h:2206
const MeshBase & get_mesh() const
Definition: system.h:2358

◆ n_constrained_dofs()

dof_id_type libMesh::System::n_constrained_dofs ( ) const
inherited
Returns
The total number of constrained degrees of freedom in the system.

Definition at line 128 of file system.C.

References libMesh::System::_dof_map.

Referenced by form_functionA(), form_functionB(), form_matrixA(), libMesh::System::get_info(), libMesh::System::n_active_dofs(), libMesh::EigenSystem::solve(), and BoundaryInfoTest::testShellFaceConstraints().

129 {
130 #ifdef LIBMESH_ENABLE_CONSTRAINTS
131 
132  return _dof_map->n_constrained_dofs();
133 
134 #else
135 
136  return 0;
137 
138 #endif
139 }
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:2179

◆ n_dofs()

dof_id_type libMesh::System::n_dofs ( ) const
inherited
Returns
The number of degrees of freedom in the system

Definition at line 121 of file system.C.

References libMesh::System::_dof_map.

Referenced by add_IC_to_RB_space(), libMesh::System::add_vector(), allocate_data_structures(), libMesh::RBConstruction::allocate_data_structures(), assemble_affine_expansion(), libMesh::ClawSystem::assemble_avg_coupling_matrices(), libMesh::ClawSystem::assemble_boundary_condition_matrices(), libMesh::AdvectionSystem::assemble_claw_rhs(), libMesh::ClawSystem::assemble_jump_coupling_matrix(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), enrich_RB_space(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::System::get_info(), libMesh::SecondOrderUnsteadySolver::init_data(), libMesh::AdvectionSystem::init_data(), libMesh::UnsteadySolver::init_data(), libMesh::System::init_data(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), main(), mass_matrix_scaled_matvec(), libMesh::System::n_active_dofs(), libMesh::CondensedEigenSystem::n_global_non_condensed_dofs(), libMesh::FEMSystem::numerical_jacobian(), libMesh::RBSCMConstruction::perform_SCM_greedy(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::System::read_legacy_data(), read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::SecondOrderUnsteadySolver::reinit(), libMesh::UnsteadySolver::reinit(), libMesh::System::restrict_vectors(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), set_error_temporal_data(), libMesh::ClawSystem::solve_conservation_law(), SystemsTest::test100KVariables(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), SystemsTest::testPostInitAddVector(), SystemsTest::testPostInitAddVectorTypeChange(), SystemsTest::testProjectCubeWithMeshFunction(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), libMesh::RBConstruction::train_reduced_basis_with_POD(), libMesh::MeshFunctionSolutionTransfer::transfer(), truth_assembly(), libMesh::RBConstruction::truth_assembly(), update_RB_initial_condition_all_N(), update_RB_system_matrices(), libMesh::RBConstruction::update_RB_system_matrices(), update_residual_terms(), and libMesh::RBConstruction::update_residual_terms().

122 {
123  return _dof_map->n_dofs();
124 }
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:2179

◆ n_linear_iterations()

unsigned int libMesh::LinearImplicitSystem::n_linear_iterations ( ) const
inlineinherited
Returns
The number of iterations taken for the most recent linear solve.

Definition at line 155 of file linear_implicit_system.h.

References libMesh::LinearImplicitSystem::_n_linear_iterations.

Referenced by libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_output_dual_innerprods(), main(), update_residual_terms(), and libMesh::RBConstruction::update_residual_terms().

155 { return _n_linear_iterations; }
unsigned int _n_linear_iterations
The number of linear iterations required to solve the linear system Ax=b.

◆ n_local_constrained_dofs()

dof_id_type libMesh::System::n_local_constrained_dofs ( ) const
inherited
Returns
The number of constrained degrees of freedom on this processor.

Definition at line 143 of file system.C.

References libMesh::System::_dof_map.

Referenced by libMesh::System::get_info().

144 {
145 #ifdef LIBMESH_ENABLE_CONSTRAINTS
146 
147  return _dof_map->n_local_constrained_dofs();
148 
149 #else
150 
151  return 0;
152 
153 #endif
154 }
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:2179

◆ n_local_dofs()

dof_id_type libMesh::System::n_local_dofs ( ) const
inherited
Returns
The number of degrees of freedom local to this processor

Definition at line 158 of file system.C.

References libMesh::System::_dof_map.

Referenced by add_IC_to_RB_space(), libMesh::System::add_vector(), allocate_data_structures(), libMesh::RBConstruction::allocate_data_structures(), assemble_affine_expansion(), libMesh::AdvectionSystem::assemble_claw_rhs(), libMesh::PetscDMWrapper::build_section(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), enrich_RB_space(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::System::get_info(), libMesh::SecondOrderUnsteadySolver::init_data(), libMesh::AdvectionSystem::init_data(), libMesh::UnsteadySolver::init_data(), libMesh::System::init_data(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), main(), mass_matrix_scaled_matvec(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::SecondOrderUnsteadySolver::reinit(), libMesh::UnsteadySolver::reinit(), libMesh::System::restrict_vectors(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), set_error_temporal_data(), libMesh::ClawSystem::solve_conservation_law(), MeshFunctionTest::test_p_level(), libMesh::RBConstruction::train_reduced_basis_with_POD(), truth_assembly(), libMesh::RBConstruction::truth_assembly(), update_RB_initial_condition_all_N(), update_RB_system_matrices(), libMesh::RBConstruction::update_RB_system_matrices(), update_residual_terms(), and libMesh::RBConstruction::update_residual_terms().

159 {
160  return _dof_map->n_local_dofs();
161 }
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:2179

◆ n_matrices()

unsigned int libMesh::System::n_matrices ( ) const
inlineinherited
Returns
The number of matrices handled by this system. This is the size of the _matrices map

Definition at line 2699 of file system.h.

References libMesh::System::_matrices.

Referenced by libMesh::ImplicitSystem::add_matrices(), and libMesh::System::get_info().

2700 {
2701  return cast_int<unsigned int>(_matrices.size());
2702 }
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
Some systems need an arbitrary number of matrices.
Definition: system.h:2247

◆ n_objects() [1/2]

static unsigned int libMesh::ReferenceCounter::n_objects ( )
inlinestaticinherited

Prints the number of outstanding (created, but not yet destroyed) objects.

Definition at line 85 of file reference_counter.h.

References libMesh::ReferenceCounter::_n_objects.

Referenced by libMesh::LibMeshInit::~LibMeshInit().

86  { return _n_objects; }
static Threads::atomic< unsigned int > _n_objects
The number of objects.

◆ n_objects() [2/2]

static unsigned int libMesh::ReferenceCounter::n_objects ( )
inlinestaticinherited

Prints the number of outstanding (created, but not yet destroyed) objects.

Definition at line 85 of file reference_counter.h.

References libMesh::ReferenceCounter::_n_objects.

Referenced by libMesh::LibMeshInit::~LibMeshInit().

86  { return _n_objects; }
static Threads::atomic< unsigned int > _n_objects
The number of objects.

◆ n_processors()

processor_id_type libMesh::ParallelObject::n_processors ( ) const
inlineinherited
Returns
The number of processors in the group.

Definition at line 103 of file parallel_object.h.

References libMesh::ParallelObject::_communicator, libMesh::libmesh_assert(), and TIMPI::Communicator::size().

Referenced by libMesh::Partitioner::_find_global_index_by_pid_map(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::DofMap::add_constraints_to_send_list(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::System::add_vector(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::FEMSystem::assembly(), libMesh::Nemesis_IO::assert_symmetric_cmaps(), libMesh::Partitioner::assign_partitioning(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::Partitioner::build_graph(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::DistributedMesh::clear(), libMesh::DistributedMesh::clear_elems(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::UnstructuredMesh::copy_nodes_and_elements(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_scalar_dofs(), libMesh::DistributedMesh::DistributedMesh(), libMesh::EnsightIO::EnsightIO(), libMesh::RBEIMEvaluation::gather_bfs(), libMesh::MeshBase::get_info(), libMesh::StaticCondensation::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_petscdm(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::DistributedMesh::insert_elem(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::DofMap::local_variable_indices(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_elem_on_proc(), libMesh::DofMap::n_dofs_per_processor(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), libMesh::RBEIMEvaluation::node_gather_bfs(), libMesh::Partitioner::partition(), libMesh::MeshBase::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::DofMap::prepare_send_list(), libMesh::MeshBase::print_constraint_rows(), libMesh::DofMap::print_dof_constraints(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::XdrIO::read_header(), libMesh::CheckpointIO::read_nodes(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::System::read_serialized_vector(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::Partitioner::repartition(), OverlappingFunctorTest::run_partitioner_test(), libMesh::DofMap::scatter_constraints(), libMesh::DistributedMesh::set_next_unique_id(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), WriteVecAndScalar::setupTests(), libMesh::RBEIMEvaluation::side_gather_bfs(), DistributedMeshTest::testRemoteElemError(), CheckpointIOTest::testSplitter(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::VTKIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

104  {
105  processor_id_type returnval =
106  cast_int<processor_id_type>(_communicator.size());
107  libmesh_assert(returnval); // We never have an empty comm
108  return returnval;
109  }
const Parallel::Communicator & _communicator
processor_id_type size() const
uint8_t processor_id_type
libmesh_assert(ctx)

◆ n_qois()

unsigned int libMesh::System::n_qois ( ) const
inlineinherited

Number of currently active quantities of interest.

Definition at line 2621 of file system.h.

References libMesh::System::qoi, and libMesh::System::qoi_error_estimates.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::AdaptiveTimeSolver::adjoint_advance_timestep(), libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::ImplicitSystem::adjoint_qoi_parameter_sensitivity(), libMesh::TwostepTimeSolver::adjoint_solve(), libMesh::ImplicitSystem::adjoint_solve(), libMesh::SensitivityData::allocate_data(), libMesh::SensitivityData::allocate_hessian_data(), libMesh::ExplicitSystem::assemble_qoi(), libMesh::FEMSystem::assemble_qoi(), libMesh::ExplicitSystem::assemble_qoi_derivative(), libMesh::FEMSystem::assemble_qoi_derivative(), libMesh::DiffContext::DiffContext(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::FileSolutionHistory::FileSolutionHistory(), libMesh::ImplicitSystem::forward_qoi_parameter_sensitivity(), libMesh::UnsteadySolver::init_adjoints(), libMesh::TimeSolver::init_adjoints(), libMesh::System::init_qois(), libMesh::Euler2Solver::integrate_adjoint_refinement_error_estimate(), libMesh::TwostepTimeSolver::integrate_adjoint_refinement_error_estimate(), libMesh::EulerSolver::integrate_adjoint_refinement_error_estimate(), libMesh::Euler2Solver::integrate_qoi_timestep(), libMesh::TwostepTimeSolver::integrate_qoi_timestep(), libMesh::EulerSolver::integrate_qoi_timestep(), main(), libMesh::FEMContext::pre_fe_reinit(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), libMesh::FileSolutionHistory::retrieve(), libMesh::QoISet::size(), libMesh::UnsteadySolver::UnsteadySolver(), and libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().

2622 {
2623 #ifndef LIBMESH_ENABLE_DEPRECATED
2624  libmesh_assert_equal_to(this->qoi.size(), this->qoi_error_estimates.size());
2625 #endif
2626 
2627  return cast_int<unsigned int>(this->qoi.size());
2628 }
std::vector< Number > qoi
Values of the quantities of interest.
Definition: system.h:1631
std::vector< Number > qoi_error_estimates
Vector to hold error estimates for qois, either from a steady state calculation, or from a single uns...
Definition: system.h:1639

◆ n_variable_groups()

unsigned int libMesh::System::n_variable_groups ( ) const
inlineinherited
Returns
The number of VariableGroup variable groups in the system

Definition at line 2438 of file system.h.

References libMesh::System::_variable_groups.

Referenced by libMesh::System::add_variable(), libMesh::System::add_variables(), libMesh::FEMSystem::assembly(), libMesh::System::get_info(), and libMesh::System::init_data().

2439 {
2440  return cast_int<unsigned int>(_variable_groups.size());
2441 }
std::vector< VariableGroup > _variable_groups
The VariableGroup in this System.
Definition: system.h:2211

◆ n_vars()

unsigned int libMesh::System::n_vars ( ) const
inlineinherited
Returns
The number of variables in the system

Definition at line 2430 of file system.h.

References libMesh::System::_variables.

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::PetscDMWrapper::add_dofs_helper(), libMesh::DiffContext::add_localized_vector(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::System::add_variable(), libMesh::System::add_variables(), libMesh::TwostepTimeSolver::adjoint_solve(), libMesh::FEMContext::attach_quadrature_rules(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::PetscDMWrapper::build_section(), libMesh::System::calculate_norm(), compute_stresses(), LinearElasticityWithContact::compute_stresses(), LinearElasticity::compute_stresses(), LargeDeformationElasticity::compute_stresses(), libMesh::DGFEMContext::DGFEMContext(), libMesh::DiffContext::DiffContext(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::ErrorEstimator::estimate_errors(), libMesh::ExactSolution::ExactSolution(), libMesh::FEMContext::find_hardest_fe_type(), libMesh::EquationSystems::find_variable_numbers(), libMesh::System::get_all_variable_numbers(), libMesh::FEMSystem::init_context(), libMesh::RBEIMConstruction::init_context(), libMesh::FEMContext::init_internal_data(), libMesh::PetscDMWrapper::init_petscdm(), libMesh::DifferentiablePhysics::init_physics(), AssemblyA0::interior_assembly(), AssemblyA1::interior_assembly(), AssemblyA2::interior_assembly(), InnerProductAssembly::interior_assembly(), main(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), output_norms(), libMesh::petsc_auto_fieldsplit(), libMesh::FEMContext::pre_fe_reinit(), libMesh::InterMeshProjection::project_system_vectors(), libMesh::System::re_update(), libMesh::System::read_legacy_data(), libMesh::System::read_parallel_data(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::System::reinit_mesh(), libMesh::HPCoarsenTest::select_refinement(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::SystemSubsetBySubdomain::set_var_nums(), OverlappingTestBase::setup_coupling_matrix(), SystemsTest::testDofCouplingWithVarGroups(), SlitMeshRefinedSystemTest::testRestart(), SlitMeshRefinedSystemTest::testSystem(), libMesh::System::write_header(), libMesh::System::write_parallel_data(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::System::write_serialized_vector(), libMesh::System::write_serialized_vectors(), and libMesh::System::zero_variable().

2431 {
2432  return cast_int<unsigned int>(_variables.size());
2433 }
std::vector< Variable > _variables
The Variable in this System.
Definition: system.h:2206

◆ n_vectors()

unsigned int libMesh::System::n_vectors ( ) const
inlineinherited
Returns
The number of vectors (in addition to the solution) handled by this system This is the size of the _vectors map

Definition at line 2558 of file system.h.

References libMesh::System::_vectors.

Referenced by libMesh::ExplicitSystem::add_system_rhs(), libMesh::System::compare(), libMesh::System::get_info(), main(), libMesh::InterMeshProjection::project_system_vectors(), and libMesh::System::write_header().

2559 {
2560  return cast_int<unsigned int>(_vectors.size());
2561 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2230

◆ name()

const std::string & libMesh::System::name ( ) const
inlineinherited

◆ number()

unsigned int libMesh::System::number ( ) const
inlineinherited
Returns
The system number.

Definition at line 2350 of file system.h.

References libMesh::System::_sys_number.

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::PetscDMWrapper::add_dofs_helper(), assemble_matrix_and_rhs(), assemble_shell(), libMesh::VariationalSmootherSystem::assembly(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::Nemesis_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::Nemesis_IO::copy_nodal_solution(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::find_squared_element_error(), libMesh::EquationSystems::find_variable_numbers(), libMesh::VariationalSmootherConstraint::fix_node(), libMesh::System::get_info(), libMesh::VariationalSmootherSystem::init_data(), main(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SortAndCopy::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectVertices::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectEdges::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectSides::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectInteriors::operator()(), libMesh::System::read_legacy_data(), libMesh::System::read_parallel_data(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::StaticCondensationDofMap::reinit(), LinearElasticityWithContact::residual_and_jacobian(), SolidSystem::save_initial_mesh(), libMesh::HPCoarsenTest::select_refinement(), libMesh::PetscDMWrapper::set_point_range_in_section(), MeshInputTest::testCopyElementVectorImpl(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), libMesh::BoundaryVolumeSolutionTransfer::transfer_volume_boundary(), libMesh::DTKAdapter::update_variable_values(), libMesh::System::write_parallel_data(), libMesh::System::write_serialized_blocked_dof_objects(), and libMesh::System::zero_variable().

2351 {
2352  return _sys_number;
2353 }
const unsigned int _sys_number
The number associated with this system.
Definition: system.h:2201

◆ old_solution()

Number libMesh::TransientSystem< RBConstruction >::old_solution ( const dof_id_type  global_dof_number) const
inherited
Returns
The old solution (at the previous timestep) for the specified global DOF.

Definition at line 111 of file transient_system.C.

112 {
113  // Check the sizes
114  libmesh_assert_less (global_dof_number, this->get_dof_map().n_dofs());
115  libmesh_assert_less (global_dof_number, old_local_solution->size());
116 
117  return (*old_local_solution)(global_dof_number);
118 }
virtual numeric_index_type size() const =0
NumericVector< Number > * old_local_solution
All the values I need to compute my contribution to the simulation at hand.
dof_id_type n_dofs() const
Definition: system.C:121
const DofMap & get_dof_map() const
Definition: system.h:2374

◆ older_solution()

Number libMesh::TransientSystem< RBConstruction >::older_solution ( const dof_id_type  global_dof_number) const
inherited
Returns
The older solution (two timesteps ago) for the specified global DOF.

Definition at line 123 of file transient_system.C.

124 {
125  // Check the sizes
126  libmesh_assert_less (global_dof_number, this->get_dof_map().n_dofs());
127  libmesh_assert_less (global_dof_number, older_local_solution->size());
128 
129  return (*older_local_solution)(global_dof_number);
130 }
virtual numeric_index_type size() const =0
dof_id_type n_dofs() const
Definition: system.C:121
NumericVector< Number > * older_local_solution
All the values I need to compute my contribution to the simulation at hand.
const DofMap & get_dof_map() const
Definition: system.h:2374

◆ operator=() [1/2]

TransientRBConstruction& libMesh::TransientRBConstruction::operator= ( const TransientRBConstruction )
delete

◆ operator=() [2/2]

TransientRBConstruction& libMesh::TransientRBConstruction::operator= ( TransientRBConstruction &&  )
delete

◆ point_gradient() [1/4]

Gradient libMesh::System::point_gradient ( unsigned int  var,
const Point p,
const bool  insist_on_success = true,
const NumericVector< Number > *  sol = nullptr 
) const
inherited
Returns
The gradient of the solution variable var at the physical point p in the mesh, similarly to point_value.

Definition at line 2550 of file system.C.

References libMesh::Variable::active_subdomains(), TIMPI::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::PointLocatorBase::enable_out_of_mesh_mode(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::libmesh_assert(), mesh, TIMPI::Communicator::min(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), and libMesh::System::variable().

Referenced by line_print(), and libMesh::System::point_gradient().

2554 {
2555  // This function must be called on every processor; there's no
2556  // telling where in the partition p falls.
2557  parallel_object_only();
2558 
2559  // And every processor had better agree about which point we're
2560  // looking for
2561 #ifndef NDEBUG
2562  libmesh_assert(this->comm().verify(p(0)));
2563 #if LIBMESH_DIM > 1
2564  libmesh_assert(this->comm().verify(p(1)));
2565 #endif
2566 #if LIBMESH_DIM > 2
2567  libmesh_assert(this->comm().verify(p(2)));
2568 #endif
2569 #endif // NDEBUG
2570 
2571  // Get a reference to the mesh object associated with the system object that calls this function
2572  const MeshBase & mesh = this->get_mesh();
2573 
2574  // Use an existing PointLocator or create a new one
2575  std::unique_ptr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2576  PointLocatorBase & locator = *locator_ptr;
2577 
2578  if (!insist_on_success || !mesh.is_serial())
2579  locator.enable_out_of_mesh_mode();
2580 
2581  // Get a pointer to an element that contains p and allows us to
2582  // evaluate var
2583  const std::set<subdomain_id_type> & raw_subdomains =
2584  this->variable(var).active_subdomains();
2585  const std::set<subdomain_id_type> * implicit_subdomains =
2586  raw_subdomains.empty() ? nullptr : &raw_subdomains;
2587  const Elem * e = locator(p, implicit_subdomains);
2588 
2589  Gradient grad_u;
2590 
2591  if (e && this->get_dof_map().is_evaluable(*e, var))
2592  grad_u = point_gradient(var, p, *e, sol);
2593 
2594  // If I have an element containing p, then let's let everyone know
2595  processor_id_type lowest_owner =
2596  (e && (e->processor_id() == this->processor_id())) ?
2597  this->processor_id() : this->n_processors();
2598  this->comm().min(lowest_owner);
2599 
2600  // Everybody should get their value from a processor that was able
2601  // to compute it.
2602  // If nobody admits owning the point, we may have a problem.
2603  if (lowest_owner != this->n_processors())
2604  this->comm().broadcast(grad_u, lowest_owner);
2605  else
2606  libmesh_assert(!insist_on_success);
2607 
2608  return grad_u;
2609 }
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2458
Gradient point_gradient(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:2550
MeshBase & mesh
const Parallel::Communicator & comm() const
const MeshBase & get_mesh() const
Definition: system.h:2358
uint8_t processor_id_type
processor_id_type n_processors() const
const std::set< subdomain_id_type > & active_subdomains() const
Definition: variable.h:181
void min(const T &r, T &o, Request &req) const
NumberVectorValue Gradient
libmesh_assert(ctx)
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
processor_id_type processor_id() const
const DofMap & get_dof_map() const
Definition: system.h:2374

◆ point_gradient() [2/4]

Gradient libMesh::System::point_gradient ( unsigned int  var,
const Point p,
const Elem e,
const NumericVector< Number > *  sol = nullptr 
) const
inherited
Returns
The gradient of the solution variable var at the physical point p in local Elem e in the mesh, similarly to point_value.

Definition at line 2612 of file system.C.

References libMesh::FEInterface::compute_data(), libMesh::Elem::contains_point(), libMesh::System::current_local_solution, dim, libMesh::Elem::dim(), libMesh::DofMap::dof_indices(), libMesh::FEComputeData::dshape, libMesh::FEComputeData::enable_derivative(), libMesh::System::get_dof_map(), libMesh::System::get_equation_systems(), libMesh::FEMap::inverse_map(), libMesh::DofMap::is_evaluable(), libMesh::libmesh_assert(), libMesh::FEComputeData::local_transform, and libMesh::DofMap::variable_type().

2616 {
2617  // Ensuring that the given point is really in the element is an
2618  // expensive assert, but as long as debugging is turned on we might
2619  // as well try to catch a particularly nasty potential error
2620  libmesh_assert (e.contains_point(p));
2621 
2622  if (!sol)
2623  sol = this->current_local_solution.get();
2624 
2625  // Get the dof map to get the proper indices for our computation
2626  const DofMap & dof_map = this->get_dof_map();
2627 
2628  // write the element dimension into a separate variable.
2629  const unsigned int dim = e.dim();
2630 
2631  // Make sure we can evaluate on this element.
2632  libmesh_assert (dof_map.is_evaluable(e, var));
2633 
2634  // Need dof_indices for phi[i][j]
2635  std::vector<dof_id_type> dof_indices;
2636 
2637  // Fill in the dof_indices for our element
2638  dof_map.dof_indices (&e, dof_indices, var);
2639 
2640  // Get the no of dofs associated with this point
2641  const unsigned int num_dofs = cast_int<unsigned int>
2642  (dof_indices.size());
2643 
2644  FEType fe_type = dof_map.variable_type(var);
2645 
2646  // Map the physical co-ordinates to the master co-ordinates
2647  Point coor = FEMap::inverse_map(dim, &e, p);
2648 
2649  // get the shape function value via the FEInterface to also handle the case
2650  // of infinite elements correctly, the shape function is not fe->phi().
2651  FEComputeData fe_data(this->get_equation_systems(), coor);
2652  fe_data.enable_derivative();
2653  FEInterface::compute_data(dim, fe_type, &e, fe_data);
2654 
2655  // Get ready to accumulate a gradient
2656  Gradient grad_u;
2657 
2658  for (unsigned int l=0; l<num_dofs; l++)
2659  {
2660  // Chartesian coordinates have always LIBMESH_DIM entries,
2661  // local coordinates have as many coordinates as the element has.
2662  for (std::size_t v=0; v<dim; v++)
2663  for (std::size_t xyz=0; xyz<LIBMESH_DIM; xyz++)
2664  {
2665  // FIXME: this needs better syntax: It is matrix-vector multiplication.
2666  grad_u(xyz) += fe_data.local_transform[v][xyz]
2667  * fe_data.dshape[l](v)
2668  * (*sol)(dof_indices[l]);
2669  }
2670  }
2671 
2672  return grad_u;
2673 }
unsigned int dim
static Point inverse_map(const unsigned int dim, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true, const bool extra_checks=true)
Definition: fe_map.C:1628
const EquationSystems & get_equation_systems() const
Definition: system.h:721
static void compute_data(const unsigned int dim, const FEType &fe_t, const Elem *elem, FEComputeData &data)
Lets the appropriate child of FEBase compute the requested data for the input specified in data...
NumberVectorValue Gradient
libmesh_assert(ctx)
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Definition: system.h:1605
const DofMap & get_dof_map() const
Definition: system.h:2374

◆ point_gradient() [3/4]

Gradient libMesh::System::point_gradient ( unsigned int  var,
const Point p,
const Elem e 
) const
inherited

Calls the version of point_gradient() which takes a reference.

This function exists only to prevent people from calling the version of point_gradient() that has a boolean third argument, which would result in unnecessary PointLocator calls.

Definition at line 2677 of file system.C.

References libMesh::libmesh_assert(), and libMesh::System::point_gradient().

2678 {
2679  libmesh_assert(e);
2680  return this->point_gradient(var, p, *e);
2681 }
Gradient point_gradient(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:2550
libmesh_assert(ctx)

◆ point_gradient() [4/4]

Gradient libMesh::System::point_gradient ( unsigned int  var,
const Point p,
const NumericVector< Number > *  sol 
) const
inherited

Calls the parallel version of point_gradient().

This function exists only to prevent people from accidentally calling the version of point_gradient() that has a boolean third argument, which would result in incorrect output.

Definition at line 2685 of file system.C.

References libMesh::System::point_gradient().

2686 {
2687  return this->point_gradient(var, p, true, sol);
2688 }
Gradient point_gradient(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:2550

◆ point_hessian() [1/4]

Tensor libMesh::System::point_hessian ( unsigned int  var,
const Point p,
const bool  insist_on_success = true,
const NumericVector< Number > *  sol = nullptr 
) const
inherited
Returns
The second derivative tensor of the solution variable var at the physical point p in the mesh, similarly to point_value.

Definition at line 2694 of file system.C.

References libMesh::Variable::active_subdomains(), TIMPI::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::PointLocatorBase::enable_out_of_mesh_mode(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::libmesh_assert(), mesh, TIMPI::Communicator::min(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), and libMesh::System::variable().

Referenced by libMesh::System::point_hessian().

2698 {
2699  // This function must be called on every processor; there's no
2700  // telling where in the partition p falls.
2701  parallel_object_only();
2702 
2703  // And every processor had better agree about which point we're
2704  // looking for
2705 #ifndef NDEBUG
2706  libmesh_assert(this->comm().verify(p(0)));
2707 #if LIBMESH_DIM > 1
2708  libmesh_assert(this->comm().verify(p(1)));
2709 #endif
2710 #if LIBMESH_DIM > 2
2711  libmesh_assert(this->comm().verify(p(2)));
2712 #endif
2713 #endif // NDEBUG
2714 
2715  // Get a reference to the mesh object associated with the system object that calls this function
2716  const MeshBase & mesh = this->get_mesh();
2717 
2718  // Use an existing PointLocator or create a new one
2719  std::unique_ptr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2720  PointLocatorBase & locator = *locator_ptr;
2721 
2722  if (!insist_on_success || !mesh.is_serial())
2723  locator.enable_out_of_mesh_mode();
2724 
2725  // Get a pointer to an element that contains p and allows us to
2726  // evaluate var
2727  const std::set<subdomain_id_type> & raw_subdomains =
2728  this->variable(var).active_subdomains();
2729  const std::set<subdomain_id_type> * implicit_subdomains =
2730  raw_subdomains.empty() ? nullptr : &raw_subdomains;
2731  const Elem * e = locator(p, implicit_subdomains);
2732 
2733  Tensor hess_u;
2734 
2735  if (e && this->get_dof_map().is_evaluable(*e, var))
2736  hess_u = point_hessian(var, p, *e, sol);
2737 
2738  // If I have an element containing p, then let's let everyone know
2739  processor_id_type lowest_owner =
2740  (e && (e->processor_id() == this->processor_id())) ?
2741  this->processor_id() : this->n_processors();
2742  this->comm().min(lowest_owner);
2743 
2744  // Everybody should get their value from a processor that was able
2745  // to compute it.
2746  // If nobody admits owning the point, we may have a problem.
2747  if (lowest_owner != this->n_processors())
2748  this->comm().broadcast(hess_u, lowest_owner);
2749  else
2750  libmesh_assert(!insist_on_success);
2751 
2752  return hess_u;
2753 }
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2458
MeshBase & mesh
const Parallel::Communicator & comm() const
const MeshBase & get_mesh() const
Definition: system.h:2358
uint8_t processor_id_type
processor_id_type n_processors() const
const std::set< subdomain_id_type > & active_subdomains() const
Definition: variable.h:181
void min(const T &r, T &o, Request &req) const
libmesh_assert(ctx)
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
NumberTensorValue Tensor
Tensor point_hessian(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:2694
processor_id_type processor_id() const
const DofMap & get_dof_map() const
Definition: system.h:2374

◆ point_hessian() [2/4]

Tensor libMesh::System::point_hessian ( unsigned int  var,
const Point p,
const Elem e,
const NumericVector< Number > *  sol = nullptr 
) const
inherited
Returns
The second derivative tensor of the solution variable var at the physical point p in local Elem e in the mesh, similarly to point_value.

Definition at line 2755 of file system.C.

References libMesh::TypeTensor< T >::add_scaled(), libMesh::FEGenericBase< OutputType >::build(), libMesh::Elem::contains_point(), libMesh::System::current_local_solution, libMesh::Elem::dim(), libMesh::DofMap::dof_indices(), libMesh::System::get_dof_map(), libMesh::Elem::infinite(), libMesh::FEMap::inverse_map(), libMesh::DofMap::is_evaluable(), libMesh::libmesh_assert(), and libMesh::DofMap::variable_type().

2759 {
2760  // Ensuring that the given point is really in the element is an
2761  // expensive assert, but as long as debugging is turned on we might
2762  // as well try to catch a particularly nasty potential error
2763  libmesh_assert (e.contains_point(p));
2764 
2765  if (!sol)
2766  sol = this->current_local_solution.get();
2767 
2768  if (e.infinite())
2769  libmesh_not_implemented();
2770 
2771  // Get the dof map to get the proper indices for our computation
2772  const DofMap & dof_map = this->get_dof_map();
2773 
2774  // Make sure we can evaluate on this element.
2775  libmesh_assert (dof_map.is_evaluable(e, var));
2776 
2777  // Need dof_indices for phi[i][j]
2778  std::vector<dof_id_type> dof_indices;
2779 
2780  // Fill in the dof_indices for our element
2781  dof_map.dof_indices (&e, dof_indices, var);
2782 
2783  // Get the no of dofs associated with this point
2784  const unsigned int num_dofs = cast_int<unsigned int>
2785  (dof_indices.size());
2786 
2787  FEType fe_type = dof_map.variable_type(var);
2788 
2789  // Build a FE again so we can calculate u(p)
2790  std::unique_ptr<FEBase> fe (FEBase::build(e.dim(), fe_type));
2791 
2792  // Map the physical co-ordinates to the master co-ordinates
2793  // Build a vector of point co-ordinates to send to reinit
2794  std::vector<Point> coor(1, FEMap::inverse_map(e.dim(), &e, p));
2795 
2796  // Get the values of the shape function derivatives
2797  const std::vector<std::vector<RealTensor>> & d2phi = fe->get_d2phi();
2798 
2799  // Reinitialize the element and compute the shape function values at coor
2800  fe->reinit (&e, &coor);
2801 
2802  // Get ready to accumulate a hessian
2803  Tensor hess_u;
2804 
2805  for (unsigned int l=0; l<num_dofs; l++)
2806  {
2807  hess_u.add_scaled (d2phi[l][0], (*sol)(dof_indices[l]));
2808  }
2809 
2810  return hess_u;
2811 }
static Point inverse_map(const unsigned int dim, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true, const bool extra_checks=true)
Definition: fe_map.C:1628
static std::unique_ptr< FEGenericBase > build(const unsigned int dim, const FEType &type)
Builds a specific finite element type.
libmesh_assert(ctx)
void add_scaled(const TypeTensor< T2 > &, const T &)
Add a scaled tensor to this tensor without creating a temporary.
Definition: type_tensor.h:851
NumberTensorValue Tensor
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Definition: system.h:1605
const DofMap & get_dof_map() const
Definition: system.h:2374

◆ point_hessian() [3/4]

Tensor libMesh::System::point_hessian ( unsigned int  var,
const Point p,
const Elem e 
) const
inherited

Calls the version of point_hessian() which takes a reference.

This function exists only to prevent people from calling the version of point_hessian() that has a boolean third argument, which would result in unnecessary PointLocator calls.

Definition at line 2815 of file system.C.

References libMesh::libmesh_assert(), and libMesh::System::point_hessian().

2816 {
2817  libmesh_assert(e);
2818  return this->point_hessian(var, p, *e);
2819 }
libmesh_assert(ctx)
Tensor point_hessian(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:2694

◆ point_hessian() [4/4]

Tensor libMesh::System::point_hessian ( unsigned int  var,
const Point p,
const NumericVector< Number > *  sol 
) const
inherited

Calls the parallel version of point_hessian().

This function exists only to prevent people from accidentally calling the version of point_hessian() that has a boolean third argument, which would result in incorrect output.

Definition at line 2823 of file system.C.

References libMesh::System::point_hessian().

2824 {
2825  return this->point_hessian(var, p, true, sol);
2826 }
Tensor point_hessian(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:2694

◆ point_value() [1/4]

Number libMesh::System::point_value ( unsigned int  var,
const Point p,
const bool  insist_on_success = true,
const NumericVector< Number > *  sol = nullptr 
) const
inherited
Returns
The value of the solution variable var at the physical point p in the mesh, without knowing a priori which element contains p, using the degree of freedom coefficients in sol (or in current_local_solution if sol is left null).
Note
This function uses MeshBase::sub_point_locator(); users may or may not want to call MeshBase::clear_point_locator() afterward. Also, point_locator() is expensive (N log N for initial construction, log N for evaluations). Avoid using this function in any context where you are already looping over elements.

Because the element containing p may lie on any processor, this function is parallel-only.

By default this method expects the point to reside inside the domain and will abort if no element can be found which contains p. The optional parameter insist_on_success can be set to false to allow the method to return 0 when the point is not located.

Definition at line 2421 of file system.C.

References libMesh::Variable::active_subdomains(), TIMPI::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::PointLocatorBase::enable_out_of_mesh_mode(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::libmesh_assert(), mesh, TIMPI::Communicator::min(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), and libMesh::System::variable().

Referenced by line_print(), main(), libMesh::System::point_value(), MeshInputTest::testCopyElementSolutionImpl(), MeshInputTest::testCopyElementVectorImpl(), MeshInputTest::testCopyNodalSolutionImpl(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), PeriodicBCTest::testPeriodicBC(), SystemsTest::testProjectCubeWithMeshFunction(), and EquationSystemsTest::testRepartitionThenReinit().

2425 {
2426  // This function must be called on every processor; there's no
2427  // telling where in the partition p falls.
2428  parallel_object_only();
2429 
2430  // And every processor had better agree about which point we're
2431  // looking for
2432 #ifndef NDEBUG
2433  libmesh_assert(this->comm().verify(p(0)));
2434 #if LIBMESH_DIM > 1
2435  libmesh_assert(this->comm().verify(p(1)));
2436 #endif
2437 #if LIBMESH_DIM > 2
2438  libmesh_assert(this->comm().verify(p(2)));
2439 #endif
2440 #endif // NDEBUG
2441 
2442  // Get a reference to the mesh object associated with the system object that calls this function
2443  const MeshBase & mesh = this->get_mesh();
2444 
2445  // Use an existing PointLocator or create a new one
2446  std::unique_ptr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2447  PointLocatorBase & locator = *locator_ptr;
2448 
2449  if (!insist_on_success || !mesh.is_serial())
2450  locator.enable_out_of_mesh_mode();
2451 
2452  // Get a pointer to an element that contains p and allows us to
2453  // evaluate var
2454  const std::set<subdomain_id_type> & raw_subdomains =
2455  this->variable(var).active_subdomains();
2456  const std::set<subdomain_id_type> * implicit_subdomains =
2457  raw_subdomains.empty() ? nullptr : &raw_subdomains;
2458  const Elem * e = locator(p, implicit_subdomains);
2459 
2460  Number u = 0;
2461 
2462  if (e && this->get_dof_map().is_evaluable(*e, var))
2463  u = point_value(var, p, *e, sol);
2464 
2465  // If I have an element containing p, then let's let everyone know
2466  processor_id_type lowest_owner =
2467  (e && (e->processor_id() == this->processor_id())) ?
2468  this->processor_id() : this->n_processors();
2469  this->comm().min(lowest_owner);
2470 
2471  // Everybody should get their value from a processor that was able
2472  // to compute it.
2473  // If nobody admits owning the point, we have a problem.
2474  if (lowest_owner != this->n_processors())
2475  this->comm().broadcast(u, lowest_owner);
2476  else
2477  libmesh_assert(!insist_on_success);
2478 
2479  return u;
2480 }
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2458
MeshBase & mesh
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:2421
const Parallel::Communicator & comm() const
const MeshBase & get_mesh() const
Definition: system.h:2358
uint8_t processor_id_type
processor_id_type n_processors() const
const std::set< subdomain_id_type > & active_subdomains() const
Definition: variable.h:181
void min(const T &r, T &o, Request &req) const
libmesh_assert(ctx)
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
processor_id_type processor_id() const
const DofMap & get_dof_map() const
Definition: system.h:2374

◆ point_value() [2/4]

Number libMesh::System::point_value ( unsigned int  var,
const Point p,
const Elem e,
const NumericVector< Number > *  sol = nullptr 
) const
inherited
Returns
The value of the solution variable var at the physical point p contained in local Elem e, using the degree of freedom coefficients in sol (or in current_local_solution if sol is left null).

This version of point_value can be run in serial, but assumes e is in the local mesh partition or is algebraically ghosted.

Definition at line 2482 of file system.C.

References libMesh::FEInterface::compute_data(), libMesh::Elem::contains_point(), libMesh::System::current_local_solution, libMesh::Elem::dim(), libMesh::DofMap::dof_indices(), libMesh::System::get_dof_map(), libMesh::System::get_equation_systems(), libMesh::FEMap::inverse_map(), libMesh::DofMap::is_evaluable(), libMesh::libmesh_assert(), and libMesh::DofMap::variable_type().

2486 {
2487  // Ensuring that the given point is really in the element is an
2488  // expensive assert, but as long as debugging is turned on we might
2489  // as well try to catch a particularly nasty potential error
2490  libmesh_assert (e.contains_point(p));
2491 
2492  if (!sol)
2493  sol = this->current_local_solution.get();
2494 
2495  // Get the dof map to get the proper indices for our computation
2496  const DofMap & dof_map = this->get_dof_map();
2497 
2498  // Make sure we can evaluate on this element.
2499  libmesh_assert (dof_map.is_evaluable(e, var));
2500 
2501  // Need dof_indices for phi[i][j]
2502  std::vector<dof_id_type> dof_indices;
2503 
2504  // Fill in the dof_indices for our element
2505  dof_map.dof_indices (&e, dof_indices, var);
2506 
2507  // Get the no of dofs associated with this point
2508  const unsigned int num_dofs = cast_int<unsigned int>
2509  (dof_indices.size());
2510 
2511  FEType fe_type = dof_map.variable_type(var);
2512 
2513  // Map the physical co-ordinates to the master co-ordinates
2514  Point coor = FEMap::inverse_map(e.dim(), &e, p);
2515 
2516  // get the shape function value via the FEInterface to also handle the case
2517  // of infinite elements correctly, the shape function is not fe->phi().
2518  FEComputeData fe_data(this->get_equation_systems(), coor);
2519  FEInterface::compute_data(e.dim(), fe_type, &e, fe_data);
2520 
2521  // Get ready to accumulate a value
2522  Number u = 0;
2523 
2524  for (unsigned int l=0; l<num_dofs; l++)
2525  {
2526  u += fe_data.shape[l] * (*sol)(dof_indices[l]);
2527  }
2528 
2529  return u;
2530 }
static Point inverse_map(const unsigned int dim, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true, const bool extra_checks=true)
Definition: fe_map.C:1628
const EquationSystems & get_equation_systems() const
Definition: system.h:721
static void compute_data(const unsigned int dim, const FEType &fe_t, const Elem *elem, FEComputeData &data)
Lets the appropriate child of FEBase compute the requested data for the input specified in data...
libmesh_assert(ctx)
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Definition: system.h:1605
const DofMap & get_dof_map() const
Definition: system.h:2374

◆ point_value() [3/4]

Number libMesh::System::point_value ( unsigned int  var,
const Point p,
const Elem e 
) const
inherited

Calls the version of point_value() which takes a reference.

This function exists only to prevent people from calling the version of point_value() that has a boolean third argument, which would result in unnecessary PointLocator calls.

Definition at line 2534 of file system.C.

References libMesh::libmesh_assert(), and libMesh::System::point_value().

2535 {
2536  libmesh_assert(e);
2537  return this->point_value(var, p, *e);
2538 }
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:2421
libmesh_assert(ctx)

◆ point_value() [4/4]

Number libMesh::System::point_value ( unsigned int  var,
const Point p,
const NumericVector< Number > *  sol 
) const
inherited

Calls the parallel version of point_value().

This function exists only to prevent people from accidentally calling the version of point_value() that has a boolean third argument, which would result in incorrect output.

Definition at line 2542 of file system.C.

References libMesh::System::point_value().

2543 {
2544  return this->point_value(var, p, true, sol);
2545 }
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:2421

◆ post_process_elem_matrix_and_vector()

virtual void libMesh::RBConstruction::post_process_elem_matrix_and_vector ( DGFEMContext )
inlineprotectedvirtualinherited

This function is called from add_scaled_matrix_and_vector() before each element matrix and vector are assembled into their global counterparts.

By default it is a no-op, but it could be used to apply any user-defined transformations immediately prior to assembly. We use DGFEMContext since it allows for both DG and continuous Galerkin formulations.

Definition at line 715 of file rb_construction.h.

Referenced by libMesh::RBConstruction::add_scaled_matrix_and_vector().

715 {}

◆ post_process_truth_solution()

virtual void libMesh::RBConstruction::post_process_truth_solution ( )
inlineprotectedvirtualinherited

Similarly, provide an opportunity to post-process the truth solution after the solve is complete.

By default this is a no-op, but it could be used to apply any required user-defined post processing to the solution vector. Note: the truth solution is stored in the "solution" member of this class, which is inherited from the parent System class several levels up.

Definition at line 725 of file rb_construction.h.

Referenced by libMesh::RBConstruction::enrich_basis_from_rhs_terms(), and libMesh::RBConstruction::truth_solve().

725 {}

◆ preevaluate_thetas()

void libMesh::RBConstruction::preevaluate_thetas ( )
protectedvirtualinherited

Definition at line 2755 of file rb_construction.C.

References libMesh::RBConstruction::_evaluated_thetas, libMesh::RBConstruction::_preevaluate_thetas_completed, libMesh::RBConstructionBase< LinearImplicitSystem >::get_first_local_training_index(), libMesh::RBConstructionBase< LinearImplicitSystem >::get_local_n_training_samples(), libMesh::RBThetaExpansion::get_n_A_terms(), libMesh::RBParametrized::get_parameters(), libMesh::RBConstruction::get_rb_evaluation(), libMesh::RBEvaluation::get_rb_theta_expansion(), libMesh::index_range(), libMesh::make_range(), and libMesh::RBConstructionBase< LinearImplicitSystem >::set_params_from_training_set().

Referenced by libMesh::RBConstruction::train_reduced_basis_with_greedy().

2756 {
2757  LOG_SCOPE("preevaluate_thetas()", "RBConstruction");
2758 
2760 
2761  // Early return if we've already preevaluated thetas.
2763  return;
2764 
2765  if ( get_local_n_training_samples() == 0 )
2766  return;
2767 
2768  auto & rb_theta_expansion = get_rb_evaluation().get_rb_theta_expansion();
2769  const unsigned int n_A_terms = rb_theta_expansion.get_n_A_terms();
2770  const unsigned int n_F_terms = rb_theta_expansion.get_n_F_terms();
2771  const unsigned int n_outputs = rb_theta_expansion.get_total_n_output_terms();
2772 
2773  // Collect all training parameters
2774  // TODO: Here instead of using a vector of RBParameters objects,
2775  // we could use a single RBParameters object with multiple samples.
2776  // This would save memory over the current approach, but that may
2777  // not be a big deal in practice unless the number of training samples
2778  // is very large for some reason.
2779  std::vector<RBParameters> mus(get_local_n_training_samples());
2780  const numeric_index_type first_index = get_first_local_training_index();
2781  for (unsigned int i=0; i<get_local_n_training_samples(); i++)
2782  {
2783  // Load training parameter i, this is only loaded
2784  // locally since the RB solves are local.
2785  set_params_from_training_set( first_index+i );
2786  mus[i] = get_parameters();
2787  _evaluated_thetas[i].resize(n_A_terms + n_F_terms + n_outputs);
2788  }
2789 
2790  // Evaluate thetas for all training parameters simultaneously
2791  for (unsigned int q_a=0; q_a<n_A_terms; q_a++)
2792  {
2793  const auto A_vals = rb_theta_expansion.eval_A_theta(q_a, mus);
2794  for (auto i : make_range(get_local_n_training_samples()))
2795  _evaluated_thetas[i][q_a] = A_vals[i];
2796  }
2797 
2798  for (unsigned int q_f=0; q_f<n_F_terms; q_f++)
2799  {
2800  const auto F_vals = rb_theta_expansion.eval_F_theta(q_f, mus);
2801  for (auto i : make_range(get_local_n_training_samples()))
2802  _evaluated_thetas[i][n_A_terms + q_f] = F_vals[i];
2803  }
2804 
2805  {
2806  unsigned int output_counter = 0;
2807  for (unsigned int n=0; n<rb_theta_expansion.get_n_outputs(); n++)
2808  for (unsigned int q_l=0; q_l<rb_theta_expansion.get_n_output_terms(n); q_l++)
2809  {
2810  // Evaluate the current output functional term for all
2811  // training parameters simultaneously.
2812  const auto output_vals = rb_theta_expansion.eval_output_theta(n, q_l, mus);
2813 
2814  // TODO: the size of _evaluated_thetas is currently assumed to be
2815  // the same as get_local_n_training_samples(), but this won't be
2816  // the case if we use RBParameters objects that have multiple samples.
2817  // So just make sure that's the case for now.
2818  libmesh_error_msg_if(output_vals.size() != get_local_n_training_samples(),
2819  "We currently only support single-sample RBParameters "
2820  "objects during the training stage.");
2821 
2822  for (auto i : index_range(output_vals))
2823  _evaluated_thetas[i][n_A_terms + n_F_terms + output_counter] = output_vals[i];
2824 
2825  // Go to next output term
2826  output_counter++;
2827  }
2828  }
2829 
2831 }
numeric_index_type get_first_local_training_index() const
Get the first local index of the training parameters.
std::vector< std::vector< Number > > _evaluated_thetas
Storage of evaluated theta functions at a set of parameters.
unsigned int get_n_A_terms() const
Get Q_a, the number of terms in the affine expansion for the bilinear form.
dof_id_type numeric_index_type
Definition: id_types.h:99
numeric_index_type get_local_n_training_samples() const
Get the total number of training samples local to this processor.
const RBParameters & get_parameters() const
Get the current parameters.
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...
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...
Definition: int_range.h:140
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:117
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the rb_theta_expansion.
Definition: rb_evaluation.C:85
bool _preevaluate_thetas_completed
Flag to indicate if the preevaluate_thetas function has been called, since this allows us to avoid ca...

◆ prefer_hash_table_matrix_assembly()

void libMesh::System::prefer_hash_table_matrix_assembly ( bool  preference)
inlineinherited

Sets whether to use hash table matrix assembly if the matrix sub-classes support it.

Definition at line 2728 of file system.h.

References libMesh::System::_matrices_initialized, and libMesh::System::_prefer_hash_table_matrix_assembly.

Referenced by main().

2729 {
2730  libmesh_error_msg_if(
2732  "System::prefer_hash_table_matrix_assembly() should be called before matrices are initialized");
2734 }
bool _prefer_hash_table_matrix_assembly
Whether to use hash table matrix assembly if the matrix sub-classes support it.
Definition: system.h:2324
bool _matrices_initialized
false when additional matrices being added require initialization, true otherwise.
Definition: system.h:2257

◆ prefix()

std::string libMesh::System::prefix ( ) const
inlineinherited
Returns
A prefix that may be applied to solver options. Note that this prefix is only used if prefix_with_name()

Definition at line 1938 of file system.h.

References libMesh::System::name().

Referenced by libMesh::ImplicitSystem::get_linear_solver(), libMesh::LinearImplicitSystem::solve(), and libMesh::NonlinearImplicitSystem::solve().

1938 { return this->name() + "_"; }
const std::string & name() const
Definition: system.h:2342

◆ prefix_with_name() [1/2]

void libMesh::System::prefix_with_name ( bool  value)
inlineinherited

Instructs this system to prefix solve options with its name for solvers that leverage prefixes.

Definition at line 1927 of file system.h.

References libMesh::System::_prefix_with_name, and value.

1927 { _prefix_with_name = value; }
static const bool value
Definition: xdr_io.C:54
bool _prefix_with_name
Whether we are name prefixing solver options.
Definition: system.h:2334

◆ prefix_with_name() [2/2]

bool libMesh::System::prefix_with_name ( ) const
inlineinherited
Returns
Whether we are name prefixing

Definition at line 1932 of file system.h.

References libMesh::System::_prefix_with_name.

Referenced by libMesh::ContinuationSystem::ContinuationSystem(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::LinearImplicitSystem::solve(), libMesh::NonlinearImplicitSystem::solve(), and libMesh::System::System().

1932 { return _prefix_with_name; }
bool _prefix_with_name
Whether we are name prefixing solver options.
Definition: system.h:2334

◆ print_basis_function_orthogonality()

void libMesh::RBConstruction::print_basis_function_orthogonality ( ) const
inherited

Print out a matrix that shows the orthogonality of the RB basis functions.

This is a helpful debugging tool, e.g. orthogonality can be degraded due to finite precision arithmetic.

Definition at line 387 of file rb_construction.C.

References libMesh::RBEvaluation::get_n_basis_functions(), libMesh::RBConstruction::get_non_dirichlet_inner_product_matrix_if_avail(), libMesh::RBConstruction::get_rb_evaluation(), libMesh::out, libMesh::System::solution, value, and libMesh::SparseMatrix< T >::vector_mult().

Referenced by main().

388 {
389  std::unique_ptr<NumericVector<Number>> temp = solution->clone();
390 
391  for (unsigned int i=0; i<get_rb_evaluation().get_n_basis_functions(); i++)
392  {
393  for (unsigned int j=0; j<get_rb_evaluation().get_n_basis_functions(); j++)
394  {
396  Number value = temp->dot( get_rb_evaluation().get_basis_function(i) );
397 
398  libMesh::out << value << " ";
399  }
400  libMesh::out << std::endl;
401  }
402  libMesh::out << std::endl;
403 }
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...
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
OStreamProxy out
virtual unsigned int get_n_basis_functions() const
Get the current number of basis functions.
SparseMatrix< Number > * get_non_dirichlet_inner_product_matrix_if_avail()
Get the non-Dirichlet inner-product matrix if it&#39;s available, otherwise get the inner-product matrix ...
static const bool value
Definition: xdr_io.C:54
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.

◆ print_discrete_parameter_values()

void libMesh::RBParametrized::print_discrete_parameter_values ( ) const
inherited

Print out all the discrete parameter values.

Definition at line 380 of file rb_parametrized.C.

References libMesh::RBParametrized::get_discrete_parameter_values(), libMesh::Quality::name(), libMesh::out, and value.

Referenced by libMesh::RBSCMConstruction::print_info(), libMesh::RBEIMConstruction::print_info(), and libMesh::RBConstruction::print_info().

381 {
382  for (const auto & [name, values] : get_discrete_parameter_values())
383  {
384  libMesh::out << "Discrete parameter " << name << ", values: ";
385 
386  for (const auto & value : values)
387  libMesh::out << value << " ";
388  libMesh::out << std::endl;
389  }
390 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
const std::map< std::string, std::vector< Real > > & get_discrete_parameter_values() const
Get a const reference to the discrete parameter values.
OStreamProxy out
static const bool value
Definition: xdr_io.C:54

◆ print_info() [1/3]

void libMesh::ReferenceCounter::print_info ( std::ostream &  out_stream = libMesh::out)
staticinherited

Prints the reference information, by default to libMesh::out.

Definition at line 81 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter, and libMesh::ReferenceCounter::get_info().

Referenced by libMesh::LibMeshInit::~LibMeshInit().

82 {
84  out_stream << ReferenceCounter::get_info();
85 }
static std::string get_info()
Gets a string containing the reference information.
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called...

◆ print_info() [2/3]

void libMesh::ReferenceCounter::print_info ( std::ostream &  out_stream = libMesh::out)
staticinherited

Prints the reference information, by default to libMesh::out.

Definition at line 81 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter, and libMesh::ReferenceCounter::get_info().

Referenced by libMesh::LibMeshInit::~LibMeshInit().

82 {
84  out_stream << ReferenceCounter::get_info();
85 }
static std::string get_info()
Gets a string containing the reference information.
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called...

◆ print_info() [3/3]

void TransientRBConstruction::print_info ( ) const
overridevirtual

Print out info that describes the current setup of this RBConstruction.

Reimplemented from libMesh::RBConstruction.

Definition at line 143 of file transient_rb_construction.C.

References libMesh::RBConstruction::get_delta_N(), libMesh::RBTemporalDiscretization::get_delta_t(), libMesh::RBTemporalDiscretization::get_euler_theta(), libMesh::RBTemporalDiscretization::get_n_time_steps(), get_POD_tol(), libMesh::RBConstruction::get_rb_theta_expansion(), init_filename, libMesh::RBConstruction::is_rb_eval_initialized(), max_truth_solves, nonzero_initialization, libMesh::out, and libMesh::RBConstruction::print_info().

144 {
146 
147  libMesh::out << std::endl << "TransientRBConstruction parameters:" << std::endl;
148 
150  {
151  // Print out info that describes the current setup
152  auto & trans_theta_expansion =
153  cast_ref<const TransientRBThetaExpansion &>(get_rb_theta_expansion());
154  libMesh::out << "Q_m: " << trans_theta_expansion.get_n_M_terms() << std::endl;
155  }
156  else
157  {
158  libMesh::out << "RBThetaExpansion member is not set yet" << std::endl;
159  }
160  libMesh::out << "Number of time-steps: " << get_n_time_steps() << std::endl;
161  libMesh::out << "dt: " << get_delta_t() << std::endl;
162  libMesh::out << "euler_theta (time discretization parameter): " << get_euler_theta() << std::endl;
163  if (get_POD_tol() > 0.)
164  libMesh::out << "POD_tol: " << get_POD_tol() << std::endl;
165  if (max_truth_solves > 0)
166  libMesh::out << "Maximum number of truth solves: " << max_truth_solves << std::endl;
167  libMesh::out << "delta_N (number of basis functions to add each POD-Greedy step): " << get_delta_N() << std::endl;
169  {
170  libMesh::out << "Reading initial condition from " << init_filename << std::endl;
171  }
172  else
173  {
174  libMesh::out << "Using zero initial condition" << std::endl;
175  }
176  libMesh::out << std::endl;
177 }
int max_truth_solves
Maximum number of truth solves in the POD-Greedy.
Real get_POD_tol() const
Get/set POD_tol.
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.
virtual void print_info() const
Print out info that describes the current setup of this RBConstruction.
Real get_euler_theta() const
Get/set euler_theta, parameter that determines the temporal discretization.
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
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...
bool is_rb_eval_initialized() const
OStreamProxy out
unsigned int get_n_time_steps() const
Get/set the total number of time-steps.

◆ print_parameters()

void libMesh::RBParametrized::print_parameters ( ) const
inherited

Print the current parameters.

Definition at line 192 of file rb_parametrized.C.

References libMesh::RBParametrized::get_parameters(), libMesh::RBParametrized::parameters_initialized, and libMesh::RBParameters::print().

Referenced by libMesh::RBEIMConstruction::train_eim_approximation_with_greedy(), and libMesh::RBConstruction::train_reduced_basis_with_greedy().

193 {
194  libmesh_error_msg_if(!parameters_initialized, "Error: parameters not initialized in RBParametrized::print_current_parameters");
195 
196  get_parameters().print();
197 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
void print(unsigned precision=6, int max_values=5) const
Print the parameters.
const RBParameters & get_parameters() const
Get the current parameters.

◆ process_parameters_file()

void TransientRBConstruction::process_parameters_file ( const std::string &  parameters_filename)
overridevirtual

Read in the parameters from file and set up the system accordingly.

Reimplemented from libMesh::RBConstruction.

Definition at line 116 of file transient_rb_construction.C.

References libMesh::RBConstruction::delta_N, libMesh::RBConstruction::get_rb_evaluation(), init_filename, max_truth_solves, nonzero_initialization, POD_tol, libMesh::RBConstruction::process_parameters_file(), libMesh::RBTemporalDiscretization::process_temporal_parameters_file(), libMesh::RBTemporalDiscretization::pull_temporal_discretization_data(), libMesh::Real, set_delta_N(), set_max_truth_solves(), and set_POD_tol().

117 {
118  Parent::process_parameters_file(parameters_filename);
119 
120  // Read in data from parameters_filename
121  GetPot infile(parameters_filename);
122 
123  // Read in the generic temporal discretization data
124  process_temporal_parameters_file(parameters_filename);
125 
126  // Read in the data specific to Construction
127  nonzero_initialization = infile("nonzero_initialization",nonzero_initialization);
128  init_filename = infile("init_filename",init_filename);
129 
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);
133 
134  set_POD_tol(POD_tol_in);
135  set_max_truth_solves(max_truth_solves_in);
136  set_delta_N(delta_N_in);
137 
138  // Pass the temporal discretization data to the RBEvaluation
139  TransientRBEvaluation & trans_rb_eval = cast_ref<TransientRBEvaluation &>(get_rb_evaluation());
140  trans_rb_eval.pull_temporal_discretization_data( *this );
141 }
int max_truth_solves
Maximum number of truth solves in the POD-Greedy.
void set_max_truth_solves(int max_truth_solves_in)
void process_temporal_parameters_file(const std::string &parameters_filename)
Read in and initialize parameters from parameters_filename.
Real POD_tol
If positive, this tolerance determines the number of POD modes we add to the space on a call to enric...
std::string init_filename
The filename of the file containing the initial condition projected onto the truth mesh...
bool nonzero_initialization
Boolean flag to indicate whether we are using a non-zero initialization.
unsigned int delta_N
The number of basis functions that we add at each greedy step.
void set_POD_tol(const Real POD_tol_in)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void process_parameters_file(const std::string &parameters_filename)
Read in from the file specified by parameters_filename and set the this system&#39;s member variables acc...
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.
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.

◆ process_temporal_parameters_file()

void libMesh::RBTemporalDiscretization::process_temporal_parameters_file ( const std::string &  parameters_filename)
inherited

Read in and initialize parameters from parameters_filename.

Definition at line 93 of file rb_temporal_discretization.C.

References libMesh::RBTemporalDiscretization::get_delta_t(), libMesh::RBTemporalDiscretization::get_euler_theta(), libMesh::RBTemporalDiscretization::get_n_time_steps(), libMesh::Real, libMesh::RBTemporalDiscretization::set_delta_t(), libMesh::RBTemporalDiscretization::set_euler_theta(), libMesh::RBTemporalDiscretization::set_n_time_steps(), and libMesh::RBTemporalDiscretization::set_time_step().

Referenced by process_parameters_file().

94 {
95  // Read in data from parameters_filename
96  GetPot infile(parameters_filename);
97 
98  // Read in parameters related to temporal discretization
99  unsigned int n_time_steps_in = infile("n_time_steps", get_n_time_steps());
100  const Real delta_t_in = infile("delta_t", get_delta_t());
101  const Real euler_theta_in = infile("euler_theta", get_euler_theta());
102 
103  // and set the relevant member variables
104  set_n_time_steps(n_time_steps_in);
105  set_delta_t(delta_t_in);
106  set_euler_theta(euler_theta_in);
107  set_time_step(0);
108 }
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.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void set_euler_theta(const Real euler_theta_in)
unsigned int get_n_time_steps() const
Get/set the total number of time-steps.
void set_n_time_steps(const unsigned int K)

◆ processor_id()

processor_id_type libMesh::ParallelObject::processor_id ( ) const
inlineinherited
Returns
The rank of this processor in the group.

Definition at line 114 of file parallel_object.h.

References libMesh::ParallelObject::_communicator, and TIMPI::Communicator::rank().

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::MeshTools::Modification::all_tri(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::FEMSystem::assembly(), libMesh::Nemesis_IO::assert_symmetric_cmaps(), libMesh::Partitioner::assign_partitioning(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::Partitioner::build_graph(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::MeshFunction::check_found_elem(), libMesh::DistributedMesh::clear(), libMesh::DistributedMesh::clear_elems(), libMesh::ExodusII_IO_Helper::close(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::compute_communication_map_parameters(), libMesh::Nemesis_IO_Helper::compute_internal_and_border_elems_and_internal_nodes(), libMesh::RBConstruction::compute_max_error_bound(), libMesh::Nemesis_IO_Helper::compute_node_communication_maps(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::ExodusII_IO_Helper::create(), libMesh::DistributedMesh::delete_elem(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_scalar_dofs(), libMesh::DistributedMesh::DistributedMesh(), libMesh::DofMapBase::end_dof(), libMesh::DofMapBase::end_old_dof(), libMesh::EnsightIO::EnsightIO(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::find_dofs_to_send(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::DofMapBase::first_dof(), libMesh::DofMapBase::first_old_dof(), libMesh::RBEIMEvaluation::gather_bfs(), libMesh::Nemesis_IO_Helper::get_cmap_params(), libMesh::Nemesis_IO_Helper::get_eb_info_global(), libMesh::Nemesis_IO_Helper::get_elem_cmap(), libMesh::Nemesis_IO_Helper::get_elem_map(), libMesh::MeshBase::get_info(), libMesh::DofMap::get_info(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::RBEIMEvaluation::get_interior_basis_functions_as_vecs(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), libMesh::DofMap::get_local_constraints(), libMesh::MeshBase::get_local_constraints(), libMesh::Nemesis_IO_Helper::get_node_cmap(), libMesh::Nemesis_IO_Helper::get_node_map(), libMesh::Nemesis_IO_Helper::get_ns_param_global(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), libMesh::SparsityPattern::Build::handle_vi_vj(), libMesh::LaplaceMeshSmoother::init(), libMesh::SystemSubsetBySubdomain::init(), HeatSystem::init_data(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_element_variables(), libMesh::ExodusII_IO_Helper::initialize_global_variables(), libMesh::ExodusII_IO_Helper::initialize_nodal_variables(), libMesh::DistributedMesh::insert_elem(), libMesh::DofMap::is_evaluable(), libMesh::SparsityPattern::Build::join(), libMesh::TransientRBEvaluation::legacy_write_offline_data_to_files(), libMesh::RBSCMEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEvaluation::legacy_write_offline_data_to_files(), libMesh::MeshTools::libmesh_assert_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DofMap::local_variable_indices(), main(), libMesh::MeshRefinement::make_coarsening_compatible(), AugmentSparsityOnInterface::mesh_reinit(), libMesh::TriangulatorInterface::MeshedHole::MeshedHole(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::MeshTools::n_connected_components(), libMesh::MeshBase::n_constraint_rows(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::DofMapBase::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::RBEIMEvaluation::node_gather_bfs(), libMesh::DistributedMesh::own_node(), libMesh::BoundaryInfo::parallel_sync_node_ids(), libMesh::BoundaryInfo::parallel_sync_side_ids(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::print_constraint_rows(), libMesh::DofMap::print_dof_constraints(), libMesh::DofMap::process_mesh_constraint_rows(), libMesh::Nemesis_IO_Helper::put_cmap_params(), libMesh::Nemesis_IO_Helper::put_elem_cmap(), libMesh::Nemesis_IO_Helper::put_elem_map(), libMesh::Nemesis_IO_Helper::put_loadbal_param(), libMesh::Nemesis_IO_Helper::put_node_cmap(), libMesh::Nemesis_IO_Helper::put_node_map(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read(), libMesh::EquationSystems::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::ExodusII_IO_Helper::read_global_values(), libMesh::ExodusII_IO::read_header(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::DynaIO::read_mesh(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::System::read_parallel_data(), read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::System::read_serialized_data(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::Nemesis_IO_Helper::read_var_names_impl(), libMesh::SimplexRefiner::refine_via_edges(), libMesh::StaticCondensationDofMap::reinit(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::DistributedMesh::renumber_nodes_and_elements(), libMesh::DofMap::scatter_constraints(), libMesh::CheckpointIO::select_split_config(), libMesh::DistributedMesh::set_next_unique_id(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::RBEIMEvaluation::side_gather_bfs(), ExodusTest< elem_type >::test_read_gold(), ExodusTest< elem_type >::test_write(), MeshInputTest::testAbaqusRead(), MeshInputTest::testBadGmsh(), MeshInputTest::testCopyElementSolutionImpl(), MeshInputTest::testCopyElementVectorImpl(), MeshInputTest::testCopyNodalSolutionImpl(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), MeshInputTest::testDynaFileMappings(), MeshInputTest::testDynaNoSplines(), MeshInputTest::testDynaReadElem(), MeshInputTest::testDynaReadPatch(), MeshInputTest::testExodusFileMappings(), MeshInputTest::testExodusIGASidesets(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), MeshInputTest::testGmshBCIDOverlap(), MeshInputTest::testGoodGmsh(), MeshInputTest::testGoodSTL(), MeshInputTest::testGoodSTLBinary(), MeshInputTest::testLowOrderEdgeBlocks(), SystemsTest::testProjectMatrix3D(), BoundaryInfoTest::testShellFaceConstraints(), MeshInputTest::testSingleElementImpl(), WriteVecAndScalar::testSolution(), CheckpointIOTest::testSplitter(), MeshInputTest::testTetgenIO(), libMesh::MeshTools::total_weight(), libMesh::NetGenMeshInterface::triangulate(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::DTKAdapter::update_variable_values(), libMesh::MeshTools::volume(), libMesh::STLIO::write(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::CheckpointIO::write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::ExodusII_IO_Helper::write_element_values_element_major(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO_Helper::write_elemset_data(), libMesh::ExodusII_IO_Helper::write_elemsets(), libMesh::ExodusII_IO::write_global_data(), libMesh::ExodusII_IO_Helper::write_global_values(), libMesh::System::write_header(), libMesh::ExodusII_IO::write_information_records(), libMesh::ExodusII_IO_Helper::write_information_records(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::UCDIO::write_nodal_data(), libMesh::VTKIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_common(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::ExodusII_IO_Helper::write_nodal_values(), libMesh::ExodusII_IO_Helper::write_nodeset_data(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::RBEIMEvaluation::write_out_interior_basis_functions(), libMesh::RBEIMEvaluation::write_out_node_basis_functions(), libMesh::RBEIMEvaluation::write_out_side_basis_functions(), write_output_solvedata(), libMesh::System::write_parallel_data(), libMesh::RBConstruction::write_riesz_representors_to_files(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::System::write_serialized_data(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::System::write_serialized_vector(), libMesh::System::write_serialized_vectors(), libMesh::ExodusII_IO_Helper::write_sideset_data(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), libMesh::ExodusII_IO_Helper::write_timestep(), and libMesh::ExodusII_IO::write_timestep_discontinuous().

115  { return cast_int<processor_id_type>(_communicator.rank()); }
processor_id_type rank() const
const Parallel::Communicator & _communicator

◆ project_solution() [1/3]

void libMesh::System::project_solution ( FunctionBase< Number > *  f,
FunctionBase< Gradient > *  g = nullptr 
) const
inherited

Projects arbitrary functions onto the current solution.

This method projects an arbitrary function onto the solution via L2 projections and nodal interpolations on each element.

The function value f and its gradient g are user-provided cloneable functors. A gradient g is only required/used for projecting onto finite element spaces with continuous derivatives.

Definition at line 1041 of file system_projection.C.

Referenced by init_sys(), initialize(), main(), set_initial_condition(), SlitMeshRefinedSystemTest::setUp(), FETestBase< order, family, elem_type, 1 >::setUp(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), MeshFunctionTest::test_subdomain_id_sets(), MeshInputTest::testCopyElementSolutionImpl(), MeshInputTest::testCopyNodalSolutionImpl(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), SystemsTest::testProjectCubeWithMeshFunction(), MeshInputTest::testProjectionRegression(), EquationSystemsTest::testRepartitionThenReinit(), and libMesh::MeshfreeSolutionTransfer::transfer().

1043 {
1044  this->project_vector(*solution, f, g);
1045 
1046  solution->localize(*current_local_solution, _dof_map->get_send_list());
1047 }
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:2179
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Definition: system.h:1605
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
Projects arbitrary functions onto a vector of degree of freedom values for the current system...

◆ project_solution() [2/3]

void libMesh::System::project_solution ( FEMFunctionBase< Number > *  f,
FEMFunctionBase< Gradient > *  g = nullptr 
) const
inherited

Projects arbitrary functions onto the current solution.

This method projects an arbitrary function onto the solution via L2 projections and nodal interpolations on each element.

The function value f and its gradient g are user-provided cloneable functors. A gradient g is only required/used for projecting onto finite element spaces with continuous derivatives.

Definition at line 1054 of file system_projection.C.

1056 {
1057  this->project_vector(*solution, f, g);
1058 
1059  solution->localize(*current_local_solution, _dof_map->get_send_list());
1060 }
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:2179
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Definition: system.h:1605
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
Projects arbitrary functions onto a vector of degree of freedom values for the current system...

◆ project_solution() [3/3]

void libMesh::System::project_solution ( ValueFunctionPointer  fptr,
GradientFunctionPointer  gptr,
const Parameters parameters 
) const
inherited

This method projects an arbitrary function onto the solution via L2 projections and nodal interpolations on each element.

Definition at line 1027 of file system_projection.C.

References fptr(), and gptr().

1030 {
1031  WrappedFunction<Number> f(*this, fptr, &function_parameters);
1032  WrappedFunction<Gradient> g(*this, gptr, &function_parameters);
1033  this->project_solution(&f, &g);
1034 }
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:80
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr) const
Projects arbitrary functions onto the current solution.
Gradient gptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:95

◆ project_solution_on_reinit()

bool& libMesh::System::project_solution_on_reinit ( void  )
inlineinherited

Tells the System whether or not to project the solution vector onto new grids when the system is reinitialized.

The solution will be projected unless project_solution_on_reinit() = false is called.

Definition at line 838 of file system.h.

References libMesh::System::_solution_projection.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), and libMesh::MemoryHistoryData::store_vectors().

839  { return _solution_projection; }
bool _solution_projection
Holds true if the solution vector should be projected onto a changed grid, false if it should be zero...
Definition: system.h:2264

◆ project_vector() [1/5]

void libMesh::System::project_vector ( NumericVector< Number > &  new_vector,
FunctionBase< Number > *  f,
FunctionBase< Gradient > *  g = nullptr,
int  is_adjoint = -1 
) const
inherited

Projects arbitrary functions onto a vector of degree of freedom values for the current system.

This method projects an arbitrary function via L2 projections and nodal interpolations on each element.

The function value f and its gradient g are user-provided cloneable functors. A gradient g is only required/used for projecting onto finite element spaces with continuous derivatives.

Constrain the new vector using the requested adjoint rather than primal constraints if is_adjoint is non-negative.

Definition at line 1082 of file system_projection.C.

References libMesh::libmesh_assert().

Referenced by main(), libMesh::NewmarkSolver::project_initial_accel(), libMesh::SecondOrderUnsteadySolver::project_initial_rate(), libMesh::InterMeshProjection::project_system_vectors(), and libMesh::System::restrict_vectors().

1086 {
1087  LOG_SCOPE ("project_vector(FunctionBase)", "System");
1088 
1089  libmesh_assert(f);
1090 
1091  WrappedFunctor<Number> f_fem(*f);
1092 
1093  if (g)
1094  {
1095  WrappedFunctor<Gradient> g_fem(*g);
1096 
1097  this->project_vector(new_vector, &f_fem, &g_fem, is_adjoint);
1098  }
1099  else
1100  this->project_vector(new_vector, &f_fem, nullptr, is_adjoint);
1101 }
libmesh_assert(ctx)
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
Projects arbitrary functions onto a vector of degree of freedom values for the current system...

◆ project_vector() [2/5]

void libMesh::System::project_vector ( NumericVector< Number > &  new_vector,
FEMFunctionBase< Number > *  f,
FEMFunctionBase< Gradient > *  g = nullptr,
int  is_adjoint = -1 
) const
inherited

Projects arbitrary functions onto a vector of degree of freedom values for the current system.

This method projects an arbitrary function via L2 projections and nodal interpolations on each element.

The function value f and its gradient g are user-provided cloneable functors. A gradient g is only required/used for projecting onto finite element spaces with continuous derivatives.

Constrain the new vector using the requested adjoint rather than primal constraints if is_adjoint is non-negative.

Definition at line 1108 of file system_projection.C.

References libMesh::NumericVector< T >::close(), libMesh::FEMFunctionBase< Output >::component(), libMesh::FEType::family, libMesh::Utility::iota(), libMesh::libmesh_assert(), libMesh::libmesh_ignore(), libMesh::make_range(), n_vars, libMesh::NODEELEM, libMesh::FEMContext::pre_fe_reinit(), libMesh::RATIONAL_BERNSTEIN, libMesh::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), libMesh::NumericVector< T >::set(), and libMesh::Variable::type().

1112 {
1113  LOG_SCOPE ("project_fem_vector()", "System");
1114 
1115  libmesh_assert (f);
1116 
1117  ConstElemRange active_local_range
1118  (this->get_mesh().active_local_elements_begin(),
1119  this->get_mesh().active_local_elements_end() );
1120 
1121  VectorSetAction<Number> setter(new_vector);
1122 
1123  const unsigned int n_variables = this->n_vars();
1124 
1125  std::vector<unsigned int> vars(n_variables);
1126  std::iota(vars.begin(), vars.end(), 0);
1127 
1128  // Use a typedef to make the calling sequence for parallel_for() a bit more readable
1129  typedef
1130  GenericProjector<FEMFunctionWrapper<Number>, FEMFunctionWrapper<Gradient>,
1131  Number, VectorSetAction<Number>> FEMProjector;
1132 
1133  FEMFunctionWrapper<Number> fw(*f);
1134 
1135  if (g)
1136  {
1137  FEMFunctionWrapper<Gradient> gw(*g);
1138 
1139  FEMProjector projector(*this, fw, &gw, setter, vars);
1140  projector.project(active_local_range);
1141  }
1142  else
1143  {
1144  FEMProjector projector(*this, fw, nullptr, setter, vars);
1145  projector.project(active_local_range);
1146  }
1147 
1148  // Also, load values into the SCALAR dofs
1149  // Note: We assume that all SCALAR dofs are on the
1150  // processor with highest ID
1151  if (this->processor_id() == (this->n_processors()-1))
1152  {
1153  // FIXME: Do we want to first check for SCALAR vars before building this? [PB]
1154  FEMContext context( *this );
1155 
1156  const DofMap & dof_map = this->get_dof_map();
1157  for (auto var : make_range(this->n_vars()))
1158  if (this->variable(var).type().family == SCALAR)
1159  {
1160  // FIXME: We reinit with an arbitrary element in case the user
1161  // doesn't override FEMFunctionBase::component. Is there
1162  // any use case we're missing? [PB]
1163  context.pre_fe_reinit(*this, *(this->get_mesh().active_local_elements_begin()));
1164 
1165  std::vector<dof_id_type> SCALAR_indices;
1166  dof_map.SCALAR_dof_indices (SCALAR_indices, var);
1167  const unsigned int n_SCALAR_dofs =
1168  cast_int<unsigned int>(SCALAR_indices.size());
1169 
1170  for (unsigned int i=0; i<n_SCALAR_dofs; i++)
1171  {
1172  const dof_id_type global_index = SCALAR_indices[i];
1173  const unsigned int component_index =
1174  this->variable_scalar_number(var,i);
1175 
1176  new_vector.set(global_index, f->component(context, component_index, Point(), this->time));
1177  }
1178  }
1179  }
1180 
1181  new_vector.close();
1182 
1183  // Look for spline bases, in which case we need to backtrack
1184  // to calculate the spline DoF values.
1185  std::vector<const Variable *> rational_vars;
1186  for (auto varnum : vars)
1187  {
1188  const Variable & var = this->get_dof_map().variable(varnum);
1189  if (var.type().family == RATIONAL_BERNSTEIN)
1190  rational_vars.push_back(&var);
1191  }
1192 
1193  // Okay, but are we really using any *spline* bases, or just
1194  // unconstrained rational bases?
1195  bool using_spline_bases = false;
1196  if (!rational_vars.empty())
1197  {
1198  // Look for a spline node: a NodeElem with a rational variable
1199  // on it.
1200  for (auto & elem : active_local_range)
1201  if (elem->type() == NODEELEM)
1202  for (auto rational_var : rational_vars)
1203  if (rational_var->active_on_subdomain(elem->subdomain_id()))
1204  {
1205  using_spline_bases = true;
1206  goto checked_on_splines;
1207  }
1208  }
1209 
1210 checked_on_splines:
1211 
1212  // Not every processor may have a NodeElem, especially while
1213  // we're not partitioning them efficiently yet.
1214  this->comm().max(using_spline_bases);
1215 
1216  if (using_spline_bases)
1217  this->solve_for_unconstrained_dofs(new_vector, is_adjoint);
1218 
1219 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1220  if (is_adjoint == -1)
1221  this->get_dof_map().enforce_constraints_exactly(*this, &new_vector);
1222  else if (is_adjoint >= 0)
1224  is_adjoint);
1225 #else
1226  libmesh_ignore(is_adjoint);
1227 #endif
1228 }
Real time
For time-dependent problems, this is the time t at the beginning of the current timestep.
Definition: system.h:1615
unsigned int variable_scalar_number(std::string_view var, unsigned int component) const
Definition: system.h:2489
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2458
const Parallel::Communicator & comm() const
const MeshBase & get_mesh() const
Definition: system.h:2358
void iota(ForwardIter first, ForwardIter last, T value)
Utility::iota was created back when std::iota was just an SGI STL extension.
Definition: utility.h:229
StoredRange< MeshBase::const_element_iterator, const Elem * > ConstElemRange
Definition: elem_range.h:34
const Variable & variable(const unsigned int c) const override
Definition: dof_map.h:2190
void enforce_adjoint_constraints_exactly(NumericVector< Number > &v, unsigned int q) const
Heterogeneously constrains the numeric vector v, which represents an adjoint solution defined on the ...
Definition: dof_map.h:2354
processor_id_type n_processors() const
void libmesh_ignore(const Args &...)
libmesh_assert(ctx)
virtual void close()=0
Calls the NumericVector&#39;s internal assembly routines, ensuring that the values are consistent across ...
void max(const T &r, T &o, Request &req) const
virtual Output component(const FEMContext &, unsigned int i, const Point &p, Real time=0.)
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...
Definition: int_range.h:140
virtual void set(const numeric_index_type i, const T value)=0
Sets v(i) = value.
unsigned int n_vars() const
Definition: system.h:2430
processor_id_type processor_id() const
const DofMap & get_dof_map() const
Definition: system.h:2374
void solve_for_unconstrained_dofs(NumericVector< Number > &, int is_adjoint=-1) const
uint8_t dof_id_type
Definition: id_types.h:67
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. ...
Definition: dof_map.h:2350

◆ project_vector() [3/5]

void libMesh::System::project_vector ( ValueFunctionPointer  fptr,
GradientFunctionPointer  gptr,
const Parameters parameters,
NumericVector< Number > &  new_vector,
int  is_adjoint = -1 
) const
inherited

Projects arbitrary functions onto a vector of degree of freedom values for the current system.

This method projects an arbitrary function via L2 projections and nodal interpolations on each element.

The function value fptr and its gradient gptr are represented by function pointers. A gradient gptr is only required/used for projecting onto finite element spaces with continuous derivatives.

Constrain the new vector using the requested adjoint rather than primal constraints if is_adjoint is non-negative.

Definition at line 1067 of file system_projection.C.

References fptr(), and gptr().

1072 {
1073  WrappedFunction<Number> f(*this, fptr, &function_parameters);
1074  WrappedFunction<Gradient> g(*this, gptr, &function_parameters);
1075  this->project_vector(new_vector, &f, &g, is_adjoint);
1076 }
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:80
Gradient gptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:95
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
Projects arbitrary functions onto a vector of degree of freedom values for the current system...

◆ project_vector() [4/5]

void libMesh::System::project_vector ( NumericVector< Number > &  vector,
int  is_adjoint = -1 
) const
protectedinherited

Projects the vector defined on the old mesh onto the new mesh.

Constrain the new vector using the requested adjoint rather than primal constraints if is_adjoint is non-negative.

Definition at line 247 of file system_projection.C.

References libMesh::NumericVector< T >::clone().

249 {
250  // Create a copy of the vector, which currently
251  // contains the old data.
252  std::unique_ptr<NumericVector<Number>>
253  old_vector (vector.clone());
254 
255  // Project the old vector to the new vector
256  this->project_vector (*old_vector, vector, is_adjoint);
257 }
virtual std::unique_ptr< NumericVector< T > > clone() const =0
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
Projects arbitrary functions onto a vector of degree of freedom values for the current system...

◆ project_vector() [5/5]

void libMesh::System::project_vector ( const NumericVector< Number > &  old_v,
NumericVector< Number > &  new_v,
int  is_adjoint = -1 
) const
protectedinherited

Projects the vector defined on the old mesh onto the new mesh.

This method projects the vector via L2 projections or nodal interpolations on each element.

The original vector is unchanged and the new vector is passed through the second argument.

Constrain the new vector using the requested adjoint rather than primal constraints if is_adjoint is non-negative.

This method projects a solution from an old mesh to a current, refined mesh. The input vector old_v gives the solution on the old mesh, while the new_v gives the solution (to be computed) on the new mesh.

Definition at line 265 of file system_projection.C.

References libMesh::NumericVector< T >::clear(), libMesh::NumericVector< T >::close(), libMesh::NumericVector< T >::get(), libMesh::GHOSTED, libMesh::index_range(), libMesh::NumericVector< T >::init(), libMesh::Utility::iota(), libMesh::libmesh_assert(), libMesh::libmesh_ignore(), libMesh::NumericVector< T >::local_size(), libMesh::NumericVector< T >::localize(), libMesh::make_range(), n_vars, libMesh::PARALLEL, libMesh::Threads::parallel_reduce(), libMesh::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), libMesh::BuildProjectionList::send_list, libMesh::SERIAL, libMesh::NumericVector< T >::set(), libMesh::NumericVector< T >::size(), libMesh::NumericVector< T >::type(), libMesh::TYPE_SCALAR, and libMesh::BuildProjectionList::unique().

268 {
269  LOG_SCOPE ("project_vector(old,new)", "System");
270 
277  new_v.clear();
278 
279 #ifdef LIBMESH_ENABLE_AMR
280 
281  // Resize the new vector and get a serial version.
282  NumericVector<Number> * new_vector_ptr = nullptr;
283  std::unique_ptr<NumericVector<Number>> new_vector_built;
284  NumericVector<Number> * local_old_vector;
285  std::unique_ptr<NumericVector<Number>> local_old_vector_built;
286  const NumericVector<Number> * old_vector_ptr = nullptr;
287 
288  ConstElemRange active_local_elem_range
289  (this->get_mesh().active_local_elements_begin(),
290  this->get_mesh().active_local_elements_end());
291 
292  // If the old vector was uniprocessor, make the new
293  // vector uniprocessor
294  if (old_v.type() == SERIAL)
295  {
296  new_v.init (this->n_dofs(), false, SERIAL);
297  new_vector_ptr = &new_v;
298  old_vector_ptr = &old_v;
299  }
300 
301  // Otherwise it is a parallel, distributed vector, which
302  // we need to localize.
303  else if (old_v.type() == PARALLEL)
304  {
305  // Build a send list for efficient localization
306  BuildProjectionList projection_list(*this);
307  Threads::parallel_reduce (active_local_elem_range,
308  projection_list);
309 
310  // Create a sorted, unique send_list
311  projection_list.unique();
312 
313  new_v.init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
314  new_vector_built = NumericVector<Number>::build(this->comm());
315  local_old_vector_built = NumericVector<Number>::build(this->comm());
316  new_vector_ptr = new_vector_built.get();
317  local_old_vector = local_old_vector_built.get();
318  new_vector_ptr->init(this->n_dofs(), this->n_local_dofs(),
319  this->get_dof_map().get_send_list(), false,
320  GHOSTED);
321  local_old_vector->init(old_v.size(), old_v.local_size(),
322  projection_list.send_list, false, GHOSTED);
323  old_v.localize(*local_old_vector, projection_list.send_list);
324  local_old_vector->close();
325  old_vector_ptr = local_old_vector;
326  }
327  else if (old_v.type() == GHOSTED)
328  {
329  // Build a send list for efficient localization
330  BuildProjectionList projection_list(*this);
331  Threads::parallel_reduce (active_local_elem_range,
332  projection_list);
333 
334  // Create a sorted, unique send_list
335  projection_list.unique();
336 
337  new_v.init (this->n_dofs(), this->n_local_dofs(),
338  this->get_dof_map().get_send_list(), false, GHOSTED);
339 
340  local_old_vector_built = NumericVector<Number>::build(this->comm());
341  new_vector_ptr = &new_v;
342  local_old_vector = local_old_vector_built.get();
343  local_old_vector->init(old_v.size(), old_v.local_size(),
344  projection_list.send_list, false, GHOSTED);
345  old_v.localize(*local_old_vector, projection_list.send_list);
346  local_old_vector->close();
347  old_vector_ptr = local_old_vector;
348  }
349  else // unknown old_v.type()
350  libmesh_error_msg("ERROR: Unknown old_v.type() == " << old_v.type());
351 
352  // Note that the above will have zeroed the new_vector.
353  // Just to be sure, assert that new_vector_ptr and old_vector_ptr
354  // were successfully set before trying to deref them.
355  libmesh_assert(new_vector_ptr);
356  libmesh_assert(old_vector_ptr);
357 
358  NumericVector<Number> & new_vector = *new_vector_ptr;
359  const NumericVector<Number> & old_vector = *old_vector_ptr;
360 
361  const unsigned int n_variables = this->n_vars();
362 
363  if (n_variables)
364  {
365  std::vector<unsigned int> vars(n_variables);
366  std::iota(vars.begin(), vars.end(), 0);
367  std::vector<unsigned int> regular_vars, vector_vars;
368  for (auto var : vars)
369  {
371  regular_vars.push_back(var);
372  else
373  vector_vars.push_back(var);
374  }
375 
376  VectorSetAction<Number> setter(new_vector);
377 
378  if (!regular_vars.empty())
379  {
380  // Use a typedef to make the calling sequence for parallel_for() a bit more readable
381  typedef
382  GenericProjector<OldSolutionValue<Number, &FEMContext::point_value>,
383  OldSolutionValue<Gradient, &FEMContext::point_gradient>,
384  Number, VectorSetAction<Number>> FEMProjector;
385 
386  OldSolutionValue<Number, &FEMContext::point_value>
387  f(*this, old_vector, &regular_vars);
388  OldSolutionValue<Gradient, &FEMContext::point_gradient>
389  g(*this, old_vector, &regular_vars);
390 
391  FEMProjector projector(*this, f, &g, setter, regular_vars);
392  projector.project(active_local_elem_range);
393  }
394 
395  if (!vector_vars.empty())
396  {
397  typedef
398  GenericProjector<OldSolutionValue<Gradient, &FEMContext::point_value>,
399  OldSolutionValue<Tensor, &FEMContext::point_gradient>,
400  Gradient, VectorSetAction<Number>> FEMVectorProjector;
401 
402  OldSolutionValue<Gradient, &FEMContext::point_value> f_vector(*this, old_vector, &vector_vars);
403  OldSolutionValue<Tensor, &FEMContext::point_gradient> g_vector(*this, old_vector, &vector_vars);
404 
405  FEMVectorProjector vector_projector(*this, f_vector, &g_vector, setter, vector_vars);
406  vector_projector.project(active_local_elem_range);
407  }
408 
409  // Copy the SCALAR dofs from old_vector to new_vector
410  // Note: We assume that all SCALAR dofs are on the
411  // processor with highest ID
412  if (this->processor_id() == (this->n_processors()-1))
413  {
414  const DofMap & dof_map = this->get_dof_map();
415  for (auto var : make_range(this->n_vars()))
416  if (this->variable(var).type().family == SCALAR)
417  {
418  // We can just map SCALAR dofs directly across
419  std::vector<dof_id_type> new_SCALAR_indices, old_SCALAR_indices;
420  dof_map.SCALAR_dof_indices (new_SCALAR_indices, var, false);
421  dof_map.SCALAR_dof_indices (old_SCALAR_indices, var, true);
422  for (auto i : index_range(new_SCALAR_indices))
423  new_vector.set(new_SCALAR_indices[i], old_vector(old_SCALAR_indices[i]));
424  }
425  }
426  }
427 
428  new_vector.close();
429 
430  // If the old vector was serial, we probably need to send our values
431  // to other processors
432  //
433  // FIXME: I'm not sure how to make a NumericVector do that without
434  // creating a temporary parallel vector to use localize! - RHS
435  if (old_v.type() == SERIAL)
436  {
437  std::unique_ptr<NumericVector<Number>> dist_v = NumericVector<Number>::build(this->comm());
438  dist_v->init(this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
439  dist_v->close();
440 
441  for (auto i : make_range(dist_v->size()))
442  if (new_vector(i) != 0.0)
443  dist_v->set(i, new_vector(i));
444 
445  dist_v->close();
446 
447  dist_v->localize (new_v, this->get_dof_map().get_send_list());
448  new_v.close();
449  }
450  // If the old vector was parallel, we need to update it
451  // and free the localized copies
452  else if (old_v.type() == PARALLEL)
453  {
454  // We may have to set dof values that this processor doesn't
455  // own in certain special cases, like LAGRANGE FIRST or
456  // HERMITE THIRD elements on second-order meshes?
457  new_v = new_vector;
458  new_v.close();
459  }
460 
461 
462  // Apply constraints only if we we are asked to
463  if(this->project_with_constraints)
464  {
465  if (is_adjoint == -1)
466  {
467  this->get_dof_map().enforce_constraints_exactly(*this, &new_v);
468  }
469  else if (is_adjoint >= 0)
470  {
472  is_adjoint);
473  }
474  }
475 #else
476 
477  // AMR is disabled: simply copy the vector
478  new_v = old_v;
479 
480  libmesh_ignore(is_adjoint);
481 
482 #endif // #ifdef LIBMESH_ENABLE_AMR
483 }
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2458
virtual void get(const std::vector< numeric_index_type > &index, T *values) const
Access multiple components at once.
virtual numeric_index_type size() const =0
static FEFieldType field_type(const FEType &fe_type)
const Parallel::Communicator & comm() const
dof_id_type n_local_dofs() const
Definition: system.C:158
const MeshBase & get_mesh() const
Definition: system.h:2358
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 iota(ForwardIter first, ForwardIter last, T value)
Utility::iota was created back when std::iota was just an SGI STL extension.
Definition: utility.h:229
dof_id_type n_dofs() const
Definition: system.C:121
StoredRange< MeshBase::const_element_iterator, const Elem * > ConstElemRange
Definition: elem_range.h:34
void enforce_adjoint_constraints_exactly(NumericVector< Number > &v, unsigned int q) const
Heterogeneously constrains the numeric vector v, which represents an adjoint solution defined on the ...
Definition: dof_map.h:2354
processor_id_type n_processors() const
void libmesh_ignore(const Args &...)
NumberVectorValue Gradient
bool project_with_constraints
Do we want to apply constraints while projecting vectors ?
Definition: system.h:2319
libmesh_assert(ctx)
virtual void close()=0
Calls the NumericVector&#39;s internal assembly routines, ensuring that the values are consistent across ...
ParallelType type() const
const FEType & variable_type(const unsigned int i) const
Definition: system.h:2508
virtual numeric_index_type local_size() const =0
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...
Definition: int_range.h:140
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 parallel_reduce(const Range &range, Body &body)
Execute the provided reduction operation in parallel on the specified range.
Definition: threads_none.h:101
virtual void clear()
Restores the NumericVector<T> to a pristine state.
unsigned int n_vars() const
Definition: system.h:2430
processor_id_type processor_id() const
const DofMap & get_dof_map() const
Definition: system.h:2374
template class LIBMESH_EXPORT NumericVector< Number >
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:117
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. ...
Definition: dof_map.h:2350
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.

◆ projection_matrix()

void libMesh::System::projection_matrix ( SparseMatrix< Number > &  proj_mat) const
inherited

This method creates a projection matrix which corresponds to the operation of project_vector between old and new solution spaces.

Heterogeneous Dirichlet boundary conditions are not taken into account here; if this matrix is used for prolongation (mesh refinement) on a side with a heterogeneous BC, the newly created degrees of freedom on that side will still match the coarse grid approximation of the BC, not the fine grid approximation.

Definition at line 961 of file system_projection.C.

References libMesh::Utility::iota(), libMesh::make_range(), n_vars, libMesh::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), and libMesh::SparseMatrix< T >::set().

Referenced by libMesh::PetscDMWrapper::init_petscdm(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), and SystemsTest::testProjectMatrix3D().

962 {
963  LOG_SCOPE ("projection_matrix()", "System");
964 
965  const unsigned int n_variables = this->n_vars();
966 
967  if (n_variables)
968  {
969  ConstElemRange active_local_elem_range
970  (this->get_mesh().active_local_elements_begin(),
971  this->get_mesh().active_local_elements_end());
972 
973  std::vector<unsigned int> vars(n_variables);
974  std::iota(vars.begin(), vars.end(), 0);
975 
976  // Use a typedef to make the calling sequence for parallel_for() a bit more readable
977  typedef OldSolutionCoefs<Real, &FEMContext::point_value> OldSolutionValueCoefs;
978  typedef OldSolutionCoefs<RealGradient, &FEMContext::point_gradient> OldSolutionGradientCoefs;
979 
980  typedef
981  GenericProjector<OldSolutionValueCoefs,
982  OldSolutionGradientCoefs,
983  DynamicSparseNumberArray<Real,dof_id_type>,
984  MatrixFillAction<Real, Number> > ProjMatFiller;
985 
986  OldSolutionValueCoefs f(*this, &vars);
987  OldSolutionGradientCoefs g(*this, &vars);
988  MatrixFillAction<Real, Number> setter(proj_mat);
989 
990  ProjMatFiller mat_filler(*this, f, &g, setter, vars);
991  mat_filler.project(active_local_elem_range);
992 
993  // Set the SCALAR dof transfer entries too.
994  // Note: We assume that all SCALAR dofs are on the
995  // processor with highest ID
996  if (this->processor_id() == (this->n_processors()-1))
997  {
998  const DofMap & dof_map = this->get_dof_map();
999  for (auto var : make_range(this->n_vars()))
1000  if (this->variable(var).type().family == SCALAR)
1001  {
1002  // We can just map SCALAR dofs directly across
1003  std::vector<dof_id_type> new_SCALAR_indices, old_SCALAR_indices;
1004  dof_map.SCALAR_dof_indices (new_SCALAR_indices, var, false);
1005  dof_map.SCALAR_dof_indices (old_SCALAR_indices, var, true);
1006  const unsigned int new_n_dofs =
1007  cast_int<unsigned int>(new_SCALAR_indices.size());
1008 
1009  for (unsigned int i=0; i<new_n_dofs; i++)
1010  {
1011  proj_mat.set( new_SCALAR_indices[i],
1012  old_SCALAR_indices[i], 1);
1013  }
1014  }
1015  }
1016  }
1017 }
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2458
const MeshBase & get_mesh() const
Definition: system.h:2358
void iota(ForwardIter first, ForwardIter last, T value)
Utility::iota was created back when std::iota was just an SGI STL extension.
Definition: utility.h:229
StoredRange< MeshBase::const_element_iterator, const Elem * > ConstElemRange
Definition: elem_range.h:34
virtual void set(const numeric_index_type i, const numeric_index_type j, const T value)=0
Set the element (i,j) to value.
processor_id_type n_processors() const
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...
Definition: int_range.h:140
unsigned int n_vars() const
Definition: system.h:2430
processor_id_type processor_id() const
const DofMap & get_dof_map() const
Definition: system.h:2374

◆ prolong_vectors()

void libMesh::System::prolong_vectors ( )
virtualinherited

Prolong vectors after the mesh has refined.

Definition at line 444 of file system.C.

References libMesh::System::restrict_vectors().

Referenced by libMesh::EquationSystems::reinit_solutions().

445 {
446 #ifdef LIBMESH_ENABLE_AMR
447  // Currently project_vector handles both restriction and prolongation
448  this->restrict_vectors();
449 #endif
450 }
virtual void restrict_vectors()
Restrict vectors after the mesh has coarsened.
Definition: system.C:386

◆ pull_temporal_discretization_data()

void libMesh::RBTemporalDiscretization::pull_temporal_discretization_data ( RBTemporalDiscretization other)
inherited

Pull the temporal discretization data from other.

Definition at line 110 of file rb_temporal_discretization.C.

References libMesh::RBTemporalDiscretization::_control, libMesh::RBTemporalDiscretization::get_delta_t(), libMesh::RBTemporalDiscretization::get_euler_theta(), libMesh::RBTemporalDiscretization::get_n_time_steps(), libMesh::RBTemporalDiscretization::get_time_step(), libMesh::RBTemporalDiscretization::set_control(), libMesh::RBTemporalDiscretization::set_delta_t(), libMesh::RBTemporalDiscretization::set_euler_theta(), libMesh::RBTemporalDiscretization::set_n_time_steps(), and libMesh::RBTemporalDiscretization::set_time_step().

Referenced by process_parameters_file().

111 {
112  this->set_delta_t( other.get_delta_t() );
113  this->set_euler_theta( other.get_euler_theta() );
114  this->set_n_time_steps( other.get_n_time_steps() );
115  this->set_time_step( other.get_time_step() );
116  this->set_control( other._control );
117 }
void set_euler_theta(const Real euler_theta_in)
void set_n_time_steps(const unsigned int K)
void set_control(const std::vector< Real > &control)

◆ qoi_parameter_hessian()

void libMesh::ImplicitSystem::qoi_parameter_hessian ( const QoISet qoi_indices,
const ParameterVector parameters,
SensitivityData hessian 
)
overridevirtualinherited

For each of the system's quantities of interest q in qoi[qoi_indices], and for a vector of parameters p, the parameter sensitivity Hessian H_ij is defined as H_ij = (d^2 q)/(d p_i d p_j) This Hessian is the output of this method, where for each q_i, H_jk is stored in hessian.second_derivative(i,j,k).

Note that in some cases only current_local_solution is used during assembly, and, therefore, if solution has been altered without update() being called, then the user must call update() before calling this function.

Reimplemented from libMesh::System.

Definition at line 918 of file implicit_system.C.

References libMesh::ImplicitSystem::adjoint_solve(), libMesh::SensitivityData::allocate_hessian_data(), libMesh::ExplicitSystem::assemble_qoi(), libMesh::ExplicitSystem::assemble_qoi_derivative(), libMesh::ImplicitSystem::assembly(), libMesh::NumericVector< T >::close(), libMesh::SparseMatrix< T >::close(), libMesh::NumericVector< T >::dot(), libMesh::System::get_adjoint_rhs(), libMesh::System::get_adjoint_solution(), libMesh::System::get_qoi_value(), libMesh::System::get_qoi_values(), libMesh::System::get_sensitivity_solution(), libMesh::QoISet::has_index(), libMesh::System::is_adjoint_already_solved(), libMesh::ImplicitSystem::matrix, libMesh::System::n_qois(), libMesh::Real, libMesh::ExplicitSystem::rhs, libMesh::SensitivityData::second_derivative(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::ParameterVector::size(), libMesh::System::solution, libMesh::TOLERANCE, libMesh::System::update(), and libMesh::SparseMatrix< T >::vector_mult().

921 {
922  // We currently get partial derivatives via finite differencing
923  const Real delta_p = TOLERANCE;
924 
925  ParameterVector & parameters_vec =
926  const_cast<ParameterVector &>(parameters_in);
927 
928  // We'll use one temporary vector for matrix-vector-vector products
929  std::unique_ptr<NumericVector<Number>> tempvec = this->solution->zero_clone();
930 
931  // And another temporary vector to hold a copy of the true solution
932  // so we can safely perturb this->solution.
933  std::unique_ptr<NumericVector<Number>> oldsolution = this->solution->clone();
934 
935  const unsigned int Np = cast_int<unsigned int>
936  (parameters_vec.size());
937  const unsigned int Nq = this->n_qois();
938 
939  // For each quantity of interest q, the parameter sensitivity
940  // Hessian is defined as q''_{kl} = {d^2 q}/{d p_k d p_l}.
941  //
942  // We calculate it from values and partial derivatives of the
943  // quantity of interest function Q, solution u, adjoint solution z,
944  // and residual R, as:
945  //
946  // q''_{kl} =
947  // Q''_{kl} + Q''_{uk}(u)*u'_l + Q''_{ul}(u) * u'_k +
948  // Q''_{uu}(u)*u'_k*u'_l -
949  // R''_{kl}(u,z) -
950  // R''_{uk}(u,z)*u'_l - R''_{ul}(u,z)*u'_k -
951  // R''_{uu}(u,z)*u'_k*u'_l
952  //
953  // See the adjoints model document for more details.
954 
955  // We first do an adjoint solve to get z for each quantity of
956  // interest
957  // if we haven't already or dont have an initial condition for the adjoint
958  if (!this->is_adjoint_already_solved())
959  {
960  this->adjoint_solve(qoi_indices);
961  }
962 
963  // And a sensitivity solve to get u_k for each parameter
964  this->sensitivity_solve(parameters_vec);
965 
966  // Get ready to fill in second derivatives:
967  sensitivities.allocate_hessian_data(qoi_indices, *this, parameters_vec);
968 
969  for (unsigned int k=0; k != Np; ++k)
970  {
971  Number old_parameterk = *parameters_vec[k];
972 
973  // The Hessian is symmetric, so we just calculate the lower
974  // triangle and the diagonal, and we get the upper triangle from
975  // the transpose of the lower
976 
977  for (unsigned int l=0; l != k+1; ++l)
978  {
979  // The second partial derivatives with respect to parameters_vec
980  // are all calculated via a central finite difference
981  // stencil:
982  // F''_{kl} ~= (F(p+dp*e_k+dp*e_l) - F(p+dp*e_k-dp*e_l) -
983  // F(p-dp*e_k+dp*e_l) + F(p-dp*e_k-dp*e_l))/(4*dp^2)
984  // We will add Q''_{kl}(u) and subtract R''_{kl}(u,z) at the
985  // same time.
986  //
987  // We have to be careful with the perturbations to handle
988  // the k=l case
989 
990  Number old_parameterl = *parameters_vec[l];
991 
992  *parameters_vec[k] += delta_p;
993  *parameters_vec[l] += delta_p;
994  this->assemble_qoi(qoi_indices);
995  this->assembly(true, false, true);
996  this->rhs->close();
997  std::vector<Number> partial2q_term = this->get_qoi_values();
998  std::vector<Number> partial2R_term(this->n_qois());
999  for (unsigned int i=0; i != Nq; ++i)
1000  if (qoi_indices.has_index(i))
1001  partial2R_term[i] = this->rhs->dot(this->get_adjoint_solution(i));
1002 
1003  *parameters_vec[l] -= 2.*delta_p;
1004  this->assemble_qoi(qoi_indices);
1005  this->assembly(true, false, true);
1006  this->rhs->close();
1007  for (unsigned int i=0; i != Nq; ++i)
1008  if (qoi_indices.has_index(i))
1009  {
1010  partial2q_term[i] -= this->get_qoi_value(i);
1011  partial2R_term[i] -= this->rhs->dot(this->get_adjoint_solution(i));
1012  }
1013 
1014  *parameters_vec[k] -= 2.*delta_p;
1015  this->assemble_qoi(qoi_indices);
1016  this->assembly(true, false, true);
1017  this->rhs->close();
1018  for (unsigned int i=0; i != Nq; ++i)
1019  if (qoi_indices.has_index(i))
1020  {
1021  partial2q_term[i] += this->get_qoi_value(i);
1022  partial2R_term[i] += this->rhs->dot(this->get_adjoint_solution(i));
1023  }
1024 
1025  *parameters_vec[l] += 2.*delta_p;
1026  this->assemble_qoi(qoi_indices);
1027  this->assembly(true, false, true);
1028  this->rhs->close();
1029  for (unsigned int i=0; i != Nq; ++i)
1030  if (qoi_indices.has_index(i))
1031  {
1032  partial2q_term[i] -= this->get_qoi_value(i);
1033  partial2R_term[i] -= this->rhs->dot(this->get_adjoint_solution(i));
1034  partial2q_term[i] /= (4. * delta_p * delta_p);
1035  partial2R_term[i] /= (4. * delta_p * delta_p);
1036  }
1037 
1038  for (unsigned int i=0; i != Nq; ++i)
1039  if (qoi_indices.has_index(i))
1040  {
1041  Number current_terms = partial2q_term[i] - partial2R_term[i];
1042  sensitivities.second_derivative(i,k,l) += current_terms;
1043  if (k != l)
1044  sensitivities.second_derivative(i,l,k) += current_terms;
1045  }
1046 
1047  // Don't leave the parameters_vec perturbed
1048  *parameters_vec[l] = old_parameterl;
1049  *parameters_vec[k] = old_parameterk;
1050  }
1051 
1052  // We get (partial q / partial u) and
1053  // (partial R / partial u) from the user, but centrally
1054  // difference to get q_uk and R_uk terms:
1055  // (partial^2 q / partial u partial k)
1056  // q_uk*u'_l = (q_u(p+dp*e_k)*u'_l - q_u(p-dp*e_k)*u'_l)/(2*dp)
1057  // R_uk*z*u'_l = (R_u(p+dp*e_k)*z*u'_l - R_u(p-dp*e_k)*z*u'_l)/(2*dp)
1058  //
1059  // To avoid creating Nq temporary vectors, we add these
1060  // subterms to the sensitivities output one by one.
1061  //
1062  // FIXME: this is probably a bad order of operations for
1063  // controlling floating point error.
1064 
1065  *parameters_vec[k] = old_parameterk + delta_p;
1066  this->assembly(false, true);
1067  this->matrix->close();
1068  this->assemble_qoi_derivative(qoi_indices,
1069  /* include_liftfunc = */ true,
1070  /* apply_constraints = */ false);
1071 
1072  for (unsigned int l=0; l != Np; ++l)
1073  {
1074  this->matrix->vector_mult(*tempvec, this->get_sensitivity_solution(l));
1075  for (unsigned int i=0; i != Nq; ++i)
1076  if (qoi_indices.has_index(i))
1077  {
1078  this->get_adjoint_rhs(i).close();
1079  Number current_terms =
1080  (this->get_adjoint_rhs(i).dot(this->get_sensitivity_solution(l)) -
1081  tempvec->dot(this->get_adjoint_solution(i))) / (2.*delta_p);
1082  sensitivities.second_derivative(i,k,l) += current_terms;
1083 
1084  // We use the _uk terms twice; symmetry lets us reuse
1085  // these calculations for the _ul terms.
1086 
1087  sensitivities.second_derivative(i,l,k) += current_terms;
1088  }
1089  }
1090 
1091  *parameters_vec[k] = old_parameterk - delta_p;
1092  this->assembly(false, true);
1093  this->matrix->close();
1094  this->assemble_qoi_derivative(qoi_indices,
1095  /* include_liftfunc = */ true,
1096  /* apply_constraints = */ false);
1097 
1098  for (unsigned int l=0; l != Np; ++l)
1099  {
1100  this->matrix->vector_mult(*tempvec, this->get_sensitivity_solution(l));
1101  for (unsigned int i=0; i != Nq; ++i)
1102  if (qoi_indices.has_index(i))
1103  {
1104  this->get_adjoint_rhs(i).close();
1105  Number current_terms =
1106  (-this->get_adjoint_rhs(i).dot(this->get_sensitivity_solution(l)) +
1107  tempvec->dot(this->get_adjoint_solution(i))) / (2.*delta_p);
1108  sensitivities.second_derivative(i,k,l) += current_terms;
1109 
1110  // We use the _uk terms twice; symmetry lets us reuse
1111  // these calculations for the _ul terms.
1112 
1113  sensitivities.second_derivative(i,l,k) += current_terms;
1114  }
1115  }
1116 
1117  // Don't leave the parameter perturbed
1118  *parameters_vec[k] = old_parameterk;
1119 
1120  // Our last remaining terms are -R_uu(u,z)*u_k*u_l and
1121  // Q_uu(u)*u_k*u_l
1122  //
1123  // We take directional central finite differences of R_u and Q_u
1124  // to approximate these terms, e.g.:
1125  //
1126  // Q_uu(u)*u_k ~= (Q_u(u+dp*u_k) - Q_u(u-dp*u_k))/(2*dp)
1127 
1128  *this->solution = this->get_sensitivity_solution(k);
1129  *this->solution *= delta_p;
1130  *this->solution += *oldsolution;
1131 
1132  // We've modified solution, so we need to update before calling
1133  // assembly since assembly may only use current_local_solution
1134  this->update();
1135  this->assembly(false, true);
1136  this->matrix->close();
1137  this->assemble_qoi_derivative(qoi_indices,
1138  /* include_liftfunc = */ true,
1139  /* apply_constraints = */ false);
1140 
1141  // The Hessian is symmetric, so we just calculate the lower
1142  // triangle and the diagonal, and we get the upper triangle from
1143  // the transpose of the lower
1144  //
1145  // Note that, because we took the directional finite difference
1146  // with respect to k and not l, we've added an O(delta_p^2)
1147  // error to any permutational symmetry in the Hessian...
1148  for (unsigned int l=0; l != k+1; ++l)
1149  {
1150  this->matrix->vector_mult(*tempvec, this->get_sensitivity_solution(l));
1151  for (unsigned int i=0; i != Nq; ++i)
1152  if (qoi_indices.has_index(i))
1153  {
1154  this->get_adjoint_rhs(i).close();
1155  Number current_terms =
1156  (this->get_adjoint_rhs(i).dot(this->get_sensitivity_solution(l)) -
1157  tempvec->dot(this->get_adjoint_solution(i))) / (2.*delta_p);
1158  sensitivities.second_derivative(i,k,l) += current_terms;
1159  if (k != l)
1160  sensitivities.second_derivative(i,l,k) += current_terms;
1161  }
1162  }
1163 
1164  *this->solution = this->get_sensitivity_solution(k);
1165  *this->solution *= -delta_p;
1166  *this->solution += *oldsolution;
1167 
1168  // We've modified solution, so we need to update before calling
1169  // assembly since assembly may only use current_local_solution
1170  this->update();
1171  this->assembly(false, true);
1172  this->matrix->close();
1173  this->assemble_qoi_derivative(qoi_indices,
1174  /* include_liftfunc = */ true,
1175  /* apply_constraints = */ false);
1176 
1177  for (unsigned int l=0; l != k+1; ++l)
1178  {
1179  this->matrix->vector_mult(*tempvec, this->get_sensitivity_solution(l));
1180  for (unsigned int i=0; i != Nq; ++i)
1181  if (qoi_indices.has_index(i))
1182  {
1183  this->get_adjoint_rhs(i).close();
1184  Number current_terms =
1185  (-this->get_adjoint_rhs(i).dot(this->get_sensitivity_solution(l)) +
1186  tempvec->dot(this->get_adjoint_solution(i))) / (2.*delta_p);
1187  sensitivities.second_derivative(i,k,l) += current_terms;
1188  if (k != l)
1189  sensitivities.second_derivative(i,l,k) += current_terms;
1190  }
1191  }
1192 
1193  // Don't leave the solution perturbed
1194  *this->solution = *oldsolution;
1195  }
1196 
1197  // All parameters_vec have been reset.
1198  // Don't leave the qoi or system changed - principle of least
1199  // surprise.
1200  // We've modified solution, so we need to update before calling
1201  // assembly since assembly may only use current_local_solution
1202  this->update();
1203  this->assembly(true, true);
1204  this->rhs->close();
1205  this->matrix->close();
1206  this->assemble_qoi(qoi_indices);
1207 }
static constexpr Real TOLERANCE
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...
Number get_qoi_value(unsigned int qoi_index) const
Definition: system.C:2386
unsigned int n_qois() const
Number of currently active quantities of interest.
Definition: system.h:2621
NumericVector< Number > & get_sensitivity_solution(unsigned int i=0)
Definition: system.C:1192
NumericVector< Number > * rhs
The system matrix.
virtual std::pair< unsigned int, Real > sensitivity_solve(const ParameterVector &parameters) override
Assembles & solves the linear system(s) (dR/du)*u_p = -dR/dp, for those parameters contained within p...
virtual T dot(const NumericVector< T > &v) const =0
virtual std::pair< unsigned int, Real > adjoint_solve(const QoISet &qoi_indices=QoISet()) override
Assembles & solves the linear system (dR/du)^T*z = dq/du, for those quantities of interest q specifie...
virtual void assembly(bool, bool, bool=false, bool=false)
Assembles a residual in rhs and/or a jacobian in matrix, as requested.
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
bool is_adjoint_already_solved() const
Accessor for the adjoint_already_solved boolean.
Definition: system.h:409
virtual void close()=0
Calls the NumericVector&#39;s internal assembly routines, ensuring that the values are consistent across ...
virtual void update()
Update the local values to reflect the solution on neighboring processors.
Definition: system.C:510
virtual void close()=0
Calls the SparseMatrix&#39;s internal assembly routines, ensuring that the values are consistent across p...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
SparseMatrix< Number > * matrix
The system matrix.
virtual void assemble_qoi(const QoISet &qoi_indices=QoISet()) override
Prepares qoi for quantity of interest assembly, then calls user qoi function.
virtual void assemble_qoi_derivative(const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true) override
Prepares adjoint_rhs for quantity of interest derivative assembly, then calls user qoi derivative fun...
NumericVector< Number > & get_adjoint_solution(unsigned int i=0)
Definition: system.C:1245
std::vector< Number > get_qoi_values() const
Returns a copy of qoi, not a reference.
Definition: system.C:2393
NumericVector< Number > & get_adjoint_rhs(unsigned int i=0)
Definition: system.C:1307

◆ qoi_parameter_hessian_vector_product()

void libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product ( const QoISet qoi_indices,
const ParameterVector parameters,
const ParameterVector vector,
SensitivityData product 
)
overridevirtualinherited

For each of the system's quantities of interest q in qoi[qoi_indices], and for a vector of parameters p, the parameter sensitivity Hessian H_ij is defined as H_ij = (d^2 q)/(d p_i d p_j) The Hessian-vector product, for a vector v_k in parameter space, is S_j = H_jk v_k This product is the output of this method, where for each q_i, S_j is stored in sensitivities[i][j].

Reimplemented from libMesh::System.

Definition at line 713 of file implicit_system.C.

References libMesh::ImplicitSystem::adjoint_solve(), libMesh::SensitivityData::allocate_data(), libMesh::ExplicitSystem::assemble_qoi(), libMesh::ExplicitSystem::assemble_qoi_derivative(), libMesh::ImplicitSystem::assembly(), libMesh::NumericVector< T >::close(), libMesh::SparseMatrix< T >::close(), libMesh::ParameterVector::deep_copy(), libMesh::NumericVector< T >::dot(), libMesh::System::get_adjoint_rhs(), libMesh::System::get_adjoint_solution(), libMesh::System::get_qoi_value(), libMesh::System::get_qoi_values(), libMesh::System::get_weighted_sensitivity_adjoint_solution(), libMesh::System::get_weighted_sensitivity_solution(), libMesh::QoISet::has_index(), libMesh::System::is_adjoint_already_solved(), libMesh::ImplicitSystem::matrix, libMesh::System::n_qois(), libMesh::Real, libMesh::ExplicitSystem::rhs, libMesh::ParameterVector::size(), libMesh::System::solution, libMesh::TOLERANCE, libMesh::ParameterVector::value_copy(), libMesh::SparseMatrix< T >::vector_mult(), libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve(), and libMesh::ImplicitSystem::weighted_sensitivity_solve().

717 {
718  // We currently get partial derivatives via finite differencing
719  const Real delta_p = TOLERANCE;
720 
721  ParameterVector & parameters_vec =
722  const_cast<ParameterVector &>(parameters_in);
723 
724  // We'll use a single temporary vector for matrix-vector-vector products
725  std::unique_ptr<NumericVector<Number>> tempvec = this->solution->zero_clone();
726 
727  const unsigned int Np = cast_int<unsigned int>
728  (parameters_vec.size());
729  const unsigned int Nq = this->n_qois();
730 
731  // For each quantity of interest q, the parameter sensitivity
732  // Hessian is defined as q''_{kl} = {d^2 q}/{d p_k d p_l}.
733  // Given a vector of parameter perturbation weights w_l, this
734  // function evaluates the hessian-vector product sum_l(q''_{kl}*w_l)
735  //
736  // We calculate it from values and partial derivatives of the
737  // quantity of interest function Q, solution u, adjoint solution z,
738  // parameter sensitivity adjoint solutions z^l, and residual R, as:
739  //
740  // sum_l(q''_{kl}*w_l) =
741  // sum_l(w_l * Q''_{kl}) + Q''_{uk}(u)*(sum_l(w_l u'_l)) -
742  // R'_k(u, sum_l(w_l*z^l)) - R'_{uk}(u,z)*(sum_l(w_l u'_l) -
743  // sum_l(w_l*R''_{kl}(u,z))
744  //
745  // See the adjoints model document for more details.
746 
747  // We first do an adjoint solve to get z for each quantity of
748  // interest
749  // if we haven't already or dont have an initial condition for the adjoint
750  if (!this->is_adjoint_already_solved())
751  {
752  this->adjoint_solve(qoi_indices);
753  }
754 
755  // Get ready to fill in sensitivities:
756  sensitivities.allocate_data(qoi_indices, *this, parameters_vec);
757 
758  // We can't solve for all the solution sensitivities u'_l or for all
759  // of the parameter sensitivity adjoint solutions z^l without
760  // requiring O(Nq*Np) linear solves. So we'll solve directly for their
761  // weighted sum - this is just O(Nq) solves.
762 
763  // First solve for sum_l(w_l u'_l).
764  this->weighted_sensitivity_solve(parameters_vec, vector);
765 
766  // Then solve for sum_l(w_l z^l).
767  this->weighted_sensitivity_adjoint_solve(parameters_vec, vector, qoi_indices);
768 
769  for (unsigned int k=0; k != Np; ++k)
770  {
771  // We approximate sum_l(w_l * Q''_{kl}) with a central
772  // differencing perturbation:
773  // sum_l(w_l * Q''_{kl}) ~=
774  // (Q(p + dp*w_l*e_l + dp*e_k) - Q(p - dp*w_l*e_l + dp*e_k) -
775  // Q(p + dp*w_l*e_l - dp*e_k) + Q(p - dp*w_l*e_l - dp*e_k))/(4*dp^2)
776 
777  // The sum(w_l*R''_kl) term requires the same sort of perturbation,
778  // and so we subtract it in at the same time:
779  // sum_l(w_l * R''_{kl}) ~=
780  // (R(p + dp*w_l*e_l + dp*e_k) - R(p - dp*w_l*e_l + dp*e_k) -
781  // R(p + dp*w_l*e_l - dp*e_k) + R(p - dp*w_l*e_l - dp*e_k))/(4*dp^2)
782 
783  ParameterVector oldparameters, parameterperturbation;
784  parameters_vec.deep_copy(oldparameters);
785  vector.deep_copy(parameterperturbation);
786  parameterperturbation *= delta_p;
787  parameters_vec += parameterperturbation;
788 
789  Number old_parameter = *parameters_vec[k];
790 
791  *parameters_vec[k] = old_parameter + delta_p;
792  this->assemble_qoi(qoi_indices);
793  this->assembly(true, false, true);
794  this->rhs->close();
795  std::vector<Number> partial2q_term = this->get_qoi_values();
796  std::vector<Number> partial2R_term(this->n_qois());
797  for (unsigned int i=0; i != Nq; ++i)
798  if (qoi_indices.has_index(i))
799  partial2R_term[i] = this->rhs->dot(this->get_adjoint_solution(i));
800 
801  *parameters_vec[k] = old_parameter - delta_p;
802  this->assemble_qoi(qoi_indices);
803  this->assembly(true, false, true);
804  this->rhs->close();
805  for (unsigned int i=0; i != Nq; ++i)
806  if (qoi_indices.has_index(i))
807  {
808  partial2q_term[i] -= this->get_qoi_value(i);
809  partial2R_term[i] -= this->rhs->dot(this->get_adjoint_solution(i));
810  }
811 
812  oldparameters.value_copy(parameters_vec);
813  parameterperturbation *= -1.0;
814  parameters_vec += parameterperturbation;
815 
816  // Re-center old_parameter, which may be affected by vector
817  old_parameter = *parameters_vec[k];
818 
819  *parameters_vec[k] = old_parameter + delta_p;
820  this->assemble_qoi(qoi_indices);
821  this->assembly(true, false, true);
822  this->rhs->close();
823  for (unsigned int i=0; i != Nq; ++i)
824  if (qoi_indices.has_index(i))
825  {
826  partial2q_term[i] -= this->get_qoi_value(i);
827  partial2R_term[i] -= this->rhs->dot(this->get_adjoint_solution(i));
828  }
829 
830  *parameters_vec[k] = old_parameter - delta_p;
831  this->assemble_qoi(qoi_indices);
832  this->assembly(true, false, true);
833  this->rhs->close();
834  for (unsigned int i=0; i != Nq; ++i)
835  if (qoi_indices.has_index(i))
836  {
837  partial2q_term[i] += this->get_qoi_value(i);
838  partial2R_term[i] += this->rhs->dot(this->get_adjoint_solution(i));
839  }
840 
841  for (unsigned int i=0; i != Nq; ++i)
842  if (qoi_indices.has_index(i))
843  {
844  partial2q_term[i] /= (4. * delta_p * delta_p);
845  partial2R_term[i] /= (4. * delta_p * delta_p);
846  }
847 
848  for (unsigned int i=0; i != Nq; ++i)
849  if (qoi_indices.has_index(i))
850  sensitivities[i][k] = partial2q_term[i] - partial2R_term[i];
851 
852  // We get (partial q / partial u), R, and
853  // (partial R / partial u) from the user, but centrally
854  // difference to get q_uk, R_k, and R_uk terms:
855  // (partial R / partial k)
856  // R_k*sum(w_l*z^l) = (R(p+dp*e_k)*sum(w_l*z^l) - R(p-dp*e_k)*sum(w_l*z^l))/(2*dp)
857  // (partial^2 q / partial u partial k)
858  // q_uk = (q_u(p+dp*e_k) - q_u(p-dp*e_k))/(2*dp)
859  // (partial^2 R / partial u partial k)
860  // R_uk*z*sum(w_l*u'_l) = (R_u(p+dp*e_k)*z*sum(w_l*u'_l) - R_u(p-dp*e_k)*z*sum(w_l*u'_l))/(2*dp)
861 
862  // To avoid creating Nq temporary vectors for q_uk or R_uk, we add
863  // subterms to the sensitivities output one by one.
864  //
865  // FIXME: this is probably a bad order of operations for
866  // controlling floating point error.
867 
868  *parameters_vec[k] = old_parameter + delta_p;
869  this->assembly(true, true);
870  this->rhs->close();
871  this->matrix->close();
872  this->assemble_qoi_derivative(qoi_indices,
873  /* include_liftfunc = */ true,
874  /* apply_constraints = */ false);
875 
876  this->matrix->vector_mult(*tempvec, this->get_weighted_sensitivity_solution());
877 
878  for (unsigned int i=0; i != Nq; ++i)
879  if (qoi_indices.has_index(i))
880  {
881  this->get_adjoint_rhs(i).close();
882  sensitivities[i][k] += (this->get_adjoint_rhs(i).dot(this->get_weighted_sensitivity_solution()) -
884  this->get_adjoint_solution(i).dot(*tempvec)) / (2.*delta_p);
885  }
886 
887  *parameters_vec[k] = old_parameter - delta_p;
888  this->assembly(true, true);
889  this->rhs->close();
890  this->matrix->close();
891  this->assemble_qoi_derivative(qoi_indices,
892  /* include_liftfunc = */ true,
893  /* apply_constraints = */ false);
894 
895  this->matrix->vector_mult(*tempvec, this->get_weighted_sensitivity_solution());
896 
897  for (unsigned int i=0; i != Nq; ++i)
898  if (qoi_indices.has_index(i))
899  {
900  this->get_adjoint_rhs(i).close();
901  sensitivities[i][k] += (-this->get_adjoint_rhs(i).dot(this->get_weighted_sensitivity_solution()) +
903  this->get_adjoint_solution(i).dot(*tempvec)) / (2.*delta_p);
904  }
905  }
906 
907  // All parameters have been reset.
908  // Don't leave the qoi or system changed - principle of least
909  // surprise.
910  this->assembly(true, true);
911  this->rhs->close();
912  this->matrix->close();
913  this->assemble_qoi(qoi_indices);
914 }
static constexpr Real TOLERANCE
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...
Number get_qoi_value(unsigned int qoi_index) const
Definition: system.C:2386
unsigned int n_qois() const
Number of currently active quantities of interest.
Definition: system.h:2621
virtual std::pair< unsigned int, Real > weighted_sensitivity_solve(const ParameterVector &parameters, const ParameterVector &weights) override
Assembles & solves the linear system(s) (dR/du)*u_w = sum(w_p*-dR/dp), for those parameters p contain...
NumericVector< Number > * rhs
The system matrix.
virtual T dot(const NumericVector< T > &v) const =0
virtual std::pair< unsigned int, Real > adjoint_solve(const QoISet &qoi_indices=QoISet()) override
Assembles & solves the linear system (dR/du)^T*z = dq/du, for those quantities of interest q specifie...
NumericVector< Number > & get_weighted_sensitivity_solution()
Definition: system.C:1219
virtual void assembly(bool, bool, bool=false, bool=false)
Assembles a residual in rhs and/or a jacobian in matrix, as requested.
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
bool is_adjoint_already_solved() const
Accessor for the adjoint_already_solved boolean.
Definition: system.h:409
virtual void close()=0
Calls the NumericVector&#39;s internal assembly routines, ensuring that the values are consistent across ...
virtual void close()=0
Calls the SparseMatrix&#39;s internal assembly routines, ensuring that the values are consistent across p...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
SparseMatrix< Number > * matrix
The system matrix.
virtual void assemble_qoi(const QoISet &qoi_indices=QoISet()) override
Prepares qoi for quantity of interest assembly, then calls user qoi function.
virtual void assemble_qoi_derivative(const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true) override
Prepares adjoint_rhs for quantity of interest derivative assembly, then calls user qoi derivative fun...
NumericVector< Number > & get_adjoint_solution(unsigned int i=0)
Definition: system.C:1245
virtual std::pair< unsigned int, Real > weighted_sensitivity_adjoint_solve(const ParameterVector &parameters, const ParameterVector &weights, const QoISet &qoi_indices=QoISet()) override
Assembles & solves the linear system(s) (dR/du)^T*z_w = sum(w_p*(d^2q/dudp - d^2R/dudp*z)), for those parameters p contained within parameters, weighted by the values w_p found within weights.
NumericVector< Number > & get_weighted_sensitivity_adjoint_solution(unsigned int i=0)
Definition: system.C:1277
std::vector< Number > get_qoi_values() const
Returns a copy of qoi, not a reference.
Definition: system.C:2393
NumericVector< Number > & get_adjoint_rhs(unsigned int i=0)
Definition: system.C:1307

◆ qoi_parameter_sensitivity()

void libMesh::System::qoi_parameter_sensitivity ( const QoISet qoi_indices,
const ParameterVector parameters,
SensitivityData sensitivities 
)
virtualinherited

Solves for the derivative of each of the system's quantities of interest q in qoi[qoi_indices] with respect to each parameter in parameters, placing the result for qoi i and parameter j into sensitivities[i][j].

Note
parameters is a const vector, not a vector-of-const; parameter values in this vector need to be mutable for finite differencing to work.

Automatically chooses the forward method for problems with more quantities of interest than parameters, or the adjoint method otherwise.

This method is only usable in derived classes which override an implementation.

Definition at line 602 of file system.C.

References libMesh::System::adjoint_qoi_parameter_sensitivity(), libMesh::System::forward_qoi_parameter_sensitivity(), libMesh::ParameterVector::size(), and libMesh::QoISet::size().

605 {
606  // Forward sensitivities are more efficient for Nq > Np
607  if (qoi_indices.size(*this) > parameters_vec.size())
608  forward_qoi_parameter_sensitivity(qoi_indices, parameters_vec, sensitivities);
609  // Adjoint sensitivities are more efficient for Np > Nq,
610  // and an adjoint may be more reusable than a forward
611  // solution sensitivity in the Np == Nq case.
612  else
613  adjoint_qoi_parameter_sensitivity(qoi_indices, parameters_vec, sensitivities);
614 }
virtual void forward_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
Solves for parameter sensitivities using the forward method.
Definition: system.h:2672
virtual void adjoint_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
Solves for parameter sensitivities using the adjoint method.
Definition: system.h:2663

◆ re_update()

void libMesh::TransientSystem< RBConstruction >::re_update ( )
overrideprotectedvirtualinherited

Re-update the local values when the mesh has changed.

This method takes the data updated by update() and makes it up-to-date on the current mesh.

Reimplemented from libMesh::System.

Definition at line 76 of file transient_system.C.

77 {
78  // re_update the parent system
79  Base::re_update ();
80 
81  const std::vector<dof_id_type> & send_list = this->get_dof_map().get_send_list ();
82 
83  const dof_id_type first_local_dof = Base::get_dof_map().first_dof();
84  const dof_id_type end_local_dof = Base::get_dof_map().end_dof();
85 
86  // Check sizes
87  libmesh_assert_greater_equal (end_local_dof, first_local_dof);
88  libmesh_assert_greater_equal (older_local_solution->size(), send_list.size());
89  libmesh_assert_greater_equal (old_local_solution->size(), send_list.size());
90 
91  // Even if we don't have to do anything ourselves, localize() may
92  // use parallel_only tools
93  // if (first_local_dof == end_local_dof)
94  // return;
95 
96  // Update the old & older solutions with the send_list,
97  // which may have changed since their last update.
98  older_local_solution->localize (first_local_dof,
99  end_local_dof-1,
100  send_list);
101 
102  old_local_solution->localize (first_local_dof,
103  end_local_dof-1,
104  send_list);
105 }
virtual numeric_index_type size() const =0
NumericVector< Number > * old_local_solution
All the values I need to compute my contribution to the simulation at hand.
NumericVector< Number > * older_local_solution
All the values I need to compute my contribution to the simulation at hand.
const DofMap & get_dof_map() const
Definition: system.h:2374
const std::vector< dof_id_type > & get_send_list() const
Definition: dof_map.h:526
uint8_t dof_id_type
Definition: id_types.h:67
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.

◆ read_header()

void libMesh::System::read_header ( Xdr io,
std::string_view  version,
const bool  read_header = true,
const bool  read_additional_data = true,
const bool  read_legacy_format = false 
)
inherited

Reads the basic data header for this System.

Definition at line 97 of file system_io.C.

References libMesh::System::_additional_data_written, libMesh::System::_written_var_indices, libMesh::System::add_variable(), libMesh::System::add_vector(), TIMPI::Communicator::broadcast(), libMesh::System::clear(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::FEType::family, libMesh::System::get_mesh(), libMesh::OrderWrapper::get_order(), libMesh::FEType::inf_map, libMesh::libmesh_assert(), libMesh::MeshBase::mesh_dimension(), libMesh::MONOMIAL, libMesh::on_command_line(), libMesh::FEType::order, libMesh::out, libMesh::ParallelObject::processor_id(), libMesh::FEType::radial_family, libMesh::FEType::radial_order, libMesh::Xdr::reading(), libMesh::System::variable_number(), libMesh::Xdr::version(), and libMesh::XYZ.

Referenced by libMesh::EquationSystems::read(), and libMesh::RBEvaluation::read_in_vectors_from_multiple_files().

102 {
103  // This method implements the input of a
104  // System object, embedded in the output of
105  // an EquationSystems<T_sys>. This warrants some
106  // documentation. The output file essentially
107  // consists of 5 sections:
108  //
109  // for this system
110  //
111  // 5.) The number of variables in the system (unsigned int)
112  //
113  // for each variable in the system
114  //
115  // 6.) The name of the variable (string)
116  //
117  // 6.1.) Variable subdomains
118  //
119  // 7.) Combined in an FEType:
120  // - The approximation order(s) of the variable
121  // (Order Enum, cast to int/s)
122  // - The finite element family/ies of the variable
123  // (FEFamily Enum, cast to int/s)
124  //
125  // end variable loop
126  //
127  // 8.) The number of additional vectors (unsigned int),
128  //
129  // for each additional vector in the system object
130  //
131  // 9.) the name of the additional vector (string)
132  //
133  // end system
134  libmesh_assert (io.reading());
135 
136  // Possibly clear data structures and start from scratch.
137  if (read_header_in)
138  this->clear ();
139 
140  // Figure out if we need to read infinite element information.
141  // This will be true if the version string contains " with infinite elements"
142  const bool read_ifem_info =
143  (version.rfind(" with infinite elements") < version.size()) ||
144  libMesh::on_command_line ("--read-ifem-systems");
145 
146 
147  {
148  // 5.)
149  // Read the number of variables in the system
150  unsigned int nv=0;
151  if (this->processor_id() == 0)
152  io.data (nv);
153  this->comm().broadcast(nv);
154 
155  _written_var_indices.clear();
156  _written_var_indices.resize(nv, 0);
157 
158  for (unsigned int var=0; var<nv; var++)
159  {
160  // 6.)
161  // Read the name of the var-th variable
162  std::string var_name;
163  if (this->processor_id() == 0)
164  io.data (var_name);
165  this->comm().broadcast(var_name);
166 
167  // 6.1.)
168  std::set<subdomain_id_type> domains;
169  if (io.version() >= LIBMESH_VERSION_ID(0,7,2))
170  {
171  std::vector<subdomain_id_type> domain_array;
172  if (this->processor_id() == 0)
173  io.data (domain_array);
174  for (const auto & id : domain_array)
175  domains.insert(id);
176  }
177  this->comm().broadcast(domains);
178 
179  // 7.)
180  // Read the approximation order(s) of the var-th variable
181  int order=0;
182  if (this->processor_id() == 0)
183  io.data (order);
184  this->comm().broadcast(order);
185 
186 
187  // do the same for infinite element radial_order
188  int rad_order=0;
189  if (read_ifem_info)
190  {
191  if (this->processor_id() == 0)
192  io.data(rad_order);
193  this->comm().broadcast(rad_order);
194  }
195 
196  // Read the finite element type of the var-th variable
197  int fam=0;
198  if (this->processor_id() == 0)
199  io.data (fam);
200  this->comm().broadcast(fam);
201  FEType type;
202  type.order = static_cast<Order>(order);
203  type.family = static_cast<FEFamily>(fam);
204 
205  // Check for incompatibilities. The shape function indexing was
206  // changed for the monomial and xyz finite element families to
207  // simplify extension to arbitrary p. The consequence is that
208  // old restart files will not be read correctly. This is expected
209  // to be an unlikely occurrence, but catch it anyway.
210  if (read_legacy_format)
211  if ((type.family == MONOMIAL || type.family == XYZ) &&
212  ((type.order.get_order() > 2 && this->get_mesh().mesh_dimension() == 2) ||
213  (type.order.get_order() > 1 && this->get_mesh().mesh_dimension() == 3)))
214  {
215  libmesh_here();
216  libMesh::out << "*****************************************************************\n"
217  << "* WARNING: reading a potentially incompatible restart file!!! *\n"
218  << "* contact [email protected] for more details *\n"
219  << "*****************************************************************"
220  << std::endl;
221  }
222 
223  // Read additional information for infinite elements
224  int radial_fam=0;
225  int i_map=0;
226  if (read_ifem_info)
227  {
228  if (this->processor_id() == 0)
229  io.data (radial_fam);
230  this->comm().broadcast(radial_fam);
231  if (this->processor_id() == 0)
232  io.data (i_map);
233  this->comm().broadcast(i_map);
234  }
235 
236 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
237 
238  type.radial_order = static_cast<Order>(rad_order);
239  type.radial_family = static_cast<FEFamily>(radial_fam);
240  type.inf_map = static_cast<InfMapType>(i_map);
241 
242 #endif
243 
244  if (read_header_in)
245  {
246  if (domains.empty())
247  _written_var_indices[var] = this->add_variable (var_name, type);
248  else
249  _written_var_indices[var] = this->add_variable (var_name, type, &domains);
250  }
251  else
252  _written_var_indices[var] = this->variable_number(var_name);
253  }
254  }
255 
256  // 8.)
257  // Read the number of additional vectors.
258  unsigned int nvecs=0;
259  if (this->processor_id() == 0)
260  io.data (nvecs);
261  this->comm().broadcast(nvecs);
262 
263  // If nvecs > 0, this means that write_additional_data
264  // was true when this file was written. We will need to
265  // make use of this fact later.
266  this->_additional_data_written = nvecs;
267 
268  for (unsigned int vec=0; vec<nvecs; vec++)
269  {
270  // 9.)
271  // Read the name of the vec-th additional vector
272  std::string vec_name;
273  if (this->processor_id() == 0)
274  io.data (vec_name);
275  this->comm().broadcast(vec_name);
276  if (io.version() >= LIBMESH_VERSION_ID(1,7,0))
277  {
278  int vec_projection = 0;
279  if (this->processor_id() == 0)
280  io.data (vec_projection);
281  this->comm().broadcast(vec_projection);
282  int vec_type;
283  if (this->processor_id() == 0)
284  io.data (vec_type);
285  this->comm().broadcast(vec_type);
286 
287  if (read_additional_data)
288  this->add_vector(vec_name, bool(vec_projection), ParallelType(vec_type));
289  }
290  else if (read_additional_data)
291  // Systems now can handle adding post-initialization vectors
292  // libmesh_assert(this->_can_add_vectors);
293  // Some systems may have added their own vectors already
294  // libmesh_assert_equal_to (this->_vectors.count(vec_name), 0);
295  this->add_vector(vec_name);
296  }
297 }
virtual void clear()
Clear all the data structures associated with the system.
Definition: system.C:176
Order
defines an enum for polynomial orders.
Definition: enum_order.h:40
const Parallel::Communicator & comm() const
NumericVector< Number > & add_vector(std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Adds the additional vector vec_name to this system.
Definition: system.C:768
const MeshBase & get_mesh() const
Definition: system.h:2358
unsigned int variable_number(std::string_view var) const
Definition: system.C:1609
libmesh_assert(ctx)
unsigned int _additional_data_written
This flag is used only when reading in a system from file.
Definition: system.h:2289
unsigned int add_variable(std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system.
Definition: system.C:1357
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
InfMapType
defines an enum for the types of coordinate mappings available in infinite elements.
OStreamProxy out
unsigned int mesh_dimension() const
Definition: mesh_base.C:372
bool on_command_line(std::string arg)
Definition: libmesh.C:987
FEFamily
defines an enum for finite element families.
processor_id_type processor_id() const
std::vector< unsigned int > _written_var_indices
This vector is used only when reading in a system from file.
Definition: system.h:2301
ParallelType
Defines an enum for parallel data structure types.

◆ read_legacy_data()

void libMesh::System::read_legacy_data ( Xdr io,
const bool  read_additional_data = true 
)
inherited

Reads additional data, namely vectors, for this System.

Deprecated:
The ability to read XDR data files in the old (aka "legacy") XDR format has been deprecated for many years, this capability may soon disappear altogether.

Definition at line 302 of file system_io.C.

References libMesh::System::_additional_data_written, libMesh::System::_vectors, libMesh::System::_written_var_indices, TIMPI::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::System::get_mesh(), libMesh::DofObject::invalid_id, libMesh::libmesh_assert(), libMesh::make_range(), libMesh::System::n_dofs(), libMesh::System::n_vars(), libMesh::System::number(), libMesh::ParallelObject::processor_id(), libMesh::Xdr::reading(), libMesh::System::solution, and libMesh::zero.

304 {
305  libmesh_deprecated();
306 
307  // This method implements the output of the vectors
308  // contained in this System object, embedded in the
309  // output of an EquationSystems<T_sys>.
310  //
311  // 10.) The global solution vector, re-ordered to be node-major
312  // (More on this later.)
313  //
314  // for each additional vector in the object
315  //
316  // 11.) The global additional vector, re-ordered to be
317  // node-major (More on this later.)
318  libmesh_assert (io.reading());
319 
320  // directly-read and reordered buffers, declared here for reuse
321  // without heap juggling.
322  std::vector<Number> global_vector;
323  std::vector<Number> reordered_vector;
324 
325  auto reorder_vector_into =
326  [this, &global_vector, &reordered_vector]
327  (NumericVector<Number> & vec)
328  {
329  this->comm().broadcast(global_vector);
330 
331  // If we have been reading multiple vectors, they should all be
332  // the same size.
333  libmesh_assert (reordered_vector.empty() ||
334  reordered_vector.size() == global_vector.size());
335 
336  // Remember that the stored vector is node-major.
337  // We need to put it into whatever application-specific
338  // ordering we may have using the dof_map.
339  reordered_vector.resize(global_vector.size());
340 
341  //libMesh::out << "global_vector.size()=" << global_vector.size() << std::endl;
342  //libMesh::out << "this->n_dofs()=" << this->n_dofs() << std::endl;
343 
344  libmesh_assert_equal_to (global_vector.size(), this->n_dofs());
345 
346  dof_id_type cnt=0;
347 
348  const unsigned int sys = this->number();
349  const unsigned int nv = cast_int<unsigned int>
350  (this->_written_var_indices.size());
351  libmesh_assert_less_equal (nv, this->n_vars());
352 
353  for (unsigned int data_var=0; data_var<nv; data_var++)
354  {
355  const unsigned int var = _written_var_indices[data_var];
356 
357  // First reorder the nodal DOF values
358  for (auto & node : this->get_mesh().node_ptr_range())
359  for (auto index : make_range(node->n_comp(sys,var)))
360  {
361  libmesh_assert_not_equal_to (node->dof_number(sys, var, index),
363 
364  libmesh_assert_less (cnt, global_vector.size());
365 
366  reordered_vector[node->dof_number(sys, var, index)] =
367  global_vector[cnt++];
368  }
369 
370  // Then reorder the element DOF values
371  for (auto & elem : this->get_mesh().active_element_ptr_range())
372  for (auto index : make_range(elem->n_comp(sys,var)))
373  {
374  libmesh_assert_not_equal_to (elem->dof_number(sys, var, index),
376 
377  libmesh_assert_less (cnt, global_vector.size());
378 
379  reordered_vector[elem->dof_number(sys, var, index)] =
380  global_vector[cnt++];
381  }
382  }
383 
384  // use the overloaded operator=(std::vector) to assign the values
385  vec = reordered_vector;
386  };
387 
388  // 10.)
389  // Read and set the solution vector
390  if (this->processor_id() == 0)
391  io.data (global_vector);
392  reorder_vector_into(*(this->solution));
393 
394  // For each additional vector, simply go through the list.
395  // ONLY attempt to do this IF additional data was actually
396  // written to the file for this system (controlled by the
397  // _additional_data_written flag).
398  if (this->_additional_data_written)
399  {
400  const std::size_t nvecs = this->_vectors.size();
401 
402  // If the number of additional vectors written is non-zero, and
403  // the number of additional vectors we have is non-zero, and
404  // they don't match, then something is wrong and we can't be
405  // sure we're reading data into the correct places.
406  if (read_additional_data && nvecs &&
407  nvecs != this->_additional_data_written)
408  libmesh_error_msg
409  ("Additional vectors in file do not match system");
410 
411  auto pos = this->_vectors.begin();
412 
413  for (std::size_t i = 0; i != this->_additional_data_written; ++i)
414  {
415  // 11.)
416  // Read the values of the vec-th additional vector.
417  // Prior do _not_ clear, but fill with zero, since the
418  // additional vectors _have_ to have the same size
419  // as the solution vector
420  std::fill (global_vector.begin(), global_vector.end(), libMesh::zero);
421 
422  if (this->processor_id() == 0)
423  io.data (global_vector);
424 
425  // If read_additional_data==true and we have additional vectors,
426  // then we will keep this vector data; otherwise we are going to
427  // throw it away.
428  if (read_additional_data && nvecs)
429  {
430  std::fill (reordered_vector.begin(),
431  reordered_vector.end(),
432  libMesh::zero);
433 
434  reorder_vector_into(*(pos->second));
435  }
436 
437  // If we've got vectors then we need to be iterating through
438  // those too
439  if (pos != this->_vectors.end())
440  ++pos;
441  }
442  } // end if (_additional_data_written)
443 }
const Parallel::Communicator & comm() const
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2230
const Number zero
.
Definition: libmesh.h:304
const MeshBase & get_mesh() const
Definition: system.h:2358
dof_id_type n_dofs() const
Definition: system.C:121
unsigned int number() const
Definition: system.h:2350
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
libmesh_assert(ctx)
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:482
unsigned int _additional_data_written
This flag is used only when reading in a system from file.
Definition: system.h:2289
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
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...
Definition: int_range.h:140
unsigned int n_vars() const
Definition: system.h:2430
processor_id_type processor_id() const
template class LIBMESH_EXPORT NumericVector< Number >
std::vector< unsigned int > _written_var_indices
This vector is used only when reading in a system from file.
Definition: system.h:2301
uint8_t dof_id_type
Definition: id_types.h:67

◆ read_parallel_data() [1/2]

template<typename InValType >
void libMesh::System::read_parallel_data ( Xdr io,
const bool  read_additional_data 
)
inherited

Reads additional data, namely vectors, for this System.

This method may safely be called on a distributed-memory mesh. This method will read an individual file for each processor in the simulation where the local solution components for that processor are stored.

This method implements the output of the vectors contained in this System object, embedded in the output of an EquationSystems<T_sys>.

9.) The global solution vector, re-ordered to be node-major (More on this later.)

for each additional vector in the object

10.) The global additional vector, re-ordered to be node-major (More on this later.)

Note that the actual IO is handled through the Xdr class (to be renamed later?) which provides a uniform interface to both the XDR (eXternal Data Representation) interface and standard ASCII output. Thus this one section of code will read XDR or ASCII files with no changes.

Definition at line 449 of file system_io.C.

References libMesh::System::_additional_data_written, libMesh::System::_vectors, libMesh::System::_written_var_indices, libMesh::Xdr::data(), libMesh::FEType::family, libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::DofObject::invalid_id, libMesh::Xdr::is_open(), libMesh::libmesh_assert(), libMesh::make_range(), libMesh::ParallelObject::n_processors(), libMesh::System::n_vars(), libMesh::System::number(), libMesh::ParallelObject::processor_id(), libMesh::Xdr::reading(), libMesh::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), libMesh::System::solution, libMesh::Variable::type(), and libMesh::System::variable().

451 {
471  // PerfLog pl("IO Performance",false);
472  // pl.push("read_parallel_data");
473  dof_id_type total_read_size = 0;
474 
475  libmesh_assert (io.reading());
476  libmesh_assert (io.is_open());
477 
478  // build the ordered nodes and element maps.
479  // when writing/reading parallel files we need to iterate
480  // over our nodes/elements in order of increasing global id().
481  // however, this is not guaranteed to be ordering we obtain
482  // by using the node_iterators/element_iterators directly.
483  // so build a set, sorted by id(), that provides the ordering.
484  // further, for memory economy build the set but then transfer
485  // its contents to vectors, which will be sorted.
486  std::vector<const DofObject *> ordered_nodes, ordered_elements;
487  {
488  std::set<const DofObject *, CompareDofObjectsByID>
489  ordered_nodes_set (this->get_mesh().local_nodes_begin(),
490  this->get_mesh().local_nodes_end());
491 
492  ordered_nodes.insert(ordered_nodes.end(),
493  ordered_nodes_set.begin(),
494  ordered_nodes_set.end());
495  }
496  {
497  std::set<const DofObject *, CompareDofObjectsByID>
498  ordered_elements_set (this->get_mesh().local_elements_begin(),
499  this->get_mesh().local_elements_end());
500 
501  ordered_elements.insert(ordered_elements.end(),
502  ordered_elements_set.begin(),
503  ordered_elements_set.end());
504  }
505 
506  // std::vector<Number> io_buffer;
507  std::vector<InValType> io_buffer;
508 
509  // 9.)
510  //
511  // Actually read the solution components
512  // for the ith system to disk
513  io.data(io_buffer);
514 
515  total_read_size += cast_int<dof_id_type>(io_buffer.size());
516 
517  const unsigned int sys_num = this->number();
518  const unsigned int nv = cast_int<unsigned int>
519  (this->_written_var_indices.size());
520  libmesh_assert_less_equal (nv, this->n_vars());
521 
522  dof_id_type cnt=0;
523 
524  // Loop over each non-SCALAR variable and each node, and read out the value.
525  for (unsigned int data_var=0; data_var<nv; data_var++)
526  {
527  const unsigned int var = _written_var_indices[data_var];
528  if (this->variable(var).type().family != SCALAR)
529  {
530  // First read the node DOF values
531  for (const auto & node : ordered_nodes)
532  for (auto comp : make_range(node->n_comp(sys_num,var)))
533  {
534  libmesh_assert_not_equal_to (node->dof_number(sys_num, var, comp),
536  libmesh_assert_less (cnt, io_buffer.size());
537  this->solution->set(node->dof_number(sys_num, var, comp), io_buffer[cnt++]);
538  }
539 
540  // Then read the element DOF values
541  for (const auto & elem : ordered_elements)
542  for (auto comp : make_range(elem->n_comp(sys_num,var)))
543  {
544  libmesh_assert_not_equal_to (elem->dof_number(sys_num, var, comp),
546  libmesh_assert_less (cnt, io_buffer.size());
547  this->solution->set(elem->dof_number(sys_num, var, comp), io_buffer[cnt++]);
548  }
549  }
550  }
551 
552  // Finally, read the SCALAR variables on the last processor
553  for (unsigned int data_var=0; data_var<nv; data_var++)
554  {
555  const unsigned int var = _written_var_indices[data_var];
556  if (this->variable(var).type().family == SCALAR)
557  {
558  if (this->processor_id() == (this->n_processors()-1))
559  {
560  const DofMap & dof_map = this->get_dof_map();
561  std::vector<dof_id_type> SCALAR_dofs;
562  dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
563 
564  for (auto dof : SCALAR_dofs)
565  this->solution->set(dof, io_buffer[cnt++]);
566  }
567  }
568  }
569 
570  // And we're done setting solution entries
571  this->solution->close();
572 
573  // For each additional vector, simply go through the list.
574  // ONLY attempt to do this IF additional data was actually
575  // written to the file for this system (controlled by the
576  // _additional_data_written flag).
577  if (this->_additional_data_written)
578  {
579  const std::size_t nvecs = this->_vectors.size();
580 
581  // If the number of additional vectors written is non-zero, and
582  // the number of additional vectors we have is non-zero, and
583  // they don't match, then something is wrong and we can't be
584  // sure we're reading data into the correct places.
585  if (read_additional_data && nvecs &&
586  nvecs != this->_additional_data_written)
587  libmesh_error_msg
588  ("Additional vectors in file do not match system");
589 
590  auto pos = _vectors.begin();
591 
592  for (std::size_t i = 0; i != this->_additional_data_written; ++i)
593  {
594  cnt=0;
595  io_buffer.clear();
596 
597  // 10.)
598  //
599  // Actually read the additional vector components
600  // for the ith system from disk
601  io.data(io_buffer);
602 
603  total_read_size += cast_int<dof_id_type>(io_buffer.size());
604 
605  // If read_additional_data==true and we have additional vectors,
606  // then we will keep this vector data; otherwise we are going to
607  // throw it away.
608  if (read_additional_data && nvecs)
609  {
610  // Loop over each non-SCALAR variable and each node, and read out the value.
611  for (unsigned int data_var=0; data_var<nv; data_var++)
612  {
613  const unsigned int var = _written_var_indices[data_var];
614  if (this->variable(var).type().family != SCALAR)
615  {
616  // First read the node DOF values
617  for (const auto & node : ordered_nodes)
618  for (auto comp : make_range(node->n_comp(sys_num,var)))
619  {
620  libmesh_assert_not_equal_to (node->dof_number(sys_num, var, comp),
622  libmesh_assert_less (cnt, io_buffer.size());
623  pos->second->set(node->dof_number(sys_num, var, comp), io_buffer[cnt++]);
624  }
625 
626  // Then read the element DOF values
627  for (const auto & elem : ordered_elements)
628  for (auto comp : make_range(elem->n_comp(sys_num,var)))
629  {
630  libmesh_assert_not_equal_to (elem->dof_number(sys_num, var, comp),
632  libmesh_assert_less (cnt, io_buffer.size());
633  pos->second->set(elem->dof_number(sys_num, var, comp), io_buffer[cnt++]);
634  }
635  }
636  }
637 
638  // Finally, read the SCALAR variables on the last processor
639  for (unsigned int data_var=0; data_var<nv; data_var++)
640  {
641  const unsigned int var = _written_var_indices[data_var];
642  if (this->variable(var).type().family == SCALAR)
643  {
644  if (this->processor_id() == (this->n_processors()-1))
645  {
646  const DofMap & dof_map = this->get_dof_map();
647  std::vector<dof_id_type> SCALAR_dofs;
648  dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
649 
650  for (auto dof : SCALAR_dofs)
651  pos->second->set(dof, io_buffer[cnt++]);
652  }
653  }
654  }
655 
656  // And we're done setting entries for this variable
657  pos->second->close();
658  }
659 
660  // If we've got vectors then we need to be iterating through
661  // those too
662  if (pos != this->_vectors.end())
663  ++pos;
664  }
665  }
666 
667  // const Real
668  // dt = pl.get_elapsed_time(),
669  // rate = total_read_size*sizeof(Number)/dt;
670 
671  // libMesh::err << "Read " << total_read_size << " \"Number\" values\n"
672  // << " Elapsed time = " << dt << '\n'
673  // << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";
674 
675  // pl.pop("read_parallel_data");
676 }
FEFamily family
The type of finite element.
Definition: fe_type.h:221
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2458
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2230
const MeshBase & get_mesh() const
Definition: system.h:2358
processor_id_type n_processors() const
unsigned int number() const
Definition: system.h:2350
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
libmesh_assert(ctx)
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:482
unsigned int _additional_data_written
This flag is used only when reading in a system from file.
Definition: system.h:2289
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...
Definition: int_range.h:140
unsigned int n_vars() const
Definition: system.h:2430
processor_id_type processor_id() const
const DofMap & get_dof_map() const
Definition: system.h:2374
std::vector< unsigned int > _written_var_indices
This vector is used only when reading in a system from file.
Definition: system.h:2301
uint8_t dof_id_type
Definition: id_types.h:67
const FEType & type() const
Definition: variable.h:144

◆ read_parallel_data() [2/2]

template LIBMESH_EXPORT void libMesh::System::read_parallel_data< Real > ( Xdr io,
const bool  read_additional_data 
)
inlineinherited

Non-templated version for backward compatibility.

Reads additional data, namely vectors, for this System. This method may safely be called on a distributed-memory mesh. This method will read an individual file for each processor in the simulation where the local solution components for that processor are stored.

Definition at line 1350 of file system.h.

1352  { read_parallel_data<Number>(io, read_additional_data); }

◆ read_parameter_data_from_files()

void libMesh::RBParametrized::read_parameter_data_from_files ( const std::string &  continuous_param_file_name,
const std::string &  discrete_param_file_name,
const bool  read_binary_data 
)
inherited

Read in the parameter ranges from files.

Definition at line 276 of file rb_parametrized.C.

References libMesh::RBParametrized::initialize_parameters(), libMesh::RBParametrized::read_discrete_parameter_values_from_file(), and libMesh::RBParametrized::read_parameter_ranges_from_file().

Referenced by libMesh::RBSCMEvaluation::legacy_read_offline_data_from_files(), and libMesh::RBEvaluation::legacy_read_offline_data_from_files().

279 {
280  RBParameters param_min;
281  RBParameters param_max;
282  read_parameter_ranges_from_file(continuous_param_file_name,
283  read_binary_data,
284  param_min,
285  param_max);
286 
287  std::map<std::string, std::vector<Real>> discrete_parameter_values_in;
288  read_discrete_parameter_values_from_file(discrete_param_file_name,
289  read_binary_data,
290  discrete_parameter_values_in);
291 
292  initialize_parameters(param_min, param_max, discrete_parameter_values_in);
293 }
void read_parameter_ranges_from_file(const std::string &file_name, const bool read_binary, RBParameters &param_min, RBParameters &param_max)
Read in the parameter ranges from file.
void read_discrete_parameter_values_from_file(const std::string &file_name, const bool read_binary_data, std::map< std::string, std::vector< Real >> &discrete_parameter_values_in)
Read in the discrete parameter values from file, if we have any.
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.

◆ read_riesz_representors_from_files()

void TransientRBConstruction::read_riesz_representors_from_files ( const std::string &  riesz_representors_dir,
const bool  write_binary_residual_representors 
)
overridevirtual

Write out all the Riesz representor data to files.

Override to read in transient data too.

Reimplemented from libMesh::RBConstruction.

Definition at line 1293 of file transient_rb_construction.C.

References libMesh::NumericVector< T >::build(), libMesh::ParallelObject::comm(), libMesh::DECODE, libMesh::RBConstruction::get_rb_evaluation(), libMesh::System::n_dofs(), libMesh::System::n_local_dofs(), libMesh::out, libMesh::PARALLEL, libMesh::ParallelObject::processor_id(), libMesh::READ, libMesh::System::read_serialized_data(), and libMesh::System::solution.

1295 {
1296  LOG_SCOPE("read_riesz_representors_from_files()", "TransientRBConstruction");
1297 
1298  const std::string riesz_representor_suffix =
1299  (read_binary_residual_representors ? ".xdr" : ".dat");
1300 
1301  std::ostringstream file_name;
1302  struct stat stat_info;
1303 
1304  TransientRBEvaluation & trans_rb_eval = cast_ref<TransientRBEvaluation &>(get_rb_evaluation());
1305 
1306  libMesh::out << "Reading in the M_q_representors..." << std::endl;
1307 
1308  // Read in the Aq representors. The class makes room for [Q_m][Nmax] of these. We are going to
1309  // read in [Q_m][this->rb_eval->get_n_basis_functions()]. FIXME:
1310  // should we be worried about leaks in the locations where we're about to fill entries?
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.");
1315 
1316  // Now ready to read them 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)
1319  {
1320  file_name.str(""); // reset filename
1321  file_name << riesz_representors_dir
1322  << "/M_q_representor" << i << "_" << j << riesz_representor_suffix;
1323 
1324  // On processor zero check to be sure the file exists
1325  if (this->processor_id() == 0)
1326  {
1327  int stat_result = stat(file_name.str().c_str(), &stat_info);
1328 
1329  libmesh_error_msg_if(stat_result != 0, "File does not exist: " << file_name.str());
1330  }
1331 
1332  Xdr aqr_data(file_name.str(),
1333  read_binary_residual_representors ? DECODE : READ);
1334 
1335  read_serialized_data(aqr_data, false);
1336 
1337  trans_rb_eval.M_q_representor[i][j] = NumericVector<Number>::build(this->comm());
1338  trans_rb_eval.M_q_representor[i][j]->init (n_dofs(), n_local_dofs(),
1339  false, PARALLEL);
1340 
1341  // No need to copy, just swap
1342  //*M_q_representor[i][j] = *solution;
1343  trans_rb_eval.M_q_representor[i][j]->swap(*solution);
1344  }
1345 }
const Parallel::Communicator & comm() const
dof_id_type n_local_dofs() const
Definition: system.C:158
dof_id_type n_dofs() const
Definition: system.C:121
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
OStreamProxy out
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...
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.
processor_id_type processor_id() const
void read_serialized_data(Xdr &io, const bool read_additional_data=true)
Reads additional data, namely vectors, for this System.
Definition: system_io.C:680

◆ read_serialized_data() [1/2]

template<typename InValType >
void libMesh::System::read_serialized_data ( Xdr io,
const bool  read_additional_data = true 
)
inherited

Reads additional data, namely vectors, for this System.

This method may safely be called on a distributed-memory mesh.

Definition at line 680 of file system_io.C.

References libMesh::System::_additional_data_written, libMesh::System::_vectors, libMesh::ParallelObject::processor_id(), and libMesh::System::solution.

Referenced by initialize_truth(), read_riesz_representors_from_files(), and libMesh::RBConstruction::read_riesz_representors_from_files().

682 {
683  // This method implements the input of the vectors
684  // contained in this System object, embedded in the
685  // output of an EquationSystems<T_sys>.
686  //
687  // 10.) The global solution vector, re-ordered to be node-major
688  // (More on this later.)
689  //
690  // for each additional vector in the object
691  //
692  // 11.) The global additional vector, re-ordered to be
693  // node-major (More on this later.)
694  parallel_object_only();
695  std::string comment;
696 
697  // PerfLog pl("IO Performance",false);
698  // pl.push("read_serialized_data");
699  // std::size_t total_read_size = 0;
700 
701  // 10.)
702  // Read the global solution vector
703  {
704  // total_read_size +=
705  this->read_serialized_vector<InValType>(io, this->solution.get());
706 
707  // get the comment
708  if (this->processor_id() == 0)
709  io.comment (comment);
710  }
711 
712  // 11.)
713  // Only read additional vectors if data is available, and only use
714  // that data to fill our vectors if the user requested it.
715  if (this->_additional_data_written)
716  {
717  const std::size_t nvecs = this->_vectors.size();
718 
719  // If the number of additional vectors written is non-zero, and
720  // the number of additional vectors we have is non-zero, and
721  // they don't match, then we can't read additional vectors
722  // and be sure we're reading data into the correct places.
723  if (read_additional_data && nvecs &&
724  nvecs != this->_additional_data_written)
725  libmesh_error_msg
726  ("Additional vectors in file do not match system");
727 
728  auto pos = _vectors.begin();
729 
730  for (std::size_t i = 0; i != this->_additional_data_written; ++i)
731  {
732  // Read data, but only put it into a vector if we've been
733  // asked to and if we have a corresponding vector to read.
734 
735  // total_read_size +=
736  this->read_serialized_vector<InValType>
737  (io, (read_additional_data && nvecs) ? pos->second.get() : nullptr);
738 
739  // get the comment
740  if (this->processor_id() == 0)
741  io.comment (comment);
742 
743 
744  // If we've got vectors then we need to be iterating through
745  // those too
746  if (pos != this->_vectors.end())
747  ++pos;
748  }
749  }
750 
751  // const Real
752  // dt = pl.get_elapsed_time(),
753  // rate = total_read_size*sizeof(Number)/dt;
754 
755  // libMesh::out << "Read " << total_read_size << " \"Number\" values\n"
756  // << " Elapsed time = " << dt << '\n'
757  // << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";
758 
759  // pl.pop("read_serialized_data");
760 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2230
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
unsigned int _additional_data_written
This flag is used only when reading in a system from file.
Definition: system.h:2289
processor_id_type processor_id() const

◆ read_serialized_data() [2/2]

template LIBMESH_EXPORT void libMesh::System::read_serialized_data< Real > ( Xdr io,
const bool  read_additional_data = true 
)
inlineinherited

Non-templated version for backward compatibility.

Reads additional data, namely vectors, for this System. This method may safely be called on a distributed-memory mesh.

Definition at line 1308 of file system.h.

1310  { read_serialized_data<Number>(io, read_additional_data); }

◆ read_serialized_vectors() [1/2]

template<typename InValType >
std::size_t libMesh::System::read_serialized_vectors ( Xdr io,
const std::vector< NumericVector< Number > *> &  vectors 
) const
inherited

Read a number of identically distributed vectors.

This method allows for optimization for the multiple vector case by only communicating the metadata once.

Definition at line 2165 of file system_io.C.

References libMesh::Xdr::data(), libMesh::System::get_mesh(), libMesh::libmesh_assert(), libMesh::make_range(), libMesh::MeshTools::n_elem(), libMesh::MeshBase::n_elem(), n_nodes, libMesh::MeshBase::n_nodes(), libMesh::System::n_vars(), libMesh::ParallelObject::processor_id(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::Xdr::reading(), libMesh::SCALAR, and libMesh::System::variable().

Referenced by libMesh::RBEvaluation::read_in_vectors_from_multiple_files().

2167 {
2168  parallel_object_only();
2169 
2170  // Error checking
2171  // #ifndef NDEBUG
2172  // // In parallel we better be reading a parallel vector -- if not
2173  // // we will not set all of its components below!!
2174  // if (this->n_processors() > 1)
2175  // {
2176  // libmesh_assert (vec.type() == PARALLEL ||
2177  // vec.type() == GHOSTED);
2178  // }
2179  // #endif
2180 
2181  libmesh_assert (io.reading());
2182 
2183  if (this->processor_id() == 0)
2184  {
2185  // sizes
2186  unsigned int num_vecs=0;
2187  dof_id_type vector_length=0;
2188 
2189  // Get the number of vectors
2190  io.data(num_vecs);
2191  // Get the buffer size
2192  io.data(vector_length);
2193 
2194  libmesh_error_msg_if
2195  (num_vecs != vectors.size(),
2196  "Xdr file header declares " << num_vecs << " vectors, but we were asked to read " << vectors.size());
2197 
2198  if (num_vecs != 0)
2199  {
2200  libmesh_error_msg_if (vectors[0] == nullptr, "vectors[0] should not be null");
2201  libmesh_error_msg_if (vectors[0]->size() != vector_length, "Inconsistent vector sizes");
2202  }
2203  }
2204 
2205  // no need to actually communicate these.
2206  // this->comm().broadcast(num_vecs);
2207  // this->comm().broadcast(vector_length);
2208 
2209  // Cache these - they are not free!
2210  const dof_id_type
2211  n_nodes = this->get_mesh().n_nodes(),
2212  n_elem = this->get_mesh().n_elem();
2213 
2214  std::size_t read_length = 0;
2215 
2216  //---------------------------------
2217  // Collect the values for all nodes
2218  read_length +=
2219  this->read_serialized_blocked_dof_objects (n_nodes,
2220  this->get_mesh().local_nodes_begin(),
2221  this->get_mesh().local_nodes_end(),
2222  InValType(),
2223  io,
2224  vectors);
2225 
2226  //------------------------------------
2227  // Collect the values for all elements
2228  read_length +=
2230  this->get_mesh().local_elements_begin(),
2231  this->get_mesh().local_elements_end(),
2232  InValType(),
2233  io,
2234  vectors);
2235 
2236  //-------------------------------------------
2237  // Finally loop over all the SCALAR variables
2238  for (NumericVector<Number> * vec : vectors)
2239  for (auto var : make_range(this->n_vars()))
2240  if (this->variable(var).type().family == SCALAR)
2241  {
2242  libmesh_assert_not_equal_to (vec, 0);
2243 
2244  read_length +=
2245  this->read_SCALAR_dofs (var, io, vec);
2246  }
2247 
2248  //---------------------------------------
2249  // last step - must close all the vectors
2250  for (NumericVector<Number> * vec : vectors)
2251  {
2252  libmesh_assert_not_equal_to (vec, 0);
2253  vec->close();
2254  }
2255 
2256  return read_length;
2257 }
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2458
dof_id_type n_elem(const MeshBase::const_element_iterator &begin, const MeshBase::const_element_iterator &end)
Count up the number of elements of a specific type (as defined by an iterator range).
Definition: mesh_tools.C:969
std::size_t read_serialized_blocked_dof_objects(const dof_id_type n_objects, const iterator_type begin, const iterator_type end, const InValType dummy, Xdr &io, const std::vector< NumericVector< Number > *> &vecs, const unsigned int var_to_read=libMesh::invalid_uint) const
Reads an input vector from the stream io and assigns the values to a set of DofObjects.
Definition: system_io.C:765
const MeshBase & get_mesh() const
Definition: system.h:2358
const dof_id_type n_nodes
Definition: tecplot_io.C:67
libmesh_assert(ctx)
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...
Definition: int_range.h:140
unsigned int read_SCALAR_dofs(const unsigned int var, Xdr &io, NumericVector< Number > *vec) const
Reads the SCALAR dofs from the stream io and assigns the values to the appropriate entries of vec...
Definition: system_io.C:1089
unsigned int n_vars() const
Definition: system.h:2430
virtual dof_id_type n_elem() const =0
processor_id_type processor_id() const
template class LIBMESH_EXPORT NumericVector< Number >
virtual dof_id_type n_nodes() const =0
uint8_t dof_id_type
Definition: id_types.h:67

◆ read_serialized_vectors() [2/2]

template LIBMESH_EXPORT std::size_t libMesh::System::read_serialized_vectors< Real > ( Xdr io,
const std::vector< NumericVector< Number > *> &  vectors 
) const
inlineinherited

Non-templated version for backward compatibility.

Read a number of identically distributed vectors. This method allows for optimization for the multiple vector case by only communicating the metadata once.

Definition at line 1328 of file system.h.

1330  { return read_serialized_vectors<Number>(io, vectors); }

◆ recompute_all_residual_terms()

void libMesh::RBConstruction::recompute_all_residual_terms ( const bool  compute_inner_products = true)
virtualinherited

This function computes all of the residual representors, can be useful when restarting a basis training computation.

If compute_inner_products is false, we just compute the residual Riesz representors, whereas if true, we also compute all the corresponding inner product terms.

Definition at line 1802 of file rb_construction.C.

References libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::delta_N, libMesh::RBConstruction::Fq_representor_innerprods_computed, libMesh::RBEvaluation::get_n_basis_functions(), libMesh::RBConstruction::get_rb_evaluation(), and libMesh::RBConstruction::update_residual_terms().

Referenced by libMesh::RBConstruction::train_reduced_basis_with_POD().

1803 {
1804  // Compute the basis independent terms
1806  compute_Fq_representor_innerprods(compute_inner_products);
1807 
1808  // and all the basis dependent terms
1809  unsigned int saved_delta_N = delta_N;
1811 
1812  update_residual_terms(compute_inner_products);
1813 
1814  delta_N = saved_delta_N;
1815 }
bool Fq_representor_innerprods_computed
A boolean flag to indicate whether or not the Fq representor norms have already been computed — used...
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 delta_N
The number of basis functions that we add at each greedy step.
virtual unsigned int get_n_basis_functions() const
Get the current number of basis functions.
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.
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.

◆ reinit()

void libMesh::LinearImplicitSystem::reinit ( )
overridevirtualinherited

Reinitializes the member data fields associated with the system, so that, e.g., assemble() may be used.

Reimplemented from libMesh::System.

Reimplemented in libMesh::NewmarkSystem.

Definition at line 95 of file linear_implicit_system.C.

References libMesh::ImplicitSystem::linear_solver, and libMesh::System::reinit().

Referenced by fe_assembly().

96 {
97  // re-initialize the linear solver interface
98  linear_solver->clear();
99 
100  // initialize parent data
101  Parent::reinit();
102 }
virtual void reinit()
Reinitializes degrees of freedom and other required data on the current mesh.
Definition: system.C:454
std::unique_ptr< LinearSolver< Number > > linear_solver
This class handles all the details of interfacing with various linear algebra packages like PETSc or ...

◆ reinit_constraints()

void libMesh::System::reinit_constraints ( )
virtualinherited

Reinitializes the constraints for this system.

Also prepares the send_list, whether or not constraints have changed.

Definition at line 495 of file system.C.

References libMesh::System::_mesh, libMesh::DofMap::create_dof_constraints(), libMesh::System::get_dof_map(), libMesh::on_command_line(), libMesh::out, libMesh::DofMap::prepare_send_list(), libMesh::DofMap::print_dof_constraints(), libMesh::DofMap::process_constraints(), libMesh::System::time, and libMesh::System::user_constrain().

Referenced by libMesh::EquationSystems::allgather(), libMesh::System::init_data(), libMesh::PetscDMWrapper::init_petscdm(), and libMesh::EquationSystems::reinit_solutions().

496 {
497  parallel_object_only();
498 
499 #ifdef LIBMESH_ENABLE_CONSTRAINTS
501  user_constrain();
503  if (libMesh::on_command_line ("--print-constraints"))
505 #endif
507 }
Real time
For time-dependent problems, this is the time t at the beginning of the current timestep.
Definition: system.h:1615
void print_dof_constraints(std::ostream &os=libMesh::out, bool print_nonlocal=false) const
Prints (from processor 0) all DoF and Node constraints.
void process_constraints(MeshBase &)
Postprocesses any constrained degrees of freedom to be constrained only in terms of unconstrained dof...
OStreamProxy out
void create_dof_constraints(const MeshBase &, Real time=0)
Rebuilds the raw degree of freedom and DofObject constraints, based on attached DirichletBoundary obj...
void prepare_send_list()
Takes the _send_list vector (which may have duplicate entries) and sorts it.
Definition: dof_map.C:1864
bool on_command_line(std::string arg)
Definition: libmesh.C:987
virtual void user_constrain()
Calls user&#39;s attached constraint function, or is overridden by the user in derived classes...
Definition: system.C:2325
const DofMap & get_dof_map() const
Definition: system.h:2374
MeshBase & _mesh
Constant reference to the mesh data structure used for the simulation.
Definition: system.h:2191

◆ reinit_mesh()

void libMesh::System::reinit_mesh ( )
virtualinherited

Reinitializes the system with a new mesh.

Definition at line 301 of file system.C.

References libMesh::System::_basic_system_only, libMesh::System::init_data(), libMesh::System::n_vars(), and libMesh::System::user_initialization().

Referenced by libMesh::System::init().

302 {
303  parallel_object_only();
304 
305  // First initialize any required data:
306  // either only the basic System data
307  if (_basic_system_only)
309  // or all the derived class' data too
310  else
311  this->init_data();
312 
313  // If no variables have been added to this system
314  // don't do anything
315  if (!this->n_vars())
316  return;
317 
318  // Then call the user-provided initialization function
319  this->user_initialization();
320 
321 }
bool _basic_system_only
Holds true if the components of more advanced system types (e.g.
Definition: system.h:2270
virtual void init_data()
Initializes the data for the system.
Definition: system.C:208
virtual void user_initialization()
Calls user&#39;s attached initialization function, or is overridden by the user in derived classes...
Definition: system.C:2297
unsigned int n_vars() const
Definition: system.h:2430

◆ release_linear_solver()

void libMesh::ImplicitSystem::release_linear_solver ( LinearSolver< Number > *  ) const
virtualinherited

Currently a no-op.

Deprecated:
This function no longer needs to be called, since get_linear_solver() no longer returns a heap-allocated dumb pointer.

Definition at line 1248 of file implicit_system.C.

1249 {
1250  // This function was originally paired with get_linear_solver()
1251  // calls when that returned a dumb pointer which needed to be
1252  // cleaned up. Since get_linear_solver() now just returns a pointer
1253  // to a LinearSolver object managed by this class, this function no
1254  // longer needs to do any cleanup.
1255  libmesh_deprecated();
1256 }

◆ remove_matrix()

void libMesh::System::remove_matrix ( std::string_view  mat_name)
inherited

Removes the additional matrix mat_name from this system.

Definition at line 1089 of file system.C.

References libMesh::System::_matrices.

1090 {
1091  parallel_object_only(); // Not strictly needed, but the only safe way to keep in sync
1092 
1093  if (const auto pos = _matrices.find(mat_name);
1094  pos != _matrices.end())
1095  _matrices.erase(pos); // erase()'d entries are destroyed
1096 }
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
Some systems need an arbitrary number of matrices.
Definition: system.h:2247

◆ remove_vector()

void libMesh::System::remove_vector ( std::string_view  vec_name)
inherited

Removes the additional vector vec_name from this system.

Definition at line 873 of file system.C.

References libMesh::System::_vector_is_adjoint, libMesh::System::_vector_projections, libMesh::System::_vectors, and libMesh::libmesh_assert().

Referenced by libMesh::AdjointRefinementEstimator::estimate_error(), and libMesh::UnsteadySolver::integrate_adjoint_sensitivity().

874 {
875  parallel_object_only(); // Not strictly needed, but the only safe way to keep in sync
876 
877  if (const auto pos = _vectors.find(vec_name);
878  pos != _vectors.end())
879  {
880  _vectors.erase(pos);
881  auto proj_it = _vector_projections.find(vec_name);
882  libmesh_assert(proj_it != _vector_projections.end());
883  _vector_projections.erase(proj_it);
884 
885  auto adj_it = _vector_is_adjoint.find(vec_name);
886  libmesh_assert(adj_it != _vector_is_adjoint.end());
887  _vector_is_adjoint.erase(adj_it);
888  }
889 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2230
std::map< std::string, int, std::less<> > _vector_is_adjoint
Holds non-negative if a vector by that name should be projected using adjoint constraints/BCs, -1 if primal.
Definition: system.h:2242
libmesh_assert(ctx)
std::map< std::string, bool, std::less<> > _vector_projections
Holds true if a vector by that name should be projected onto a changed grid, false if it should be ze...
Definition: system.h:2236

◆ request_matrix() [1/2]

const SparseMatrix< Number > * libMesh::System::request_matrix ( std::string_view  mat_name) const
inherited
Returns
A const pointer to this system's additional matrix named mat_name, or nullptr if no matrix by that name exists.

Definition at line 1100 of file system.C.

References libMesh::System::_matrices.

Referenced by libMesh::EigenSystem::has_matrix_A(), libMesh::EigenSystem::has_matrix_B(), libMesh::EigenSystem::has_precond_matrix(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::NewtonSolver::solve(), and libMesh::LinearImplicitSystem::solve().

1101 {
1102  if (const auto pos = _matrices.find(mat_name);
1103  pos != _matrices.end())
1104  return pos->second.get();
1105 
1106  // Otherwise, mat_name does not exist
1107  return nullptr;
1108 }
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
Some systems need an arbitrary number of matrices.
Definition: system.h:2247

◆ request_matrix() [2/2]

SparseMatrix< Number > * libMesh::System::request_matrix ( std::string_view  mat_name)
inherited
Returns
A writable pointer to this system's additional matrix named mat_name, or nullptr if no matrix by that name exists.

Definition at line 1112 of file system.C.

References libMesh::System::_matrices.

1113 {
1114  if (auto pos = _matrices.find(mat_name);
1115  pos != _matrices.end())
1116  return pos->second.get();
1117 
1118  // Otherwise, mat_name does not exist
1119  return nullptr;
1120 }
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
Some systems need an arbitrary number of matrices.
Definition: system.h:2247

◆ request_vector() [1/4]

const NumericVector< Number > * libMesh::System::request_vector ( std::string_view  vec_name) const
inherited
Returns
A const pointer to the vector if this System has a vector associated with the given name, nullptr otherwise.

Definition at line 891 of file system.C.

References libMesh::System::_vectors, and libMesh::NumericVector< T >::get().

Referenced by libMesh::UniformRefinementEstimator::_estimate_error().

892 {
893  if (const auto pos = _vectors.find(vec_name);
894  pos != _vectors.end())
895  return pos->second.get();
896 
897  // Otherwise, vec_name was not found
898  return nullptr;
899 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2230

◆ request_vector() [2/4]

NumericVector< Number > * libMesh::System::request_vector ( std::string_view  vec_name)
inherited
Returns
A pointer to the vector if this System has a vector associated with the given name, nullptr otherwise.

Definition at line 903 of file system.C.

References libMesh::System::_vectors, and libMesh::NumericVector< T >::get().

904 {
905  if (auto pos = _vectors.find(vec_name);
906  pos != _vectors.end())
907  return pos->second.get();
908 
909  // Otherwise, vec_name was not found
910  return nullptr;
911 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2230

◆ request_vector() [3/4]

const NumericVector< Number > * libMesh::System::request_vector ( const unsigned int  vec_num) const
inherited
Returns
A const pointer to this system's additional vector number vec_num (where the vectors are counted starting with 0), or nullptr if the system has no such vector.

Definition at line 915 of file system.C.

References libMesh::System::_vectors, and libMesh::System::vectors_begin().

916 {
917  // If we don't have that many vectors, return nullptr
918  if (vec_num >= _vectors.size())
919  return nullptr;
920 
921  // Otherwise return a pointer to the vec_num'th vector
922  auto it = vectors_begin();
923  std::advance(it, vec_num);
924  return it->second.get();
925 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2230
vectors_iterator vectors_begin()
Beginning of vectors container.
Definition: system.h:2564

◆ request_vector() [4/4]

NumericVector< Number > * libMesh::System::request_vector ( const unsigned int  vec_num)
inherited
Returns
A writable pointer to this system's additional vector number vec_num (where the vectors are counted starting with 0), or nullptr if the system has no such vector.

Definition at line 929 of file system.C.

References libMesh::System::_vectors, and libMesh::System::vectors_begin().

930 {
931  // If we don't have that many vectors, return nullptr
932  if (vec_num >= _vectors.size())
933  return nullptr;
934 
935  // Otherwise return a pointer to the vec_num'th vector
936  auto it = vectors_begin();
937  std::advance(it, vec_num);
938  return it->second.get();
939 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2230
vectors_iterator vectors_begin()
Beginning of vectors container.
Definition: system.h:2564

◆ reset_preevaluate_thetas_completed()

void libMesh::RBConstruction::reset_preevaluate_thetas_completed ( )
protectedinherited

Reset the _preevaluate_thetas_completed flag to false.

We can use this to force us to recalculate preevaluate thetas, in cases where that is necessary.

Definition at line 2833 of file rb_construction.C.

References libMesh::RBConstruction::_preevaluate_thetas_completed.

2834 {
2836 }
bool _preevaluate_thetas_completed
Flag to indicate if the preevaluate_thetas function has been called, since this allows us to avoid ca...

◆ restrict_solve_to()

void libMesh::LinearImplicitSystem::restrict_solve_to ( const SystemSubset subset,
const SubsetSolveMode  subset_solve_mode = SUBSET_ZERO 
)
overridevirtualinherited

After calling this method, any solve will be limited to the given subset.

To disable this mode, call this method with subset being a nullptr.

Reimplemented from libMesh::System.

Definition at line 106 of file linear_implicit_system.C.

References libMesh::LinearImplicitSystem::_subset, libMesh::LinearImplicitSystem::_subset_solve_mode, and libMesh::SystemSubset::get_system().

Referenced by libMesh::LinearImplicitSystem::clear(), and main().

108 {
109  _subset = subset;
110  _subset_solve_mode = subset_solve_mode;
111 
112  if (subset != nullptr)
113  libmesh_assert_equal_to (&subset->get_system(), this);
114 }
SubsetSolveMode _subset_solve_mode
If restrict-solve-to-subset mode is active, this member decides what happens with the dofs outside th...
const SystemSubset * _subset
The current subset on which to solve (or nullptr if none).

◆ restrict_vectors()

void libMesh::System::restrict_vectors ( )
virtualinherited

Restrict vectors after the mesh has coarsened.

Definition at line 386 of file system.C.

References libMesh::System::_dof_map, libMesh::System::_solution_projection, libMesh::System::_vector_projections, libMesh::System::_vectors, libMesh::System::current_local_solution, libMesh::NumericVector< T >::get(), libMesh::GHOSTED, libMesh::System::n_dofs(), libMesh::System::n_local_dofs(), libMesh::PARALLEL, libMesh::System::project_vector(), libMesh::System::solution, and libMesh::System::vector_is_adjoint().

Referenced by libMesh::System::prolong_vectors(), and libMesh::EquationSystems::reinit_solutions().

387 {
388  parallel_object_only();
389 
390 #ifdef LIBMESH_ENABLE_AMR
391  // Restrict the _vectors on the coarsened cells
392  for (auto & [vec_name, vec] : _vectors)
393  {
394  NumericVector<Number> * v = vec.get();
395 
396  if (_vector_projections[vec_name])
397  {
398  this->project_vector (*v, this->vector_is_adjoint(vec_name));
399  }
400  else
401  {
402  const ParallelType type = vec->type();
403 
404  if (type == GHOSTED)
405  {
406 #ifdef LIBMESH_ENABLE_GHOSTED
407  vec->init (this->n_dofs(), this->n_local_dofs(),
408  _dof_map->get_send_list(), /*fast=*/false,
409  GHOSTED);
410 #else
411  libmesh_error_msg("Cannot initialize ghosted vectors when they are not enabled.");
412 #endif
413  }
414  else
415  vec->init (this->n_dofs(), this->n_local_dofs(), false, type);
416  }
417  }
418 
419  const std::vector<dof_id_type> & send_list = _dof_map->get_send_list ();
420 
421  // Restrict the solution on the coarsened cells
423  this->project_vector (*solution);
424  // Or at least make sure the solution vector is the correct size
425  else
426  solution->init (this->n_dofs(), this->n_local_dofs(), true, PARALLEL);
427 
428 #ifdef LIBMESH_ENABLE_GHOSTED
429  current_local_solution->init(this->n_dofs(),
430  this->n_local_dofs(), send_list,
431  false, GHOSTED);
432 #else
433  current_local_solution->init(this->n_dofs());
434 #endif
435 
437  solution->localize (*current_local_solution, send_list);
438 
439 #endif // LIBMESH_ENABLE_AMR
440 }
int vector_is_adjoint(std::string_view vec_name) const
Definition: system.C:1173
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:2179
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2230
dof_id_type n_local_dofs() const
Definition: system.C:158
dof_id_type n_dofs() const
Definition: system.C:121
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
bool _solution_projection
Holds true if the solution vector should be projected onto a changed grid, false if it should be zero...
Definition: system.h:2264
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Definition: system.h:1605
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
Projects arbitrary functions onto a vector of degree of freedom values for the current system...
template class LIBMESH_EXPORT NumericVector< Number >
std::map< std::string, bool, std::less<> > _vector_projections
Holds true if a vector by that name should be projected onto a changed grid, false if it should be ze...
Definition: system.h:2236
ParallelType
Defines an enum for parallel data structure types.

◆ sensitivity_solve()

std::pair< unsigned int, Real > libMesh::ImplicitSystem::sensitivity_solve ( const ParameterVector parameters)
overridevirtualinherited

Assembles & solves the linear system(s) (dR/du)*u_p = -dR/dp, for those parameters contained within parameters.

Returns
A pair with the total number of linear iterations performed and the (sum of the) final residual norms

Reimplemented from libMesh::System.

Definition at line 136 of file implicit_system.C.

References libMesh::System::add_sensitivity_solution(), libMesh::System::assemble_before_solve, libMesh::ImplicitSystem::assemble_residual_derivatives(), libMesh::ImplicitSystem::assembly(), libMesh::SparseMatrix< T >::close(), libMesh::DofMap::enforce_constraints_exactly(), libMesh::System::get_dof_map(), libMesh::ImplicitSystem::get_linear_solve_parameters(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::System::get_sensitivity_rhs(), libMesh::System::get_sensitivity_solution(), libMesh::make_range(), libMesh::ImplicitSystem::matrix, libMesh::System::request_matrix(), libMesh::ParameterVector::size(), and libMesh::LinearSolver< T >::solve().

Referenced by libMesh::ImplicitSystem::forward_qoi_parameter_sensitivity(), and libMesh::ImplicitSystem::qoi_parameter_hessian().

137 {
138  // Log how long the linear solve takes.
139  LOG_SCOPE("sensitivity_solve()", "ImplicitSystem");
140 
141  // The forward system should now already be solved.
142  // Now assemble the corresponding sensitivity system.
143 
144  if (this->assemble_before_solve)
145  {
146  // Build the Jacobian
147  this->assembly(false, true);
148  this->matrix->close();
149 
150  // Reset and build the RHS from the residual derivatives
151  this->assemble_residual_derivatives(parameters_vec);
152  }
153 
154  // The sensitivity problem is linear
155  LinearSolver<Number> * solver = this->get_linear_solver();
156 
157  // Our iteration counts and residuals will be sums of the individual
158  // results
159  std::pair<unsigned int, Real> solver_params =
161  std::pair<unsigned int, Real> totalrval = std::make_pair(0,0.0);
162 
163  // Solve the linear system.
164  SparseMatrix<Number> * pc = this->request_matrix("Preconditioner");
165  for (auto p : make_range(parameters_vec.size()))
166  {
167  std::pair<unsigned int, Real> rval =
168  solver->solve (*matrix, pc,
169  this->add_sensitivity_solution(p),
170  this->get_sensitivity_rhs(p),
171  double(solver_params.second),
172  solver_params.first);
173 
174  totalrval.first += rval.first;
175  totalrval.second += rval.second;
176  }
177 
178  // The linear solver may not have fit our constraints exactly
179 #ifdef LIBMESH_ENABLE_CONSTRAINTS
180  for (auto p : make_range(parameters_vec.size()))
182  (*this, &this->get_sensitivity_solution(p),
183  /* homogeneous = */ true);
184 #endif
185 
186  return totalrval;
187 }
virtual std::pair< unsigned int, Real > get_linear_solve_parameters() const
NumericVector< Number > & get_sensitivity_solution(unsigned int i=0)
Definition: system.C:1192
NumericVector< Number > & get_sensitivity_rhs(unsigned int i=0)
Definition: system.C:1337
virtual LinearSolver< Number > * get_linear_solver() const
const SparseMatrix< Number > * request_matrix(std::string_view mat_name) const
Definition: system.C:1100
virtual void assembly(bool, bool, bool=false, bool=false)
Assembles a residual in rhs and/or a jacobian in matrix, as requested.
template class LIBMESH_EXPORT LinearSolver< Number >
virtual void close()=0
Calls the SparseMatrix&#39;s internal assembly routines, ensuring that the values are consistent across p...
template class LIBMESH_EXPORT SparseMatrix< Number >
SparseMatrix< Number > * matrix
The system matrix.
virtual void assemble_residual_derivatives(const ParameterVector &parameters) override
Residual parameter derivative function.
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...
Definition: int_range.h:140
NumericVector< Number > & add_sensitivity_solution(unsigned int i=0)
Definition: system.C:1182
bool assemble_before_solve
Flag which tells the system to whether or not to call the user assembly function during each call to ...
Definition: system.h:1547
const DofMap & get_dof_map() const
Definition: system.h:2374
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. ...
Definition: dof_map.h:2350

◆ set_abs_training_tolerance()

void libMesh::RBConstruction::set_abs_training_tolerance ( Real  new_training_tolerance)
inlineinherited

Get/set the absolute tolerance for the basis training.

Definition at line 225 of file rb_construction.h.

References libMesh::RBConstruction::abs_training_tolerance.

Referenced by libMesh::RBConstruction::set_rb_construction_parameters().

226  {this->abs_training_tolerance = new_training_tolerance; }

◆ set_adjoint_already_solved()

void libMesh::System::set_adjoint_already_solved ( bool  setting)
inlineinherited

Setter for the adjoint_already_solved boolean.

Definition at line 415 of file system.h.

References libMesh::System::adjoint_already_solved.

Referenced by main().

416  { adjoint_already_solved = setting;}
bool adjoint_already_solved
Has the adjoint problem already been solved? If the user sets adjoint_already_solved to true...
Definition: system.h:2308

◆ set_basic_system_only()

void libMesh::System::set_basic_system_only ( )
inlineinherited

Sets the system to be "basic only": i.e.

advanced system components such as ImplicitSystem matrices may not be initialized. This is useful for efficiency in certain utility programs that never use System::solve(). This method must be called after the System or derived class is created but before it is initialized; e.g. from within EquationSystems::read()

Definition at line 2422 of file system.h.

References libMesh::System::_basic_system_only.

Referenced by libMesh::EquationSystems::read().

2423 {
2424  _basic_system_only = true;
2425 }
bool _basic_system_only
Holds true if the components of more advanced system types (e.g.
Definition: system.h:2270

◆ set_context_solution_vec()

void libMesh::RBConstruction::set_context_solution_vec ( NumericVector< Number > &  vec)
protectedvirtualinherited

Set current_local_solution = vec so that we can access vec from FEMContext during assembly.

Override in subclasses if different behavior is required.

Definition at line 952 of file rb_construction.C.

References libMesh::System::current_local_solution, libMesh::System::get_dof_map(), and libMesh::NumericVector< T >::localize().

953 {
954  // Set current_local_solution = vec so that we can access
955  // vec from DGFEMContext during assembly
956  vec.localize
957  (*current_local_solution, this->get_dof_map().get_send_list());
958 }
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Definition: system.h:1605
const DofMap & get_dof_map() const
Definition: system.h:2374
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.

◆ set_control()

void libMesh::RBTemporalDiscretization::set_control ( const std::vector< Real > &  control)
inherited

Definition at line 85 of file rb_temporal_discretization.C.

References libMesh::RBTemporalDiscretization::_control, and libMesh::RBTemporalDiscretization::_n_time_steps.

Referenced by libMesh::RBTemporalDiscretization::pull_temporal_discretization_data().

86 {
87  libmesh_assert_less_equal(control.size(),_n_time_steps+1);
88  _control = control;
89  // If the input vector is smaller than the number of time steps (+1), we complete it with zeros
90  _control.resize(_n_time_steps+1);
91 }
std::vector< Real > _control
The RHS control (scalar function of time).
unsigned int _n_time_steps
The number of time-steps.

◆ set_convergence_assertion_flag()

void libMesh::RBConstruction::set_convergence_assertion_flag ( bool  flag)
inherited

Setter for the flag determining if convergence should be checked after each solve.

Definition at line 2718 of file rb_construction.C.

References libMesh::RBConstruction::assert_convergence.

2719 {
2720  assert_convergence = flag;
2721 }
bool assert_convergence
A boolean flag to indicate whether to check for proper convergence after each solve.

◆ set_current_training_parameter_index()

void libMesh::RBConstruction::set_current_training_parameter_index ( unsigned int  index)
protectedinherited

Definition at line 2738 of file rb_construction.C.

References libMesh::RBConstruction::_current_training_parameter_index.

Referenced by libMesh::RBConstruction::compute_max_error_bound().

2739 {
2741 }
unsigned int _current_training_parameter_index
The current training parameter index during reduced basis training.

◆ set_delta_N()

void libMesh::TransientRBConstruction::set_delta_N ( const unsigned int  new_delta_N)
inline

Set delta_N, the number of basis functions we add to the RB space from each POD.

Definition at line 227 of file transient_rb_construction.h.

References libMesh::RBConstruction::delta_N.

Referenced by add_IC_to_RB_space(), enrich_RB_space(), and process_parameters_file().

227 { this->delta_N = new_delta_N; }
unsigned int delta_N
The number of basis functions that we add at each greedy step.

◆ set_delta_t()

void libMesh::RBTemporalDiscretization::set_delta_t ( const Real  delta_t_in)
inherited

◆ set_deterministic_training_parameter_name()

void libMesh::RBConstructionBase< LinearImplicitSystem >::set_deterministic_training_parameter_name ( const std::string &  name)
inherited

In some cases we only want to allow discrete parameter values, instead of parameters that may take any value in a specified interval.

Here we provide a method to set the d Set the discrete values for parameter mu that are allowed in the training set. This must be called before the training set is generated. Set the name of the parameter that we will generate deterministic training parameters for. Defaults to "NONE".

◆ set_energy_inner_product()

void libMesh::RBConstruction::set_energy_inner_product ( const std::vector< Number > &  energy_inner_product_coeffs_in)
inherited

Specify the coefficients of the A_q operators to be used in the energy inner-product.

Definition at line 434 of file rb_construction.C.

References libMesh::RBConstruction::energy_inner_product_coeffs, and libMesh::RBConstruction::use_energy_inner_product.

435 {
437  energy_inner_product_coeffs = energy_inner_product_coeffs_in;
438 }
std::vector< Number > energy_inner_product_coeffs
We may optionally want to use the "energy inner-product" rather than the inner-product assembly speci...
bool use_energy_inner_product
Boolean to indicate whether we&#39;re using the energy inner-product.

◆ set_error_temporal_data()

Number TransientRBConstruction::set_error_temporal_data ( )
protected

Set column k (i.e.

the current time level) of temporal_data to the difference between the current solution and the orthogonal projection of the current solution onto the current RB space.

Definition at line 629 of file transient_rb_construction.C.

References libMesh::NumericVector< T >::build(), libMesh::ParallelObject::comm(), libMesh::DenseVector< T >::dot(), libMesh::RBEvaluation::get_n_basis_functions(), libMesh::RBConstruction::get_non_dirichlet_inner_product_matrix_if_avail(), libMesh::RBConstruction::get_rb_evaluation(), libMesh::RBTemporalDiscretization::get_time_step(), libMesh::RBConstructionBase< LinearImplicitSystem >::inner_product_storage_vector, libMesh::DenseMatrix< T >::lu_solve(), libMesh::System::n_dofs(), libMesh::System::n_local_dofs(), libMesh::PARALLEL, libMesh::RBEvaluation::RB_inner_product_matrix, libMesh::System::solution, temporal_data, and libMesh::SparseMatrix< T >::vector_mult().

Referenced by truth_solve().

630 {
631  LOG_SCOPE("set_error_temporal_data()", "TransientRBConstruction");
632 
633  // first compute the projection of solution onto the current
634  // RB space
635 
636  const unsigned int time_step = get_time_step();
637 
638  if (get_rb_evaluation().get_n_basis_functions() == 0)
639  {
640  // If the basis is empty, then the error is the solution itself
641  temporal_data[time_step]->zero();
642  temporal_data[time_step]->add(1., *solution);
643  }
644  else
645  {
646  unsigned int RB_size = get_rb_evaluation().get_n_basis_functions();
647 
648  std::unique_ptr<NumericVector<Number>> temp = NumericVector<Number>::build(this->comm());
649  temp->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
650 
651  // First compute the right-hand side vector for the projection
653 
654  // zero_dirichlet_dofs_on_vector(*temp);
655 
656  // Do not assume that RB_stiffness matrix is diagonal,
657  // diagonality degrades as N increases
658 
659  // Get an appropriately sized copy of RB_inner_product_matrix
660  DenseMatrix<Number> RB_inner_product_matrix_N(RB_size,RB_size);
661  for (unsigned int i=0; i<RB_size; i++)
662  for (unsigned int j=0; j<RB_size; j++)
663  {
664  RB_inner_product_matrix_N(i,j) = get_rb_evaluation().RB_inner_product_matrix(i,j);
665  }
666 
667  // Compute the projection RHS
668  DenseVector<Number> RB_proj_rhs(RB_size);
669  for (unsigned int i=0; i<RB_size; i++)
670  {
671  RB_proj_rhs(i) = temp->dot(get_rb_evaluation().get_basis_function(i));
672  }
673 
674  DenseVector<Number> RB_proj(RB_size);
675 
676  // Now solve the linear system
677  RB_inner_product_matrix_N.lu_solve(RB_proj_rhs, RB_proj);
678 
679  // Load the RB projection into temp
680  temp->zero();
681  for (unsigned int i=0; i<RB_size; i++)
682  {
683  temp->add(RB_proj(i), get_rb_evaluation().get_basis_function(i));
684  }
685 
686  temp->add(-1., *solution);
687 
688  // Now temp holds the projection error, store in temporal_data
689  *(temporal_data[time_step]) = *temp;
690  }
691 
692  // return the square of the X norm of the truth solution
694 
696 }
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...
DenseMatrix< Number > RB_inner_product_matrix
The inner product matrix.
const Parallel::Communicator & comm() const
dof_id_type n_local_dofs() const
Definition: system.C:158
dof_id_type n_dofs() const
Definition: system.C:121
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...
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
unsigned int get_time_step() const
Get/set the current time-step.
std::vector< std::unique_ptr< NumericVector< Number > > > temporal_data
Dense matrix to store the data that we use for the temporal POD.
virtual unsigned int get_n_basis_functions() const
Get the current number of basis functions.
SparseMatrix< Number > * get_non_dirichlet_inner_product_matrix_if_avail()
Get the non-Dirichlet inner-product matrix if it&#39;s available, otherwise get the inner-product 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...
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.

◆ set_euler_theta()

void libMesh::RBTemporalDiscretization::set_euler_theta ( const Real  euler_theta_in)
inherited

◆ set_inner_product_assembly()

void libMesh::RBConstruction::set_inner_product_assembly ( ElemAssembly inner_product_assembly_in)
inherited

Set the rb_assembly_expansion object.

Definition at line 417 of file rb_construction.C.

References libMesh::RBConstruction::inner_product_assembly, and libMesh::RBConstruction::use_energy_inner_product.

Referenced by SimpleRBConstruction::init_data().

418 {
419  use_energy_inner_product = false;
420  inner_product_assembly = &inner_product_assembly_in;
421 }
bool use_energy_inner_product
Boolean to indicate whether we&#39;re using the energy inner-product.
ElemAssembly * inner_product_assembly
Pointer to inner product assembly.

◆ set_L2_assembly()

void TransientRBConstruction::set_L2_assembly ( ElemAssembly L2_assembly_in)

Set the L2 object.

Definition at line 453 of file transient_rb_construction.C.

References L2_assembly.

454 {
455  L2_assembly = &L2_assembly_in;
456 }
ElemAssembly * L2_assembly
Function pointer for assembling the L2 matrix.

◆ set_max_truth_solves()

void libMesh::TransientRBConstruction::set_max_truth_solves ( int  max_truth_solves_in)
inline

Definition at line 215 of file transient_rb_construction.h.

References max_truth_solves.

Referenced by process_parameters_file().

215 { this->max_truth_solves = max_truth_solves_in; }
int max_truth_solves
Maximum number of truth solves in the POD-Greedy.

◆ set_n_time_steps()

void libMesh::RBTemporalDiscretization::set_n_time_steps ( const unsigned int  K)
inherited

◆ set_Nmax()

void libMesh::RBConstruction::set_Nmax ( unsigned int  Nmax)
virtualinherited

Definition at line 1687 of file rb_construction.C.

References libMesh::RBConstruction::Nmax.

Referenced by libMesh::RBConstruction::set_rb_construction_parameters().

1688 {
1689  this->Nmax = Nmax_in;
1690 }
unsigned int Nmax
Maximum number of reduced basis functions we are willing to use.

◆ set_normalize_rb_bound_in_greedy()

void libMesh::RBConstruction::set_normalize_rb_bound_in_greedy ( bool  normalize_rb_bound_in_greedy_in)
inlineinherited

Get/set the boolean to indicate if we normalize the RB error in the greedy.

Definition at line 232 of file rb_construction.h.

References libMesh::RBConstruction::normalize_rb_bound_in_greedy.

Referenced by libMesh::RBConstruction::set_rb_construction_parameters().

233  {this->normalize_rb_bound_in_greedy = normalize_rb_bound_in_greedy_in; }
bool normalize_rb_bound_in_greedy
This boolean indicates if we normalize the RB error in the greedy using RBEvaluation::get_error_bound...

◆ set_normalize_solution_snapshots()

void libMesh::RBConstructionBase< LinearImplicitSystem >::set_normalize_solution_snapshots ( bool  value)
inherited

Set the boolean option that indicates if we normalization solution snapshots or not.

Definition at line 147 of file rb_construction_base.C.

148 {
150 }
bool _normalize_solution_snapshots
Set this boolean to true if we want to normalize solution snapshots used in training to have norm of ...
static const bool value
Definition: xdr_io.C:54

◆ set_parameters()

bool libMesh::RBParametrized::set_parameters ( const RBParameters params)
inherited

Set the current parameters to params The parameters are checked for validity; an error is thrown if the number of parameters or samples is different than expected.

We

Returns
a boolean true if the new parameters are within the min/max range, and false otherwise (but the parameters are set regardless). Enabling the "verbose_mode" flag will also print more details.

Definition at line 143 of file rb_parametrized.C.

References libMesh::RBParametrized::check_if_valid_params(), libMesh::RBParametrized::parameters, and libMesh::RBParametrized::parameters_initialized.

Referenced by libMesh::RBSCMConstruction::compute_SCM_bounds_on_training_set(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_interiors(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_nodes(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_sides(), libMesh::RBConstruction::get_RB_error_bound(), SimpleRBEvaluation::get_stability_lower_bound(), libMesh::RBParametrized::initialize_parameters(), libMesh::RBSCMEvaluation::reload_current_parameters(), libMesh::RBSCMEvaluation::set_current_parameters_from_C_J(), and RBParametersTest::testRBParametrized().

144 {
145  libmesh_error_msg_if(!parameters_initialized, "Error: parameters not initialized in RBParametrized::set_parameters");
146 
147  // Terminate if params has the wrong number of parameters or samples.
148  // If the parameters are outside the min/max range, return false.
149  const bool valid_params = check_if_valid_params(params);
150 
151  // Make a copy of params (default assignment operator just does memberwise copy, which is sufficient here)
152  this->parameters = params;
153 
154  return valid_params;
155 }
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
bool check_if_valid_params(const RBParameters &params) const
Helper function to check that params is valid:
RBParameters parameters
Vector storing the current parameters.

◆ set_params_from_training_set()

void libMesh::RBConstructionBase< LinearImplicitSystem >::set_params_from_training_set ( unsigned int  global_index)
protectedinherited

Set parameters to the RBParameters stored in index global_index of the global training set.

Definition at line 225 of file rb_construction_base.C.

Referenced by libMesh::RBConstruction::compute_max_error_bound(), libMesh::RBConstruction::preevaluate_thetas(), and libMesh::RBConstruction::train_reduced_basis_with_POD().

226 {
228 }
bool set_parameters(const RBParameters &params)
Set the current parameters to params The parameters are checked for validity; an error is thrown if t...
RBParameters get_params_from_training_set(unsigned int global_index)
Return the RBParameters in index global_index of the global training set.

◆ set_params_from_training_set_and_broadcast()

void libMesh::RBConstructionBase< LinearImplicitSystem >::set_params_from_training_set_and_broadcast ( unsigned int  global_index)
protectedvirtualinherited

Load the specified training parameter and then broadcast to all processors.

Definition at line 270 of file rb_construction_base.C.

271 {
272  libmesh_error_msg_if(!_training_parameters_initialized,
273  "Error: training parameters must first be initialized.");
274 
275  processor_id_type root_id = 0;
276  if ((this->get_first_local_training_index() <= global_index) &&
277  (global_index < this->get_last_local_training_index()))
278  {
279  // Set parameters on only one processor
280  set_params_from_training_set(global_index);
281 
282  // set root_id, only non-zero on one processor
283  root_id = this->processor_id();
284  }
285 
286  // broadcast
287  this->comm().max(root_id);
288  broadcast_parameters(root_id);
289 }
numeric_index_type get_first_local_training_index() const
Get the first local index of the training parameters.
const Parallel::Communicator & comm() const
void broadcast_parameters(const unsigned int proc_id)
Broadcasts parameters from processor proc_id to all processors.
uint8_t processor_id_type
numeric_index_type get_last_local_training_index() const
Get the last local index of the training parameters.
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...
void max(const T &r, T &o, Request &req) const
processor_id_type processor_id() const
bool _training_parameters_initialized
Boolean flag to indicate whether or not the parameter ranges have been initialized.

◆ set_POD_tol()

void libMesh::TransientRBConstruction::set_POD_tol ( const Real  POD_tol_in)
inline

Definition at line 221 of file transient_rb_construction.h.

References POD_tol.

Referenced by process_parameters_file().

221 { this->POD_tol = POD_tol_in; }
Real POD_tol
If positive, this tolerance determines the number of POD modes we add to the space on a call to enric...

◆ set_preevaluate_thetas_flag()

void libMesh::RBConstruction::set_preevaluate_thetas_flag ( bool  flag)
inherited

Definition at line 2728 of file rb_construction.C.

References libMesh::RBConstruction::_preevaluate_thetas_flag.

2729 {
2730  _preevaluate_thetas_flag = flag;
2731 }
bool _preevaluate_thetas_flag
Flag to indicate if we preevaluate the theta functions.

◆ set_project_with_constraints()

void libMesh::System::set_project_with_constraints ( bool  _project_with_constraints)
inlineinherited

Definition at line 1800 of file system.h.

References libMesh::System::project_with_constraints.

Referenced by libMesh::AdjointRefinementEstimator::estimate_error().

1801  {
1802  project_with_constraints = _project_with_constraints;
1803  }
bool project_with_constraints
Do we want to apply constraints while projecting vectors ?
Definition: system.h:2319

◆ set_qoi() [1/2]

void libMesh::System::set_qoi ( unsigned int  qoi_index,
Number  qoi_value 
)
inherited

Definition at line 2378 of file system.C.

References libMesh::libmesh_assert(), and libMesh::System::qoi.

Referenced by libMesh::ExplicitSystem::assemble_qoi(), libMesh::FEMSystem::assemble_qoi(), libMesh::Euler2Solver::integrate_qoi_timestep(), libMesh::TwostepTimeSolver::integrate_qoi_timestep(), and libMesh::EulerSolver::integrate_qoi_timestep().

2379 {
2380  libmesh_assert(qoi_index < qoi.size());
2381 
2382  qoi[qoi_index] = qoi_value;
2383 }
std::vector< Number > qoi
Values of the quantities of interest.
Definition: system.h:1631
libmesh_assert(ctx)

◆ set_qoi() [2/2]

void libMesh::System::set_qoi ( std::vector< Number new_qoi)
inherited

Definition at line 2399 of file system.C.

References libMesh::System::qoi.

2400 {
2401  libmesh_assert_equal_to(this->qoi.size(), new_qoi.size());
2402  this->qoi = std::move(new_qoi);
2403 }
std::vector< Number > qoi
Values of the quantities of interest.
Definition: system.h:1631

◆ set_qoi_error_estimate()

void libMesh::System::set_qoi_error_estimate ( unsigned int  qoi_index,
Number  qoi_error_estimate 
)
inherited

Definition at line 2406 of file system.C.

References libMesh::libmesh_assert(), and libMesh::System::qoi_error_estimates.

Referenced by libMesh::Euler2Solver::integrate_adjoint_refinement_error_estimate(), libMesh::TwostepTimeSolver::integrate_adjoint_refinement_error_estimate(), and libMesh::EulerSolver::integrate_adjoint_refinement_error_estimate().

2407 {
2408  libmesh_assert(qoi_index < qoi_error_estimates.size());
2409 
2410  qoi_error_estimates[qoi_index] = qoi_error_estimate;
2411 }
libmesh_assert(ctx)
std::vector< Number > qoi_error_estimates
Vector to hold error estimates for qois, either from a steady state calculation, or from a single uns...
Definition: system.h:1639

◆ set_quiet_mode()

void libMesh::RBConstructionBase< LinearImplicitSystem >::set_quiet_mode ( bool  quiet_mode_in)
inlineinherited

Set the quiet_mode flag.

If quiet == false then we print out a lot of extra information during the Offline stage.

Definition at line 100 of file rb_construction_base.h.

Referenced by libMesh::RBConstruction::set_rb_construction_parameters().

101  { this->quiet_mode = quiet_mode_in; }
bool quiet_mode
Flag to indicate whether we print out extra information during the Offline stage. ...

◆ set_rb_assembly_expansion()

void libMesh::RBConstruction::set_rb_assembly_expansion ( RBAssemblyExpansion rb_assembly_expansion_in)
inherited

Set the rb_assembly_expansion object.

Definition at line 405 of file rb_construction.C.

References libMesh::RBConstruction::rb_assembly_expansion.

Referenced by SimpleRBConstruction::init_data().

406 {
407  rb_assembly_expansion = &rb_assembly_expansion_in;
408 }
RBAssemblyExpansion * rb_assembly_expansion
This member holds the (parameter independent) assembly functors that define the "affine expansion" of...

◆ set_rb_construction_parameters()

void libMesh::RBConstruction::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 
)
inherited

Set the state of this RBConstruction object based on the arguments to this function.

Definition at line 286 of file rb_construction.C.

References libMesh::RBParametrized::get_parameters_max(), libMesh::RBParametrized::get_parameters_min(), libMesh::RBParametrized::initialize_parameters(), libMesh::RBConstructionBase< LinearImplicitSystem >::initialize_training_parameters(), libMesh::RBConstructionBase< LinearImplicitSystem >::load_training_set(), libMesh::RBConstruction::set_abs_training_tolerance(), libMesh::RBConstruction::set_Nmax(), libMesh::RBConstruction::set_normalize_rb_bound_in_greedy(), libMesh::RBConstructionBase< LinearImplicitSystem >::set_quiet_mode(), libMesh::RBConstruction::set_RB_training_type(), libMesh::RBConstruction::set_rel_training_tolerance(), and libMesh::RBConstructionBase< LinearImplicitSystem >::set_training_random_seed().

Referenced by libMesh::RBConstruction::process_parameters_file().

301 {
302  // Read in training_parameters_random_seed value. This is used to
303  // seed the RNG when picking the training parameters. By default the
304  // value is -1, which means use std::time to seed the RNG.
305  set_training_random_seed(training_parameters_random_seed_in);
306 
307  // Set quiet mode
308  set_quiet_mode(quiet_mode_in);
309 
310  // Initialize RB parameters
311  set_Nmax(Nmax_in);
312 
313  set_rel_training_tolerance(rel_training_tolerance_in);
314  set_abs_training_tolerance(abs_training_tolerance_in);
315 
316  set_normalize_rb_bound_in_greedy(normalize_rb_bound_in_greedy_in);
317 
318  set_RB_training_type(RB_training_type_in);
319 
320  // Initialize the parameter ranges and the parameters themselves
321  initialize_parameters(mu_min_in, mu_max_in, discrete_parameter_values_in);
322 
323  bool updated_deterministic_training = deterministic_training_in;
324  if (training_sample_list && (this->get_parameters_min().n_parameters() > 3))
325  {
326  // In this case we force deterministic_training to be false because
327  // a) deterministic training samples are not currrently supported with
328  // more than 3 parameters, and
329  // b) we will overwrite the training samples anyway in the call to
330  // load_training_set() below, so we do not want to generate an
331  // error due to deterministic training sample generation when
332  // the samples will be overwritten anyway.
333  updated_deterministic_training = false;
334  }
335 
337  this->get_parameters_max(),
338  n_training_samples_in,
339  log_scaling_in,
340  updated_deterministic_training); // use deterministic parameters
341 
342  if (training_sample_list)
343  {
344  // Note that we must call initialize_training_parameters() before
345  // load_training_set() in order to initialize the parameter vectors.
346  load_training_set(*training_sample_list);
347  }
348 }
void set_RB_training_type(const std::string &RB_training_type_in)
Get/set the string that determines the training type.
const RBParameters & get_parameters_max() const
Get an RBParameters object that specifies the maximum allowable value for each parameter.
void set_quiet_mode(bool quiet_mode_in)
Set the quiet_mode flag.
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 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_training_random_seed(int seed)
Set the seed that is used to randomly generate training parameters.
const RBParameters & get_parameters_min() const
Get an RBParameters object that specifies the minimum allowable value for each parameter.
void set_abs_training_tolerance(Real new_training_tolerance)
Get/set the absolute tolerance for the basis training.
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.
virtual void set_Nmax(unsigned int Nmax)
void set_rel_training_tolerance(Real new_training_tolerance)
Get/set the relative tolerance for the basis training.
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.

◆ set_rb_evaluation()

void libMesh::RBConstruction::set_rb_evaluation ( RBEvaluation rb_eval_in)
inherited

Set the RBEvaluation object.

Definition at line 170 of file rb_construction.C.

References libMesh::RBConstruction::rb_eval.

Referenced by main().

171 {
172  rb_eval = &rb_eval_in;
173 }
RBEvaluation * rb_eval
The current RBEvaluation object we are using to perform the Evaluation stage of the reduced basis met...

◆ set_RB_training_type()

void libMesh::RBConstruction::set_RB_training_type ( const std::string &  RB_training_type_in)
inherited

Get/set the string that determines the training type.

Definition at line 1670 of file rb_construction.C.

References libMesh::RBConstruction::is_serial_training_type(), libMesh::RBConstruction::RB_training_type, and libMesh::RBConstructionBase< LinearImplicitSystem >::serial_training_set.

Referenced by libMesh::RBConstruction::set_rb_construction_parameters().

1671 {
1672  this->RB_training_type = RB_training_type_in;
1673 
1674  if(is_serial_training_type(RB_training_type_in))
1675  {
1676  // We need to use a serial training set (so that the training
1677  // set is the same on all processes) if we're using POD
1678  this->serial_training_set = true;
1679  }
1680 }
std::string RB_training_type
This string indicates the type of training that we will use.
virtual bool is_serial_training_type(const std::string &RB_training_type_in)
bool serial_training_set
This boolean flag indicates whether or not the training set should be the same on all processors...

◆ set_rel_training_tolerance()

void libMesh::RBConstruction::set_rel_training_tolerance ( Real  new_training_tolerance)
inlineinherited

Get/set the relative tolerance for the basis training.

Definition at line 218 of file rb_construction.h.

References libMesh::RBConstruction::rel_training_tolerance.

Referenced by libMesh::RBConstruction::set_rb_construction_parameters().

219  {this->rel_training_tolerance = new_training_tolerance; }
Real rel_training_tolerance
Relative and absolute tolerances for training reduced basis using the Greedy scheme.

◆ set_time_step()

void libMesh::RBTemporalDiscretization::set_time_step ( const unsigned int  k)
inherited

◆ set_training_parameter_values()

void libMesh::RBConstructionBase< LinearImplicitSystem >::set_training_parameter_values ( const std::string &  param_name,
const std::vector< RBParameter > &  values 
)
inherited

Overwrite the local training samples for param_name using values.

This assumes that values.size() matches get_local_n_training_samples().

Definition at line 456 of file rb_construction_base.C.

458 {
459  libmesh_error_msg_if(!_training_parameters_initialized,
460  "Training parameters must be initialized before calling set_training_parameter_values");
461  libmesh_error_msg_if(values.size() != get_local_n_training_samples(),
462  "Inconsistent sizes");
463 
464  // Copy the new data, overwriting the old data.
465  auto & training_vector = libmesh_map_find(_training_parameters, param_name);
466  training_vector = values;
467 }
numeric_index_type get_local_n_training_samples() const
Get the total number of training samples local to this processor.
std::map< std::string, std::vector< RBParameter > > _training_parameters
The training samples for each parameter.
bool _training_parameters_initialized
Boolean flag to indicate whether or not the parameter ranges have been initialized.

◆ set_training_random_seed()

void libMesh::RBConstructionBase< LinearImplicitSystem >::set_training_random_seed ( int  seed)
inherited

Set the seed that is used to randomly generate training parameters.

Definition at line 780 of file rb_construction_base.C.

Referenced by libMesh::RBConstruction::set_rb_construction_parameters().

781 {
783 }
int _training_parameters_random_seed
If < 0, use std::time() * processor_id() to seed the random number generator for the training paramet...

◆ set_vector_as_adjoint()

void libMesh::System::set_vector_as_adjoint ( const std::string &  vec_name,
int  qoi_num 
)
inherited

Allows one to set the QoI index controlling whether the vector identified by vec_name represents a solution from the adjoint (qoi_num >= 0) or primal (qoi_num == -1) space.

This becomes significant if those spaces have differing heterogeneous Dirichlet constraints.

qoi_num == -2 can be used to indicate a vector which should not be affected by constraints during projection operations.

Definition at line 1160 of file system.C.

References libMesh::System::_vector_is_adjoint.

Referenced by libMesh::System::add_adjoint_solution(), and libMesh::System::add_weighted_sensitivity_adjoint_solution().

1162 {
1163  parallel_object_only(); // Not strictly needed, but the only safe way to keep in sync
1164 
1165  // We reserve -1 for vectors which get primal constraints, -2 for
1166  // vectors which get no constraints
1167  libmesh_assert_greater_equal(qoi_num, -2);
1168  _vector_is_adjoint[vec_name] = qoi_num;
1169 }
std::map< std::string, int, std::less<> > _vector_is_adjoint
Holds non-negative if a vector by that name should be projected using adjoint constraints/BCs, -1 if primal.
Definition: system.h:2242

◆ set_vector_preservation()

void libMesh::System::set_vector_preservation ( const std::string &  vec_name,
bool  preserve 
)
inherited

Allows one to set the boolean controlling whether the vector identified by vec_name should be "preserved": projected to new meshes, saved, etc.

Definition at line 1138 of file system.C.

References libMesh::System::_vector_projections.

Referenced by libMesh::AdjointRefinementEstimator::estimate_error(), and main().

1140 {
1141  parallel_object_only(); // Not strictly needed, but the only safe way to keep in sync
1142 
1143  _vector_projections[vec_name] = preserve;
1144 }
std::map< std::string, bool, std::less<> > _vector_projections
Holds true if a vector by that name should be projected onto a changed grid, false if it should be ze...
Definition: system.h:2236

◆ setup_static_condensation_preconditioner()

template<typename T >
template void libMesh::ImplicitSystem::setup_static_condensation_preconditioner ( T &  solver)
protectedinherited

Sets up the static condensation preconditioner for the supplied solver.

Definition at line 71 of file implicit_system.C.

References libMesh::ImplicitSystem::_sc_system_matrix, libMesh::StaticCondensation::get_preconditioner(), and libMesh::libmesh_assert().

Referenced by libMesh::LinearImplicitSystem::create_static_condensation(), libMesh::NonlinearImplicitSystem::create_static_condensation(), libMesh::LinearImplicitSystem::LinearImplicitSystem(), and libMesh::NonlinearImplicitSystem::NonlinearImplicitSystem().

72 {
74  solver.attach_preconditioner(&_sc_system_matrix->get_preconditioner());
75 }
StaticCondensation * _sc_system_matrix
The system matrix for static condensation problems.
libmesh_assert(ctx)
StaticCondensationPreconditioner & get_preconditioner()
Get the preconditioning wrapper.

◆ solve()

void libMesh::LinearImplicitSystem::solve ( )
overridevirtualinherited

Assembles & solves the linear system A*x=b.

Reimplemented from libMesh::ImplicitSystem.

Reimplemented in libMesh::FrequencySystem.

Definition at line 118 of file linear_implicit_system.C.

References libMesh::LinearImplicitSystem::_final_linear_residual, libMesh::LinearImplicitSystem::_n_linear_iterations, libMesh::LinearImplicitSystem::_shell_matrix, libMesh::LinearImplicitSystem::_subset, libMesh::LinearImplicitSystem::_subset_solve_mode, libMesh::LinearImplicitSystem::assemble(), libMesh::System::assemble_before_solve, libMesh::SystemSubset::dof_ids(), libMesh::ImplicitSystem::get_linear_solve_parameters(), libMesh::ImplicitSystem::linear_solver, libMesh::ImplicitSystem::matrix, libMesh::System::prefix(), libMesh::System::prefix_with_name(), libMesh::System::request_matrix(), libMesh::ExplicitSystem::rhs, libMesh::System::solution, and libMesh::System::update().

Referenced by assemble_and_solve(), main(), libMesh::ClawSystem::solve_conservation_law(), SystemsTest::testDofCouplingWithVarGroups(), and PeriodicBCTest::testPeriodicBC().

119 {
120  if (this->assemble_before_solve)
121  // Assemble the linear system
122  this->assemble ();
123 
124  // If the linear solver hasn't been initialized, we do so here.
125  if (this->prefix_with_name())
126  linear_solver->init(this->prefix().c_str());
127  else
128  linear_solver->init();
129 
130  linear_solver->init_names(*this);
131 
132  // Get the user-specified linear solver tolerance
133  const auto [maxits, tol] = this->get_linear_solve_parameters();
134 
135  if (_subset != nullptr)
136  linear_solver->restrict_solve_to(&_subset->dof_ids(),_subset_solve_mode);
137 
138  // Solve the linear system. Several cases:
139  std::pair<unsigned int, Real> rval = std::make_pair(0,0.0);
140  if (_shell_matrix)
141  // 1.) Shell matrix with or without user-supplied preconditioner.
142  rval = linear_solver->solve(*_shell_matrix, this->request_matrix("Preconditioner"), *solution, *rhs, tol, maxits);
143  else
144  // 2.) No shell matrix, with or without user-supplied preconditioner
145  rval = linear_solver->solve (*matrix, this->request_matrix("Preconditioner"), *solution, *rhs, tol, maxits);
146 
147  if (_subset != nullptr)
148  linear_solver->restrict_solve_to(nullptr);
149 
150  // Store the number of linear iterations required to
151  // solve and the final residual.
152  _n_linear_iterations = rval.first;
153  _final_linear_residual = rval.second;
154 
155  // Update the system after the solve
156  this->update();
157 }
virtual void assemble() override
Prepares matrix and _dof_map for matrix assembly.
ShellMatrix< Number > * _shell_matrix
User supplies shell matrix or nullptr if no shell matrix is used.
unsigned int _n_linear_iterations
The number of linear iterations required to solve the linear system Ax=b.
virtual std::pair< unsigned int, Real > get_linear_solve_parameters() const
NumericVector< Number > * rhs
The system matrix.
SubsetSolveMode _subset_solve_mode
If restrict-solve-to-subset mode is active, this member decides what happens with the dofs outside th...
const SparseMatrix< Number > * request_matrix(std::string_view mat_name) const
Definition: system.C:1100
std::string prefix() const
Definition: system.h:1938
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
virtual const std::vector< unsigned int > & dof_ids() const =0
Real _final_linear_residual
The final residual for the linear system Ax=b.
virtual void update()
Update the local values to reflect the solution on neighboring processors.
Definition: system.C:510
SparseMatrix< Number > * matrix
The system matrix.
const SystemSubset * _subset
The current subset on which to solve (or nullptr if none).
bool assemble_before_solve
Flag which tells the system to whether or not to call the user assembly function during each call to ...
Definition: system.h:1547
std::unique_ptr< LinearSolver< Number > > linear_solver
This class handles all the details of interfacing with various linear algebra packages like PETSc or ...
bool prefix_with_name() const
Definition: system.h:1932

◆ solve_for_matrix_and_rhs()

void libMesh::RBConstruction::solve_for_matrix_and_rhs ( LinearSolver< Number > &  input_solver,
SparseMatrix< Number > &  input_matrix,
NumericVector< Number > &  input_rhs 
)
virtualinherited

Assembles & solves the linear system A*x=b for the specified matrix input_matrix and right-hand side rhs.

Definition at line 133 of file rb_construction.C.

References libMesh::LinearImplicitSystem::_final_linear_residual, libMesh::LinearImplicitSystem::_n_linear_iterations, libMesh::DofMap::enforce_constraints_exactly(), libMesh::Parameters::get(), libMesh::System::get_dof_map(), libMesh::System::get_equation_systems(), libMesh::LinearSolver< T >::init(), libMesh::EquationSystems::parameters, libMesh::Real, libMesh::System::solution, libMesh::LinearSolver< T >::solve(), and libMesh::System::update().

Referenced by libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), libMesh::RBConstruction::enrich_basis_from_rhs_terms(), truth_solve(), libMesh::RBConstruction::truth_solve(), update_residual_terms(), and libMesh::RBConstruction::update_residual_terms().

136 {
137  // This is similar to LinearImplicitSysmte::solve()
138 
139  // Get a reference to the EquationSystems
140  const EquationSystems & es =
141  this->get_equation_systems();
142 
143  // If the linear solver hasn't been initialized, we do so here.
144  input_solver.init();
145 
146  // Get the user-specifiied linear solver tolerance
147  const double tol =
148  double(es.parameters.get<Real>("linear solver tolerance"));
149 
150  // Get the user-specified maximum # of linear solver iterations
151  const unsigned int maxits =
152  es.parameters.get<unsigned int>("linear solver maximum iterations");
153 
154  // It's good practice to clear the solution vector first since it can
155  // affect convergence of iterative solvers
156  solution->zero();
157 
158  // Solve the linear system.
159  // Store the number of linear iterations required to
160  // solve and the final residual.
162  input_solver.solve (input_matrix, *solution, input_rhs, tol, maxits);
163 
165 
166  // Update the system after the solve
167  this->update();
168 }
unsigned int _n_linear_iterations
The number of linear iterations required to solve the linear system Ax=b.
const EquationSystems & get_equation_systems() const
Definition: system.h:721
virtual void init(const char *name=nullptr)=0
Initialize data structures if not done so already.
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
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...
Real _final_linear_residual
The final residual for the linear system Ax=b.
virtual void update()
Update the local values to reflect the solution on neighboring processors.
Definition: system.C:510
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const DofMap & get_dof_map() const
Definition: system.h:2374
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. ...
Definition: dof_map.h:2350

◆ solve_for_unconstrained_dofs()

void libMesh::System::solve_for_unconstrained_dofs ( NumericVector< Number > &  vec,
int  is_adjoint = -1 
) const
protectedinherited

Definition at line 2041 of file system_projection.C.

References libMesh::DofMap::build_sparsity(), libMesh::DofMap::computed_sparsity_already(), libMesh::DofMapBase::end_dof(), libMesh::DofMapBase::first_dof(), libMesh::NumericVector< T >::get(), libMesh::DofMap::heterogenously_constrain_element_matrix_and_vector(), libMesh::DofMap::is_constrained_dof(), libMesh::NumericVector< T >::local_size(), libMesh::DofMap::n_dofs(), libMesh::DofMap::n_local_dofs(), libMesh::PARALLEL, libMesh::Real, libMesh::NumericVector< T >::size(), and libMesh::DofMap::update_sparsity_pattern().

2043 {
2044  const DofMap & dof_map = this->get_dof_map();
2045 
2046  std::unique_ptr<SparseMatrix<Number>> mat =
2048 
2049  std::unique_ptr<SparsityPattern::Build> sp;
2050 
2051  if (dof_map.computed_sparsity_already())
2052  dof_map.update_sparsity_pattern(*mat);
2053  else
2054  {
2055  mat->attach_dof_map(dof_map);
2056  sp = dof_map.build_sparsity(this->get_mesh());
2057  mat->attach_sparsity_pattern(*sp);
2058  }
2059 
2060  mat->init();
2061 
2062  libmesh_assert_equal_to(vec.size(), dof_map.n_dofs());
2063  libmesh_assert_equal_to(vec.local_size(), dof_map.n_local_dofs());
2064 
2065  std::unique_ptr<NumericVector<Number>> rhs =
2067 
2068  rhs->init(dof_map.n_dofs(), dof_map.n_local_dofs(), false,
2069  PARALLEL);
2070 
2071  // Here we start with the unconstrained (and indeterminate) linear
2072  // system, K*u = f, where K is the identity matrix for constrained
2073  // DoFs and 0 elsewhere, and f is the current solution values for
2074  // constrained DoFs and 0 elsewhere.
2075  // We then apply the usual heterogeneous constraint matrix C and
2076  // offset h, where u = C*x + h,
2077  // to get C^T*K*C*x = C^T*f - C^T*K*h
2078  // - a constrained and no-longer-singular system that finds the
2079  // closest approximation for the unconstrained degrees of freedom.
2080  //
2081  // Here, though "closest" is in an algebraic sense; we're
2082  // effectively using a pseudoinverse that optimizes in a
2083  // discretization-dependent norm. That only seems to give ~0.1%
2084  // excess error even in coarse unit test cases, but at some point it
2085  // might be reasonable to weight K and f properly.
2086 
2087  for (dof_id_type d : IntRange<dof_id_type>(dof_map.first_dof(),
2088  dof_map.end_dof()))
2089  {
2090  if (dof_map.is_constrained_dof(d))
2091  {
2092  DenseMatrix<Number> K(1,1);
2093  DenseVector<Number> F(1);
2094  std::vector<dof_id_type> dof_indices(1, d);
2095  K(0,0) = 1;
2096  F(0) = (*this->solution)(d);
2097  dof_map.heterogenously_constrain_element_matrix_and_vector
2098  (K, F, dof_indices, false, is_adjoint);
2099  mat->add_matrix(K, dof_indices);
2100  rhs->add_vector(F, dof_indices);
2101  }
2102  }
2103 
2104  std::unique_ptr<LinearSolver<Number>> linear_solver =
2106 
2107  linear_solver->solve(*mat, vec, *rhs,
2108  double(this->get_equation_systems().parameters.get<Real>("linear solver tolerance")),
2109  this->get_equation_systems().parameters.get<unsigned int>("linear solver maximum iterations"));
2110 }
static std::unique_ptr< LinearSolver< T > > build(const libMesh::Parallel::Communicator &comm_in, const SolverPackage solver_package=libMesh::default_solver_package())
Builds a LinearSolver using the linear solver package specified by solver_package.
Definition: linear_solver.C:59
virtual numeric_index_type size() const =0
const EquationSystems & get_equation_systems() const
Definition: system.h:721
const Parallel::Communicator & comm() const
Parameters parameters
Parameters for the system. If a parameter is not provided, it should be retrieved from the EquationSy...
Definition: system.h:1526
const MeshBase & get_mesh() const
Definition: system.h:2358
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.
const T & get(std::string_view) const
Definition: parameters.h:426
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual numeric_index_type local_size() 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...
const DofMap & get_dof_map() const
Definition: system.h:2374
uint8_t dof_id_type
Definition: id_types.h:67

◆ system()

sys_type& libMesh::TransientSystem< RBConstruction >::system ( )
inlineinherited
Returns
A reference to *this.

Definition at line 89 of file transient_system.h.

89 { return *this; }

◆ system_type()

std::string libMesh::TransientSystem< RBConstruction >::system_type ( ) const
inlineoverridevirtualinherited
Returns
"Transient" prepended to T::system_type(). Helps in identifying the system type in an equation system file.

Reimplemented from libMesh::RBConstruction.

Definition at line 172 of file transient_system.h.

173 {
174  std::string type = "Transient";
175  type += Base::system_type ();
176 
177  return type;
178 }

◆ train_reduced_basis()

Real TransientRBConstruction::train_reduced_basis ( const bool  resize_rb_eval_data = true)
overridevirtual

Train the reduced basis.

Overridden so that we can set the flag compute_truth_projection_error to true so that the calls to truth_solve during the basis construction will compute the projection error. Other calls to truth_solve generally do not need to perform these projection calculations.

Reimplemented from libMesh::RBConstruction.

Definition at line 281 of file transient_rb_construction.C.

References compute_truth_projection_error, libMesh::RBConstruction::get_RB_training_type(), libMesh::Real, libMesh::RBConstruction::train_reduced_basis(), and value.

282 {
283  libmesh_error_msg_if(get_RB_training_type() == "POD",
284  "POD RB training is not supported with TransientRBConstruction");
285 
287  Real value = Parent::train_reduced_basis(resize_rb_eval_data);
289 
290  return value;
291 }
virtual Real train_reduced_basis(const bool resize_rb_eval_data=true)
Train the reduced basis.
const std::string & get_RB_training_type() const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const bool value
Definition: xdr_io.C:54
bool compute_truth_projection_error
Boolean flag that indicates whether we will compute the projection error for the truth solution into ...

◆ train_reduced_basis_with_greedy()

Real libMesh::RBConstruction::train_reduced_basis_with_greedy ( const bool  resize_rb_eval_data)
inherited

Train the reduced basis using the "Greedy algorithm.".

Each stage of the Greedy algorithm involves solving the reduced basis over a large training set and selecting the parameter at which the reduced basis error bound is largest, then performing a truth_solve at that parameter and enriching the reduced basis with the corresponding snapshot.

resize_rb_eval_data is a boolean flag to indicate whether or not we call rb_eval->resize_data_structures(Nmax). True by default, but we may set it to false if, for example, we are continuing from a previous training run and don't want to clobber the existing rb_eval data.

Returns
The final maximum a posteriori error bound on the training set.

Definition at line 1196 of file rb_construction.C.

References libMesh::RBConstruction::check_if_zero_truth_solve(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_max_error_bound(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::enrich_RB_space(), libMesh::RBEvaluation::get_n_basis_functions(), libMesh::RBConstruction::get_Nmax(), libMesh::RBConstruction::get_preevaluate_thetas_flag(), libMesh::RBConstruction::get_rb_evaluation(), libMesh::RBEvaluation::greedy_param_list, libMesh::RBConstruction::greedy_termination_test(), libMesh::RBParametrized::initialize_parameters(), libMesh::out, libMesh::RBConstruction::preevaluate_thetas(), libMesh::RBParametrized::print_parameters(), libMesh::Real, libMesh::RBEvaluation::resize_data_structures(), libMesh::RBConstruction::skip_residual_in_train_reduced_basis, libMesh::RBConstruction::truth_solve(), libMesh::RBConstruction::update_greedy_param_list(), libMesh::RBConstruction::update_residual_terms(), libMesh::RBConstruction::update_system(), and libMesh::RBConstruction::use_empty_rb_solve_in_greedy.

Referenced by libMesh::RBConstruction::train_reduced_basis().

1197 {
1198  LOG_SCOPE("train_reduced_basis_with_greedy()", "RBConstruction");
1199 
1200  int count = 0;
1201 
1202  RBEvaluation & rbe = get_rb_evaluation();
1203 
1204  // initialize rbe's parameters
1205  rbe.initialize_parameters(*this);
1206 
1207  // possibly resize data structures according to Nmax
1208  if (resize_rb_eval_data)
1209  rbe.resize_data_structures(get_Nmax());
1210 
1211  // Clear the Greedy param list
1212  for (auto & plist : rbe.greedy_param_list)
1213  plist.clear();
1214 
1215  rbe.greedy_param_list.clear();
1216 
1217  Real training_greedy_error = 0.;
1218 
1219 
1220  // If we are continuing from a previous training run,
1221  // we might already be at the max number of basis functions.
1222  // If so, we can just return.
1223  if (rbe.get_n_basis_functions() >= get_Nmax())
1224  {
1225  libMesh::out << "Maximum number of basis functions reached: Nmax = "
1226  << get_Nmax() << std::endl;
1227  return 0.;
1228  }
1229 
1230  // Optionally pre-evaluate the theta functions on the entire (local) training parameter set.
1233 
1235  {
1236  // Compute the dual norms of the outputs if we haven't already done so.
1238 
1239  // Compute the Fq Riesz representor dual norms if we haven't already done so.
1241  }
1242 
1243  libMesh::out << std::endl << "---- Performing Greedy basis enrichment ----" << std::endl;
1244  Real initial_greedy_error = 0.;
1245  bool initial_greedy_error_initialized = false;
1246  while (true)
1247  {
1248  libMesh::out << std::endl << "---- Basis dimension: "
1249  << rbe.get_n_basis_functions() << " ----" << std::endl;
1250 
1251  if (count > 0 || (count==0 && use_empty_rb_solve_in_greedy))
1252  {
1253  libMesh::out << "Performing RB solves on training set" << std::endl;
1254  training_greedy_error = compute_max_error_bound();
1255 
1256  libMesh::out << "Maximum error bound is " << training_greedy_error << std::endl << std::endl;
1257 
1258  // record the initial error
1259  if (!initial_greedy_error_initialized)
1260  {
1261  initial_greedy_error = training_greedy_error;
1262  initial_greedy_error_initialized = true;
1263  }
1264 
1265  // Break out of training phase if we have reached Nmax
1266  // or if the training_tolerance is satisfied.
1267  if (greedy_termination_test(training_greedy_error, initial_greedy_error, count))
1268  break;
1269  }
1270 
1271  libMesh::out << "Performing truth solve at parameter:" << std::endl;
1272  print_parameters();
1273 
1274  // Update the list of Greedily selected parameters
1275  this->update_greedy_param_list();
1276 
1277  // Perform an Offline truth solve for the current parameter
1278  truth_solve(-1);
1279 
1281  {
1282  libMesh::out << "Zero basis function encountered hence ending basis enrichment" << std::endl;
1283  break;
1284  }
1285 
1286  // Add orthogonal part of the snapshot to the RB space
1287  libMesh::out << "Enriching the RB space" << std::endl;
1288  enrich_RB_space();
1289 
1290  update_system();
1291 
1292  // Check if we've reached Nmax now. We do this before calling
1293  // update_residual_terms() since we can skip that step if we've
1294  // already reached Nmax.
1295  if (rbe.get_n_basis_functions() >= this->get_Nmax())
1296  {
1297  libMesh::out << "Maximum number of basis functions reached: Nmax = "
1298  << get_Nmax() << std::endl;
1299  break;
1300  }
1301 
1303  {
1305  }
1306 
1307  // Increment counter
1308  count++;
1309  }
1310  this->update_greedy_param_list();
1311 
1312  return training_greedy_error;
1313 }
virtual Real truth_solve(int plot_solution)
Perform a "truth" solve, i.e.
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 compute_max_error_bound()
(i) Compute the a posteriori error bound for each set of parameters in the training set...
bool use_empty_rb_solve_in_greedy
A boolean flag to indicate whether or not we initialize the Greedy algorithm by performing rb_solves ...
bool get_preevaluate_thetas_flag() const
Get/set flag to pre-evaluate the theta functions.
void update_greedy_param_list()
Update the list of Greedily chosen parameters with current_parameters.
unsigned int get_Nmax() const
Get/set Nmax, the maximum number of RB functions we are willing to compute.
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.
virtual void update_system()
Update the system after enriching the RB space; this calls a series of functions to update the system...
void print_parameters() const
Print the current parameters.
bool skip_residual_in_train_reduced_basis
Boolean flag to indicate if we skip residual calculations in train_reduced_basis. ...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
OStreamProxy out
virtual void preevaluate_thetas()
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 bool check_if_zero_truth_solve() const
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.
virtual void compute_output_dual_innerprods()
Compute and store the dual norm of each output functional.
virtual void enrich_RB_space()
Add a new basis function to the RB space.

◆ train_reduced_basis_with_POD()

void libMesh::RBConstruction::train_reduced_basis_with_POD ( )
inherited

Train the reduced basis using Proper Orthogonal Decomposition (POD).

This is an alternative to train_reduced_basis(), which uses the RB greedy algorithm. In contrast to the RB greedy algorithm, POD requires us to perform truth solves at all training samples, which can be computationally intensive.

The main advantage of using POD is that it does not rely on the RB error indicator. The RB error indicator typically stagnates due to rounding error at approximately square-root of machine precision, since it involves taking the square-root of a sum of terms that cancel. This error indicator stagnation puts a limit on the accuracy level that can be achieved with the RB greedy algorithm, so for cases where we need higher accuracy, the POD approach is a good alternative.

Definition at line 1409 of file rb_construction.C.

References libMesh::RBConstructionBase< LinearImplicitSystem >::_normalize_solution_snapshots, libMesh::RBEvaluation::basis_functions, libMesh::NumericVector< T >::build(), libMesh::ParallelObject::comm(), libMesh::RBConstruction::delta_N, libMesh::DenseMatrix< T >::el(), libMesh::RBEvaluation::get_n_basis_functions(), libMesh::RBParametrized::get_n_params(), libMesh::RBConstructionBase< LinearImplicitSystem >::get_n_training_samples(), libMesh::RBConstruction::get_Nmax(), libMesh::RBConstruction::get_non_dirichlet_inner_product_matrix_if_avail(), libMesh::RBConstruction::get_rb_evaluation(), libMesh::RBParametrized::initialize_parameters(), libMesh::RBConstructionBase< LinearImplicitSystem >::inner_product_storage_vector, libMesh::libmesh_assert(), libMesh::libmesh_conj(), libMesh::System::n_dofs(), libMesh::System::n_local_dofs(), libMesh::TensorTools::norm(), libMesh::out, libMesh::PARALLEL, std::real(), libMesh::Real, libMesh::RBConstruction::recompute_all_residual_terms(), libMesh::RBConstruction::rel_training_tolerance, libMesh::RBEvaluation::resize_data_structures(), libMesh::RBConstructionBase< LinearImplicitSystem >::serial_training_set, libMesh::RBConstructionBase< LinearImplicitSystem >::set_params_from_training_set(), libMesh::System::solution, libMesh::DenseMatrix< T >::svd(), libMesh::RBConstruction::truth_solve(), libMesh::RBConstruction::update_system(), and libMesh::SparseMatrix< T >::vector_mult().

Referenced by libMesh::RBConstruction::train_reduced_basis().

1410 {
1411  // We need to use the same training set on all processes so that
1412  // the truth solves below work correctly in parallel.
1413  libmesh_error_msg_if(!serial_training_set, "We must use a serial training set with POD");
1414  libmesh_error_msg_if(get_rb_evaluation().get_n_basis_functions() > 0, "Basis should not already be initialized");
1415 
1418 
1419  // Storage for the POD snapshots
1420  unsigned int n_snapshots = get_n_training_samples();
1421 
1422  if (get_n_params() == 0)
1423  {
1424  // In this case we should have generated an empty training set
1425  // so assert this
1426  libmesh_assert(n_snapshots == 0);
1427 
1428  // If we have no parameters, then we should do exactly one "truth solve"
1429  n_snapshots = 1;
1430  }
1431 
1432  std::vector<std::unique_ptr<NumericVector<Number>>> POD_snapshots(n_snapshots);
1433  for (unsigned int i=0; i<n_snapshots; i++)
1434  {
1435  POD_snapshots[i] = NumericVector<Number>::build(this->comm());
1436  POD_snapshots[i]->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
1437  }
1438 
1439  // We use the same training set on all processes
1440  libMesh::out << std::endl;
1441  for (unsigned int i=0; i<n_snapshots; i++)
1442  {
1443  if (get_n_params() > 0)
1444  {
1446  }
1447 
1448  libMesh::out << "Truth solve " << (i+1) << " of " << n_snapshots << std::endl;
1449 
1450  truth_solve(-1);
1451 
1452  *POD_snapshots[i] = *solution;
1453  }
1454  libMesh::out << std::endl;
1455 
1457  {
1458  libMesh::out << "Normalizing solution snapshots" << std::endl;
1459  for (unsigned int i=0; i<n_snapshots; i++)
1460  {
1462  *inner_product_storage_vector, *POD_snapshots[i]);
1463  Real norm = std::sqrt(std::real(POD_snapshots[i]->dot(*inner_product_storage_vector)));
1464 
1465  if (norm > 0.)
1466  POD_snapshots[i]->scale(1./norm);
1467  }
1468  }
1469 
1470  // Set up the "correlation matrix"
1471  DenseMatrix<Number> correlation_matrix(n_snapshots,n_snapshots);
1472  for (unsigned int i=0; i<n_snapshots; i++)
1473  {
1475  *inner_product_storage_vector, *POD_snapshots[i]);
1476 
1477  for (unsigned int j=0; j<=i; j++)
1478  {
1479  Number inner_prod = (POD_snapshots[j]->dot(*inner_product_storage_vector));
1480 
1481  correlation_matrix(i,j) = inner_prod;
1482  if(i != j)
1483  {
1484  correlation_matrix(j,i) = libmesh_conj(inner_prod);
1485  }
1486  }
1487  }
1488 
1489  // compute SVD of correlation matrix
1490  DenseVector<Real> sigma( n_snapshots );
1491  DenseMatrix<Number> U( n_snapshots, n_snapshots );
1492  DenseMatrix<Number> VT( n_snapshots, n_snapshots );
1493  correlation_matrix.svd(sigma, U, VT );
1494 
1495  if (sigma(0) == 0.)
1496  return;
1497 
1498  // Add dominant vectors from the POD as basis functions.
1499  unsigned int j = 0;
1500  while (true)
1501  {
1502  if (j >= get_Nmax() || j >= n_snapshots)
1503  {
1504  libMesh::out << "Maximum number of basis functions (" << j << ") reached." << std::endl;
1505  break;
1506  }
1507 
1508  // The "energy" error in the POD approximation is determined by the first omitted
1509  // singular value, i.e. sigma(j). We normalize by sigma(0), which gives the total
1510  // "energy", in order to obtain a relative error.
1511  const Real rel_err = std::sqrt(sigma(j)) / std::sqrt(sigma(0));
1512 
1513  libMesh::out << "Number of basis functions: " << j
1514  << ", POD error norm: " << rel_err << std::endl;
1515 
1516  if (rel_err < this->rel_training_tolerance)
1517  {
1518  libMesh::out << "Training tolerance reached." << std::endl;
1519  break;
1520  }
1521 
1522  std::unique_ptr< NumericVector<Number> > v = POD_snapshots[j]->zero_clone();
1523  for ( unsigned int i=0; i<n_snapshots; ++i )
1524  {
1525  v->add( U.el(i, j), *POD_snapshots[i] );
1526  }
1527 
1528  Real norm_v = std::sqrt(sigma(j));
1529  v->scale( 1./norm_v );
1530 
1531  get_rb_evaluation().basis_functions.emplace_back( std::move(v) );
1532 
1533  j++;
1534  }
1535  libMesh::out << std::endl;
1536 
1538  update_system();
1539 
1540  // We now compute all terms required to evaluate the RB error indicator.
1541  // Unlike in the case of the RB Greedy algorithm, for the POD approach
1542  // we do not need this data in order to compute the basis. However, we
1543  // do need this data in order to evaluate error indicator quantities in
1544  // the Online stage, so we compute it now so that it can be saved in
1545  // the training data.
1547 }
boost::multiprecision::float128 real(const boost::multiprecision::float128 in)
T libmesh_conj(T a)
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.
bool _normalize_solution_snapshots
Set this boolean to true if we want to normalize solution snapshots used in training to have norm of ...
virtual Real truth_solve(int plot_solution)
Perform a "truth" solve, i.e.
template class LIBMESH_EXPORT DenseVector< Real >
Definition: dense_vector.C:29
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...
std::vector< std::unique_ptr< NumericVector< Number > > > basis_functions
The libMesh vectors storing the finite element coefficients of the RB basis functions.
const Parallel::Communicator & comm() const
dof_id_type n_local_dofs() const
Definition: system.C:158
dof_id_type n_dofs() const
Definition: system.C:121
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 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...
Real rel_training_tolerance
Relative and absolute tolerances for training reduced basis using the Greedy scheme.
unsigned int get_Nmax() const
Get/set Nmax, the maximum number of RB functions we are willing to compute.
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
virtual void update_system()
Update the system after enriching the RB space; this calls a series of functions to update the system...
libmesh_assert(ctx)
auto norm(const T &a) -> decltype(std::abs(a))
Definition: tensor_tools.h:74
unsigned int delta_N
The number of basis functions that we add at each greedy step.
numeric_index_type get_n_training_samples() const
Get the number of global training samples.
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...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
OStreamProxy out
virtual unsigned int get_n_basis_functions() const
Get the current number of basis functions.
SparseMatrix< Number > * get_non_dirichlet_inner_product_matrix_if_avail()
Get the non-Dirichlet inner-product matrix if it&#39;s available, otherwise get the inner-product 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...
bool serial_training_set
This boolean flag indicates whether or not the training set should be the same on all processors...
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.
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.
unsigned int get_n_params() const
Get the number of parameters.

◆ truth_assembly()

void TransientRBConstruction::truth_assembly ( )
overridevirtual

Assemble the truth system in the transient linear case.

Reimplemented from libMesh::RBConstruction.

Definition at line 400 of file transient_rb_construction.C.

References libMesh::SparseMatrix< T >::add(), libMesh::NumericVector< T >::add(), add_scaled_mass_matrix(), libMesh::NumericVector< T >::build(), libMesh::NumericVector< T >::close(), libMesh::SparseMatrix< T >::close(), libMesh::ParallelObject::comm(), libMesh::System::current_local_solution, libMesh::RBThetaExpansion::eval_A_theta(), libMesh::RBThetaExpansion::eval_F_theta(), libMesh::RBConstruction::get_Aq(), libMesh::RBTemporalDiscretization::get_control(), libMesh::RBTemporalDiscretization::get_delta_t(), libMesh::RBTemporalDiscretization::get_euler_theta(), libMesh::RBConstruction::get_Fq(), libMesh::RBThetaExpansion::get_n_A_terms(), libMesh::RBThetaExpansion::get_n_F_terms(), libMesh::RBParametrized::get_parameters(), libMesh::RBConstruction::get_rb_theta_expansion(), libMesh::RBTemporalDiscretization::get_time_step(), mass_matrix_scaled_matvec(), libMesh::ImplicitSystem::matrix, libMesh::System::n_dofs(), libMesh::System::n_local_dofs(), libMesh::PARALLEL, libMesh::Real, libMesh::ExplicitSystem::rhs, libMesh::SparseMatrix< T >::vector_mult(), libMesh::NumericVector< T >::zero(), and libMesh::SparseMatrix< T >::zero().

Referenced by truth_solve().

401 {
402  LOG_SCOPE("truth_assembly()", "TransientRBConstruction");
403 
404  this->matrix->close();
405 
406  this->matrix->zero();
407  this->rhs->zero();
408 
409  const RBParameters & mu = get_parameters();
410 
411  TransientRBThetaExpansion & trans_theta_expansion =
412  cast_ref<TransientRBThetaExpansion &>(get_rb_theta_expansion());
413 
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();
416 
417  const Real dt = get_delta_t();
418  const Real euler_theta = get_euler_theta();
419 
420  {
421  // We should have already assembled the matrices
422  // and vectors in the affine expansion, so
423  // just use them
424 
427 
428  std::unique_ptr<NumericVector<Number>> temp_vec = NumericVector<Number>::build(this->comm());
429  temp_vec->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
430 
431  for (unsigned int q_a=0; q_a<Q_a; q_a++)
432  {
433  matrix->add(euler_theta*trans_theta_expansion.eval_A_theta(q_a,mu), *get_Aq(q_a));
434 
435  get_Aq(q_a)->vector_mult(*temp_vec, *current_local_solution);
436  temp_vec->scale( -(1.-euler_theta)*trans_theta_expansion.eval_A_theta(q_a,mu) );
437  rhs->add(*temp_vec);
438  }
439 
440  for (unsigned int q_f=0; q_f<Q_f; q_f++)
441  {
442  *temp_vec = *get_Fq(q_f);
443  temp_vec->scale( get_control(get_time_step())*trans_theta_expansion.eval_F_theta(q_f,mu) );
444  rhs->add(*temp_vec);
445  }
446 
447  }
448 
449  this->matrix->close();
450  this->rhs->close();
451 }
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...
SparseMatrix< Number > * get_Aq(unsigned int q)
Get a pointer to Aq.
NumericVector< Number > * rhs
The system matrix.
const Parallel::Communicator & comm() const
NumericVector< Number > * get_Fq(unsigned int q)
Get a pointer to Fq.
dof_id_type n_local_dofs() const
Definition: system.C:158
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.
dof_id_type n_dofs() const
Definition: system.C:121
virtual void zero()=0
Set all entries to zero.
virtual void add(const numeric_index_type i, const numeric_index_type j, const T value)=0
Add value to the element (i,j).
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
virtual void zero()=0
Set all entries to 0.
const RBParameters & get_parameters() const
Get the current parameters.
unsigned int get_time_step() const
Get/set the current time-step.
virtual void close()=0
Calls the NumericVector&#39;s internal assembly routines, ensuring that the values are consistent across ...
virtual void close()=0
Calls the SparseMatrix&#39;s internal assembly routines, ensuring that the values are consistent across p...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
SparseMatrix< Number > * matrix
The system 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. ...
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Definition: system.h:1605
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...
virtual void add(const numeric_index_type i, const T value)=0
Adds value to the vector entry specified by i.
Real get_control(const unsigned int k) const
Get/set the RHS control.

◆ truth_solve()

Real TransientRBConstruction::truth_solve ( int  write_interval)
overridevirtual

Perform a truth solve at the current parameter.

Reimplemented from libMesh::RBConstruction.

Definition at line 516 of file transient_rb_construction.C.

References libMesh::RBConstruction::assert_convergence, libMesh::RBConstruction::check_convergence(), compute_truth_projection_error, libMesh::System::current_local_solution, libMesh::NumericVector< T >::dot(), libMesh::RBThetaExpansion::eval_output_theta(), libMesh::System::get_equation_systems(), libMesh::LinearImplicitSystem::get_linear_solver(), libMesh::System::get_mesh(), libMesh::RBThetaExpansion::get_n_output_terms(), libMesh::RBThetaExpansion::get_n_outputs(), libMesh::RBTemporalDiscretization::get_n_time_steps(), libMesh::RBConstruction::get_output_vector(), libMesh::RBParametrized::get_parameters(), libMesh::RBConstruction::get_rb_theta_expansion(), initialize_truth(), libMesh::RBConstructionBase< LinearImplicitSystem >::inner_product_storage_vector, L2_matrix, libMesh::libmesh_real(), libMesh::ImplicitSystem::linear_solver, libMesh::ImplicitSystem::matrix, libMesh::TransientSystem< RBConstruction >::old_local_solution, libMesh::out, libMesh::Real, libMesh::ExplicitSystem::rhs, set_error_temporal_data(), libMesh::RBTemporalDiscretization::set_time_step(), libMesh::System::solution, libMesh::RBConstruction::solve_for_matrix_and_rhs(), truth_assembly(), truth_outputs_all_k, and libMesh::ExodusII_IO::write_equation_systems().

517 {
518  LOG_SCOPE("truth_solve()", "TransientRBConstruction");
519 
520  const RBParameters & mu = get_parameters();
521  const unsigned int n_time_steps = get_n_time_steps();
522 
523  // // NumericVector for computing true L2 error
524  // std::unique_ptr<NumericVector<Number>> temp = NumericVector<Number>::build();
525  // temp->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
526 
527  // Apply initial condition again.
529  set_time_step(0);
530 
531  // Now compute the truth outputs
532  for (unsigned int n=0; n<get_rb_theta_expansion().get_n_outputs(); n++)
533  {
534  truth_outputs_all_k[n][0] = 0.;
535  for (unsigned int q_l=0; q_l<get_rb_theta_expansion().get_n_output_terms(n); q_l++)
536  {
538  get_output_vector(n,q_l)->dot(*solution);
539  }
540  }
541 
542  // Load initial projection error into temporal_data dense matrix
545 
546  for (unsigned int time_level=1; time_level<=n_time_steps; time_level++)
547  {
548  set_time_step(time_level);
549 
551 
552  // We assume that the truth assembly has been attached to the system
553  truth_assembly();
554 
555  // truth_assembly assembles into matrix and rhs, so use those for the solve
557 
558  // The matrix doesn't change at each timestep, so we
559  // can set reuse_preconditioner == true
560  linear_solver->reuse_preconditioner(true);
561 
562  if (assert_convergence)
563  {
565  }
566 
567  // Now compute the truth outputs
568  for (unsigned int n=0; n<get_rb_theta_expansion().get_n_outputs(); n++)
569  {
570  truth_outputs_all_k[n][time_level] = 0.;
571  for (unsigned int q_l=0; q_l<get_rb_theta_expansion().get_n_output_terms(n); q_l++)
572  {
573  truth_outputs_all_k[n][time_level] +=
575  }
576  }
577 
578  // load projection error into column _k of temporal_data matrix
581 
582  if ((write_interval > 0) && (time_level%write_interval == 0))
583  {
584  libMesh::out << std::endl << "Truth solve, plotting time step " << time_level << std::endl;
585 
586  std::ostringstream file_name;
587 
588  file_name << "truth.e.";
589  file_name << std::setw(3)
590  << std::setprecision(0)
591  << std::setfill('0')
592  << std::right
593  << time_level;
594 
595 #ifdef LIBMESH_HAVE_EXODUS_API
596  ExodusII_IO(get_mesh()).write_equation_systems (file_name.str(),
597  this->get_equation_systems());
598 #endif
599  }
600  }
601 
602  // Set reuse_preconditioner back to false for subsequent solves.
603  linear_solver->reuse_preconditioner(false);
604 
605  // Get the L2 norm of the truth solution at time-level _K
606  // Useful for normalizing our true error data
608  Real final_truth_L2_norm = libmesh_real(std::sqrt(inner_product_storage_vector->dot(*solution)));
609 
610 
611  return final_truth_L2_norm;
612 }
T libmesh_real(T a)
std::unique_ptr< SparseMatrix< Number > > L2_matrix
The L2 matrix.
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.
bool assert_convergence
A boolean flag to indicate whether to check for proper convergence after each solve.
virtual void truth_assembly() override
Assemble the truth system in the transient linear case.
virtual void initialize_truth()
This function imposes a truth initial condition, defaults to zero initial condition if the flag nonze...
const EquationSystems & get_equation_systems() const
Definition: system.h:721
NumericVector< Number > * rhs
The system matrix.
std::vector< std::vector< Number > > truth_outputs_all_k
The truth outputs for all time-levels from the most recent truth_solve.
virtual LinearSolver< Number > * get_linear_solver() const override
virtual T dot(const NumericVector< T > &v) const =0
unsigned int get_n_outputs() const
Get n_outputs, the number output functionals.
const MeshBase & get_mesh() const
Definition: system.h:2358
NumericVector< Number > * old_local_solution
All the values I need to compute my contribution to the simulation at hand.
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 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 ...
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
Number set_error_temporal_data()
Set column k (i.e.
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
const RBParameters & get_parameters() const
Get the current parameters.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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.
OStreamProxy out
SparseMatrix< Number > * matrix
The system matrix.
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Definition: system.h:1605
unsigned int get_n_time_steps() const
Get/set the total number of time-steps.
NumericVector< Number > * get_output_vector(unsigned int n, unsigned int q_l)
Get a pointer to the n^th output.
bool compute_truth_projection_error
Boolean flag that indicates whether we will compute the projection error for the truth solution into ...
std::unique_ptr< LinearSolver< Number > > linear_solver
This class handles all the details of interfacing with various linear algebra packages like PETSc or ...

◆ update()

void libMesh::System::update ( )
virtualinherited

Update the local values to reflect the solution on neighboring processors.

Reimplemented in SolidSystem.

Definition at line 510 of file system.C.

References libMesh::System::_dof_map, libMesh::System::current_local_solution, libMesh::libmesh_assert(), and libMesh::System::solution.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::FEMSystem::assemble_qoi(), libMesh::FEMSystem::assemble_qoi_derivative(), libMesh::NonlinearImplicitSystem::assembly(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::NewmarkSolver::compute_initial_accel(), compute_stresses(), LinearElasticityWithContact::compute_stresses(), LinearElasticity::compute_stresses(), LargeDeformationElasticity::compute_stresses(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::Nemesis_IO::copy_elemental_solution(), libMesh::GMVIO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::Nemesis_IO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), DMlibMeshFunction(), DMlibMeshJacobian(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::CondensedEigenSystem::get_eigenpair(), initialize_truth(), libMesh::Euler2Solver::integrate_adjoint_refinement_error_estimate(), libMesh::EulerSolver::integrate_adjoint_refinement_error_estimate(), libMesh::libmesh_petsc_snes_fd_residual(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_mffd_residual(), libMesh::libmesh_petsc_snes_residual(), libMesh::libmesh_petsc_snes_residual_helper(), libMesh::NewtonSolver::line_search(), libMesh::RBConstruction::load_basis_function(), load_rb_solution(), libMesh::RBConstruction::load_rb_solution(), main(), libMesh::FEMSystem::mesh_position_get(), HeatSystem::perturb_accumulate_residuals(), libMesh::FEMSystem::postprocess(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::MemorySolutionHistory::retrieve(), libMesh::FileSolutionHistory::retrieve(), libMesh::NewtonSolver::solve(), libMesh::ExplicitSystem::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::OptimizationSystem::solve(), libMesh::NonlinearImplicitSystem::solve(), libMesh::ClawSystem::solve_conservation_law(), libMesh::RBConstruction::solve_for_matrix_and_rhs(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::DirectSolutionTransfer::transfer(), and update_current_local_solution().

511 {
512  parallel_object_only();
513 
514  libmesh_assert(solution->closed());
515 
516  const std::vector<dof_id_type> & send_list = _dof_map->get_send_list ();
517 
518  // Check sizes
519  libmesh_assert_equal_to (current_local_solution->size(), solution->size());
520  // More processors than elements => empty send_list
521  // libmesh_assert (!send_list.empty());
522  libmesh_assert_less_equal (send_list.size(), solution->size());
523 
524  // Create current_local_solution from solution. This will
525  // put a local copy of solution into current_local_solution.
526  // Only the necessary values (specified by the send_list)
527  // are copied to minimize communication
528  solution->localize (*current_local_solution, send_list);
529 }
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:2179
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
libmesh_assert(ctx)
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Definition: system.h:1605

◆ update_global_solution() [1/2]

void libMesh::System::update_global_solution ( std::vector< Number > &  global_soln) const
inherited

Fill the input vector global_soln so that it contains the global solution on all processors.

Requires communication with all other processors.

Definition at line 745 of file system.C.

References libMesh::System::solution.

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::ExactErrorEstimator::estimate_error(), main(), and libMesh::InterMeshProjection::project_system_vectors().

746 {
747  parallel_object_only();
748 
749  global_soln.resize (solution->size());
750 
751  solution->localize (global_soln);
752 }
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593

◆ update_global_solution() [2/2]

void libMesh::System::update_global_solution ( std::vector< Number > &  global_soln,
const processor_id_type  dest_proc 
) const
inherited

Fill the input vector global_soln so that it contains the global solution on processor dest_proc.

Requires communication with all other processors.

Definition at line 756 of file system.C.

References libMesh::System::solution.

758 {
759  parallel_object_only();
760 
761  global_soln.resize (solution->size());
762 
763  solution->localize_to_one (global_soln, dest_proc);
764 }
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593

◆ update_greedy_param_list()

void libMesh::RBConstruction::update_greedy_param_list ( )
protectedinherited

Update the list of Greedily chosen parameters with current_parameters.

Definition at line 1586 of file rb_construction.C.

References libMesh::RBParametrized::get_parameters(), libMesh::RBConstruction::get_rb_evaluation(), and libMesh::RBEvaluation::greedy_param_list.

Referenced by libMesh::RBConstruction::train_reduced_basis_with_greedy().

1587 {
1589 }
std::vector< RBParameters > greedy_param_list
The list of parameters selected by the Greedy algorithm in generating the Reduced Basis associated wi...
const RBParameters & get_parameters() const
Get the current parameters.
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.

◆ update_RB_initial_condition_all_N()

void TransientRBConstruction::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 each projection in RB_initial_condition_matrix.

Definition at line 1101 of file transient_rb_construction.C.

References libMesh::NumericVector< T >::build(), libMesh::ParallelObject::comm(), libMesh::RBConstruction::delta_N, libMesh::DenseVector< T >::dot(), libMesh::RBEvaluation::get_n_basis_functions(), libMesh::DenseMatrix< T >::get_principal_submatrix(), libMesh::DenseVector< T >::get_principal_subvector(), libMesh::RBConstruction::get_rb_evaluation(), libMesh::TransientRBEvaluation::initial_L2_error_all_N, initialize_truth(), L2_matrix, libMesh::libmesh_real(), libMesh::DenseMatrix< T >::lu_solve(), libMesh::System::n_dofs(), libMesh::System::n_local_dofs(), libMesh::PARALLEL, RB_ic_proj_rhs_all_N, libMesh::TransientRBEvaluation::RB_initial_condition_all_N, libMesh::TransientRBEvaluation::RB_L2_matrix, libMesh::System::solution, and libMesh::DenseVector< T >::zero().

Referenced by update_system().

1102 {
1103  LOG_SCOPE("update_RB_initial_condition_all_N()", "TransientRBConstruction");
1104 
1105  TransientRBEvaluation & trans_rb_eval = cast_ref<TransientRBEvaluation &>(get_rb_evaluation());
1106 
1107  // Load the initial condition into the solution vector
1108  initialize_truth();
1109 
1110  std::unique_ptr<NumericVector<Number>> temp1 = NumericVector<Number>::build(this->comm());
1111  temp1->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
1112 
1113  std::unique_ptr<NumericVector<Number>> temp2 = NumericVector<Number>::build(this->comm());
1114  temp2->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
1115 
1116 
1117  unsigned int RB_size = get_rb_evaluation().get_n_basis_functions();
1118 
1119  // First compute the right-hand side vector for the L2 projection
1120  L2_matrix->vector_mult(*temp1, *solution);
1121 
1122  for (unsigned int i=(RB_size-delta_N); i<RB_size; i++)
1123  {
1124  RB_ic_proj_rhs_all_N(i) = temp1->dot(get_rb_evaluation().get_basis_function(i));
1125  }
1126 
1127 
1128  // Now compute the projection for each N
1129  DenseMatrix<Number> RB_L2_matrix_N;
1130  DenseVector<Number> RB_rhs_N;
1131  for (unsigned int N=(RB_size-delta_N); N<RB_size; N++)
1132  {
1133  // We have to index here by N+1 since the loop index is zero-based.
1134  trans_rb_eval.RB_L2_matrix.get_principal_submatrix(N+1, RB_L2_matrix_N);
1135 
1137 
1138  DenseVector<Number> RB_ic_N(N+1);
1139 
1140  // Now solve the linear system
1141  RB_L2_matrix_N.lu_solve(RB_rhs_N, RB_ic_N);
1142 
1143  // Load RB_ic_N into RB_initial_condition_all_N
1144  trans_rb_eval.RB_initial_condition_all_N[N] = RB_ic_N;
1145 
1146  // Compute the L2 error for the RB initial condition
1147  // This part is dependent on the truth space.
1148 
1149  // load the RB solution into temp1
1150  temp1->zero();
1151  for (unsigned int i=0; i<N+1; i++)
1152  {
1153  temp1->add(RB_ic_N(i), get_rb_evaluation().get_basis_function(i));
1154  }
1155 
1156  // subtract truth initial condition from RB_ic_N
1157  temp1->add(-1., *solution);
1158 
1159  // Compute L2 norm error, i.e. sqrt(M(solution,solution))
1160  temp2->zero();
1161  L2_matrix->vector_mult(*temp2, *temp1);
1162 
1163  trans_rb_eval.initial_L2_error_all_N[N] = libmesh_real(std::sqrt(temp2->dot(*temp1)));
1164  }
1165 }
T libmesh_real(T a)
std::unique_ptr< SparseMatrix< Number > > L2_matrix
The L2 matrix.
virtual void initialize_truth()
This function imposes a truth initial condition, defaults to zero initial condition if the flag nonze...
const Parallel::Communicator & comm() const
dof_id_type n_local_dofs() const
Definition: system.C:158
void get_principal_subvector(unsigned int sub_n, DenseVector< T > &dest) const
Puts the principal subvector of size sub_n (i.e.
Definition: dense_vector.h:713
dof_id_type n_dofs() const
Definition: system.C:121
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
unsigned int delta_N
The number of basis functions that we add at each greedy step.
CompareTypes< T, T2 >::supertype dot(const DenseVector< T2 > &vec) const
Definition: dense_vector.h:492
virtual unsigned int get_n_basis_functions() const
Get the current number of basis functions.
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...
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.
DenseVector< Number > RB_ic_proj_rhs_all_N
The vector that stores the right-hand side for the initial condition projections. ...

◆ update_RB_system_matrices()

void TransientRBConstruction::update_RB_system_matrices ( )
overrideprotectedvirtual

Compute the reduced basis matrices for the current basis.

Reimplemented from libMesh::RBConstruction.

Definition at line 908 of file transient_rb_construction.C.

References libMesh::NumericVector< T >::build(), libMesh::ParallelObject::comm(), libMesh::RBConstruction::delta_N, libMesh::NumericVector< T >::dot(), libMesh::RBEvaluation::get_basis_function(), get_M_q(), libMesh::RBEvaluation::get_n_basis_functions(), libMesh::TransientRBThetaExpansion::get_n_M_terms(), libMesh::RBConstruction::get_rb_evaluation(), libMesh::RBConstruction::get_rb_theta_expansion(), L2_matrix, libMesh::System::n_dofs(), libMesh::System::n_local_dofs(), libMesh::PARALLEL, libMesh::TransientRBEvaluation::RB_L2_matrix, libMesh::TransientRBEvaluation::RB_M_q_vector, libMesh::RBConstruction::update_RB_system_matrices(), value, and libMesh::SparseMatrix< T >::vector_mult().

909 {
910  LOG_SCOPE("update_RB_system_matrices()", "TransientRBConstruction");
911 
913 
914  TransientRBEvaluation & trans_rb_eval = cast_ref<TransientRBEvaluation &>(get_rb_evaluation());
915 
916  TransientRBThetaExpansion & trans_theta_expansion =
917  cast_ref<TransientRBThetaExpansion &>(get_rb_theta_expansion());
918  const unsigned int Q_m = trans_theta_expansion.get_n_M_terms();
919 
920  unsigned int RB_size = get_rb_evaluation().get_n_basis_functions();
921 
922  std::unique_ptr<NumericVector<Number>> temp = NumericVector<Number>::build(this->comm());
923  temp->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
924 
925  for (unsigned int i=(RB_size-delta_N); i<RB_size; i++)
926  {
927  for (unsigned int j=0; j<RB_size; j++)
928  {
929  // Compute reduced L2 matrix
930  temp->zero();
931  L2_matrix->vector_mult(*temp, get_rb_evaluation().get_basis_function(j));
932 
934  trans_rb_eval.RB_L2_matrix(i,j) = value;
935  if (i!=j)
936  {
937  // The L2 matrix is assumed
938  // to be symmetric
939  trans_rb_eval.RB_L2_matrix(j,i) = value;
940  }
941 
942  for (unsigned int q_m=0; q_m<Q_m; q_m++)
943  {
944  // Compute reduced M_q matrix
945  temp->zero();
946  get_M_q(q_m)->vector_mult(*temp, get_rb_evaluation().get_basis_function(j));
947 
948  value = (get_rb_evaluation().get_basis_function(i)).dot(*temp);
949  trans_rb_eval.RB_M_q_vector[q_m](i,j) = value;
950 
951  if (i!=j)
952  {
953  // Each mass matrix term is assumed
954  // to be symmetric
955  trans_rb_eval.RB_M_q_vector[q_m](j,i) = value;
956  }
957  }
958 
959  }
960  }
961 }
std::unique_ptr< SparseMatrix< Number > > L2_matrix
The L2 matrix.
SparseMatrix< Number > * get_M_q(unsigned int q)
Get a pointer to M_q.
void vector_mult(NumericVector< T > &dest, const NumericVector< T > &arg) const
Multiplies the matrix by the NumericVector arg and stores the result in NumericVector dest...
const Parallel::Communicator & comm() const
virtual T dot(const NumericVector< T > &v) const =0
dof_id_type n_local_dofs() const
Definition: system.C:158
dof_id_type n_dofs() const
Definition: system.C:121
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
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.
unsigned int delta_N
The number of basis functions that we add at each greedy step.
virtual unsigned int get_n_basis_functions() const
Get the current number of basis functions.
static const bool value
Definition: xdr_io.C:54
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...
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.

◆ update_residual_terms()

void TransientRBConstruction::update_residual_terms ( bool  compute_inner_products)
overrideprotectedvirtual

Compute the terms that are combined ‘online’ to determine the dual norm of the residual.

Reimplemented from libMesh::RBConstruction.

Definition at line 966 of file transient_rb_construction.C.

References libMesh::TransientRBEvaluation::Aq_Mq_representor_innerprods, libMesh::RBEvaluation::Aq_representor, libMesh::RBConstruction::assert_convergence, libMesh::NumericVector< T >::build(), libMesh::RBConstruction::check_convergence(), libMesh::ParallelObject::comm(), libMesh::RBConstruction::delta_N, libMesh::LinearImplicitSystem::final_linear_residual(), libMesh::TransientRBEvaluation::Fq_Mq_representor_innerprods, libMesh::RBConstruction::Fq_representor, libMesh::RBEvaluation::get_n_basis_functions(), libMesh::TransientRBThetaExpansion::get_n_M_terms(), libMesh::RBConstruction::get_non_dirichlet_inner_product_matrix_if_avail(), libMesh::RBConstruction::get_rb_evaluation(), libMesh::RBConstruction::get_rb_theta_expansion(), libMesh::Utility::get_timestamp(), libMesh::RBConstruction::inner_product_matrix, libMesh::RBConstruction::inner_product_solver, libMesh::RBConstructionBase< LinearImplicitSystem >::inner_product_storage_vector, libMesh::RBConstructionBase< LinearImplicitSystem >::is_quiet(), libMesh::libmesh_assert(), libMesh::TransientRBEvaluation::M_q_representor, M_q_vector, libMesh::TransientRBEvaluation::Mq_Mq_representor_innerprods, libMesh::System::n_dofs(), libMesh::LinearImplicitSystem::n_linear_iterations(), libMesh::System::n_local_dofs(), libMesh::out, libMesh::PARALLEL, libMesh::ExplicitSystem::rhs, libMesh::System::solution, libMesh::RBConstruction::solve_for_matrix_and_rhs(), libMesh::RBConstruction::update_residual_terms(), libMesh::SparseMatrix< T >::vector_mult(), and libMesh::NumericVector< T >::zero().

967 {
968  LOG_SCOPE("update_residual_terms()", "TransientRBConstruction");
969 
970  Parent::update_residual_terms(compute_inner_products);
971 
972  TransientRBEvaluation & trans_rb_eval = cast_ref<TransientRBEvaluation &>(get_rb_evaluation());
973 
974  TransientRBThetaExpansion & trans_theta_expansion =
975  cast_ref<TransientRBThetaExpansion &>(get_rb_theta_expansion());
976 
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();
980 
981  unsigned int RB_size = get_rb_evaluation().get_n_basis_functions();
982 
983  for (unsigned int q_m=0; q_m<Q_m; q_m++)
984  {
985  for (unsigned int i=(RB_size-delta_N); i<RB_size; i++)
986  {
987  // Initialize the vectors when we need them
988  if (!trans_rb_eval.M_q_representor[q_m][i])
989  {
990  trans_rb_eval.M_q_representor[q_m][i] = NumericVector<Number>::build(this->comm());
991  trans_rb_eval.M_q_representor[q_m][i]->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
992  }
993 
994  libmesh_assert(trans_rb_eval.M_q_representor[q_m][i]->size() == this->n_dofs() &&
995  trans_rb_eval.M_q_representor[q_m][i]->local_size() == this->n_local_dofs() );
996 
997  rhs->zero();
998  M_q_vector[q_m]->vector_mult(*rhs, get_rb_evaluation().get_basis_function(i));
999 
1000  if (!is_quiet())
1001  libMesh::out << "Starting solve i="
1002  << i << " in TransientRBConstruction::update_residual_terms() at "
1003  << Utility::get_timestamp() << std::endl;
1004 
1006 
1007  if (assert_convergence)
1009 
1010  if (!is_quiet())
1011  {
1012  libMesh::out << "Finished solve i="
1013  << i << " in TransientRBConstruction::update_residual_terms() at "
1014  << Utility::get_timestamp() << std::endl;
1015 
1017  << " iterations, final residual "
1018  << this->final_linear_residual() << std::endl;
1019  }
1020 
1021  *trans_rb_eval.M_q_representor[q_m][i] = *solution;
1022  }
1023  }
1024 
1025  // Now compute and store the inner products if requested
1026  if (compute_inner_products)
1027  {
1028  for (unsigned int q_f=0; q_f<Q_f; q_f++)
1029  {
1031 
1032  for (unsigned int i=(RB_size-delta_N); i<RB_size; i++)
1033  {
1034  for (unsigned int q_m=0; q_m<Q_m; q_m++)
1035  {
1036  trans_rb_eval.Fq_Mq_representor_innerprods[q_f][q_m][i] =
1037  trans_rb_eval.M_q_representor[q_m][i]->dot(*inner_product_storage_vector);
1038  } // end for q_m
1039  } // end for i
1040  } // end for q_f
1041 
1042  unsigned int q=0;
1043  for (unsigned int q_m1=0; q_m1<Q_m; q_m1++)
1044  {
1045  for (unsigned int q_m2=q_m1; q_m2<Q_m; q_m2++)
1046  {
1047  for (unsigned int i=(RB_size-delta_N); i<RB_size; i++)
1048  {
1049  for (unsigned int j=0; j<RB_size; j++)
1050  {
1052 
1053  trans_rb_eval.Mq_Mq_representor_innerprods[q][i][j] =
1054  trans_rb_eval.M_q_representor[q_m1][i]->dot(*inner_product_storage_vector);
1055 
1056  if (i != j)
1057  {
1059  *trans_rb_eval.M_q_representor[q_m2][i]);
1060 
1061  trans_rb_eval.Mq_Mq_representor_innerprods[q][j][i] =
1062  trans_rb_eval.M_q_representor[q_m1][j]->dot(*inner_product_storage_vector);
1063  }
1064  } // end for j
1065  } // end for i
1066  q++;
1067  } // end for q_m2
1068  } // end for q_m1
1069 
1070 
1071  for (unsigned int i=(RB_size-delta_N); i<RB_size; i++)
1072  {
1073  for (unsigned int j=0; j<RB_size; j++)
1074  {
1075  for (unsigned int q_a=0; q_a<Q_a; q_a++)
1076  {
1077  for (unsigned int q_m=0; q_m<Q_m; q_m++)
1078  {
1080  *trans_rb_eval.M_q_representor[q_m][j]);
1081 
1082  trans_rb_eval.Aq_Mq_representor_innerprods[q_a][q_m][i][j] =
1083  trans_rb_eval.Aq_representor[q_a][i]->dot(*inner_product_storage_vector);
1084 
1085  if (i != j)
1086  {
1088  *trans_rb_eval.M_q_representor[q_m][i]);
1089 
1090  trans_rb_eval.Aq_Mq_representor_innerprods[q_a][q_m][j][i] =
1091  trans_rb_eval.Aq_representor[q_a][j]->dot(*inner_product_storage_vector);
1092  }
1093  } // end for q_m
1094  } // end for q_a
1095  } // end for j
1096  } // end for i
1097  } // end if (compute_inner_products)
1098 }
std::vector< std::unique_ptr< NumericVector< Number > > > Fq_representor
Vector storing the residual representors associated with the right-hand side.
bool assert_convergence
A boolean flag to indicate whether to check for proper convergence after each solve.
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...
std::string get_timestamp()
Definition: timestamp.C:37
NumericVector< Number > * rhs
The system matrix.
const Parallel::Communicator & comm() const
bool is_quiet() const
Is the system in quiet mode?
std::unique_ptr< SparseMatrix< Number > > inner_product_matrix
The inner product matrix.
dof_id_type n_local_dofs() const
Definition: system.C:158
dof_id_type n_dofs() const
Definition: system.C:121
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 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 ...
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
unsigned int n_linear_iterations() const
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::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
libmesh_assert(ctx)
unsigned int delta_N
The number of basis functions that we add at each greedy step.
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...
OStreamProxy out
virtual unsigned int get_n_basis_functions() const
Get the current number of basis functions.
SparseMatrix< Number > * get_non_dirichlet_inner_product_matrix_if_avail()
Get the non-Dirichlet inner-product matrix if it&#39;s available, otherwise get the inner-product 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...
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.
std::vector< std::unique_ptr< SparseMatrix< Number > > > M_q_vector
Vector storing the Q_m matrices from the mass operator.

◆ update_system()

void TransientRBConstruction::update_system ( )
overrideprotectedvirtual

Update the system after enriching the RB space.

Reimplemented from libMesh::RBConstruction.

Definition at line 867 of file transient_rb_construction.C.

References libMesh::RBConstruction::get_delta_N(), libMesh::out, update_RB_initial_condition_all_N(), and libMesh::RBConstruction::update_system().

Referenced by add_IC_to_RB_space(), and enrich_RB_space().

868 {
869  // If delta_N is set to zero, there is nothing to update
870  if (get_delta_N() == 0)
871  return;
872 
874 
875  libMesh::out << "Updating RB initial conditions" << std::endl;
877 }
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 void update_system()
Update the system after enriching the RB space; this calls a series of functions to update the system...
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...
OStreamProxy out

◆ user_assembly()

void libMesh::System::user_assembly ( )
virtualinherited

Calls user's attached assembly function, or is overridden by the user in derived classes.

Definition at line 2311 of file system.C.

References libMesh::System::_assemble_system_function, libMesh::System::_assemble_system_object, libMesh::System::_equation_systems, libMesh::System::Assembly::assemble(), and libMesh::System::name().

Referenced by libMesh::System::assemble().

2312 {
2313  // Call the user-provided assembly function,
2314  // if it was provided
2315  if (_assemble_system_function != nullptr)
2317 
2318  // ...or the user-provided assembly object.
2319  else if (_assemble_system_object != nullptr)
2321 }
Assembly * _assemble_system_object
Object that assembles the system.
Definition: system.h:2136
virtual void assemble()=0
Assembly function.
EquationSystems & _equation_systems
Constant reference to the EquationSystems object used for the simulation.
Definition: system.h:2185
const std::string & name() const
Definition: system.h:2342
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Function that assembles the system.
Definition: system.h:2130

◆ user_constrain()

void libMesh::System::user_constrain ( )
virtualinherited

Calls user's attached constraint function, or is overridden by the user in derived classes.

Definition at line 2325 of file system.C.

References libMesh::System::_constrain_system_function, libMesh::System::_constrain_system_object, libMesh::System::_equation_systems, libMesh::System::Constraint::constrain(), and libMesh::System::name().

Referenced by libMesh::System::reinit_constraints().

2326 {
2327  // Call the user-provided constraint function,
2328  // if it was provided
2329  if (_constrain_system_function!= nullptr)
2331 
2332  // ...or the user-provided constraint object.
2333  else if (_constrain_system_object != nullptr)
2335 }
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Function to impose constraints.
Definition: system.h:2141
Constraint * _constrain_system_object
Object that constrains the system.
Definition: system.h:2147
EquationSystems & _equation_systems
Constant reference to the EquationSystems object used for the simulation.
Definition: system.h:2185
virtual void constrain()=0
Constraint function.
const std::string & name() const
Definition: system.h:2342

◆ user_initialization()

void libMesh::System::user_initialization ( )
virtualinherited

Calls user's attached initialization function, or is overridden by the user in derived classes.

Definition at line 2297 of file system.C.

References libMesh::System::_equation_systems, libMesh::System::_init_system_function, libMesh::System::_init_system_object, libMesh::System::Initialization::initialize(), and libMesh::System::name().

Referenced by libMesh::NewmarkSystem::initial_conditions(), and libMesh::System::reinit_mesh().

2298 {
2299  // Call the user-provided initialization function,
2300  // if it was provided
2301  if (_init_system_function != nullptr)
2302  this->_init_system_function (_equation_systems, this->name());
2303 
2304  // ...or the user-provided initialization object.
2305  else if (_init_system_object != nullptr)
2307 }
virtual void initialize()=0
Initialization function.
Initialization * _init_system_object
Object that initializes the system.
Definition: system.h:2125
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Function that initializes the system.
Definition: system.h:2119
EquationSystems & _equation_systems
Constant reference to the EquationSystems object used for the simulation.
Definition: system.h:2185
const std::string & name() const
Definition: system.h:2342

◆ user_QOI()

void libMesh::System::user_QOI ( const QoISet qoi_indices)
virtualinherited

Calls user's attached quantity of interest function, or is overridden by the user in derived classes.

Definition at line 2339 of file system.C.

References libMesh::System::_equation_systems, libMesh::System::_qoi_evaluate_function, libMesh::System::_qoi_evaluate_object, libMesh::System::name(), and libMesh::System::QOI::qoi().

Referenced by libMesh::System::assemble_qoi().

2340 {
2341  // Call the user-provided quantity of interest function,
2342  // if it was provided
2343  if (_qoi_evaluate_function != nullptr)
2344  this->_qoi_evaluate_function(_equation_systems, this->name(), qoi_indices);
2345 
2346  // ...or the user-provided QOI function object.
2347  else if (_qoi_evaluate_object != nullptr)
2348  this->_qoi_evaluate_object->qoi(qoi_indices);
2349 }
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Function to evaluate quantity of interest.
Definition: system.h:2152
virtual void qoi(const QoISet &qoi_indices)=0
Quantity of interest function.
QOI * _qoi_evaluate_object
Object to compute quantities of interest.
Definition: system.h:2159
EquationSystems & _equation_systems
Constant reference to the EquationSystems object used for the simulation.
Definition: system.h:2185
const std::string & name() const
Definition: system.h:2342

◆ user_QOI_derivative()

void libMesh::System::user_QOI_derivative ( const QoISet qoi_indices = QoISet(),
bool  include_liftfunc = true,
bool  apply_constraints = true 
)
virtualinherited

Calls user's attached quantity of interest derivative function, or is overridden by the user in derived classes.

Definition at line 2353 of file system.C.

References libMesh::System::_equation_systems, libMesh::System::_qoi_evaluate_derivative_function, libMesh::System::_qoi_evaluate_derivative_object, libMesh::System::name(), and libMesh::System::QOIDerivative::qoi_derivative().

Referenced by libMesh::System::assemble_qoi_derivative().

2356 {
2357  // Call the user-provided quantity of interest derivative,
2358  // if it was provided
2359  if (_qoi_evaluate_derivative_function != nullptr)
2361  (_equation_systems, this->name(), qoi_indices, include_liftfunc,
2362  apply_constraints);
2363 
2364  // ...or the user-provided QOI derivative function object.
2365  else if (_qoi_evaluate_derivative_object != nullptr)
2367  (qoi_indices, include_liftfunc, apply_constraints);
2368 }
QOIDerivative * _qoi_evaluate_derivative_object
Object to compute derivatives of quantities of interest.
Definition: system.h:2173
virtual void qoi_derivative(const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)=0
Quantity of interest derivative function.
EquationSystems & _equation_systems
Constant reference to the EquationSystems object used for the simulation.
Definition: system.h:2185
const std::string & name() const
Definition: system.h:2342
void(* _qoi_evaluate_derivative_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
Function to evaluate quantity of interest derivative.
Definition: system.h:2164

◆ variable()

const Variable & libMesh::System::variable ( unsigned int  var) const
inlineinherited

Return a constant reference to Variable var.

Definition at line 2458 of file system.h.

References libMesh::System::_variables.

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DifferentiableSystem::add_second_order_dot_vars(), libMesh::System::add_variable(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::FirstOrderUnsteadySolver::compute_second_order_eqns(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::find_dofs_to_send(), libMesh::DifferentiableSystem::have_first_order_scalar_vars(), libMesh::DifferentiableSystem::have_second_order_scalar_vars(), main(), libMesh::DifferentiablePhysics::nonlocal_mass_residual(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SortAndCopy::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectVertices::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectEdges::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectSides::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectInteriors::operator()(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::System::write_header(), libMesh::Nemesis_IO_Helper::write_nodal_solution(), libMesh::System::write_parallel_data(), libMesh::System::write_serialized_vector(), and libMesh::System::write_serialized_vectors().

2459 {
2460  libmesh_assert_less (i, _variables.size());
2461 
2462  return _variables[i];
2463 }
std::vector< Variable > _variables
The Variable in this System.
Definition: system.h:2206

◆ variable_group()

const VariableGroup & libMesh::System::variable_group ( unsigned int  vg) const
inlineinherited

Return a constant reference to VariableGroup vg.

Definition at line 2468 of file system.h.

References libMesh::System::_variable_groups.

Referenced by libMesh::FEMSystem::assembly(), libMesh::System::get_info(), and libMesh::System::init_data().

2469 {
2470  libmesh_assert_less (vg, _variable_groups.size());
2471 
2472  return _variable_groups[vg];
2473 }
std::vector< VariableGroup > _variable_groups
The VariableGroup in this System.
Definition: system.h:2211

◆ variable_name()

const std::string & libMesh::System::variable_name ( const unsigned int  i) const
inlineinherited

◆ variable_number()

unsigned int libMesh::System::variable_number ( std::string_view  var) const
inherited
Returns
The variable number associated with the user-specified variable named var.

Definition at line 1609 of file system.C.

References libMesh::System::_variable_numbers, libMesh::System::_variables, and libMesh::System::name().

Referenced by libMesh::ExactSolution::_compute_error(), alternative_fe_assembly(), LinearElasticity::assemble(), AssembleOptimization::assemble_A_and_F(), assemble_divgrad(), assemble_elasticity(), assemble_graddiv(), assemble_matrix_and_rhs(), assemble_shell(), assemble_stokes(), compute_enriched_soln(), compute_stresses(), LinearElasticityWithContact::compute_stresses(), LinearElasticity::compute_stresses(), LargeDeformationElasticity::compute_stresses(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::Nemesis_IO::copy_elemental_solution(), libMesh::GMVIO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::Nemesis_IO::copy_nodal_solution(), libMesh::ExactErrorEstimator::estimate_error(), fe_assembly(), libMesh::ExactErrorEstimator::find_squared_element_error(), CoupledSystemQoI::init_context(), libMesh::HDGProblem::jacobian(), LargeDeformationElasticity::jacobian(), line_print(), main(), LinearElasticityWithContact::move_mesh(), libMesh::System::read_header(), libMesh::HDGProblem::residual(), LargeDeformationElasticity::residual(), LinearElasticityWithContact::residual_and_jacobian(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), OverlappingTestBase::setup_coupling_matrix(), libMesh::DTKAdapter::update_variable_values(), libMesh::System::variable_scalar_number(), libMesh::System::variable_type(), libMesh::EnsightIO::write_scalar_ascii(), and libMesh::EnsightIO::write_vector_ascii().

1610 {
1611  auto var_num = libmesh_map_find(_variable_numbers, var);
1612  libmesh_assert_equal_to (_variables[var_num].name(), var);
1613  return var_num;
1614 }
std::vector< Variable > _variables
The Variable in this System.
Definition: system.h:2206
std::map< std::string, unsigned int, std::less<> > _variable_numbers
The variable numbers corresponding to user-specified names, useful for name-based lookups...
Definition: system.h:2217
const std::string & name() const
Definition: system.h:2342

◆ variable_scalar_number() [1/2]

unsigned int libMesh::System::variable_scalar_number ( std::string_view  var,
unsigned int  component 
) const
inlineinherited
Returns
An index, starting from 0 for the first component of the first variable, and incrementing for each component of each (potentially vector-valued) variable in the system in order. For systems with only scalar-valued variables, this will be the same as variable_number(var)

Irony: currently our only non-scalar-valued variable type is SCALAR.

Definition at line 2489 of file system.h.

References libMesh::System::variable_number().

Referenced by libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), libMesh::ExactErrorEstimator::find_squared_element_error(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectVertices::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectEdges::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectSides::operator()(), and libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectInteriors::operator()().

2491 {
2492  return variable_scalar_number(this->variable_number(var), component);
2493 }
unsigned int variable_scalar_number(std::string_view var, unsigned int component) const
Definition: system.h:2489
unsigned int variable_number(std::string_view var) const
Definition: system.C:1609

◆ variable_scalar_number() [2/2]

unsigned int libMesh::System::variable_scalar_number ( unsigned int  var_num,
unsigned int  component 
) const
inlineinherited
Returns
An index, starting from 0 for the first component of the first variable, and incrementing for each component of each (potentially vector-valued) variable in the system in order. For systems with only scalar-valued variables, this will be the same as var_num

Irony: currently our only non-scalar-valued variable type is SCALAR.

Definition at line 2499 of file system.h.

References libMesh::System::_variables.

2501 {
2502  return _variables[var_num].first_scalar_number() + component;
2503 }
std::vector< Variable > _variables
The Variable in this System.
Definition: system.h:2206

◆ variable_type() [1/2]

const FEType & libMesh::System::variable_type ( const unsigned int  i) const
inlineinherited
Returns
The finite element type variable number i.

Definition at line 2508 of file system.h.

References libMesh::System::_variables.

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::System::add_variable(), libMesh::System::add_variables(), alternative_fe_assembly(), assemble(), libMesh::ClawSystem::assemble_advection_matrices(), libMesh::ClawSystem::assemble_avg_coupling_matrices(), libMesh::ClawSystem::assemble_boundary_condition_matrices(), assemble_ellipticdg(), libMesh::ClawSystem::assemble_jump_coupling_matrix(), libMesh::ClawSystem::assemble_mass_matrix(), assemble_shell(), assemble_stokes(), libMesh::FEMContext::attach_quadrature_rules(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::Nemesis_IO::copy_elemental_solution(), libMesh::GMVIO::copy_nodal_solution(), libMesh::DGFEMContext::DGFEMContext(), fe_assembly(), libMesh::FEMContext::find_hardest_fe_type(), libMesh::EquationSystems::find_variable_numbers(), form_functionA(), form_functionB(), form_matrixA(), libMesh::FEMSystem::init_context(), libMesh::FEMContext::init_internal_data(), RationalMapTest< elem_type >::setUp(), FETestBase< order, family, elem_type, 1 >::setUp(), EquationSystemsTest::testBadVarNames(), libMesh::Nemesis_IO_Helper::write_element_values(), libMesh::System::write_header(), libMesh::Nemesis_IO_Helper::write_nodal_solution(), libMesh::EnsightIO::write_scalar_ascii(), and libMesh::EnsightIO::write_vector_ascii().

2509 {
2510  libmesh_assert_less (i, _variables.size());
2511 
2512  return _variables[i].type();
2513 }
std::vector< Variable > _variables
The Variable in this System.
Definition: system.h:2206

◆ variable_type() [2/2]

const FEType & libMesh::System::variable_type ( std::string_view  var) const
inlineinherited
Returns
The finite element type for variable var.

Definition at line 2518 of file system.h.

References libMesh::System::_variables, and libMesh::System::variable_number().

2519 {
2520  return _variables[this->variable_number(var)].type();
2521 }
std::vector< Variable > _variables
The Variable in this System.
Definition: system.h:2206
unsigned int variable_number(std::string_view var) const
Definition: system.C:1609

◆ vector_is_adjoint()

int libMesh::System::vector_is_adjoint ( std::string_view  vec_name) const
inherited
Returns
The integer describing whether the vector identified by vec_name represents a solution from an adjoint (non-negative) or the primal (-1) space.

Definition at line 1173 of file system.C.

References libMesh::System::_vector_is_adjoint, and libMesh::libmesh_assert().

Referenced by libMesh::InterMeshProjection::project_system_vectors(), and libMesh::System::restrict_vectors().

1174 {
1175  const auto it = _vector_is_adjoint.find(vec_name);
1176  libmesh_assert(it != _vector_is_adjoint.end());
1177  return it->second;
1178 }
std::map< std::string, int, std::less<> > _vector_is_adjoint
Holds non-negative if a vector by that name should be projected using adjoint constraints/BCs, -1 if primal.
Definition: system.h:2242
libmesh_assert(ctx)

◆ vector_name() [1/2]

const std::string & libMesh::System::vector_name ( const unsigned int  vec_num) const
inherited
Returns
The name of this system's additional vector number vec_num (where the vectors are counted starting with 0).

Definition at line 983 of file system.C.

References libMesh::System::_vectors, and libMesh::System::vectors_begin().

Referenced by libMesh::AdjointRefinementEstimator::estimate_error(), and main().

984 {
985  // If we don't have that many vectors, throw an error
986  libmesh_assert_less(vec_num, _vectors.size());
987 
988  // Otherwise return a reference to the vec_num'th vector name
989  auto it = vectors_begin();
990  std::advance(it, vec_num);
991  return it->first;
992 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2230
vectors_iterator vectors_begin()
Beginning of vectors container.
Definition: system.h:2564

◆ vector_name() [2/2]

const std::string & libMesh::System::vector_name ( const NumericVector< Number > &  vec_reference) const
inherited
Returns
The name of a system vector, given a reference to that vector

Definition at line 994 of file system.C.

References libMesh::System::_vectors, libMesh::NumericVector< T >::get(), libMesh::libmesh_assert(), libMesh::System::vectors_begin(), and libMesh::System::vectors_end().

995 {
996  // Linear search for a vector whose pointer matches vec_reference
997  auto it = std::find_if(vectors_begin(), vectors_end(),
998  [&vec_reference](const decltype(_vectors)::value_type & pr)
999  { return &vec_reference == pr.second.get(); });
1000 
1001  // Before returning, make sure we didn't loop till the end and not find any match
1002  libmesh_assert (it != vectors_end());
1003 
1004  // Return the string associated with the current vector
1005  return it->first;
1006 }
vectors_iterator vectors_end()
End of vectors container.
Definition: system.h:2576
virtual void get(const std::vector< numeric_index_type > &index, T *values) const
Access multiple components at once.
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2230
vectors_iterator vectors_begin()
Beginning of vectors container.
Definition: system.h:2564
libmesh_assert(ctx)

◆ vector_preservation()

bool libMesh::System::vector_preservation ( std::string_view  vec_name) const
inherited
Returns
The boolean describing whether the vector identified by vec_name should be "preserved": projected to new meshes, saved, etc.

Definition at line 1148 of file system.C.

References libMesh::System::_vector_projections.

Referenced by libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::MemoryHistoryData::store_vectors(), SystemsTest::testAddVectorProjChange(), SystemsTest::testAddVectorTypeChange(), and SystemsTest::testPostInitAddVectorTypeChange().

1149 {
1150  if (auto it = _vector_projections.find(vec_name);
1151  it != _vector_projections.end())
1152  return it->second;
1153 
1154  // vec_name was not in the map, return false
1155  return false;
1156 }
std::map< std::string, bool, std::less<> > _vector_projections
Holds true if a vector by that name should be projected onto a changed grid, false if it should be ze...
Definition: system.h:2236

◆ vectors_begin() [1/2]

System::vectors_iterator libMesh::System::vectors_begin ( )
inlineinherited

Beginning of vectors container.

Definition at line 2564 of file system.h.

References libMesh::System::_vectors.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::System::get_vector(), libMesh::InterMeshProjection::project_system_vectors(), libMesh::System::request_vector(), libMesh::MemoryHistoryData::store_vectors(), and libMesh::System::vector_name().

2565 {
2566  return _vectors.begin();
2567 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2230

◆ vectors_begin() [2/2]

System::const_vectors_iterator libMesh::System::vectors_begin ( ) const
inlineinherited

Beginning of vectors container.

Definition at line 2570 of file system.h.

References libMesh::System::_vectors.

2571 {
2572  return _vectors.begin();
2573 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2230

◆ vectors_end() [1/2]

System::vectors_iterator libMesh::System::vectors_end ( )
inlineinherited

End of vectors container.

Definition at line 2576 of file system.h.

References libMesh::System::_vectors.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::InterMeshProjection::project_system_vectors(), libMesh::MemoryHistoryData::store_vectors(), and libMesh::System::vector_name().

2577 {
2578  return _vectors.end();
2579 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2230

◆ vectors_end() [2/2]

System::const_vectors_iterator libMesh::System::vectors_end ( ) const
inlineinherited

End of vectors container.

Definition at line 2582 of file system.h.

References libMesh::System::_vectors.

2583 {
2584  return _vectors.end();
2585 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2230

◆ weighted_sensitivity_adjoint_solve()

std::pair< unsigned int, Real > libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve ( const ParameterVector parameters,
const ParameterVector weights,
const QoISet qoi_indices = QoISet() 
)
overridevirtualinherited

Assembles & solves the linear system(s) (dR/du)^T*z_w = sum(w_p*(d^2q/dudp - d^2R/dudp*z)), for those parameters p contained within parameters, weighted by the values w_p found within weights.

Assumes that adjoint_solve has already calculated z for each qoi in qoi_indices.

Returns
A pair with the total number of linear iterations performed and the (sum of the) final residual norms

Reimplemented from libMesh::System.

Definition at line 243 of file implicit_system.C.

References libMesh::System::add_weighted_sensitivity_adjoint_solution(), libMesh::ExplicitSystem::assemble_qoi_derivative(), libMesh::ImplicitSystem::assembly(), libMesh::NumericVector< T >::close(), libMesh::SparseMatrix< T >::close(), libMesh::ParameterVector::deep_copy(), libMesh::DofMap::enforce_constraints_exactly(), libMesh::System::get_adjoint_rhs(), libMesh::System::get_adjoint_solution(), libMesh::System::get_dof_map(), libMesh::ImplicitSystem::get_linear_solve_parameters(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::SparseMatrix< T >::get_transpose(), libMesh::System::get_weighted_sensitivity_adjoint_solution(), libMesh::DofMap::has_adjoint_dirichlet_boundaries(), libMesh::QoISet::has_index(), libMesh::libmesh_assert(), libMesh::make_range(), libMesh::ImplicitSystem::matrix, libMesh::System::n_qois(), libMesh::Real, libMesh::ExplicitSystem::rhs, libMesh::LinearSolver< T >::solve(), libMesh::TOLERANCE, libMesh::ParameterVector::value_copy(), libMesh::SparseMatrix< T >::vector_mult_add(), and libMesh::NumericVector< T >::zero_clone().

Referenced by libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product().

246 {
247  // Log how long the linear solve takes.
248  LOG_SCOPE("weighted_sensitivity_adjoint_solve()", "ImplicitSystem");
249 
250  // We currently get partial derivatives via central differencing
251  const Real delta_p = TOLERANCE;
252 
253  ParameterVector & parameters_vec =
254  const_cast<ParameterVector &>(parameters_in);
255 
256  // The forward system should now already be solved.
257  // The adjoint system should now already be solved.
258  // Now we're assembling a weighted sum of adjoint-adjoint systems:
259  //
260  // dR/du (u, sum_l(w_l*z^l)) = sum_l(w_l*(Q''_ul - R''_ul (u, z)))
261 
262  // FIXME: The derivation here does not yet take adjoint boundary
263  // conditions into account.
264 #ifdef LIBMESH_ENABLE_DIRICHLET
265  for (auto i : make_range(this->n_qois()))
266  if (qoi_indices.has_index(i))
268 #endif
269 
270  // We'll assemble the rhs first, because the R'' term will require
271  // perturbing the jacobian
272 
273  // We'll use temporary rhs vectors, because we haven't (yet) found
274  // any good reasons why users might want to save these:
275 
276  std::vector<std::unique_ptr<NumericVector<Number>>> temprhs(this->n_qois());
277  for (auto i : make_range(this->n_qois()))
278  if (qoi_indices.has_index(i))
279  temprhs[i] = this->rhs->zero_clone();
280 
281  // We approximate the _l partial derivatives via a central
282  // differencing perturbation in the w_l direction:
283  //
284  // sum_l(w_l*v_l) ~= (v(p + dp*w_l*e_l) - v(p - dp*w_l*e_l))/(2*dp)
285 
286  // PETSc doesn't implement SGEMX, so neither does NumericVector,
287  // so we want to avoid calculating f -= R'*z. We'll thus evaluate
288  // the above equation by first adding -v(p+dp...), then multiplying
289  // the intermediate result vectors by -1, then adding -v(p-dp...),
290  // then finally dividing by 2*dp.
291 
292  ParameterVector oldparameters, parameterperturbation;
293  parameters_vec.deep_copy(oldparameters);
294  weights.deep_copy(parameterperturbation);
295  parameterperturbation *= delta_p;
296  parameters_vec += parameterperturbation;
297 
298  this->assembly(false, true);
299  this->matrix->close();
300 
301  // Take the discrete adjoint, so that we can calculate R_u(u,z) with
302  // a matrix-vector product of R_u and z.
304 
305  this->assemble_qoi_derivative(qoi_indices,
306  /* include_liftfunc = */ false,
307  /* apply_constraints = */ true);
308  for (auto i : make_range(this->n_qois()))
309  if (qoi_indices.has_index(i))
310  {
311  this->get_adjoint_rhs(i).close();
312  *(temprhs[i]) -= this->get_adjoint_rhs(i);
313  this->matrix->vector_mult_add(*(temprhs[i]), this->get_adjoint_solution(i));
314  *(temprhs[i]) *= -1.0;
315  }
316 
317  oldparameters.value_copy(parameters_vec);
318  parameterperturbation *= -1.0;
319  parameters_vec += parameterperturbation;
320 
321  this->assembly(false, true);
322  this->matrix->close();
324 
325  this->assemble_qoi_derivative(qoi_indices,
326  /* include_liftfunc = */ false,
327  /* apply_constraints = */ true);
328  for (auto i : make_range(this->n_qois()))
329  if (qoi_indices.has_index(i))
330  {
331  this->get_adjoint_rhs(i).close();
332  *(temprhs[i]) -= this->get_adjoint_rhs(i);
333  this->matrix->vector_mult_add(*(temprhs[i]), this->get_adjoint_solution(i));
334  *(temprhs[i]) /= (2.0*delta_p);
335  }
336 
337  // Finally, assemble the jacobian at the non-perturbed parameter
338  // values. Ignore assemble_before_solve; if we had a good
339  // non-perturbed matrix before we've already overwritten it.
340  oldparameters.value_copy(parameters_vec);
341 
342  // if (this->assemble_before_solve)
343  {
344  // Build the Jacobian
345  this->assembly(false, true);
346  this->matrix->close();
347 
348  // Take the discrete adjoint
350  }
351 
352  // The weighted adjoint-adjoint problem is linear
353  LinearSolver<Number> * solver = this->get_linear_solver();
354 
355  // Our iteration counts and residuals will be sums of the individual
356  // results
357  std::pair<unsigned int, Real> solver_params =
359  std::pair<unsigned int, Real> totalrval = std::make_pair(0,0.0);
360 
361  for (auto i : make_range(this->n_qois()))
362  if (qoi_indices.has_index(i))
363  {
364  const std::pair<unsigned int, Real> rval =
365  solver->solve (*matrix, this->add_weighted_sensitivity_adjoint_solution(i),
366  *(temprhs[i]),
367  double(solver_params.second),
368  solver_params.first);
369 
370  totalrval.first += rval.first;
371  totalrval.second += rval.second;
372  }
373 
374  // The linear solver may not have fit our constraints exactly
375 #ifdef LIBMESH_ENABLE_CONSTRAINTS
376  for (auto i : make_range(this->n_qois()))
377  if (qoi_indices.has_index(i))
380  /* homogeneous = */ true);
381 #endif
382 
383  return totalrval;
384 }
static constexpr Real TOLERANCE
virtual std::pair< unsigned int, Real > get_linear_solve_parameters() const
unsigned int n_qois() const
Number of currently active quantities of interest.
Definition: system.h:2621
virtual std::unique_ptr< NumericVector< T > > zero_clone() const =0
NumericVector< Number > * rhs
The system matrix.
virtual LinearSolver< Number > * get_linear_solver() const
NumericVector< Number > & add_weighted_sensitivity_adjoint_solution(unsigned int i=0)
Definition: system.C:1265
virtual void assembly(bool, bool, bool=false, bool=false)
Assembles a residual in rhs and/or a jacobian in matrix, as requested.
bool has_adjoint_dirichlet_boundaries(unsigned int q) const
libmesh_assert(ctx)
template class LIBMESH_EXPORT LinearSolver< Number >
virtual void close()=0
Calls the NumericVector&#39;s internal assembly routines, ensuring that the values are consistent across ...
virtual void close()=0
Calls the SparseMatrix&#39;s internal assembly routines, ensuring that the values are consistent across p...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void vector_mult_add(NumericVector< T > &dest, const NumericVector< T > &arg) const
Multiplies the matrix by the NumericVector arg and adds the result to the NumericVector dest...
SparseMatrix< Number > * matrix
The system matrix.
virtual void get_transpose(SparseMatrix< T > &dest) const =0
Copies the transpose of the matrix into dest, which may be *this.
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...
Definition: int_range.h:140
virtual void assemble_qoi_derivative(const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true) override
Prepares adjoint_rhs for quantity of interest derivative assembly, then calls user qoi derivative fun...
NumericVector< Number > & get_adjoint_solution(unsigned int i=0)
Definition: system.C:1245
const DofMap & get_dof_map() const
Definition: system.h:2374
NumericVector< Number > & get_weighted_sensitivity_adjoint_solution(unsigned int i=0)
Definition: system.C:1277
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. ...
Definition: dof_map.h:2350
NumericVector< Number > & get_adjoint_rhs(unsigned int i=0)
Definition: system.C:1307

◆ weighted_sensitivity_solve()

std::pair< unsigned int, Real > libMesh::ImplicitSystem::weighted_sensitivity_solve ( const ParameterVector parameters,
const ParameterVector weights 
)
overridevirtualinherited

Assembles & solves the linear system(s) (dR/du)*u_w = sum(w_p*-dR/dp), for those parameters p contained within parameters weighted by the values w_p found within weights.

Returns
A pair with the total number of linear iterations performed and the (sum of the) final residual norms

Reimplemented from libMesh::System.

Definition at line 389 of file implicit_system.C.

References libMesh::System::add_weighted_sensitivity_solution(), libMesh::ImplicitSystem::assembly(), libMesh::NumericVector< T >::clone(), libMesh::NumericVector< T >::close(), libMesh::SparseMatrix< T >::close(), libMesh::ParameterVector::deep_copy(), libMesh::DofMap::enforce_constraints_exactly(), libMesh::System::get_dof_map(), libMesh::ImplicitSystem::get_linear_solve_parameters(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::System::get_weighted_sensitivity_solution(), libMesh::ImplicitSystem::matrix, libMesh::Real, libMesh::ExplicitSystem::rhs, libMesh::LinearSolver< T >::solve(), libMesh::TOLERANCE, and libMesh::ParameterVector::value_copy().

Referenced by libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product().

391 {
392  // Log how long the linear solve takes.
393  LOG_SCOPE("weighted_sensitivity_solve()", "ImplicitSystem");
394 
395  // We currently get partial derivatives via central differencing
396  const Real delta_p = TOLERANCE;
397 
398  ParameterVector & parameters_vec =
399  const_cast<ParameterVector &>(parameters_in);
400 
401  // The forward system should now already be solved.
402 
403  // Now we're assembling a weighted sum of sensitivity systems:
404  //
405  // dR/du (u, v)(sum(w_l*u'_l)) = -sum_l(w_l*R'_l (u, v)) forall v
406 
407  // We'll assemble the rhs first, because the R' term will require
408  // perturbing the system, and some applications may not be able to
409  // assemble a perturbed residual without simultaneously constructing
410  // a perturbed jacobian.
411 
412  // We approximate the _l partial derivatives via a central
413  // differencing perturbation in the w_l direction:
414  //
415  // sum_l(w_l*v_l) ~= (v(p + dp*w_l*e_l) - v(p - dp*w_l*e_l))/(2*dp)
416 
417  ParameterVector oldparameters, parameterperturbation;
418  parameters_vec.deep_copy(oldparameters);
419  weights.deep_copy(parameterperturbation);
420  parameterperturbation *= delta_p;
421  parameters_vec += parameterperturbation;
422 
423  this->assembly(true, false, true);
424  this->rhs->close();
425 
426  std::unique_ptr<NumericVector<Number>> temprhs = this->rhs->clone();
427 
428  oldparameters.value_copy(parameters_vec);
429  parameterperturbation *= -1.0;
430  parameters_vec += parameterperturbation;
431 
432  this->assembly(true, false, true);
433  this->rhs->close();
434 
435  *temprhs -= *(this->rhs);
436  *temprhs /= (2.0*delta_p);
437 
438  // Finally, assemble the jacobian at the non-perturbed parameter
439  // values
440  oldparameters.value_copy(parameters_vec);
441 
442  // Build the Jacobian
443  this->assembly(false, true);
444  this->matrix->close();
445 
446  // The weighted sensitivity problem is linear
447  LinearSolver<Number> * solver = this->get_linear_solver();
448 
449  std::pair<unsigned int, Real> solver_params =
451 
452  const std::pair<unsigned int, Real> rval =
453  solver->solve (*matrix, this->add_weighted_sensitivity_solution(),
454  *temprhs,
455  double(solver_params.second),
456  solver_params.first);
457 
458  // The linear solver may not have fit our constraints exactly
459 #ifdef LIBMESH_ENABLE_CONSTRAINTS
461  (*this, &this->get_weighted_sensitivity_solution(),
462  /* homogeneous = */ true);
463 #endif
464 
465  return rval;
466 }
static constexpr Real TOLERANCE
virtual std::pair< unsigned int, Real > get_linear_solve_parameters() const
NumericVector< Number > * rhs
The system matrix.
virtual std::unique_ptr< NumericVector< T > > clone() const =0
virtual LinearSolver< Number > * get_linear_solver() const
NumericVector< Number > & add_weighted_sensitivity_solution()
Definition: system.C:1212
NumericVector< Number > & get_weighted_sensitivity_solution()
Definition: system.C:1219
virtual void assembly(bool, bool, bool=false, bool=false)
Assembles a residual in rhs and/or a jacobian in matrix, as requested.
template class LIBMESH_EXPORT LinearSolver< Number >
virtual void close()=0
Calls the NumericVector&#39;s internal assembly routines, ensuring that the values are consistent across ...
virtual void close()=0
Calls the SparseMatrix&#39;s internal assembly routines, ensuring that the values are consistent across p...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
SparseMatrix< Number > * matrix
The system matrix.
const DofMap & get_dof_map() const
Definition: system.h:2374
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. ...
Definition: dof_map.h:2350

◆ write_header()

void libMesh::System::write_header ( Xdr io,
std::string_view  version,
const bool  write_additional_data 
) const
inherited

Writes the basic data header for this System.

This method implements the output of a System object, embedded in the output of an EquationSystems<T_sys>. This warrants some documentation. The output of this part consists of 5 sections:

for this system

5.) The number of variables in the system (unsigned int)

for each variable in the system

6.) The name of the variable (string)

6.1.) subdomain where the variable lives

7.) Combined in an FEType:

  • The approximation order(s) of the variable (Order Enum, cast to int/s)
  • The finite element family/ies of the variable (FEFamily Enum, cast to int/s)

end variable loop

8.) The number of additional vectors (unsigned int),

for each additional vector in the system object

9.) the name of the additional vector (string)

end system

Definition at line 1267 of file system_io.C.

References libMesh::System::_vector_projections, libMesh::System::_vectors, libMesh::Variable::active_subdomains(), libMesh::Xdr::data(), libMesh::FEType::family, libMesh::System::get_mesh(), libMesh::FEType::inf_map, libMesh::libmesh_assert(), libMesh::make_range(), libMesh::System::n_vars(), libMesh::System::n_vectors(), libMesh::System::name(), libMesh::FEType::order, libMesh::ParallelObject::processor_id(), libMesh::FEType::radial_family, libMesh::FEType::radial_order, libMesh::System::variable(), libMesh::System::variable_name(), libMesh::System::variable_type(), and libMesh::Xdr::writing().

Referenced by libMesh::RBEvaluation::write_out_vectors().

1270 {
1304  libmesh_assert (io.writing());
1305 
1306 
1307  // Only write the header information
1308  // if we are processor 0.
1309  if (this->get_mesh().processor_id() != 0)
1310  return;
1311 
1312  std::string comment;
1313 
1314  // 5.)
1315  // Write the number of variables in the system
1316 
1317  {
1318  // set up the comment
1319  comment = "# No. of Variables in System \"";
1320  comment += this->name();
1321  comment += "\"";
1322 
1323  unsigned int nv = this->n_vars();
1324  io.data (nv, comment);
1325  }
1326 
1327 
1328  for (auto var : make_range(this->n_vars()))
1329  {
1330  // 6.)
1331  // Write the name of the var-th variable
1332  {
1333  // set up the comment
1334  comment = "# Name, Variable No. ";
1335  comment += std::to_string(var);
1336  comment += ", System \"";
1337  comment += this->name();
1338  comment += "\"";
1339 
1340  std::string var_name = this->variable_name(var);
1341  io.data (var_name, comment);
1342  }
1343 
1344  // 6.1.) Variable subdomains
1345  {
1346  // set up the comment
1347  comment = "# Subdomains, Variable \"";
1348  comment += this->variable_name(var);
1349  comment += "\", System \"";
1350  comment += this->name();
1351  comment += "\"";
1352 
1353  const std::set<subdomain_id_type> & domains = this->variable(var).active_subdomains();
1354  std::vector<subdomain_id_type> domain_array;
1355  domain_array.assign(domains.begin(), domains.end());
1356  io.data (domain_array, comment);
1357  }
1358 
1359  // 7.)
1360  // Write the approximation order of the var-th variable
1361  // in this system
1362  {
1363  // set up the comment
1364  comment = "# Approximation Order, Variable \"";
1365  comment += this->variable_name(var);
1366  comment += "\", System \"";
1367  comment += this->name();
1368  comment += "\"";
1369 
1370  int order = static_cast<int>(this->variable_type(var).order);
1371  io.data (order, comment);
1372  }
1373 
1374 
1375 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1376 
1377  // do the same for radial_order
1378  {
1379  comment = "# Radial Approximation Order, Variable \"";
1380  comment += this->variable_name(var);
1381  comment += "\", System \"";
1382  comment += this->name();
1383  comment += "\"";
1384 
1385  int rad_order = static_cast<int>(this->variable_type(var).radial_order);
1386  io.data (rad_order, comment);
1387  }
1388 
1389 #endif
1390 
1391  // Write the Finite Element type of the var-th variable
1392  // in this System
1393  {
1394  // set up the comment
1395  comment = "# FE Family, Variable \"";
1396  comment += this->variable_name(var);
1397  comment += "\", System \"";
1398  comment += this->name();
1399  comment += "\"";
1400 
1401  const FEType & type = this->variable_type(var);
1402  int fam = static_cast<int>(type.family);
1403  io.data (fam, comment);
1404 
1405 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1406 
1407  comment = "# Radial FE Family, Variable \"";
1408  comment += this->variable_name(var);
1409  comment += "\", System \"";
1410  comment += this->name();
1411  comment += "\"";
1412 
1413  int radial_fam = static_cast<int>(type.radial_family);
1414  io.data (radial_fam, comment);
1415 
1416  comment = "# Infinite Mapping Type, Variable \"";
1417  comment += this->variable_name(var);
1418  comment += "\", System \"";
1419  comment += this->name();
1420  comment += "\"";
1421 
1422  int i_map = static_cast<int>(type.inf_map);
1423  io.data (i_map, comment);
1424 #endif
1425  }
1426  } // end of the variable loop
1427 
1428  // 8.)
1429  // Write the number of additional vectors in the System.
1430  // If write_additional_data==false, then write zero for
1431  // the number of additional vectors.
1432  {
1433  {
1434  // set up the comment
1435  comment = "# No. of Additional Vectors, System \"";
1436  comment += this->name();
1437  comment += "\"";
1438 
1439  unsigned int nvecs = write_additional_data ? this->n_vectors () : 0;
1440  io.data (nvecs, comment);
1441  }
1442 
1443  if (write_additional_data)
1444  {
1445  unsigned int cnt=0;
1446  for (const auto & [vec_name, vec] : _vectors)
1447  {
1448  // 9.)
1449  // write the name of the cnt-th additional vector
1450  const std::string dth_vector = std::to_string(cnt++)+"th vector";
1451  comment = "# Name of " + dth_vector;
1452  std::string nonconst_vec_name = vec_name; // Stupid XDR API
1453 
1454  io.data (nonconst_vec_name, comment);
1455  int vec_projection = _vector_projections.at(vec_name);
1456  comment = "# Whether to do projections for " + dth_vector;
1457  io.data (vec_projection, comment);
1458  int vec_type = vec->type();
1459  comment = "# Parallel type of " + dth_vector;
1460  io.data (vec_type, comment);
1461  }
1462  }
1463  }
1464 }
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2458
OrderWrapper radial_order
The approximation order in radial direction of the infinite element.
Definition: fe_type.h:254
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2230
OrderWrapper order
The approximation order of the element.
Definition: fe_type.h:215
const MeshBase & get_mesh() const
Definition: system.h:2358
const std::set< subdomain_id_type > & active_subdomains() const
Definition: variable.h:181
unsigned int n_vectors() const
Definition: system.h:2558
libmesh_assert(ctx)
const std::string & variable_name(const unsigned int i) const
Definition: system.h:2478
const FEType & variable_type(const unsigned int i) const
Definition: system.h:2508
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...
Definition: int_range.h:140
const std::string & name() const
Definition: system.h:2342
unsigned int n_vars() const
Definition: system.h:2430
processor_id_type processor_id() const
std::map< std::string, bool, std::less<> > _vector_projections
Holds true if a vector by that name should be projected onto a changed grid, false if it should be ze...
Definition: system.h:2236

◆ write_parallel_data()

void libMesh::System::write_parallel_data ( Xdr io,
const bool  write_additional_data 
) const
inherited

Writes additional data, namely vectors, for this System.

This method may safely be called on a distributed-memory mesh. This method will create an individual file for each processor in the simulation where the local solution components for that processor will be stored.

This method implements the output of the vectors contained in this System object, embedded in the output of an EquationSystems<T_sys>.

9.) The global solution vector, re-ordered to be node-major (More on this later.)

for each additional vector in the object

10.) The global additional vector, re-ordered to be node-major (More on this later.)

Note that the actual IO is handled through the Xdr class (to be renamed later?) which provides a uniform interface to both the XDR (eXternal Data Representation) interface and standard ASCII output. Thus this one section of code will read XDR or ASCII files with no changes.

Definition at line 1468 of file system_io.C.

References libMesh::System::_vectors, libMesh::Xdr::data(), libMesh::FEType::family, libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::DofObject::invalid_id, libMesh::libmesh_assert(), libMesh::make_range(), libMesh::ParallelObject::n_processors(), libMesh::System::n_vars(), libMesh::System::name(), libMesh::System::number(), libMesh::ParallelObject::processor_id(), libMesh::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), libMesh::System::solution, libMesh::Variable::type(), libMesh::System::variable(), and libMesh::Xdr::writing().

1470 {
1490  // PerfLog pl("IO Performance",false);
1491  // pl.push("write_parallel_data");
1492  // std::size_t total_written_size = 0;
1493 
1494  std::string comment;
1495 
1496  libmesh_assert (io.writing());
1497 
1498  std::vector<Number> io_buffer; io_buffer.reserve(this->solution->local_size());
1499 
1500  // build the ordered nodes and element maps.
1501  // when writing/reading parallel files we need to iterate
1502  // over our nodes/elements in order of increasing global id().
1503  // however, this is not guaranteed to be ordering we obtain
1504  // by using the node_iterators/element_iterators directly.
1505  // so build a set, sorted by id(), that provides the ordering.
1506  // further, for memory economy build the set but then transfer
1507  // its contents to vectors, which will be sorted.
1508  std::vector<const DofObject *> ordered_nodes, ordered_elements;
1509  {
1510  std::set<const DofObject *, CompareDofObjectsByID>
1511  ordered_nodes_set (this->get_mesh().local_nodes_begin(),
1512  this->get_mesh().local_nodes_end());
1513 
1514  ordered_nodes.insert(ordered_nodes.end(),
1515  ordered_nodes_set.begin(),
1516  ordered_nodes_set.end());
1517  }
1518  {
1519  std::set<const DofObject *, CompareDofObjectsByID>
1520  ordered_elements_set (this->get_mesh().local_elements_begin(),
1521  this->get_mesh().local_elements_end());
1522 
1523  ordered_elements.insert(ordered_elements.end(),
1524  ordered_elements_set.begin(),
1525  ordered_elements_set.end());
1526  }
1527 
1528  const unsigned int sys_num = this->number();
1529  const unsigned int nv = this->n_vars();
1530 
1531  // Loop over each non-SCALAR variable and each node, and write out the value.
1532  for (unsigned int var=0; var<nv; var++)
1533  if (this->variable(var).type().family != SCALAR)
1534  {
1535  // First write the node DOF values
1536  for (const auto & node : ordered_nodes)
1537  for (auto comp : make_range(node->n_comp(sys_num,var)))
1538  {
1539  libmesh_assert_not_equal_to (node->dof_number(sys_num, var, comp),
1541 
1542  io_buffer.push_back((*this->solution)(node->dof_number(sys_num, var, comp)));
1543  }
1544 
1545  // Then write the element DOF values
1546  for (const auto & elem : ordered_elements)
1547  for (auto comp : make_range(elem->n_comp(sys_num,var)))
1548  {
1549  libmesh_assert_not_equal_to (elem->dof_number(sys_num, var, comp),
1551 
1552  io_buffer.push_back((*this->solution)(elem->dof_number(sys_num, var, comp)));
1553  }
1554  }
1555 
1556  // Finally, write the SCALAR data on the last processor
1557  for (auto var : make_range(this->n_vars()))
1558  if (this->variable(var).type().family == SCALAR)
1559  {
1560  if (this->processor_id() == (this->n_processors()-1))
1561  {
1562  const DofMap & dof_map = this->get_dof_map();
1563  std::vector<dof_id_type> SCALAR_dofs;
1564  dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
1565 
1566  for (auto dof : SCALAR_dofs)
1567  io_buffer.push_back((*this->solution)(dof));
1568  }
1569  }
1570 
1571  // 9.)
1572  //
1573  // Actually write the reordered solution vector
1574  // for the ith system to disk
1575 
1576  // set up the comment
1577  {
1578  comment = "# System \"";
1579  comment += this->name();
1580  comment += "\" Solution Vector";
1581  }
1582 
1583  io.data (io_buffer, comment);
1584 
1585  // total_written_size += io_buffer.size();
1586 
1587  // Only write additional vectors if wanted
1588  if (write_additional_data)
1589  {
1590  for (auto & [vec_name, vec] : _vectors)
1591  {
1592  io_buffer.clear();
1593  io_buffer.reserve(vec->local_size());
1594 
1595  // Loop over each non-SCALAR variable and each node, and write out the value.
1596  for (unsigned int var=0; var<nv; var++)
1597  if (this->variable(var).type().family != SCALAR)
1598  {
1599  // First write the node DOF values
1600  for (const auto & node : ordered_nodes)
1601  for (auto comp : make_range(node->n_comp(sys_num,var)))
1602  {
1603  libmesh_assert_not_equal_to (node->dof_number(sys_num, var, comp),
1605 
1606  io_buffer.push_back((*vec)(node->dof_number(sys_num, var, comp)));
1607  }
1608 
1609  // Then write the element DOF values
1610  for (const auto & elem : ordered_elements)
1611  for (auto comp : make_range(elem->n_comp(sys_num,var)))
1612  {
1613  libmesh_assert_not_equal_to (elem->dof_number(sys_num, var, comp),
1615 
1616  io_buffer.push_back((*vec)(elem->dof_number(sys_num, var, comp)));
1617  }
1618  }
1619 
1620  // Finally, write the SCALAR data on the last processor
1621  for (auto var : make_range(this->n_vars()))
1622  if (this->variable(var).type().family == SCALAR)
1623  {
1624  if (this->processor_id() == (this->n_processors()-1))
1625  {
1626  const DofMap & dof_map = this->get_dof_map();
1627  std::vector<dof_id_type> SCALAR_dofs;
1628  dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
1629 
1630  for (auto dof : SCALAR_dofs)
1631  io_buffer.push_back((*vec)(dof));
1632  }
1633  }
1634 
1635  // 10.)
1636  //
1637  // Actually write the reordered additional vector
1638  // for this system to disk
1639 
1640  // set up the comment
1641  {
1642  comment = "# System \"";
1643  comment += this->name();
1644  comment += "\" Additional Vector \"";
1645  comment += vec_name;
1646  comment += "\"";
1647  }
1648 
1649  io.data (io_buffer, comment);
1650 
1651  // total_written_size += io_buffer.size();
1652  }
1653  }
1654 
1655  // const Real
1656  // dt = pl.get_elapsed_time(),
1657  // rate = total_written_size*sizeof(Number)/dt;
1658 
1659  // libMesh::err << "Write " << total_written_size << " \"Number\" values\n"
1660  // << " Elapsed time = " << dt << '\n'
1661  // << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";
1662 
1663  // pl.pop("write_parallel_data");
1664 }
FEFamily family
The type of finite element.
Definition: fe_type.h:221
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2458
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2230
const MeshBase & get_mesh() const
Definition: system.h:2358
processor_id_type n_processors() const
unsigned int number() const
Definition: system.h:2350
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
libmesh_assert(ctx)
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:482
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...
Definition: int_range.h:140
const std::string & name() const
Definition: system.h:2342
unsigned int n_vars() const
Definition: system.h:2430
processor_id_type processor_id() const
const DofMap & get_dof_map() const
Definition: system.h:2374
const FEType & type() const
Definition: variable.h:144

◆ write_parameter_data_to_files()

void libMesh::RBParametrized::write_parameter_data_to_files ( const std::string &  continuous_param_file_name,
const std::string &  discrete_param_file_name,
const bool  write_binary_data 
)
inherited

Write out the parameter ranges to files.

Definition at line 199 of file rb_parametrized.C.

References libMesh::RBParametrized::write_discrete_parameter_values_to_file(), and libMesh::RBParametrized::write_parameter_ranges_to_file().

Referenced by libMesh::RBSCMEvaluation::legacy_write_offline_data_to_files(), and libMesh::RBEvaluation::legacy_write_offline_data_to_files().

202 {
203  write_parameter_ranges_to_file(continuous_param_file_name, write_binary_data);
204  write_discrete_parameter_values_to_file(discrete_param_file_name, write_binary_data);
205 }
void write_discrete_parameter_values_to_file(const std::string &file_name, const bool write_binary_data)
Write out the discrete parameter values to file.
void write_parameter_ranges_to_file(const std::string &file_name, const bool write_binary)
Write out the parameter ranges to file.

◆ write_riesz_representors_to_files()

void TransientRBConstruction::write_riesz_representors_to_files ( const std::string &  riesz_representors_dir,
const bool  write_binary_residual_representors 
)
overridevirtual

Write out all the Riesz representor data to files.

Override to write out transient data too.

Reimplemented from libMesh::RBConstruction.

Definition at line 1244 of file transient_rb_construction.C.

References TIMPI::Communicator::barrier(), libMesh::ParallelObject::comm(), libMesh::ENCODE, libMesh::RBConstruction::get_delta_N(), libMesh::RBEvaluation::get_n_basis_functions(), libMesh::RBConstruction::get_rb_evaluation(), libMesh::libmesh_assert(), libMesh::TransientRBEvaluation::M_q_representor, libMesh::out, libMesh::System::solution, libMesh::WRITE, and libMesh::System::write_serialized_data().

1246 {
1247  LOG_SCOPE("write_riesz_representors_to_files()", "TransientRBConstruction");
1248 
1249  // Write out the M_q_representors. These are useful to have when restarting,
1250  // so you don't have to recompute them all over again. There should be
1251  // this->rb_eval->get_n_basis_functions() of these.
1252  libMesh::out << "Writing out the M_q_representors..." << std::endl;
1253 
1254  std::ostringstream file_name;
1255  const std::string riesz_representor_suffix = (write_binary_residual_representors ? ".xdr" : ".dat");
1256 
1257  TransientRBEvaluation & trans_rb_eval = cast_ref<TransientRBEvaluation &>(get_rb_evaluation());
1258 
1259  const unsigned int istop = trans_rb_eval.get_n_basis_functions();
1260  const unsigned int istart = istop-get_delta_N();
1261 
1262  for (std::size_t q=0; q<trans_rb_eval.M_q_representor.size(); ++q)
1263  for (unsigned int i=istart; i<istop; ++i)
1264  {
1265  libMesh::out << "Writing out M_q_representor[" << q << "][" << i << "]..." << std::endl;
1266  libmesh_assert(trans_rb_eval.M_q_representor[q][i]);
1267 
1268  file_name.str(""); // reset filename
1269  file_name << riesz_representors_dir << "/M_q_representor" << i << riesz_representor_suffix;
1270 
1271  {
1272  // No need to copy!
1273  //*solution = *(M_q_representor[q][i]);
1274  trans_rb_eval.M_q_representor[q][i]->swap(*solution);
1275 
1276  Xdr mr_data(file_name.str(),
1277  write_binary_residual_representors ? ENCODE : WRITE);
1278 
1279  write_serialized_data(mr_data, false);
1280 
1281  // Synchronize before moving on
1282  this->comm().barrier();
1283 
1284  // Swap back.
1285  trans_rb_eval.M_q_representor[q][i]->swap(*solution);
1286 
1287  // TODO: bzip the resulting file? See $LIBMESH_DIR/src/mesh/unstructured_mesh.C
1288  // for the system call, be sure to do it only on one processor, etc.
1289  }
1290  }
1291 }
void write_serialized_data(Xdr &io, const bool write_additional_data=true) const
Writes additional data, namely vectors, for this System.
Definition: system_io.C:1668
void barrier() const
const Parallel::Communicator & comm() const
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
libmesh_assert(ctx)
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...
OStreamProxy out
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.

◆ write_serialized_data()

void libMesh::System::write_serialized_data ( Xdr io,
const bool  write_additional_data = true 
) const
inherited

Writes additional data, namely vectors, for this System.

This method may safely be called on a distributed-memory mesh.

This method implements the output of the vectors contained in this System object, embedded in the output of an EquationSystems<T_sys>.

9.) The global solution vector, re-ordered to be node-major (More on this later.)

for each additional vector in the object

10.) The global additional vector, re-ordered to be node-major (More on this later.)

Definition at line 1668 of file system_io.C.

References libMesh::System::_vectors, libMesh::Xdr::comment(), libMesh::System::name(), libMesh::ParallelObject::processor_id(), libMesh::System::solution, and libMesh::System::write_serialized_vector().

Referenced by write_riesz_representors_to_files(), and libMesh::RBConstruction::write_riesz_representors_to_files().

1670 {
1684  parallel_object_only();
1685  std::string comment;
1686 
1687  // PerfLog pl("IO Performance",false);
1688  // pl.push("write_serialized_data");
1689  // std::size_t total_written_size = 0;
1690 
1691  // total_written_size +=
1692  this->write_serialized_vector(io, *this->solution);
1693 
1694  // set up the comment
1695  if (this->processor_id() == 0)
1696  {
1697  comment = "# System \"";
1698  comment += this->name();
1699  comment += "\" Solution Vector";
1700 
1701  io.comment (comment);
1702  }
1703 
1704  // Only write additional vectors if wanted
1705  if (write_additional_data)
1706  {
1707  for (auto & pair : this->_vectors)
1708  {
1709  // total_written_size +=
1710  this->write_serialized_vector(io, *pair.second);
1711 
1712  // set up the comment
1713  if (this->processor_id() == 0)
1714  {
1715  comment = "# System \"";
1716  comment += this->name();
1717  comment += "\" Additional Vector \"";
1718  comment += pair.first;
1719  comment += "\"";
1720  io.comment (comment);
1721  }
1722  }
1723  }
1724 
1725  // const Real
1726  // dt = pl.get_elapsed_time(),
1727  // rate = total_written_size*sizeof(Number)/dt;
1728 
1729  // libMesh::out << "Write " << total_written_size << " \"Number\" values\n"
1730  // << " Elapsed time = " << dt << '\n'
1731  // << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";
1732 
1733  // pl.pop("write_serialized_data");
1734 
1735 
1736 
1737 
1738  // // test the new method
1739  // {
1740  // std::vector<std::string> names;
1741  // std::vector<NumericVector<Number> *> vectors_to_write;
1742 
1743  // names.push_back("Solution Vector");
1744  // vectors_to_write.push_back(this->solution.get());
1745 
1746  // // Only write additional vectors if wanted
1747  // if (write_additional_data)
1748  // {
1749  // std::map<std::string, NumericVector<Number> *>::const_iterator
1750  // pos = _vectors.begin();
1751 
1752  // for (; pos != this->_vectors.end(); ++pos)
1753  // {
1754  // names.push_back("Additional Vector " + pos->first);
1755  // vectors_to_write.push_back(pos->second);
1756  // }
1757  // }
1758 
1759  // total_written_size =
1760  // this->write_serialized_vectors (io, names, vectors_to_write);
1761 
1762  // const Real
1763  // dt2 = pl.get_elapsed_time(),
1764  // rate2 = total_written_size*sizeof(Number)/(dt2-dt);
1765 
1766  // libMesh::out << "Write (new) " << total_written_size << " \"Number\" values\n"
1767  // << " Elapsed time = " << (dt2-dt) << '\n'
1768  // << " Rate = " << rate2/1.e6 << "(MB/sec)\n\n";
1769 
1770  // }
1771 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2230
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1593
const std::string & name() const
Definition: system.h:2342
processor_id_type processor_id() const
dof_id_type write_serialized_vector(Xdr &io, const NumericVector< Number > &vec) const
Writes a vector for this System.
Definition: system_io.C:2118

◆ write_serialized_vectors()

std::size_t libMesh::System::write_serialized_vectors ( Xdr io,
const std::vector< const NumericVector< Number > *> &  vectors 
) const
inherited

Serialize & write a number of identically distributed vectors.

This method allows for optimization for the multiple vector case by only communicating the metadata once.

Definition at line 2261 of file system_io.C.

References libMesh::Xdr::data(), libMesh::System::get_mesh(), libMesh::libmesh_assert(), libMesh::make_range(), libMesh::MeshTools::n_elem(), libMesh::MeshBase::n_elem(), n_nodes, libMesh::MeshBase::n_nodes(), libMesh::System::n_vars(), libMesh::ParallelObject::processor_id(), libMesh::SCALAR, libMesh::System::variable(), libMesh::System::write_SCALAR_dofs(), libMesh::System::write_serialized_blocked_dof_objects(), and libMesh::Xdr::writing().

Referenced by libMesh::RBEvaluation::write_out_vectors().

2263 {
2264  parallel_object_only();
2265 
2266  libmesh_assert (io.writing());
2267 
2268  // Cache these - they are not free!
2269  const dof_id_type
2270  n_nodes = this->get_mesh().n_nodes(),
2271  n_elem = this->get_mesh().n_elem();
2272 
2273  std::size_t written_length = 0;
2274 
2275  if (this->processor_id() == 0)
2276  {
2277  unsigned int
2278  n_vec = cast_int<unsigned int>(vectors.size());
2279  dof_id_type
2280  vec_size = vectors.empty() ? 0 : vectors[0]->size();
2281  // Set the number of vectors
2282  io.data(n_vec, "# number of vectors");
2283  // Set the buffer size
2284  io.data(vec_size, "# vector length");
2285  }
2286 
2287  //---------------------------------
2288  // Collect the values for all nodes
2289  written_length +=
2290  this->write_serialized_blocked_dof_objects (vectors,
2291  n_nodes,
2292  this->get_mesh().local_nodes_begin(),
2293  this->get_mesh().local_nodes_end(),
2294  io);
2295 
2296  //------------------------------------
2297  // Collect the values for all elements
2298  written_length +=
2299  this->write_serialized_blocked_dof_objects (vectors,
2300  n_elem,
2301  this->get_mesh().local_elements_begin(),
2302  this->get_mesh().local_elements_end(),
2303  io);
2304 
2305  //-------------------------------------------
2306  // Finally loop over all the SCALAR variables
2307  for (const NumericVector<Number> * vec : vectors)
2308  for (auto var : make_range(this->n_vars()))
2309  if (this->variable(var).type().family == SCALAR)
2310  {
2311  libmesh_assert_not_equal_to (vec, 0);
2312 
2313  written_length +=
2314  this->write_SCALAR_dofs (*vec, var, io);
2315  }
2316 
2317  return written_length;
2318 }
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2458
dof_id_type n_elem(const MeshBase::const_element_iterator &begin, const MeshBase::const_element_iterator &end)
Count up the number of elements of a specific type (as defined by an iterator range).
Definition: mesh_tools.C:969
unsigned int write_SCALAR_dofs(const NumericVector< Number > &vec, const unsigned int var, Xdr &io) const
Writes the SCALAR dofs associated with var to the stream io.
Definition: system_io.C:2062
const MeshBase & get_mesh() const
Definition: system.h:2358
const dof_id_type n_nodes
Definition: tecplot_io.C:67
libmesh_assert(ctx)
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...
Definition: int_range.h:140
unsigned int n_vars() const
Definition: system.h:2430
virtual dof_id_type n_elem() const =0
processor_id_type processor_id() const
template class LIBMESH_EXPORT NumericVector< Number >
virtual dof_id_type n_nodes() const =0
std::size_t write_serialized_blocked_dof_objects(const std::vector< const NumericVector< Number > *> &vecs, const dof_id_type n_objects, const iterator_type begin, const iterator_type end, Xdr &io, const unsigned int var_to_write=libMesh::invalid_uint) const
Writes an output vector to the stream io for a set of DofObjects.
Definition: system_io.C:1776
uint8_t dof_id_type
Definition: id_types.h:67

◆ zero_constrained_dofs_on_vector()

void libMesh::RBConstruction::zero_constrained_dofs_on_vector ( NumericVector< Number > &  vector) const
inherited

It is sometimes useful to be able to zero vector entries that correspond to constrained dofs.

Definition at line 440 of file rb_construction.C.

References libMesh::NumericVector< T >::close(), libMesh::DofMapBase::end_dof(), libMesh::DofMapBase::first_dof(), libMesh::System::get_dof_map(), libMesh::DofMap::is_constrained_dof(), and libMesh::NumericVector< T >::set().

441 {
442 #ifdef LIBMESH_ENABLE_CONSTRAINTS
443  const DofMap & dof_map = get_dof_map();
444 
445  for (dof_id_type i=dof_map.first_dof(); i<dof_map.end_dof(); i++)
446  {
448  {
449  vector.set(i, 0.);
450  }
451  }
452 #endif
453 
454  vector.close();
455 }
bool is_constrained_dof(const dof_id_type dof) const
Definition: dof_map.h:2258
virtual void close()=0
Calls the NumericVector&#39;s internal assembly routines, ensuring that the values are consistent across ...
virtual void set(const numeric_index_type i, const T value)=0
Sets v(i) = value.
const DofMap & get_dof_map() const
Definition: system.h:2374
uint8_t dof_id_type
Definition: id_types.h:67

◆ zero_variable()

void libMesh::System::zero_variable ( NumericVector< Number > &  v,
unsigned int  var_num 
) const
inherited

Zeroes all dofs in v that correspond to variable number var_num.

Definition at line 1668 of file system.C.

References libMesh::System::get_mesh(), mesh, libMesh::System::n_vars(), libMesh::System::number(), and libMesh::NumericVector< T >::set().

1670 {
1671  /* Make sure the call makes sense. */
1672  libmesh_assert_less (var_num, this->n_vars());
1673 
1674  /* Get a reference to the mesh. */
1675  const MeshBase & mesh = this->get_mesh();
1676 
1677  /* Check which system we are. */
1678  const unsigned int sys_num = this->number();
1679 
1680  // Loop over nodes.
1681  for (const auto & node : mesh.local_node_ptr_range())
1682  {
1683  unsigned int n_comp = node->n_comp(sys_num,var_num);
1684  for (unsigned int i=0; i<n_comp; i++)
1685  {
1686  const dof_id_type index = node->dof_number(sys_num,var_num,i);
1687  v.set(index,0.0);
1688  }
1689  }
1690 
1691  // Loop over elements.
1692  for (const auto & elem : mesh.active_local_element_ptr_range())
1693  {
1694  unsigned int n_comp = elem->n_comp(sys_num,var_num);
1695  for (unsigned int i=0; i<n_comp; i++)
1696  {
1697  const dof_id_type index = elem->dof_number(sys_num,var_num,i);
1698  v.set(index,0.0);
1699  }
1700  }
1701 }
MeshBase & mesh
const MeshBase & get_mesh() const
Definition: system.h:2358
unsigned int number() const
Definition: system.h:2350
virtual void set(const numeric_index_type i, const T value)=0
Sets v(i) = value.
unsigned int n_vars() const
Definition: system.h:2430
uint8_t dof_id_type
Definition: id_types.h:67

Member Data Documentation

◆ _communicator

const Parallel::Communicator& libMesh::ParallelObject::_communicator
protectedinherited

◆ _counts [1/2]

ReferenceCounter::Counts libMesh::ReferenceCounter::_counts
staticprotectedinherited

Actually holds the data.

Definition at line 124 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::get_info().

◆ _counts [2/2]

ReferenceCounter::Counts libMesh::ReferenceCounter::_counts
staticprotectedinherited

Actually holds the data.

Definition at line 124 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::get_info().

◆ _enable_print_counter [1/2]

bool libMesh::ReferenceCounter::_enable_print_counter = true
staticprotectedinherited

Flag to control whether reference count information is printed when print_info is called.

Definition at line 143 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::disable_print_counter_info(), libMesh::ReferenceCounter::enable_print_counter_info(), and libMesh::ReferenceCounter::print_info().

◆ _enable_print_counter [2/2]

bool libMesh::ReferenceCounter::_enable_print_counter = true
staticprotectedinherited

Flag to control whether reference count information is printed when print_info is called.

Definition at line 143 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::disable_print_counter_info(), libMesh::ReferenceCounter::enable_print_counter_info(), and libMesh::ReferenceCounter::print_info().

◆ _final_linear_residual

Real libMesh::LinearImplicitSystem::_final_linear_residual
protectedinherited

◆ _mutex [1/2]

Threads::spin_mutex libMesh::ReferenceCounter::_mutex
staticprotectedinherited

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 137 of file reference_counter.h.

◆ _mutex [2/2]

Threads::spin_mutex libMesh::ReferenceCounter::_mutex
staticprotectedinherited

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 137 of file reference_counter.h.

◆ _n_linear_iterations

unsigned int libMesh::LinearImplicitSystem::_n_linear_iterations
protectedinherited

◆ _n_objects [1/2]

Threads::atomic< unsigned int > libMesh::ReferenceCounter::_n_objects
staticprotectedinherited

The number of objects.

Print the reference count information when the number returns to 0.

Definition at line 132 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::n_objects(), libMesh::ReferenceCounter::ReferenceCounter(), and libMesh::ReferenceCounter::~ReferenceCounter().

◆ _n_objects [2/2]

Threads::atomic< unsigned int > libMesh::ReferenceCounter::_n_objects
staticprotectedinherited

The number of objects.

Print the reference count information when the number returns to 0.

Definition at line 132 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::n_objects(), libMesh::ReferenceCounter::ReferenceCounter(), and libMesh::ReferenceCounter::~ReferenceCounter().

◆ _normalize_solution_snapshots

bool libMesh::RBConstructionBase< LinearImplicitSystem >::_normalize_solution_snapshots
protectedinherited

Set this boolean to true if we want to normalize solution snapshots used in training to have norm of 1.

This is relevant if snapshots have differing magnitudes and we want to approximate them all with equal accuracy.

Definition at line 281 of file rb_construction_base.h.

Referenced by libMesh::RBConstruction::train_reduced_basis_with_POD().

◆ _shell_matrix

ShellMatrix<Number>* libMesh::LinearImplicitSystem::_shell_matrix
protectedinherited

User supplies shell matrix or nullptr if no shell matrix is used.

Definition at line 202 of file linear_implicit_system.h.

Referenced by libMesh::LinearImplicitSystem::attach_shell_matrix(), libMesh::LinearImplicitSystem::get_shell_matrix(), and libMesh::LinearImplicitSystem::solve().

◆ _subset

const SystemSubset* libMesh::LinearImplicitSystem::_subset
protectedinherited

The current subset on which to solve (or nullptr if none).

Definition at line 207 of file linear_implicit_system.h.

Referenced by libMesh::LinearImplicitSystem::restrict_solve_to(), and libMesh::LinearImplicitSystem::solve().

◆ _subset_solve_mode

SubsetSolveMode libMesh::LinearImplicitSystem::_subset_solve_mode
protectedinherited

If restrict-solve-to-subset mode is active, this member decides what happens with the dofs outside the subset.

Definition at line 213 of file linear_implicit_system.h.

Referenced by libMesh::LinearImplicitSystem::restrict_solve_to(), and libMesh::LinearImplicitSystem::solve().

◆ assemble_before_solve

bool libMesh::System::assemble_before_solve
inherited

Flag which tells the system to whether or not to call the user assembly function during each call to solve().

By default, every call to solve() begins with a call to the user assemble, so this flag is true. (For explicit systems, "solving" the system occurs during the assembly step, so this flag is always true for explicit systems.)

You will only want to set this to false if you need direct control over when the system is assembled, and are willing to track the state of its assembly yourself. An example of such a case is an implicit system with multiple right hand sides. In this instance, a single assembly would likely be followed with multiple calls to solve.

The frequency system and Newmark system have their own versions of this flag, called _finished_assemble, which might be able to be replaced with this more general concept.

Definition at line 1547 of file system.h.

Referenced by libMesh::ImplicitSystem::adjoint_solve(), libMesh::ClawSystem::ClawSystem(), libMesh::ImplicitSystem::disable_cache(), libMesh::System::disable_cache(), main(), libMesh::RBConstruction::RBConstruction(), libMesh::RBSCMConstruction::RBSCMConstruction(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::EigenSystem::solve(), libMesh::CondensedEigenSystem::solve(), and libMesh::LinearImplicitSystem::solve().

◆ assert_convergence

bool libMesh::RBConstruction::assert_convergence
protectedinherited

◆ compute_RB_inner_product

bool libMesh::RBConstruction::compute_RB_inner_product
inherited

Boolean flag to indicate whether we compute the RB_inner_product_matrix.

This is false by default in RBConstruction since (in the default implementation) the RB inner-product matrix will just be the identity. But we may need the inner-product matrix subclasses.

Definition at line 617 of file rb_construction.h.

Referenced by TransientRBConstruction(), and libMesh::RBConstruction::update_RB_system_matrices().

◆ compute_truth_projection_error

bool libMesh::TransientRBConstruction::compute_truth_projection_error

Boolean flag that indicates whether we will compute the projection error for the truth solution into the RB space (at every time level).

This typically only needs to true during a call to train_reduced_basis.

Definition at line 307 of file transient_rb_construction.h.

Referenced by train_reduced_basis(), and truth_solve().

◆ current_local_solution

std::unique_ptr<NumericVector<Number> > libMesh::System::current_local_solution
inherited

All the values I need to compute my contribution to the simulation at hand.

Think of this as the current solution with any ghost values needed from other processors. This vector is necessarily larger than the solution vector in the case of a parallel simulation. The update() member is used to synchronize the contents of the solution and current_local_solution vectors.

Definition at line 1605 of file system.h.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::UniformRefinementEstimator::_estimate_error(), alternative_fe_assembly(), libMesh::VariationalSmootherSystem::assembly(), libMesh::NonlinearImplicitSystem::assembly(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::System::clear(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::System::current_solution(), DMlibMeshFunction(), DMlibMeshJacobian(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), fe_assembly(), libMesh::StaticCondensation::init(), libMesh::System::init_data(), libMesh::libmesh_petsc_snes_fd_residual(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_mffd_residual(), libMesh::libmesh_petsc_snes_residual(), libMesh::libmesh_petsc_snes_residual_helper(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::FEMContext::pre_fe_reinit(), libMesh::System::re_update(), libMesh::System::reinit(), libMesh::System::restrict_vectors(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), SolidSystem::save_initial_mesh(), libMesh::RBConstruction::set_context_solution_vec(), setup(), MeshFunctionTest::test_subdomain_id_sets(), MeshInputTest::testCopyElementVectorImpl(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), truth_assembly(), truth_solve(), libMesh::System::update(), libMesh::Nemesis_IO_Helper::write_element_values(), and libMesh::Nemesis_IO_Helper::write_nodal_solution().

◆ delta_N

unsigned int libMesh::RBConstruction::delta_N
protectedinherited

◆ exit_on_repeated_greedy_parameters

bool libMesh::RBConstruction::exit_on_repeated_greedy_parameters
inherited

Boolean flag to indicate whether we exit the greedy if we select the same parameters twice in a row.

In some problems this indicates that the greedy has "saturated" typically due to numerical rounding effects.

Definition at line 594 of file rb_construction.h.

Referenced by libMesh::RBConstruction::greedy_termination_test(), and TransientRBConstruction().

◆ extra_linear_solver

LinearSolver<Number>* libMesh::RBConstruction::extra_linear_solver
inherited

Also, we store a pointer to an extra linear solver.

This can be useful if we want to pass in the linear solver from somewhere else. For example, if a solver is already primed elsewhere then it can be more efficient to use that solver.

Definition at line 543 of file rb_construction.h.

Referenced by libMesh::RBConstruction::enrich_basis_from_rhs_terms(), and libMesh::RBConstruction::truth_solve().

◆ extra_quadrature_order

int libMesh::System::extra_quadrature_order
inherited

A member int that can be employed to indicate increased or reduced quadrature order.

Note
For FEMSystem users, by default, when calling the user-defined residual functions, the FEMSystem will first set up an appropriate FEType::default_quadrature_rule() object for performing the integration. This rule will integrate elements of order up to 2*p+1 exactly (where p is the sum of the base FEType and local p refinement levels), but if additional (or reduced) quadrature accuracy is desired then this extra_quadrature_order (default 0) will be added.

Definition at line 1578 of file system.h.

Referenced by CurlCurlSystem::init_data(), and set_system_parameters().

◆ Fq_representor

std::vector<std::unique_ptr<NumericVector<Number> > > libMesh::RBConstruction::Fq_representor
inherited

◆ Fq_representor_innerprods

std::vector<Number> libMesh::RBConstruction::Fq_representor_innerprods
inherited

Vectors storing the residual representor inner products to be used in computing the residuals online.

We store the Fq representor norms here because they are independent of a reduced basis space. The basis dependent representors are stored in RBEvaluation.

Definition at line 577 of file rb_construction.h.

Referenced by libMesh::RBConstruction::allocate_data_structures(), and libMesh::RBConstruction::compute_Fq_representor_innerprods().

◆ Fq_representor_innerprods_computed

bool libMesh::RBConstruction::Fq_representor_innerprods_computed
inherited

A boolean flag to indicate whether or not the Fq representor norms have already been computed — used to make sure that we don't recompute them unnecessarily.

Definition at line 648 of file rb_construction.h.

Referenced by libMesh::RBConstruction::clear(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::read_riesz_representors_from_files(), and libMesh::RBConstruction::recompute_all_residual_terms().

◆ impose_internal_fluxes

bool libMesh::RBConstruction::impose_internal_fluxes
inherited

Boolean flag to indicate whether we impose "fluxes" (i.e.

element boundary contributions to the weak form) on internal element boundaries in the assembly routines.

Definition at line 601 of file rb_construction.h.

Referenced by libMesh::RBConstruction::add_scaled_matrix_and_vector().

◆ init_filename

std::string libMesh::TransientRBConstruction::init_filename

The filename of the file containing the initial condition projected onto the truth mesh.

Definition at line 313 of file transient_rb_construction.h.

Referenced by initialize_truth(), print_info(), and process_parameters_file().

◆ inner_product_matrix

std::unique_ptr<SparseMatrix<Number> > libMesh::RBConstruction::inner_product_matrix
inherited

◆ inner_product_solver

std::unique_ptr<LinearSolver<Number> > libMesh::RBConstruction::inner_product_solver
inherited

We store an extra linear solver object which we can optionally use for solving all systems in which the system matrix is set to inner_product_matrix.

Definition at line 535 of file rb_construction.h.

Referenced by libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), libMesh::RBConstruction::initialize_rb_construction(), update_residual_terms(), and libMesh::RBConstruction::update_residual_terms().

◆ inner_product_storage_vector

std::unique_ptr<NumericVector<Number> > libMesh::RBConstructionBase< LinearImplicitSystem >::inner_product_storage_vector
protectedinherited

◆ L2_assembly

ElemAssembly* libMesh::TransientRBConstruction::L2_assembly
protected

Function pointer for assembling the L2 matrix.

Definition at line 399 of file transient_rb_construction.h.

Referenced by assemble_L2_matrix(), get_L2_assembly(), and set_L2_assembly().

◆ L2_matrix

std::unique_ptr<SparseMatrix<Number> > libMesh::TransientRBConstruction::L2_matrix

◆ linear_solver

std::unique_ptr<LinearSolver<Number> > libMesh::ImplicitSystem::linear_solver
mutableinherited

◆ M_q_vector

std::vector<std::unique_ptr<SparseMatrix<Number> > > libMesh::TransientRBConstruction::M_q_vector

Vector storing the Q_m matrices from the mass operator.

Definition at line 281 of file transient_rb_construction.h.

Referenced by allocate_data_structures(), clear(), get_M_q(), and update_residual_terms().

◆ matrix

SparseMatrix<Number>* libMesh::ImplicitSystem::matrix
inherited

The system matrix.

Implicit systems are characterized by the need to solve the linear system Ax=b. This is the system matrix A.

Public access to this member variable will be deprecated in the future! Use get_system_matrix() instead.

Definition at line 322 of file implicit_system.h.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), add_M_C_K_helmholtz(), libMesh::ImplicitSystem::add_matrices(), libMesh::ImplicitSystem::adjoint_solve(), libMesh::ImplicitSystem::assemble(), assemble_func(), libMesh::FEMSystem::assembly(), libMesh::LinearImplicitSystem::assembly(), libMesh::NonlinearImplicitSystem::assembly(), libMesh::ImplicitSystem::clear(), libMesh::NewmarkSystem::compute_matrix(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), libMesh::ContinuationSystem::continuation_solve(), libMesh::ImplicitSystem::create_static_condensation_system_matrix(), DMCreateMatrix_libMesh(), DMlibMeshJacobian(), libMesh::RBConstruction::enrich_basis_from_rhs_terms(), fill_dirichlet_bc(), libMesh::ImplicitSystem::forward_qoi_parameter_sensitivity(), libMesh::ImplicitSystem::get_system_matrix(), main(), periodic_bc_test_poisson(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::NewtonSolver::solve(), libMesh::PetscDiffSolver::solve(), libMesh::NoxNonlinearSolver< Number >::solve(), libMesh::EigenTimeSolver::solve(), libMesh::FrequencySystem::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::NonlinearImplicitSystem::solve(), libMesh::ClawSystem::solve_conservation_law(), libMesh::ContinuationSystem::solve_tangent(), truth_assembly(), libMesh::RBConstruction::truth_assembly(), truth_solve(), libMesh::RBConstruction::truth_solve(), libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve(), and libMesh::ImplicitSystem::weighted_sensitivity_solve().

◆ max_truth_solves

int libMesh::TransientRBConstruction::max_truth_solves
protected

Maximum number of truth solves in the POD-Greedy.

This can be different from Nmax in the transient case since we may add more than one basis function per truth solve. If negative, it's ignored.

Definition at line 394 of file transient_rb_construction.h.

Referenced by get_max_truth_solves(), print_info(), process_parameters_file(), and set_max_truth_solves().

◆ Nmax

unsigned int libMesh::RBConstruction::Nmax
protectedinherited

◆ non_dirichlet_L2_matrix

std::unique_ptr<SparseMatrix<Number> > libMesh::TransientRBConstruction::non_dirichlet_L2_matrix

The L2 matrix without Dirichlet conditions enforced.

(This is only computed if store_non_dirichlet_operators == true.)

Definition at line 276 of file transient_rb_construction.h.

Referenced by allocate_data_structures(), assemble_misc_matrices(), and get_all_matrices().

◆ non_dirichlet_M_q_vector

std::vector<std::unique_ptr<SparseMatrix<Number> > > libMesh::TransientRBConstruction::non_dirichlet_M_q_vector

We sometimes also need a second set of M_q matrices that do not have the Dirichlet boundary conditions enforced.

Definition at line 288 of file transient_rb_construction.h.

Referenced by allocate_data_structures(), clear(), and get_non_dirichlet_M_q().

◆ nonzero_initialization

bool libMesh::TransientRBConstruction::nonzero_initialization

Boolean flag to indicate whether we are using a non-zero initialization.

If we are, then an initialization function must be attached to the system.

Definition at line 300 of file transient_rb_construction.h.

Referenced by add_IC_to_RB_space(), initialize_truth(), print_info(), and process_parameters_file().

◆ old_local_solution

NumericVector<Number>* libMesh::TransientSystem< RBConstruction >::old_local_solution
inherited

All the values I need to compute my contribution to the simulation at hand.

Think of this as the current solution with any ghost values needed from other processors.

Definition at line 126 of file transient_system.h.

Referenced by truth_solve().

◆ older_local_solution

NumericVector<Number>* libMesh::TransientSystem< RBConstruction >::older_local_solution
inherited

All the values I need to compute my contribution to the simulation at hand.

Think of this as the current solution with any ghost values needed from other processors.

Definition at line 134 of file transient_system.h.

◆ output_dual_innerprods

std::vector<std::vector<Number > > libMesh::RBConstruction::output_dual_innerprods
inherited

The vector storing the dual norm inner product terms for each output.

Definition at line 560 of file rb_construction.h.

Referenced by libMesh::RBConstruction::allocate_data_structures(), and libMesh::RBConstruction::compute_output_dual_innerprods().

◆ output_dual_innerprods_computed

bool libMesh::RBConstruction::output_dual_innerprods_computed
protectedinherited

A boolean flag to indicate whether or not the output dual norms have already been computed — used to make sure that we don't recompute them unnecessarily.

Definition at line 876 of file rb_construction.h.

Referenced by libMesh::RBConstruction::compute_output_dual_innerprods().

◆ parameters

Parameters libMesh::System::parameters
inherited

◆ POD_tol

Real libMesh::TransientRBConstruction::POD_tol
protected

If positive, this tolerance determines the number of POD modes we add to the space on a call to enrich_RB_space().

If negative, we add delta_N POD modes.

Definition at line 386 of file transient_rb_construction.h.

Referenced by enrich_RB_space(), get_POD_tol(), process_parameters_file(), and set_POD_tol().

◆ quiet_mode

bool libMesh::RBConstructionBase< LinearImplicitSystem >::quiet_mode
protectedinherited

Flag to indicate whether we print out extra information during the Offline stage.

Definition at line 265 of file rb_construction_base.h.

Referenced by libMesh::RBConstruction::process_parameters_file().

◆ RB_ic_proj_rhs_all_N

DenseVector<Number> libMesh::TransientRBConstruction::RB_ic_proj_rhs_all_N
protected

The vector that stores the right-hand side for the initial condition projections.

Definition at line 405 of file transient_rb_construction.h.

Referenced by allocate_data_structures(), assemble_affine_expansion(), and update_RB_initial_condition_all_N().

◆ rhs

NumericVector<Number>* libMesh::ExplicitSystem::rhs
inherited

The system matrix.

Implicit systems are characterized by the need to solve the linear system Ax=b. This is the right-hand-side vector b.

Definition at line 124 of file explicit_system.h.

Referenced by libMesh::__libmesh_petsc_diff_solver_residual(), add_M_C_K_helmholtz(), libMesh::ExplicitSystem::add_system_rhs(), assemble(), libMesh::ImplicitSystem::assemble(), LinearElasticity::assemble(), assemble_1D(), assemble_biharmonic(), libMesh::AdvectionSystem::assemble_claw_rhs(), assemble_divgrad(), assemble_elasticity(), assemble_ellipticdg(), assemble_func(), assemble_graddiv(), assemble_laplace(), assemble_matrix_and_rhs(), assemble_poisson(), libMesh::ImplicitSystem::assemble_residual_derivatives(), assemble_shell(), assemble_stokes(), assemble_wave(), libMesh::FEMSystem::assembly(), libMesh::LinearImplicitSystem::assembly(), libMesh::NonlinearImplicitSystem::assembly(), assembly_with_dg_fem_context(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), libMesh::Problem_Interface::computeF(), libMesh::ContinuationSystem::continuation_solve(), DMlibMeshFunction(), libMesh::RBConstruction::enrich_basis_from_rhs_terms(), fill_dirichlet_bc(), libMesh::ImplicitSystem::forward_qoi_parameter_sensitivity(), libMesh::NewtonSolver::line_search(), periodic_bc_test_poisson(), HeatSystem::perturb_accumulate_residuals(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), libMesh::NewtonSolver::solve(), libMesh::PetscDiffSolver::solve(), libMesh::FrequencySystem::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::NonlinearImplicitSystem::solve(), libMesh::ContinuationSystem::solve_tangent(), truth_assembly(), libMesh::RBConstruction::truth_assembly(), truth_solve(), libMesh::RBConstruction::truth_solve(), update_residual_terms(), libMesh::RBConstruction::update_residual_terms(), libMesh::NewmarkSystem::update_rhs(), libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve(), and libMesh::ImplicitSystem::weighted_sensitivity_solve().

◆ serial_training_set

bool libMesh::RBConstructionBase< LinearImplicitSystem >::serial_training_set
protectedinherited

This boolean flag indicates whether or not the training set should be the same on all processors.

By default it is false, but in the case of the Empirical Interpolation Method (RBEIMConstruction), for example, we need the training set to be identical on all processors.

Definition at line 273 of file rb_construction_base.h.

Referenced by libMesh::RBConstruction::compute_max_error_bound(), libMesh::RBConstruction::set_RB_training_type(), and libMesh::RBConstruction::train_reduced_basis_with_POD().

◆ skip_degenerate_sides

bool libMesh::RBConstruction::skip_degenerate_sides
inherited

In some cases meshes are intentionally created with degenerate sides as a way to represent, say, triangles using a hex-only mesh.

In this situation we should detect and skip any degenerate sides in order to prevent zero or negative element Jacobian errors.

Definition at line 609 of file rb_construction.h.

Referenced by libMesh::RBConstruction::add_scaled_matrix_and_vector().

◆ skip_residual_in_train_reduced_basis

bool libMesh::RBConstruction::skip_residual_in_train_reduced_basis
inherited

Boolean flag to indicate if we skip residual calculations in train_reduced_basis.

This should only be used in special cases, e.g. when we know a priori that we want exactly one basis function and hence we do not need the residual based error indicator.

Definition at line 586 of file rb_construction.h.

Referenced by libMesh::RBConstruction::train_reduced_basis_with_greedy().

◆ solution

std::unique_ptr<NumericVector<Number> > libMesh::System::solution
inherited

Data structure to hold solution values.

Definition at line 1593 of file system.h.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), add_IC_to_RB_space(), libMesh::NewmarkSolver::advance_timestep(), libMesh::AdaptiveTimeSolver::advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), libMesh::ContinuationSystem::apply_predictor(), assemble_affine_expansion(), libMesh::VariationalSmootherSystem::assembly(), libMesh::FEMSystem::assembly(), libMesh::LinearImplicitSystem::assembly(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::RBConstruction::check_if_zero_truth_solve(), libMesh::System::clear(), libMesh::System::compare(), compute_enriched_soln(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::NewmarkSolver::compute_initial_accel(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), compute_stresses(), LinearElasticityWithContact::compute_stresses(), LinearElasticity::compute_stresses(), LargeDeformationElasticity::compute_stresses(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ContinuationSystem::continuation_solve(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::Nemesis_IO::copy_elemental_solution(), libMesh::GMVIO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::Nemesis_IO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), create_wrapped_function(), DMCreateGlobalVector_libMesh(), DMlibMeshFunction(), DMlibMeshJacobian(), libMesh::UnsteadySolver::du(), libMesh::RBConstruction::enrich_RB_space(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::RBSCMConstruction::evaluate_stability_constant(), libMesh::EigenSystem::get_eigenpair(), libMesh::CondensedEigenSystem::get_eigenpair(), LinearElasticityWithContact::get_least_and_max_gap_function(), libMesh::VariationalSmootherSystem::init_data(), libMesh::System::init_data(), libMesh::ContinuationSystem::initialize_tangent(), initialize_truth(), libMesh::libmesh_petsc_snes_fd_residual(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_mffd_residual(), libMesh::libmesh_petsc_snes_residual(), libMesh::libmesh_petsc_snes_residual_helper(), libMesh::RBConstruction::load_basis_function(), load_rb_solution(), libMesh::RBConstruction::load_rb_solution(), main(), libMesh::DofMap::max_constraint_error(), libMesh::FEMSystem::mesh_position_get(), libMesh::ErrorVector::plot_error(), libMesh::RBConstruction::print_basis_function_orthogonality(), libMesh::InterMeshProjection::project_system_vectors(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), libMesh::System::re_update(), libMesh::System::read_legacy_data(), libMesh::System::read_parallel_data(), read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::System::read_serialized_data(), libMesh::System::reinit(), libMesh::System::restrict_vectors(), libMesh::MemoryHistoryData::retrieve_vectors(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), libMesh::ContinuationSystem::save_current_solution(), set_error_temporal_data(), setup(), WriteVecAndScalar::setupTests(), libMesh::TwostepTimeSolver::solve(), libMesh::NewtonSolver::solve(), libMesh::PetscDiffSolver::solve(), libMesh::FrequencySystem::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::NonlinearImplicitSystem::solve(), libMesh::ClawSystem::solve_conservation_law(), libMesh::RBConstruction::solve_for_matrix_and_rhs(), libMesh::ContinuationSystem::solve_tangent(), libMesh::MemoryHistoryData::store_vectors(), ConstraintOperatorTest::test1DCoarseningOperator(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), SystemsTest::testBoundaryProjectCube(), ConstraintOperatorTest::testCoreform(), SystemsTest::testDofCouplingWithVarGroups(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), SystemsTest::testPostInitAddVector(), SystemsTest::testProjectCubeWithMeshFunction(), MeshInputTest::testProjectionRegression(), WriteVecAndScalar::testSolution(), libMesh::RBConstruction::train_reduced_basis_with_POD(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::DirectSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), libMesh::BoundaryVolumeSolutionTransfer::transfer_volume_boundary(), truth_solve(), libMesh::RBConstruction::truth_solve(), libMesh::System::update(), update_current_local_solution(), libMesh::System::update_global_solution(), update_RB_initial_condition_all_N(), update_residual_terms(), libMesh::RBConstruction::update_residual_terms(), libMesh::ContinuationSystem::update_solution(), libMesh::NewmarkSystem::update_u_v_a(), libMesh::DTKAdapter::update_variable_values(), libMesh::System::write_parallel_data(), write_riesz_representors_to_files(), libMesh::RBConstruction::write_riesz_representors_to_files(), and libMesh::System::write_serialized_data().

◆ store_non_dirichlet_operators

bool libMesh::RBConstruction::store_non_dirichlet_operators
inherited

◆ store_untransformed_basis

bool libMesh::RBConstruction::store_untransformed_basis
inherited

Boolean flag to indicate whether we store a second copy of the basis without constraints or dof transformations applied to it.

This is necessary when we have dof transformations and need to calculate the residual R(U) = C^T F - C^T A C U, since we need to evaluate R(U) using the untransformed basis U rather than C U to avoid "double applying" dof transformations in C.

Definition at line 634 of file rb_construction.h.

Referenced by libMesh::RBConstruction::compute_residual_dual_norm_slow(), libMesh::RBConstruction::enrich_RB_space(), libMesh::RBConstruction::truth_solve(), and libMesh::RBConstruction::update_residual_terms().

◆ temporal_data

std::vector<std::unique_ptr<NumericVector<Number> > > libMesh::TransientRBConstruction::temporal_data
private

Dense matrix to store the data that we use for the temporal POD.

Definition at line 414 of file transient_rb_construction.h.

Referenced by allocate_data_structures(), clear(), enrich_RB_space(), get_error_temporal_data(), and set_error_temporal_data().

◆ time

Real libMesh::System::time
inherited

For time-dependent problems, this is the time t at the beginning of the current timestep.

Note
For DifferentiableSystem users: do not access this time during an assembly! Use the DiffContext::time value instead to get correct results.

Definition at line 1615 of file system.h.

Referenced by libMesh::AdaptiveTimeSolver::adjoint_advance_timestep(), libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::TwostepTimeSolver::adjoint_solve(), libMesh::AdaptiveTimeSolver::advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubProjector::construct_projection(), HeatSystem::element_qoi(), fill_dirichlet_bc(), libMesh::ExactErrorEstimator::find_squared_element_error(), initialize(), libMesh::Euler2Solver::integrate_adjoint_refinement_error_estimate(), libMesh::EulerSolver::integrate_adjoint_refinement_error_estimate(), libMesh::UnsteadySolver::integrate_adjoint_sensitivity(), libMesh::Euler2Solver::integrate_qoi_timestep(), libMesh::EulerSolver::integrate_qoi_timestep(), main(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectVertices::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectEdges::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectSides::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectInteriors::operator()(), libMesh::System::reinit_constraints(), libMesh::UnsteadySolver::retrieve_timestep(), and libMesh::TwostepTimeSolver::solve().

◆ training_error_bounds

std::vector<Real> libMesh::RBConstruction::training_error_bounds
inherited

Vector storing the values of the error bound for each parameter in the training set — the parameter giving the largest error bound is chosen for the next snapshot in the Greedy basis training.

Definition at line 528 of file rb_construction.h.

Referenced by libMesh::RBConstruction::compute_max_error_bound().

◆ truth_outputs

std::vector<Number > libMesh::RBConstruction::truth_outputs
inherited

Vector storing the truth output values from the most recent truth solve.

Definition at line 554 of file rb_construction.h.

Referenced by libMesh::RBConstruction::allocate_data_structures(), and libMesh::RBConstruction::truth_solve().

◆ truth_outputs_all_k

std::vector<std::vector<Number> > libMesh::TransientRBConstruction::truth_outputs_all_k

The truth outputs for all time-levels from the most recent truth_solve.

Definition at line 294 of file transient_rb_construction.h.

Referenced by allocate_data_structures(), and truth_solve().

◆ use_empty_rb_solve_in_greedy

bool libMesh::RBConstruction::use_empty_rb_solve_in_greedy
inherited

A boolean flag to indicate whether or not we initialize the Greedy algorithm by performing rb_solves on the training set with an "empty" (i.e.

N=0) reduced basis space.

Definition at line 641 of file rb_construction.h.

Referenced by libMesh::RBConstruction::train_reduced_basis_with_greedy().

◆ use_fixed_solution

bool libMesh::System::use_fixed_solution
inherited

A boolean to be set to true by systems using elem_fixed_solution, for optional use by e.g.

stabilized methods. False by default.

Note
For FEMSystem users, if this variable is set to true, it must be before init_data() is called.

Definition at line 1563 of file system.h.

Referenced by libMesh::EulerSolver::_general_residual(), libMesh::Euler2Solver::_general_residual(), libMesh::SteadySolver::_general_residual(), libMesh::NewmarkSolver::_general_residual(), libMesh::DifferentiableSystem::clear(), libMesh::DiffContext::DiffContext(), and libMesh::FEMContext::pre_fe_reinit().

◆ verbose_mode

bool libMesh::RBParametrized::verbose_mode
inherited

Public boolean to toggle verbose mode.

Definition at line 193 of file rb_parametrized.h.

Referenced by libMesh::RBParametrized::check_if_valid_params().

◆ zero_out_matrix_and_rhs

bool libMesh::ImplicitSystem::zero_out_matrix_and_rhs
inherited

By default, the system will zero out the matrix and the right hand side.

If this flag is false, it is the responsibility of the client code to take care of setting these to zero before assembly begins

Definition at line 329 of file implicit_system.h.

Referenced by libMesh::ImplicitSystem::assemble().


The documentation for this class was generated from the following files: