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 Member Functions | Static Private Member Functions | Private Attributes | List of all members
ElasticityRBConstruction Class Reference

#include <rb_classes.h>

Inheritance diagram for ElasticityRBConstruction:
[legend]

Public Types

typedef ElasticityRBConstruction sys_type
 The type of system. More...
 
typedef RBConstruction Parent
 The type of the parent. More...
 
typedef std::map< std::string, SparseMatrix< Number > * >::iterator matrices_iterator
 Matrix iterator typedefs. More...
 
typedef std::map< std::string, SparseMatrix< Number > * >::const_iterator const_matrices_iterator
 
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, NumericVector< Number > * >::iterator vectors_iterator
 Vector iterator typedefs. More...
 
typedef std::map< std::string, NumericVector< Number > * >::const_iterator const_vectors_iterator
 

Public Member Functions

 ElasticityRBConstruction (EquationSystems &es, const std::string &name_in, const unsigned int number_in)
 
virtual ~ElasticityRBConstruction ()
 Destructor. More...
 
virtual void init_data ()
 Initialize data structures. More...
 
virtual void init_context (FEMContext &c)
 Pre-request all relevant element data. More...
 
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...
 
RBEvaluation & get_rb_evaluation ()
 Get a reference to the RBEvaluation object. More...
 
bool is_rb_eval_initialized () const
 
RBThetaExpansion & get_rb_theta_expansion ()
 Get a reference to the RBThetaExpansion object that that belongs to rb_eval. More...
 
void set_rb_assembly_expansion (RBAssemblyExpansion &rb_assembly_expansion_in)
 Set the rb_assembly_expansion object. More...
 
RBAssemblyExpansion & get_rb_assembly_expansion ()
 
sys_typesystem ()
 
virtual void clear () override
 Clear all the data structures associated with the system. More...
 
virtual std::string system_type () const override
 
virtual Real truth_solve (int plot_solution)
 Perform a "truth" solve, i.e. More...
 
virtual Real train_reduced_basis (const bool resize_rb_eval_data=true)
 Train the reduced basis. 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...
 
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 RBParameters & get_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 ()
 
void set_abs_training_tolerance (Real new_training_tolerance)
 Get/set the absolute tolerance for the basis training. More...
 
Real get_abs_training_tolerance ()
 
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 ()
 
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...
 
virtual void load_rb_solution ()
 Load the RB solution from the most recent solve with rb_eval into this system's 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...
 
SparseMatrix< Number > * get_non_dirichlet_inner_product_matrix ()
 Get the non-Dirichlet (or more generally no-constraints) version of the inner-product matrix. More...
 
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...
 
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...
 
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. 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_matrices (std::map< std::string, SparseMatrix< Number > * > &all_matrices)
 Get a map that stores pointers to all of the matrices. 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...
 
virtual void assemble_affine_expansion (bool skip_matrix_assembly, bool skip_vector_assembly)
 Assemble the matrices and vectors for this system. 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 write_riesz_representors_to_files (const std::string &riesz_representors_dir, const bool write_binary_residual_representors)
 Write out all the Riesz representor data to files. More...
 
virtual void read_riesz_representors_from_files (const std::string &riesz_representors_dir, const bool write_binary_residual_representors)
 Read in all the Riesz representor data from files. 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...
 
virtual void process_parameters_file (const std::string &parameters_filename)
 Read in from the file specified by parameters_filename and set the this system's member variables accordingly. More...
 
void set_rb_construction_parameters (unsigned int n_training_samples_in, bool deterministic_training_in, unsigned 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, RBParameters mu_min_in, RBParameters mu_max_in, std::map< std::string, std::vector< Real >> discrete_parameter_values_in, std::map< std::string, bool > log_scaling)
 Set the state of this RBConstruction object based on the arguments to this function. More...
 
virtual void print_info ()
 Print out info that describes the current setup of this RBConstruction. More...
 
void print_basis_function_orthogonality ()
 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...
 
ElemAssembly & get_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)
 It is sometimes useful to be able to zero vector entries that correspond to constrained dofs. More...
 
void set_convergence_assertion_flag (bool flag)
 Setter for the flag determining if convergence should be checked after each solve. More...
 
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...
 
numeric_index_type get_n_training_samples () const
 Get the total number of 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, unsigned int n_training_parameters, std::map< std::string, bool > log_param_scale, 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 (std::map< std::string, std::vector< Number >> &new_training_set)
 Overwrite the training parameters with new_training_set. More...
 
void broadcast_parameters (unsigned int proc_id)
 Broadcasts parameters on processor proc_id to all processors. More...
 
void set_training_random_seed (unsigned 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...
 
void set_deterministic_training_parameter_repeats (unsigned int repeats)
 Set the number of times each sample of the deterministic training parameter is repeated. More...
 
unsigned int get_deterministic_training_parameter_repeats () const
 Get the number of times each sample of the deterministic training parameter is repeated. 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 release_linear_solver (LinearSolver< Number > *) const override
 Releases a pointer to a linear solver acquired by this->get_linear_solver() More...
 
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 disable_cache () override
 Avoids use of any cached data that might affect any solve result. More...
 
virtual std::pair< unsigned int, Real > get_linear_solve_parameters () const
 
virtual void assemble_residual_derivatives (const ParameterVector &parameters) override
 Residual parameter derivative function. More...
 
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 parameters. More...
 
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 contained within parameters weighted by the values w_p found within weights. More...
 
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 specified by qoi_indices. More...
 
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. 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...
 
SparseMatrix< Number > & add_matrix (const std::string &mat_name)
 Adds the additional matrix mat_name to this system. More...
 
template<template< typename > class>
SparseMatrix< Number > & add_matrix (const std::string &mat_name)
 Adds the additional matrix mat_name to this system. More...
 
void remove_matrix (const std::string &mat_name)
 Removes the additional matrix mat_name from this system. More...
 
bool have_matrix (const std::string &mat_name) const
 
const SparseMatrix< Number > * request_matrix (const std::string &mat_name) const
 
SparseMatrix< Number > * request_matrix (const std::string &mat_name)
 
const SparseMatrix< Number > & get_matrix (const std::string &mat_name) const
 
SparseMatrix< Number > & get_matrix (const std::string &mat_name)
 
virtual unsigned int n_matrices () const override
 
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...
 
bool is_initialized ()
 
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 MeshBase & get_mesh () const
 
MeshBase & get_mesh ()
 
const DofMap & get_dof_map () const
 
DofMap & get_dof_map ()
 
const EquationSystems & get_equation_systems () const
 
EquationSystems & get_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...
 
NumericVector< Number > & add_vector (const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
 Adds the additional vector vec_name to this system. More...
 
void remove_vector (const std::string &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 (const std::string &vec_name) const
 
const NumericVector< Number > * request_vector (const std::string &vec_name) const
 
NumericVector< Number > * request_vector (const std::string &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 (const std::string &vec_name) const
 
NumericVector< Number > & get_vector (const std::string &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 (const std::string &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 (const std::string &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_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 (const std::string &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 (const std::string &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 Variable & variable (unsigned int var) const
 Return a constant reference to Variable var. More...
 
const VariableGroup & variable_group (unsigned int vg) const
 Return a constant reference to VariableGroup vg. More...
 
bool has_variable (const std::string &var) const
 
const std::string & variable_name (const unsigned int i) const
 
unsigned short int variable_number (const std::string &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 (const std::string &var, unsigned int component) const
 
unsigned int variable_scalar_number (unsigned int var_num, unsigned int component) const
 
const FEType & variable_type (const unsigned int i) const
 
const FEType & variable_type (const std::string &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, const std::string &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, const std::string &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...
 
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 re_update ()
 Re-update the local values when the mesh has changed. 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...
 
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 & 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...
 
const Parallel::Communicator & comm () 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 RBParameters & get_parameters () const
 Get the current parameters. More...
 
void set_parameters (const RBParameters &params)
 Set the current parameters to params. More...
 
const RBParameters & get_parameters_min () const
 Get an RBParameters object that specifies the minimum allowable value for each parameter. More...
 
const RBParameters & get_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...
 

Static Public Member Functions

static void print_info (std::ostream &out=libMesh::out)
 Prints the reference information, by default to libMesh::out. More...
 
static void print_info (std::ostream &out=libMesh::out)
 Prints the reference information, by default to libMesh::out. More...
 
static std::unique_ptr< DirichletBoundary > build_zero_dirichlet_boundary_object ()
 It's helpful to be able to generate a DirichletBoundary that stores a ZeroFunction in order to impose Dirichlet boundary conditions. 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

unsigned int u_var
 Variable numbers. More...
 
unsigned int v_var
 
unsigned int w_var
 
ElasticityAssemblyExpansion elasticity_assembly_expansion
 The object that stores the "assembly" expansion of the parameter dependent PDE. More...
 
InnerProductAssembly ip_assembly
 Object to assemble the inner product matrix. More...
 
std::unique_ptr< DirichletBoundarydirichlet_bc
 The object that defines which degrees of freedom are on a Dirichlet boundary. More...
 
std::vector< Real > training_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< Number > truth_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< Number > Fq_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 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...
 
std::unique_ptr< LinearSolver< Number > > linear_solver
 The LinearSolver defines the interface used to solve the linear_implicit system. 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...
 
NumericVector< Number > * rhs
 The system matrix. 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...
 
std::vector< Number > qoi
 Values of the quantities of interest. 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 ()
 Helper function that actually allocates all the data structures required by this class. More...
 
virtual void truth_assembly ()
 Assemble the truth matrix and right-hand side for current_parameters. More...
 
virtual std::unique_ptr< DGFEMContext > build_context ()
 Builds a DGFEMContext object with enough information to do evaluations on each element. More...
 
virtual SparseMatrix< Number > & get_matrix_for_output_dual_solves ()
 Return the matrix for the output residual dual norm solves. More...
 
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. 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_misc_matrices ()
 Assemble and store all the inner-product matrix, the constraint matrix (for constrained problems) and the mass matrix (for time-dependent problems). More...
 
virtual void assemble_all_affine_operators ()
 Assemble and store all Q_a affine operators as well as the inner-product matrix. 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 void enrich_RB_space ()
 Add a new basis function to the RB space. More...
 
virtual void update_system ()
 Update the system after enriching the RB space; this calls a series of functions to update the system properly. More...
 
virtual Real get_RB_error_bound ()
 
virtual void update_RB_system_matrices ()
 Compute the reduced basis matrices for the current basis. More...
 
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. 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...
 
RBParameters get_params_from_training_set (unsigned int index)
 Return the RBParameters in index index of training set. More...
 
void set_params_from_training_set (unsigned int index)
 Set parameters to the RBParameters stored in index index of the training set. More...
 
virtual void set_params_from_training_set_and_broadcast (unsigned int index)
 Load the specified training parameter and then broadcast to all processors. More...
 
virtual void init_matrices ()
 Initializes the matrices associated with this system. 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...
 
void increment_constructor_count (const std::string &name)
 Increments the construction counter. More...
 
void increment_constructor_count (const std::string &name)
 Increments the construction counter. More...
 
void increment_destructor_count (const std::string &name)
 Increments the destruction counter. More...
 
void increment_destructor_count (const std::string &name)
 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...
 
static void generate_training_parameters_random (const Parallel::Communicator &communicator, std::map< std::string, bool > log_param_scale, std::map< std::string, std::unique_ptr< NumericVector< Number >>> &training_parameters_in, unsigned int n_training_samples_in, const RBParameters &min_parameters, const RBParameters &max_parameters, int training_parameters_random_seed=-1, bool serial_training_set=false)
 Static helper function for generating a randomized set of parameters. More...
 
static void generate_training_parameters_deterministic (const Parallel::Communicator &communicator, std::map< std::string, bool > log_param_scale, std::map< std::string, std::unique_ptr< NumericVector< Number >>> &training_parameters_in, unsigned int n_training_samples_in, const RBParameters &min_parameters, const RBParameters &max_parameters, bool serial_training_set=false)
 Static helper function for generating a deterministic set of parameters. More...
 

Protected Attributes

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...
 
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 Member Functions

void add_system_matrix ()
 Add the system matrix to the _matrices data structure. More...
 
void add_system_rhs ()
 Add the system right-hand-side vector to the _vectors data structure. More...
 
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. More...
 
template<typename iterator_type , typename InValType >
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. More...
 
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. More...
 
template<typename InValType >
numeric_index_type read_serialized_vector (Xdr &io, NumericVector< Number > *vec)
 Reads a vector for this System. More...
 
numeric_index_type read_serialized_vector (Xdr &io, NumericVector< Number > &vec)
 Non-templated version for backward compatibility. More...
 
template<typename iterator_type >
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. More...
 
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. More...
 
dof_id_type write_serialized_vector (Xdr &io, const NumericVector< Number > &vec) const
 Writes a vector for this System. More...
 
void write_parameter_ranges_to_file (const std::string &file_name, const bool write_binary)
 Write out the parameter ranges to file. More...
 
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. More...
 
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. More...
 
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. More...
 
bool valid_params (const RBParameters &params)
 Helper function to check that params is valid. More...
 

Static Private Member Functions

static bool is_value_in_list (Real value, const std::vector< Real > &list_of_values, Real tol)
 Helper function to check if the specified value is in the list of values (within a tolerance given by tol). More...
 

Private Attributes

RBEvaluation * rb_eval
 The current RBEvaluation object we are using to perform the Evaluation stage of the reduced basis method. More...
 
RBAssemblyExpansion * rb_assembly_expansion
 This member holds the (parameter independent) assembly functors that define the "affine expansion" of the PDE that we are solving. More...
 
ElemAssembly * inner_product_assembly
 Pointer to inner product assembly. More...
 
bool use_energy_inner_product
 Boolean to indicate whether we're using the energy inner-product. More...
 
std::vector< Number > energy_inner_product_coeffs
 We may optionally want to use the "energy inner-product" rather than the inner-product assembly specified in inner_product_assembly. More...
 
std::vector< std::unique_ptr< SparseMatrix< Number > > > Aq_vector
 Vector storing the Q_a matrices from the affine expansion. More...
 
std::vector< std::unique_ptr< NumericVector< Number > > > Fq_vector
 Vector storing the Q_f vectors in the affine decomposition of the right-hand side. More...
 
std::vector< std::vector< std::unique_ptr< NumericVector< Number > > > > outputs_vector
 The libMesh vectors that define the output functionals. More...
 
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 enforced. More...
 
std::vector< std::unique_ptr< NumericVector< Number > > > non_dirichlet_Fq_vector
 
std::vector< std::vector< std::unique_ptr< NumericVector< Number > > > > non_dirichlet_outputs_vector
 
std::unique_ptr< SparseMatrix< Number > > non_dirichlet_inner_product_matrix
 
Real rel_training_tolerance
 Relative and absolute tolerances for training reduced basis using the Greedy scheme. More...
 
Real abs_training_tolerance
 
bool normalize_rb_bound_in_greedy
 This boolean indicates if we normalize the RB error in the greedy using RBEvaluation::get_error_bound_normalization(). More...
 
bool training_parameters_initialized
 Boolean flag to indicate whether or not the parameter ranges have been initialized. More...
 
std::map< std::string, std::unique_ptr< NumericVector< Number > > > training_parameters
 The training samples. More...
 
int training_parameters_random_seed
 If < 0, use std::time() * processor_id() to seed the random number generator for the training parameters (default). More...
 
std::map< std::string, SparseMatrix< Number > * > _matrices
 Some systems need an arbitrary number of matrices. More...
 
bool _can_add_matrices
 true when additional matrices may still be added, false otherwise. More...
 
void(* _init_system_function )(EquationSystems &es, const std::string &name)
 Function that initializes the system. More...
 
Initialization_init_system_object
 Object that initializes the system. More...
 
void(* _assemble_system_function )(EquationSystems &es, const std::string &name)
 Function that assembles the system. More...
 
Assembly_assemble_system_object
 Object that assembles the system. More...
 
void(* _constrain_system_function )(EquationSystems &es, const std::string &name)
 Function to impose constraints. More...
 
Constraint_constrain_system_object
 Object that constrains the system. More...
 
void(* _qoi_evaluate_function )(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
 Function to evaluate quantity of interest. More...
 
QOI_qoi_evaluate_object
 Object to compute quantities of interest. More...
 
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. More...
 
QOIDerivative_qoi_evaluate_derivative_object
 Object to compute derivatives of quantities of interest. More...
 
std::unique_ptr< DofMap > _dof_map
 Data structure describing the relationship between nodes, variables, etc... More...
 
EquationSystems & _equation_systems
 Constant reference to the EquationSystems object used for the simulation. More...
 
MeshBase & _mesh
 Constant reference to the mesh data structure used for the simulation. More...
 
const std::string _sys_name
 A name associated with this system. More...
 
const unsigned int _sys_number
 The number associated with this system. More...
 
std::vector< Variable > _variables
 The Variable in this System. More...
 
std::vector< VariableGroup > _variable_groups
 The VariableGroup in this System. More...
 
std::map< std::string, unsigned short int_variable_numbers
 The variable numbers corresponding to user-specified names, useful for name-based lookups. More...
 
bool _active
 Flag stating if the system is active or not. More...
 
std::map< std::string, NumericVector< Number > * > _vectors
 Some systems need an arbitrary number of vectors. More...
 
std::map< std::string, bool > _vector_projections
 Holds true if a vector by that name should be projected onto a changed grid, false if it should be zeroed. More...
 
std::map< std::string, int_vector_is_adjoint
 Holds non-negative if a vector by that name should be projected using adjoint constraints/BCs, -1 if primal. More...
 
std::map< std::string, ParallelType > _vector_types
 Holds the type of a vector. More...
 
bool _solution_projection
 Holds true if the solution vector should be projected onto a changed grid, false if it should be zeroed. More...
 
bool _basic_system_only
 Holds true if the components of more advanced system types (e.g. More...
 
bool _is_initialized
 true when additional vectors and variables do not require immediate initialization, false otherwise. More...
 
bool _identify_variable_groups
 true when VariableGroup structures should be automatically identified, false otherwise. More...
 
unsigned int _additional_data_written
 This flag is used only when reading in a system from file. More...
 
std::vector< unsigned int_written_var_indices
 This vector is used only when reading in a system from file. More...
 
bool adjoint_already_solved
 Has the adjoint problem already been solved? If the user sets adjoint_already_solved to true, we won't waste time solving it again. More...
 
bool _hide_output
 Are we allowed to write this system to file? If _hide_output is true, then EquationSystems::write will ignore this system. More...
 
bool parameters_initialized
 Flag indicating whether the parameters have been initialized. More...
 
RBParameters parameters
 Vector storing the current parameters. More...
 
RBParameters parameters_min
 Vectors that define the ranges (min and max) for the parameters. More...
 
RBParameters parameters_max
 
std::map< std::string, std::vector< Real > > _discrete_parameter_values
 Map that defines the allowable values of any discrete parameters. More...
 

Detailed Description

Definition at line 46 of file rb_classes.h.

Member Typedef Documentation

◆ const_matrices_iterator

typedef std::map<std::string, SparseMatrix<Number> *>::const_iterator libMesh::ImplicitSystem::const_matrices_iterator
inherited

Definition at line 307 of file implicit_system.h.

◆ const_vectors_iterator

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

Definition at line 757 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 117 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 117 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 532 of file system.h.

◆ matrices_iterator

typedef std::map<std::string, SparseMatrix<Number> *>::iterator libMesh::ImplicitSystem::matrices_iterator
inherited

Matrix iterator typedefs.

Definition at line 306 of file implicit_system.h.

◆ Parent

The type of the parent.

Definition at line 71 of file rb_classes.h.

◆ sys_type

The type of system.

Definition at line 66 of file rb_classes.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 528 of file system.h.

◆ vectors_iterator

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

Vector iterator typedefs.

Definition at line 756 of file system.h.

Constructor & Destructor Documentation

◆ ElasticityRBConstruction()

ElasticityRBConstruction::ElasticityRBConstruction ( EquationSystems es,
const std::string &  name_in,
const unsigned int  number_in 
)
inline

Definition at line 50 of file rb_classes.h.

52  :
53  Parent(es, name_in, number_in),
55  ip_assembly(*this)
56  {}

◆ ~ElasticityRBConstruction()

virtual ElasticityRBConstruction::~ElasticityRBConstruction ( )
inlinevirtual

Destructor.

Definition at line 61 of file rb_classes.h.

61 {}

Member Function Documentation

◆ activate()

void libMesh::System::activate ( )
inlineinherited

Activates the system.

Only active systems are solved.

Definition at line 2123 of file system.h.

2124 {
2125  _active = true;
2126 }

References libMesh::System::_active.

◆ 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 2115 of file system.h.

2116 {
2117  return _active;
2118 }

References libMesh::System::_active.

◆ 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 1009 of file system.C.

1010 {
1011  std::ostringstream adjoint_rhs_name;
1012  adjoint_rhs_name << "adjoint_rhs" << i;
1013 
1014  return this->add_vector(adjoint_rhs_name.str(), false);
1015 }

References libMesh::System::add_vector().

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

◆ 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 945 of file system.C.

946 {
947  std::ostringstream adjoint_name;
948  adjoint_name << "adjoint_solution" << i;
949 
950  NumericVector<Number> & returnval = this->add_vector(adjoint_name.str());
951  this->set_vector_as_adjoint(adjoint_name.str(), i);
952  return returnval;
953 }

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

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

◆ add_matrix() [1/2]

SparseMatrix< Number > & libMesh::ImplicitSystem::add_matrix ( const std::string &  mat_name)
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 mayor 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

Definition at line 202 of file implicit_system.C.

203 {
204  // only add matrices before initializing...
205  if (!_can_add_matrices)
206  libmesh_error_msg("ERROR: Too late. Cannot add matrices to the system after initialization"
207  << "\n any more. You should have done this earlier.");
208 
209  // Return the matrix if it is already there.
210  if (this->have_matrix(mat_name))
211  return *(_matrices[mat_name]);
212 
213  // Otherwise build the matrix and return it.
214  SparseMatrix<Number> * buf = SparseMatrix<Number>::build(this->comm()).release();
215  _matrices.insert (std::make_pair (mat_name, buf));
216 
217  return *buf;
218 }

References libMesh::ImplicitSystem::_can_add_matrices, libMesh::ImplicitSystem::_matrices, libMesh::SparseMatrix< T >::build(), libMesh::ParallelObject::comm(), and libMesh::ImplicitSystem::have_matrix().

Referenced by libMesh::ImplicitSystem::add_system_matrix(), libMesh::EigenTimeSolver::init(), main(), and libMesh::NewmarkSystem::NewmarkSystem().

◆ add_matrix() [2/2]

template<template< typename > class MatrixType>
SparseMatrix< Number > & libMesh::ImplicitSystem::add_matrix ( const std::string &  mat_name)
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 mayor 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

Definition at line 454 of file implicit_system.h.

455 {
456  // only add matrices before initializing...
457  if (!_can_add_matrices)
458  libmesh_error_msg("ERROR: Too late. Cannot add matrices to the system after initialization"
459  << "\n any more. You should have done this earlier.");
460 
461  // Return the matrix if it is already there.
462  if (this->have_matrix(mat_name))
463  return *(_matrices[mat_name]);
464 
465  // Otherwise build the matrix and return it.
466  SparseMatrix<Number> * buf = libmesh_make_unique<MatrixType<Number>>(this->comm()).release();
467  _matrices.insert (std::make_pair (mat_name, buf));
468 
469  return *buf;
470 }

References libMesh::ImplicitSystem::_can_add_matrices, libMesh::ImplicitSystem::_matrices, libMesh::ParallelObject::comm(), and libMesh::ImplicitSystem::have_matrix().

◆ 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 893 of file rb_construction.C.

897 {
898  LOG_SCOPE("add_scaled_Aq()", "RBConstruction");
899 
900  if (q_a >= get_rb_theta_expansion().get_n_A_terms())
901  libmesh_error_msg("Error: We must have q < Q_a in add_scaled_Aq.");
902 
903  if (!symmetrize)
904  {
905  input_matrix->add(scalar, *get_Aq(q_a));
906  input_matrix->close();
907  }
908  else
909  {
912  input_matrix,
913  nullptr,
914  symmetrize);
915  }
916 }

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().

◆ 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 588 of file rb_construction.C.

594 {
595  LOG_SCOPE("add_scaled_matrix_and_vector()", "RBConstruction");
596 
597  bool assemble_matrix = (input_matrix != nullptr);
598  bool assemble_vector = (input_vector != nullptr);
599 
600  if (!assemble_matrix && !assemble_vector)
601  return;
602 
603  const MeshBase & mesh = this->get_mesh();
604 
605  // First add any node-based terms (e.g. point loads)
606  // We only enter this loop if we have at least one
607  // nodeset, since we use nodesets to indicate
608  // where to impose the node-based terms.
609  if (mesh.get_boundary_info().n_nodeset_conds() > 0)
610  {
611  // build_node_list() returns a vector of (node-id, bc-id) tuples.
612  for (const auto & t : mesh.get_boundary_info().build_node_list())
613  {
614  const Node & node = mesh.node_ref(std::get<0>(t));
615 
616  // If node is on this processor, then all dofs on node are too
617  // so we can do the add below safely
618  if (node.processor_id() == this->comm().rank())
619  {
620  // Get the values to add to the rhs vector
621  std::vector<dof_id_type> nodal_dof_indices;
622  DenseMatrix<Number> nodal_matrix;
623  DenseVector<Number> nodal_rhs;
624  elem_assembly->get_nodal_values(nodal_dof_indices,
625  nodal_matrix,
626  nodal_rhs,
627  *this,
628  node);
629 
630  // Perform any required user-defined postprocessing on
631  // the matrix and rhs.
632  //
633  // TODO: We need to postprocess node matrices and vectors
634  // in some cases (e.g. when rotations are applied to
635  // nodes), but since we don't have a FEMContext at this
636  // point we would need to have a different interface
637  // taking the DenseMatrix, DenseVector, and probably the
638  // current node that we are on...
639  // this->post_process_elem_matrix_and_vector(nodal_matrix, nodal_rhs);
640 
641  if (!nodal_dof_indices.empty())
642  {
643  if (assemble_vector)
644  input_vector->add_vector(nodal_rhs, nodal_dof_indices);
645 
646  if (assemble_matrix)
647  input_matrix->add_matrix(nodal_matrix, nodal_dof_indices);
648  }
649  }
650  }
651  }
652 
653  std::unique_ptr<DGFEMContext> c = this->build_context();
654  DGFEMContext & context = cast_ref<DGFEMContext &>(*c);
655 
656  this->init_context(context);
657 
658  for (const auto & elem : mesh.active_local_element_ptr_range())
659  {
660  // Subdivision elements need special care:
661  // - skip ghost elements
662  // - init special quadrature rule
663  std::unique_ptr<QBase> qrule;
664  if (elem->type() == TRI3SUBDIVISION)
665  {
666  const Tri3Subdivision * gh_elem = static_cast<const Tri3Subdivision *> (elem);
667  if (gh_elem->is_ghost())
668  continue ;
669  // A Gauss quadrature rule for numerical integration.
670  // For subdivision shell elements, a single Gauss point per
671  // element is sufficient, hence we use extraorder = 0.
672  const int extraorder = 0;
673  FEBase * elem_fe = nullptr;
674  context.get_element_fe( 0, elem_fe );
675 
676  qrule = elem_fe->get_fe_type().default_quadrature_rule (2, extraorder);
677 
678  // Tell the finite element object to use our quadrature rule.
679  elem_fe->attach_quadrature_rule (qrule.get());
680  }
681 
682  context.pre_fe_reinit(*this, elem);
683  context.elem_fe_reinit();
684  elem_assembly->interior_assembly(context);
685 
686  const unsigned char n_sides = context.get_elem().n_sides();
687  for (context.side = 0; context.side != n_sides; ++context.side)
688  {
689  // May not need to apply fluxes on non-boundary elements
690  if ((context.get_elem().neighbor_ptr(context.get_side()) != nullptr) && !impose_internal_fluxes)
691  continue;
692 
693  // skip degenerate sides with zero area
694  if( (context.get_elem().side_ptr(context.get_side())->volume() <= 0.) && skip_degenerate_sides)
695  continue;
696 
697  context.side_fe_reinit();
698  elem_assembly->boundary_assembly(context);
699 
700  if (context.dg_terms_are_active())
701  {
702  input_matrix->add_matrix (context.get_elem_elem_jacobian(),
703  context.get_dof_indices(),
704  context.get_dof_indices());
705 
706  input_matrix->add_matrix (context.get_elem_neighbor_jacobian(),
707  context.get_dof_indices(),
708  context.get_neighbor_dof_indices());
709 
710  input_matrix->add_matrix (context.get_neighbor_elem_jacobian(),
711  context.get_neighbor_dof_indices(),
712  context.get_dof_indices());
713 
714  input_matrix->add_matrix (context.get_neighbor_neighbor_jacobian(),
715  context.get_neighbor_dof_indices(),
716  context.get_neighbor_dof_indices());
717  }
718  }
719 
720  // Do any required user post-processing before symmetrizing
721  // and/or applying constraints. Only do the post processing
722  // if we are applying the dof constraints.
723  if (apply_dof_constraints)
725 
726  // Need to symmetrize before imposing
727  // periodic constraints
728  if (assemble_matrix && symmetrize)
729  {
730  DenseMatrix<Number> Ke_transpose;
731  context.get_elem_jacobian().get_transpose(Ke_transpose);
732  context.get_elem_jacobian() += Ke_transpose;
733  context.get_elem_jacobian() *= 0.5;
734  }
735 
736  if (apply_dof_constraints)
737  {
738  // Apply constraints, e.g. Dirichlet and periodic constraints
740  (context.get_elem_jacobian(),
741  context.get_elem_residual(),
742  context.get_dof_indices(),
743  /*asymmetric_constraint_rows*/ false );
744  }
745 
746  // Scale and add to global matrix and/or vector
747  context.get_elem_jacobian() *= scalar;
748  context.get_elem_residual() *= scalar;
749 
750  if (assemble_matrix)
751  {
752 
753  CouplingMatrix * coupling_matrix = get_dof_map()._dof_coupling;
754  if (!coupling_matrix)
755  {
756  // If we haven't defined a _dof_coupling matrix then just add
757  // the whole matrix
758  input_matrix->add_matrix (context.get_elem_jacobian(),
759  context.get_dof_indices() );
760  }
761  else
762  {
763  // Otherwise we should only add the relevant submatrices
764  for (unsigned int var1=0; var1<n_vars(); var1++)
765  {
766  ConstCouplingRow ccr(var1, *coupling_matrix);
767  for (const auto & var2 : ccr)
768  {
769  unsigned int sub_m = context.get_elem_jacobian( var1, var2 ).m();
770  unsigned int sub_n = context.get_elem_jacobian( var1, var2 ).n();
771  DenseMatrix<Number> sub_jac(sub_m, sub_n);
772  for (unsigned int row=0; row<sub_m; row++)
773  for (unsigned int col=0; col<sub_n; col++)
774  {
775  sub_jac(row,col) = context.get_elem_jacobian( var1, var2 ).el(row,col);
776  }
777  input_matrix->add_matrix (sub_jac,
778  context.get_dof_indices(var1),
779  context.get_dof_indices(var2) );
780  }
781  }
782  }
783 
784  }
785 
786  if (assemble_vector)
787  input_vector->add_vector (context.get_elem_residual(),
788  context.get_dof_indices() );
789  }
790 
791  if (assemble_matrix)
792  input_matrix->close();
793  if (assemble_vector)
794  input_vector->close();
795 }

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::SparseMatrix< T >::close(), libMesh::NumericVector< 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::MeshBase::get_boundary_info(), 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(), mesh, libMesh::DenseMatrixBase< T >::n(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::Elem::n_sides(), libMesh::System::n_vars(), libMesh::Elem::neighbor_ptr(), libMesh::RBConstruction::post_process_elem_matrix_and_vector(), libMesh::FEMContext::pre_fe_reinit(), libMesh::DofObject::processor_id(), libMesh::FEMContext::side, libMesh::DGFEMContext::side_fe_reinit(), libMesh::Elem::side_ptr(), libMesh::RBConstruction::skip_degenerate_sides, and libMesh::TRI3SUBDIVISION.

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(), libMesh::TransientRBConstruction::assemble_L2_matrix(), and libMesh::TransientRBConstruction::assemble_Mq_matrix().

◆ 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 1039 of file system.C.

1040 {
1041  std::ostringstream sensitivity_rhs_name;
1042  sensitivity_rhs_name << "sensitivity_rhs" << i;
1043 
1044  return this->add_vector(sensitivity_rhs_name.str(), false);
1045 }

References libMesh::System::add_vector().

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

◆ 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 894 of file system.C.

895 {
896  std::ostringstream sensitivity_name;
897  sensitivity_name << "sensitivity_solution" << i;
898 
899  return this->add_vector(sensitivity_name.str());
900 }

References libMesh::System::add_vector().

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

◆ add_system_matrix()

void libMesh::ImplicitSystem::add_system_matrix ( )
privateinherited

Add the system matrix to the _matrices data structure.

Useful in initialization.

Definition at line 276 of file implicit_system.C.

277 {
278  // Possible that we cleared the _matrices but
279  // forgot to update the matrix pointer?
280  if (_matrices.empty())
281  matrix = nullptr;
282 
283  // Only need to add the matrix if it isn't there
284  // already!
285  if (matrix == nullptr)
286  matrix = &(this->add_matrix ("System Matrix"));
287 
289 }

References libMesh::ImplicitSystem::_matrices, libMesh::ImplicitSystem::add_matrix(), libMesh::libmesh_assert(), and libMesh::ImplicitSystem::matrix.

Referenced by libMesh::ImplicitSystem::clear(), and libMesh::ImplicitSystem::ImplicitSystem().

◆ add_system_rhs()

void libMesh::ExplicitSystem::add_system_rhs ( )
privateinherited

Add the system right-hand-side vector to the _vectors data structure.

Useful in initialization.

Definition at line 96 of file explicit_system.C.

97 {
98  // Possible that we cleared the _vectors but
99  // forgot to update the rhs pointer?
100  if (this->n_vectors() == 0)
101  rhs = nullptr;
102 
103 
104  // Only need to add the rhs if it isn't there
105  // already!
106  if (rhs == nullptr)
107  rhs = &(this->add_vector ("RHS Vector", false));
108 
110 }

References libMesh::System::add_vector(), libMesh::libmesh_assert(), libMesh::System::n_vectors(), and libMesh::ExplicitSystem::rhs.

Referenced by libMesh::ExplicitSystem::clear(), and libMesh::ExplicitSystem::ExplicitSystem().

◆ add_variable() [1/2]

unsigned int libMesh::System::add_variable ( const std::string &  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 1069 of file system.C.

1072 {
1073  libmesh_assert(!this->is_initialized());
1074 
1075  // Make sure the variable isn't there already
1076  // or if it is, that it's the type we want
1077  for (auto v : IntRange<unsigned int>(0, this->n_vars()))
1078  if (this->variable_name(v) == var)
1079  {
1080  if (this->variable_type(v) == type)
1081  return _variables[v].number();
1082 
1083  libmesh_error_msg("ERROR: incompatible variable " << var << " has already been added for this system!");
1084  }
1085 
1086  // Optimize for VariableGroups here - if the user is adding multiple
1087  // variables of the same FEType and subdomain restriction, catch
1088  // that here and add them as members of the same VariableGroup.
1089  //
1090  // start by setting this flag to whatever the user has requested
1091  // and then consider the conditions which should negate it.
1092  bool should_be_in_vg = this->identify_variable_groups();
1093 
1094  // No variable groups, nothing to add to
1095  if (!this->n_variable_groups())
1096  should_be_in_vg = false;
1097 
1098  else
1099  {
1100  VariableGroup & vg(_variable_groups.back());
1101 
1102  // get a pointer to their subdomain restriction, if any.
1103  const std::set<subdomain_id_type> * const
1104  their_active_subdomains (vg.implicitly_active() ?
1105  nullptr : &vg.active_subdomains());
1106 
1107  // Different types?
1108  if (vg.type() != type)
1109  should_be_in_vg = false;
1110 
1111  // they are restricted, we aren't?
1112  if (their_active_subdomains &&
1113  (!active_subdomains || (active_subdomains && active_subdomains->empty())))
1114  should_be_in_vg = false;
1115 
1116  // they aren't restricted, we are?
1117  if (!their_active_subdomains && (active_subdomains && !active_subdomains->empty()))
1118  should_be_in_vg = false;
1119 
1120  if (their_active_subdomains && active_subdomains)
1121  // restricted to different sets?
1122  if (*their_active_subdomains != *active_subdomains)
1123  should_be_in_vg = false;
1124 
1125  // OK, after all that, append the variable to the vg if none of the conditions
1126  // were violated
1127  if (should_be_in_vg)
1128  {
1129  const unsigned short curr_n_vars = cast_int<unsigned short>
1130  (this->n_vars());
1131 
1132  vg.append (var);
1133 
1134  _variables.push_back(vg(vg.n_variables()-1));
1135  _variable_numbers[var] = curr_n_vars;
1136  return curr_n_vars;
1137  }
1138  }
1139 
1140  // otherwise, fall back to adding a single variable group
1141  return this->add_variables (std::vector<std::string>(1, var),
1142  type,
1143  active_subdomains);
1144 }

References libMesh::System::_variable_groups, libMesh::System::_variable_numbers, libMesh::System::_variables, libMesh::System::add_variables(), libMesh::System::identify_variable_groups(), libMesh::System::is_initialized(), libMesh::libmesh_assert(), libMesh::System::n_variable_groups(), libMesh::System::n_vars(), 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(), HeatSystem::init_data(), SimpleRBConstruction::init_data(), main(), libMesh::ErrorVector::plot_error(), libMesh::System::read_header(), RationalMapTest< elem_type >::setUp(), FETest< order, family, elem_type >::setUp(), SlitMeshRefinedSystemTest::setUp(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), SystemsTest::testAssemblyWithDgFemContext(), SystemsTest::testBlockRestrictedVarNDofs(), SystemsTest::testBoundaryProjectCube(), DofMapTest::testConstraintLoopDetection(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), SystemsTest::testDofCouplingWithVarGroups(), DofMapTest::testDofOwner(), MeshInputTest::testDynaReadPatch(), MeshInputTest::testExodusCopyElementSolution(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), EquationSystemsTest::testPostInitAddElem(), EquationSystemsTest::testPostInitAddRealSystem(), SystemsTest::testProjectCubeWithMeshFunction(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), EquationSystemsTest::testRefineThenReinitPreserveFlags(), EquationSystemsTest::testReinitWithNodeElem(), EquationSystemsTest::testRepartitionThenReinit(), BoundaryInfoTest::testShellFaceConstraints(), and WriteVecAndScalar::testWrite().

◆ add_variable() [2/2]

unsigned int libMesh::System::add_variable ( const std::string &  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 1148 of file system.C.

1152 {
1153  return this->add_variable(var,
1154  FEType(order, family),
1155  active_subdomains);
1156 }

References libMesh::System::add_variable().

◆ 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 1160 of file system.C.

1163 {
1164  libmesh_assert(!this->is_initialized());
1165 
1166  // Make sure the variable isn't there already
1167  // or if it is, that it's the type we want
1168  for (auto ovar : vars)
1169  for (auto v : IntRange<unsigned int>(0, this->n_vars()))
1170  if (this->variable_name(v) == ovar)
1171  {
1172  if (this->variable_type(v) == type)
1173  return _variables[v].number();
1174 
1175  libmesh_error_msg("ERROR: incompatible variable " << ovar << " has already been added for this system!");
1176  }
1177 
1178  const unsigned short curr_n_vars = cast_int<unsigned short>
1179  (this->n_vars());
1180 
1181  const unsigned int next_first_component = this->n_components();
1182 
1183  // Add the variable group to the list
1184  _variable_groups.push_back((active_subdomains == nullptr) ?
1185  VariableGroup(this, vars, curr_n_vars,
1186  next_first_component, type) :
1187  VariableGroup(this, vars, curr_n_vars,
1188  next_first_component, type, *active_subdomains));
1189 
1190  const VariableGroup & vg (_variable_groups.back());
1191 
1192  // Add each component of the group individually
1193  for (auto v : IntRange<unsigned int>(0, vars.size()))
1194  {
1195  _variables.push_back (vg(v));
1196  _variable_numbers[vars[v]] = cast_int<unsigned short>
1197  (curr_n_vars+v);
1198  }
1199 
1200  libmesh_assert_equal_to ((curr_n_vars+vars.size()), this->n_vars());
1201 
1202  // BSK - Defer this now to System::init_data() so we can detect
1203  // VariableGroups 12/28/2012
1204  // // Add the variable group to the _dof_map
1205  // _dof_map->add_variable_group (vg);
1206 
1207  // Return the number of the new variable
1208  return cast_int<unsigned int>(curr_n_vars+vars.size()-1);
1209 }

References libMesh::System::_variable_groups, libMesh::System::_variable_numbers, libMesh::System::_variables, libMesh::System::is_initialized(), libMesh::libmesh_assert(), libMesh::System::n_components(), libMesh::System::n_vars(), libMesh::System::variable_name(), and libMesh::System::variable_type().

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

◆ 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 1213 of file system.C.

1217 {
1218  return this->add_variables(vars,
1219  FEType(order, family),
1220  active_subdomains);
1221 }

References libMesh::System::add_variables().

◆ add_vector()

NumericVector< Number > & libMesh::System::add_vector ( const std::string &  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

Definition at line 661 of file system.C.

664 {
665  // Return the vector if it is already there.
666  if (this->have_vector(vec_name))
667  return *(_vectors[vec_name]);
668 
669  // Otherwise build the vector
670  NumericVector<Number> * buf = NumericVector<Number>::build(this->comm()).release();
671  _vectors.insert (std::make_pair (vec_name, buf));
672  _vector_projections.insert (std::make_pair (vec_name, projections));
673 
674  _vector_types.insert (std::make_pair (vec_name, type));
675 
676  // Vectors are primal by default
677  _vector_is_adjoint.insert (std::make_pair (vec_name, -1));
678 
679  // Initialize it if necessary
680  if (_is_initialized)
681  {
682  if (type == GHOSTED)
683  {
684 #ifdef LIBMESH_ENABLE_GHOSTED
685  buf->init (this->n_dofs(), this->n_local_dofs(),
686  _dof_map->get_send_list(), false,
687  GHOSTED);
688 #else
689  libmesh_error_msg("Cannot initialize ghosted vectors when they are not enabled.");
690 #endif
691  }
692  else
693  buf->init (this->n_dofs(), this->n_local_dofs(), false, type);
694  }
695 
696  return *buf;
697 }

References libMesh::System::_dof_map, libMesh::System::_is_initialized, libMesh::System::_vector_is_adjoint, libMesh::System::_vector_projections, libMesh::System::_vector_types, libMesh::System::_vectors, libMesh::NumericVector< T >::build(), libMesh::ParallelObject::comm(), libMesh::GHOSTED, libMesh::System::have_vector(), libMesh::NumericVector< T >::init(), libMesh::System::n_dofs(), and libMesh::System::n_local_dofs().

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(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::SecondOrderUnsteadySolver::init(), libMesh::UnsteadySolver::init(), 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(), and libMesh::FrequencySystem::set_frequencies_by_steps().

◆ 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 977 of file system.C.

978 {
979  std::ostringstream adjoint_name;
980  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
981 
982  NumericVector<Number> & returnval = this->add_vector(adjoint_name.str());
983  this->set_vector_as_adjoint(adjoint_name.str(), i);
984  return returnval;
985 }

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

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

◆ 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 924 of file system.C.

925 {
926  return this->add_vector("weighted_sensitivity_solution");
927 }

References libMesh::System::add_vector().

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

◆ 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 686 of file implicit_system.C.

689 {
690  ParameterVector & parameters =
691  const_cast<ParameterVector &>(parameters_in);
692 
693  const unsigned int Np = cast_int<unsigned int>
694  (parameters.size());
695  const unsigned int Nq = this->n_qois();
696 
697  // An introduction to the problem:
698  //
699  // Residual R(u(p),p) = 0
700  // partial R / partial u = J = system matrix
701  //
702  // This implies that:
703  // d/dp(R) = 0
704  // (partial R / partial p) +
705  // (partial R / partial u) * (partial u / partial p) = 0
706 
707  // We first do an adjoint solve:
708  // J^T * z = (partial q / partial u)
709  // if we havent already or dont have an initial condition for the adjoint
710  if (!this->is_adjoint_already_solved())
711  {
712  this->adjoint_solve(qoi_indices);
713  }
714 
715  this->assemble_residual_derivatives(parameters_in);
716 
717  // Get ready to fill in sensitivities:
718  sensitivities.allocate_data(qoi_indices, *this, parameters);
719 
720  // We use the identities:
721  // dq/dp = (partial q / partial p) + (partial q / partial u) *
722  // (partial u / partial p)
723  // dq/dp = (partial q / partial p) + (J^T * z) *
724  // (partial u / partial p)
725  // dq/dp = (partial q / partial p) + z * J *
726  // (partial u / partial p)
727 
728  // Leading to our final formula:
729  // dq/dp = (partial q / partial p) - z * (partial R / partial p)
730 
731  // In the case of adjoints with heterogenous Dirichlet boundary
732  // function phi, where
733  // q := S(u) - R(u,phi)
734  // the final formula works out to:
735  // dq/dp = (partial S / partial p) - z * (partial R / partial p)
736  // Because we currently have no direct access to
737  // (partial S / partial p), we use the identity
738  // (partial S / partial p) = (partial q / partial p) +
739  // phi * (partial R / partial p)
740  // to derive an equivalent equation:
741  // dq/dp = (partial q / partial p) - (z-phi) * (partial R / partial p)
742 
743  // Since z-phi degrees of freedom are zero for constrained indices,
744  // we can use the same constrained -(partial R / partial p) that we
745  // use for forward sensitivity solves, taking into account the
746  // differing sign convention.
747  //
748  // Since that vector is constrained, its constrained indices are
749  // zero, so its product with phi is zero, so we can neglect the
750  // evaluation of phi terms.
751 
752  for (unsigned int j=0; j != Np; ++j)
753  {
754  // We currently get partial derivatives via central differencing
755 
756  // (partial q / partial p) ~= (q(p+dp)-q(p-dp))/(2*dp)
757  // (partial R / partial p) ~= (rhs(p+dp) - rhs(p-dp))/(2*dp)
758 
759  Number old_parameter = *parameters[j];
760 
761  const Real delta_p =
762  TOLERANCE * std::max(std::abs(old_parameter), 1e-3);
763 
764  *parameters[j] = old_parameter - delta_p;
765  this->assemble_qoi(qoi_indices);
766  std::vector<Number> qoi_minus = this->qoi;
767 
768  NumericVector<Number> & neg_partialR_partialp = this->get_sensitivity_rhs(j);
769 
770  *parameters[j] = old_parameter + delta_p;
771  this->assemble_qoi(qoi_indices);
772  std::vector<Number> & qoi_plus = this->qoi;
773 
774  std::vector<Number> partialq_partialp(Nq, 0);
775  for (unsigned int i=0; i != Nq; ++i)
776  if (qoi_indices.has_index(i))
777  partialq_partialp[i] = (qoi_plus[i] - qoi_minus[i]) / (2.*delta_p);
778 
779  // Don't leave the parameter changed
780  *parameters[j] = old_parameter;
781 
782  for (unsigned int i=0; i != Nq; ++i)
783  if (qoi_indices.has_index(i))
784  sensitivities[i][j] = partialq_partialp[i] +
785  neg_partialR_partialp.dot(this->get_adjoint_solution(i));
786  }
787 
788  // All parameters have been reset.
789  // Reset the original qoi.
790 
791  this->assemble_qoi(qoi_indices);
792 }

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

Referenced by main().

◆ 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 359 of file implicit_system.C.

360 {
361  // Log how long the linear solve takes.
362  LOG_SCOPE("adjoint_solve()", "ImplicitSystem");
363 
364  if (this->assemble_before_solve)
365  // Assemble the linear system
366  this->assembly (/* get_residual = */ false,
367  /* get_jacobian = */ true);
368 
369  // The adjoint problem is linear
370  LinearSolver<Number> * linear_solver = this->get_linear_solver();
371 
372  // Reset and build the RHS from the QOI derivative
373  this->assemble_qoi_derivative(qoi_indices,
374  /* include_liftfunc = */ false,
375  /* apply_constraints = */ true);
376 
377  // Our iteration counts and residuals will be sums of the individual
378  // results
379  std::pair<unsigned int, Real> solver_params =
381  std::pair<unsigned int, Real> totalrval = std::make_pair(0,0.0);
382 
383  for (auto i : IntRange<unsigned int>(0, this->n_qois()))
384  if (qoi_indices.has_index(i))
385  {
386  const std::pair<unsigned int, Real> rval =
387  linear_solver->adjoint_solve (*matrix, this->add_adjoint_solution(i),
388  this->get_adjoint_rhs(i),
389  double(solver_params.second),
390  solver_params.first);
391 
392  totalrval.first += rval.first;
393  totalrval.second += rval.second;
394  }
395 
396  this->release_linear_solver(linear_solver);
397 
398  // The linear solver may not have fit our constraints exactly
399 #ifdef LIBMESH_ENABLE_CONSTRAINTS
400  for (auto i : IntRange<unsigned int>(0, this->n_qois()))
401  if (qoi_indices.has_index(i))
403  (this->get_adjoint_solution(i), i);
404 #endif
405 
406  return totalrval;
407 }

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::ImplicitSystem::matrix, libMesh::System::n_qois(), and libMesh::ImplicitSystem::release_linear_solver().

Referenced by libMesh::ImplicitSystem::adjoint_qoi_parameter_sensitivity(), libMesh::DifferentiableSystem::adjoint_solve(), libMesh::ImplicitSystem::qoi_parameter_hessian(), and libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product().

◆ allocate_data_structures()

void libMesh::RBConstruction::allocate_data_structures ( )
protectedvirtualinherited

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

Reimplemented in libMesh::TransientRBConstruction.

Definition at line 467 of file rb_construction.C.

468 {
469  // Resize vectors for storing mesh-dependent data
470  Aq_vector.resize(get_rb_theta_expansion().get_n_A_terms());
471  Fq_vector.resize(get_rb_theta_expansion().get_n_F_terms());
472 
473  // Resize the Fq_representors and initialize each to nullptr.
474  // These are basis independent and hence stored here, whereas
475  // the Aq_representors are stored in RBEvaluation
476  Fq_representor.resize(get_rb_theta_expansion().get_n_F_terms());
477 
478  // Initialize vectors for the inner products of the Fq representors
479  // These are basis independent and therefore stored here.
480  unsigned int Q_f_hat = get_rb_theta_expansion().get_n_F_terms()*(get_rb_theta_expansion().get_n_F_terms()+1)/2;
481  Fq_representor_innerprods.resize(Q_f_hat);
482 
483  // Resize the output vectors
484  outputs_vector.resize(get_rb_theta_expansion().get_n_outputs());
485  for (unsigned int n=0; n<get_rb_theta_expansion().get_n_outputs(); n++)
487 
488  // Resize the output dual norm vectors
489  output_dual_innerprods.resize(get_rb_theta_expansion().get_n_outputs());
490  for (unsigned int n=0; n<get_rb_theta_expansion().get_n_outputs(); n++)
491  {
493  output_dual_innerprods[n].resize(Q_l_hat);
494  }
495 
496  {
497  DofMap & dof_map = this->get_dof_map();
498 
499  dof_map.attach_matrix(*inner_product_matrix);
500  inner_product_matrix->init();
501  inner_product_matrix->zero();
502 
504  {
505  // We also need a non-Dirichlet inner-product matrix
507  dof_map.attach_matrix(*non_dirichlet_inner_product_matrix);
510  }
511 
512  for (unsigned int q=0; q<get_rb_theta_expansion().get_n_A_terms(); q++)
513  {
514  // Initialize the memory for the matrices
516  dof_map.attach_matrix(*Aq_vector[q]);
517  Aq_vector[q]->init();
518  Aq_vector[q]->zero();
519  }
520 
521  // We also need to initialize a second set of non-Dirichlet operators
523  {
524  non_dirichlet_Aq_vector.resize(get_rb_theta_expansion().get_n_A_terms());
525  for (unsigned int q=0; q<get_rb_theta_expansion().get_n_A_terms(); q++)
526  {
527  // Initialize the memory for the matrices
529  dof_map.attach_matrix(*non_dirichlet_Aq_vector[q]);
530  non_dirichlet_Aq_vector[q]->init();
531  non_dirichlet_Aq_vector[q]->zero();
532  }
533  }
534  }
535 
536  // Initialize the vectors
537  for (unsigned int q=0; q<get_rb_theta_expansion().get_n_F_terms(); q++)
538  {
539  // Initialize the memory for the vectors
541  Fq_vector[q]->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
542  }
543 
544  // We also need to initialize a second set of non-Dirichlet operators
546  {
547  non_dirichlet_Fq_vector.resize(get_rb_theta_expansion().get_n_F_terms());
548  for (unsigned int q=0; q<get_rb_theta_expansion().get_n_F_terms(); q++)
549  {
550  // Initialize the memory for the vectors
552  non_dirichlet_Fq_vector[q]->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
553  }
554  }
555 
556  for (unsigned int n=0; n<get_rb_theta_expansion().get_n_outputs(); n++)
557  for (unsigned int q_l=0; q_l<get_rb_theta_expansion().get_n_output_terms(n); q_l++)
558  {
559  // Initialize the memory for the truth output vectors
561  outputs_vector[n][q_l]->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
562  }
563 
565  {
566  non_dirichlet_outputs_vector.resize(get_rb_theta_expansion().get_n_outputs());
567  for (unsigned int n=0; n<get_rb_theta_expansion().get_n_outputs(); n++)
568  {
569  non_dirichlet_outputs_vector[n].resize( get_rb_theta_expansion().get_n_output_terms(n) );
570  for (unsigned int q_l=0; q_l<get_rb_theta_expansion().get_n_output_terms(n); q_l++)
571  {
572  // Initialize the memory for the truth output vectors
574  non_dirichlet_outputs_vector[n][q_l]->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
575  }
576  }
577  }
578 
579  // Resize truth_outputs vector
580  truth_outputs.resize(this->get_rb_theta_expansion().get_n_outputs());
581 }

References libMesh::RBConstruction::Aq_vector, libMesh::DofMap::attach_matrix(), libMesh::SparseMatrix< T >::build(), libMesh::NumericVector< T >::build(), libMesh::ParallelObject::comm(), libMesh::RBConstruction::Fq_representor, libMesh::RBConstruction::Fq_representor_innerprods, libMesh::RBConstruction::Fq_vector, libMesh::System::get_dof_map(), libMesh::RBThetaExpansion::get_n_A_terms(), libMesh::RBThetaExpansion::get_n_F_terms(), libMesh::RBThetaExpansion::get_n_output_terms(), libMesh::RBThetaExpansion::get_n_outputs(), libMesh::RBConstruction::get_rb_theta_expansion(), libMesh::RBConstruction::inner_product_matrix, libMesh::System::n_dofs(), libMesh::System::n_local_dofs(), libMesh::RBConstruction::non_dirichlet_Aq_vector, libMesh::RBConstruction::non_dirichlet_Fq_vector, libMesh::RBConstruction::non_dirichlet_inner_product_matrix, libMesh::RBConstruction::non_dirichlet_outputs_vector, libMesh::RBConstruction::output_dual_innerprods, libMesh::RBConstruction::outputs_vector, libMesh::PARALLEL, libMesh::RBConstruction::store_non_dirichlet_operators, and libMesh::RBConstruction::truth_outputs.

Referenced by libMesh::TransientRBConstruction::allocate_data_structures(), and libMesh::RBConstruction::initialize_rb_construction().

◆ 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 110 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().

◆ assemble_affine_expansion()

void libMesh::RBConstruction::assemble_affine_expansion ( bool  skip_matrix_assembly,
bool  skip_vector_assembly 
)
virtualinherited

Assemble the matrices and vectors for this system.

Optionally skip matrix or vector assembly (e.g. we may want to read data in from disk instead).

Reimplemented in libMesh::TransientRBConstruction.

Definition at line 449 of file rb_construction.C.

451 {
452  if (!skip_matrix_assembly)
453  {
454  // Assemble and store all of the matrices
455  this->assemble_misc_matrices();
457  }
458 
459  if (!skip_vector_assembly)
460  {
461  // Assemble and store all of the vectors
464  }
465 }

References libMesh::RBConstruction::assemble_all_affine_operators(), libMesh::RBConstruction::assemble_all_affine_vectors(), libMesh::RBConstruction::assemble_all_output_vectors(), and libMesh::RBConstruction::assemble_misc_matrices().

Referenced by libMesh::TransientRBConstruction::assemble_affine_expansion(), and libMesh::RBConstruction::initialize_rb_construction().

◆ assemble_all_affine_operators()

void libMesh::RBConstruction::assemble_all_affine_operators ( )
protectedvirtualinherited

Assemble and store all Q_a affine operators as well as the inner-product matrix.

Reimplemented in libMesh::TransientRBConstruction.

Definition at line 930 of file rb_construction.C.

931 {
932  for (unsigned int q_a=0; q_a<get_rb_theta_expansion().get_n_A_terms(); q_a++)
933  {
934  libMesh::out << "Assembling affine operator " << (q_a+1) << " of "
935  << get_rb_theta_expansion().get_n_A_terms() << std::endl;
936  assemble_Aq_matrix(q_a, get_Aq(q_a));
937  }
938 
940  {
941  for (unsigned int q_a=0; q_a<get_rb_theta_expansion().get_n_A_terms(); q_a++)
942  {
943  libMesh::out << "Assembling non-Dirichlet affine operator " << (q_a+1) << " of "
944  << get_rb_theta_expansion().get_n_A_terms() << std::endl;
945  assemble_Aq_matrix(q_a, get_non_dirichlet_Aq(q_a), false);
946  }
947  }
948 }

References libMesh::RBConstruction::assemble_Aq_matrix(), libMesh::RBConstruction::get_Aq(), libMesh::RBThetaExpansion::get_n_A_terms(), libMesh::RBConstruction::get_non_dirichlet_Aq(), libMesh::RBConstruction::get_rb_theta_expansion(), libMesh::out, and libMesh::RBConstruction::store_non_dirichlet_operators.

Referenced by libMesh::RBConstruction::assemble_affine_expansion(), and libMesh::TransientRBConstruction::assemble_all_affine_operators().

◆ assemble_all_affine_vectors()

void libMesh::RBConstruction::assemble_all_affine_vectors ( )
protectedvirtualinherited

Assemble and store the affine RHS vectors.

Definition at line 950 of file rb_construction.C.

951 {
952  for (unsigned int q_f=0; q_f<get_rb_theta_expansion().get_n_F_terms(); q_f++)
953  {
954  libMesh::out << "Assembling affine vector " << (q_f+1) << " of "
955  << get_rb_theta_expansion().get_n_F_terms() << std::endl;
956  assemble_Fq_vector(q_f, get_Fq(q_f));
957  }
958 
960  {
961  for (unsigned int q_f=0; q_f<get_rb_theta_expansion().get_n_F_terms(); q_f++)
962  {
963  libMesh::out << "Assembling non-Dirichlet affine vector " << (q_f+1) << " of "
964  << get_rb_theta_expansion().get_n_F_terms() << std::endl;
965  assemble_Fq_vector(q_f, get_non_dirichlet_Fq(q_f), false);
966  }
967  }
968 
969 }

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().

◆ assemble_all_output_vectors()

void libMesh::RBConstruction::assemble_all_output_vectors ( )
protectedvirtualinherited

Assemble and store the output vectors.

Definition at line 988 of file rb_construction.C.

989 {
990  for (unsigned int n=0; n<get_rb_theta_expansion().get_n_outputs(); n++)
991  for (unsigned int q_l=0; q_l<get_rb_theta_expansion().get_n_output_terms(n); q_l++)
992  {
993  libMesh::out << "Assembling output vector, (" << (n+1) << "," << (q_l+1)
994  << ") of (" << get_rb_theta_expansion().get_n_outputs()
995  << "," << get_rb_theta_expansion().get_n_output_terms(n) << ")"
996  << std::endl;
997  get_output_vector(n, q_l)->zero();
999  nullptr,
1000  get_output_vector(n,q_l),
1001  false, /* symmetrize */
1002  true /* apply_dof_constraints */);
1003  }
1004 
1006  {
1007  for (unsigned int n=0; n<get_rb_theta_expansion().get_n_outputs(); n++)
1008  for (unsigned int q_l=0; q_l<get_rb_theta_expansion().get_n_output_terms(n); q_l++)
1009  {
1010  libMesh::out << "Assembling non-Dirichlet output vector, (" << (n+1) << "," << (q_l+1)
1011  << ") of (" << get_rb_theta_expansion().get_n_outputs()
1012  << "," << get_rb_theta_expansion().get_n_output_terms(n) << ")"
1013  << std::endl;
1016  nullptr,
1018  false, /* symmetrize */
1019  false /* apply_dof_constraints */);
1020  }
1021  }
1022 }

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().

◆ 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 876 of file rb_construction.C.

879 {
880  if (q >= get_rb_theta_expansion().get_n_A_terms())
881  libmesh_error_msg("Error: We must have q < Q_a in assemble_Aq_matrix.");
882 
883  input_matrix->zero();
884 
887  input_matrix,
888  nullptr,
889  false, /* symmetrize */
890  apply_dof_constraints);
891 }

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().

◆ 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 971 of file rb_construction.C.

974 {
975  if (q >= get_rb_theta_expansion().get_n_F_terms())
976  libmesh_error_msg("Error: We must have q < Q_f in assemble_Fq_vector.");
977 
978  input_vector->zero();
979 
982  nullptr,
983  input_vector,
984  false, /* symmetrize */
985  apply_dof_constraints /* apply_dof_constraints */);
986 }

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().

◆ 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 841 of file rb_construction.C.

843 {
844  input_matrix->zero();
845 
847  {
850  input_matrix,
851  nullptr,
852  false, /* symmetrize */
853  apply_dof_constraints);
854  }
855  else
856  {
858  {
859  libmesh_error_msg("Error: invalid number of entries in energy_inner_product_coeffs.");
860  }
861 
862  // We symmetrize below so that we may use the energy inner-product even in cases
863  // where the A_q are not symmetric.
864  for (unsigned int q_a=0; q_a<get_rb_theta_expansion().get_n_A_terms(); q_a++)
865  {
868  input_matrix,
869  nullptr,
870  true, /* symmetrize */
871  apply_dof_constraints);
872  }
873  }
874 }

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().

◆ assemble_misc_matrices()

void libMesh::RBConstruction::assemble_misc_matrices ( )
protectedvirtualinherited

Assemble and store all the inner-product matrix, the constraint matrix (for constrained problems) and the mass matrix (for time-dependent problems).

Reimplemented in libMesh::TransientRBConstruction.

Definition at line 918 of file rb_construction.C.

919 {
920  libMesh::out << "Assembling inner product matrix" << std::endl;
922 
924  {
925  libMesh::out << "Assembling non-Dirichlet inner product matrix" << std::endl;
927  }
928 }

References libMesh::RBConstruction::assemble_inner_product_matrix(), libMesh::RBConstruction::inner_product_matrix, libMesh::RBConstruction::non_dirichlet_inner_product_matrix, libMesh::out, and libMesh::RBConstruction::store_non_dirichlet_operators.

Referenced by libMesh::RBConstruction::assemble_affine_expansion(), and libMesh::TransientRBConstruction::assemble_misc_matrices().

◆ 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 56 of file explicit_system.C.

57 {
58  // The user quantity of interest assembly gets to expect to
59  // accumulate on initially zero values
60  for (auto i : IntRange<unsigned int>(0, this->n_qois()))
61  if (qoi_indices.has_index(i))
62  qoi[i] = 0;
63 
64  Parent::assemble_qoi (qoi_indices);
65 }

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

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

◆ 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 69 of file explicit_system.C.

72 {
73  // The user quantity of interest derivative assembly gets to expect
74  // to accumulate on initially zero vectors
75  for (auto i : IntRange<unsigned int>(0, this->n_qois()))
76  if (qoi_indices.has_index(i))
77  this->add_adjoint_rhs(i).zero();
78 
79  Parent::assemble_qoi_derivative (qoi_indices, include_liftfunc,
80  apply_constraints);
81 }

References libMesh::System::add_adjoint_rhs(), libMesh::System::assemble_qoi_derivative(), libMesh::QoISet::has_index(), 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().

◆ 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 643 of file implicit_system.C.

644 {
645  ParameterVector & parameters =
646  const_cast<ParameterVector &>(parameters_in);
647 
648  const unsigned int Np = cast_int<unsigned int>
649  (parameters.size());
650 
651  for (unsigned int p=0; p != Np; ++p)
652  {
653  NumericVector<Number> & sensitivity_rhs = this->add_sensitivity_rhs(p);
654 
655  // Approximate -(partial R / partial p) by
656  // (R(p-dp) - R(p+dp)) / (2*dp)
657 
658  Number old_parameter = *parameters[p];
659 
660  const Real delta_p =
661  TOLERANCE * std::max(std::abs(old_parameter), 1e-3);
662 
663  *parameters[p] -= delta_p;
664 
665  // this->assembly(true, false, true);
666  this->assembly(true, false, false);
667  this->rhs->close();
668  sensitivity_rhs = *this->rhs;
669 
670  *parameters[p] = old_parameter + delta_p;
671 
672  // this->assembly(true, false, true);
673  this->assembly(true, false, false);
674  this->rhs->close();
675 
676  sensitivity_rhs -= *this->rhs;
677  sensitivity_rhs /= (2*delta_p);
678  sensitivity_rhs.close();
679 
680  *parameters[p] = old_parameter;
681  }
682 }

References std::abs(), 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().

◆ 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 366 of file linear_implicit_system.C.

370 {
371  // Residual R(u(p),p) := A(p)*u(p) - b(p)
372  // partial R / partial u = A
373 
374  this->assemble();
375  this->rhs->close();
376  this->matrix->close();
377 
378  *(this->rhs) *= -1.0;
379  this->rhs->add_vector(*this->solution, *this->matrix);
380 }

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

◆ 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 1755 of file system.C.

1757 {
1759 
1760  if (_assemble_system_object != nullptr)
1761  {
1762  libmesh_here();
1763  libMesh::out << "WARNING: Cannot specify both assembly function and object!"
1764  << std::endl;
1765 
1766  _assemble_system_object = nullptr;
1767  }
1768 
1770 }

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

Referenced by assemble_and_solve(), main(), SystemsTest::testAssemblyWithDgFemContext(), and SystemsTest::testDofCouplingWithVarGroups().

◆ 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 1774 of file system.C.

1775 {
1776  if (_assemble_system_function != nullptr)
1777  {
1778  libmesh_here();
1779  libMesh::out << "WARNING: Cannot specify both assembly object and function!"
1780  << std::endl;
1781 
1782  _assemble_system_function = nullptr;
1783  }
1784 
1785  _assemble_system_object = &assemble_in;
1786 }

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

Referenced by main().

◆ 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 1790 of file system.C.

1792 {
1794 
1795  if (_constrain_system_object != nullptr)
1796  {
1797  libmesh_here();
1798  libMesh::out << "WARNING: Cannot specify both constraint function and object!"
1799  << std::endl;
1800 
1801  _constrain_system_object = nullptr;
1802  }
1803 
1805 }

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

◆ attach_constraint_object()

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

Register a user object for imposing constraints.

Definition at line 1809 of file system.C.

1810 {
1811  if (_constrain_system_function != nullptr)
1812  {
1813  libmesh_here();
1814  libMesh::out << "WARNING: Cannot specify both constraint object and function!"
1815  << std::endl;
1816 
1817  _constrain_system_function = nullptr;
1818  }
1819 
1820  _constrain_system_object = &constrain;
1821 }

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

Referenced by DofMapTest::testConstraintLoopDetection().

◆ 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 1720 of file system.C.

1722 {
1724 
1725  if (_init_system_object != nullptr)
1726  {
1727  libmesh_here();
1728  libMesh::out << "WARNING: Cannot specify both initialization function and object!"
1729  << std::endl;
1730 
1731  _init_system_object = nullptr;
1732  }
1733 
1735 }

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

Referenced by main().

◆ 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 1739 of file system.C.

1740 {
1741  if (_init_system_function != nullptr)
1742  {
1743  libmesh_here();
1744  libMesh::out << "WARNING: Cannot specify both initialization object and function!"
1745  << std::endl;
1746 
1747  _init_system_function = nullptr;
1748  }
1749 
1750  _init_system_object = &init_in;
1751 }

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

◆ 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 1861 of file system.C.

1863 {
1865 
1866  if (_qoi_evaluate_derivative_object != nullptr)
1867  {
1868  libmesh_here();
1869  libMesh::out << "WARNING: Cannot specify both QOI derivative function and object!"
1870  << std::endl;
1871 
1873  }
1874 
1876 }

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

◆ 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 1880 of file system.C.

1881 {
1882  if (_qoi_evaluate_derivative_function != nullptr)
1883  {
1884  libmesh_here();
1885  libMesh::out << "WARNING: Cannot specify both QOI derivative object and function!"
1886  << std::endl;
1887 
1889  }
1890 
1891  _qoi_evaluate_derivative_object = &qoi_derivative;
1892 }

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

◆ 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 1825 of file system.C.

1828 {
1830 
1831  if (_qoi_evaluate_object != nullptr)
1832  {
1833  libmesh_here();
1834  libMesh::out << "WARNING: Cannot specify both QOI function and object!"
1835  << std::endl;
1836 
1837  _qoi_evaluate_object = nullptr;
1838  }
1839 
1841 }

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

◆ 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 1845 of file system.C.

1846 {
1847  if (_qoi_evaluate_function != nullptr)
1848  {
1849  libmesh_here();
1850  libMesh::out << "WARNING: Cannot specify both QOI object and function!"
1851  << std::endl;
1852 
1853  _qoi_evaluate_function = nullptr;
1854  }
1855 
1856  _qoi_evaluate_object = &qoi_in;
1857 }

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

◆ 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 158 of file linear_implicit_system.C.

159 {
160  _shell_matrix = shell_matrix;
161 }

References libMesh::LinearImplicitSystem::_shell_matrix.

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

◆ 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. If non-default Parameters are to be used, they can be provided in the parameters argument.

Definition at line 1126 of file system_projection.C.

1130 {
1131  this->boundary_project_vector(b, variables, *solution, f, g);
1132 
1133  solution->localize(*current_local_solution);
1134 }

Referenced by SystemsTest::testBoundaryProjectCube().

◆ 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 1109 of file system_projection.C.

1114 {
1115  WrappedFunction<Number> f(*this, fptr, &parameters);
1116  WrappedFunction<Gradient> g(*this, gptr, &parameters);
1117  this->boundary_project_solution(b, variables, &f, &g);
1118 }

References fptr(), and gptr().

◆ 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. If non-default Parameters are to be used, they can be provided in the parameters argument.

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

Definition at line 1162 of file system_projection.C.

1168 {
1169  LOG_SCOPE ("boundary_project_vector()", "System");
1170 
1172  (ConstElemRange (this->get_mesh().active_local_elements_begin(),
1173  this->get_mesh().active_local_elements_end() ),
1174  BoundaryProjectSolution(b, variables, *this, f, g,
1175  this->get_equation_systems().parameters,
1176  new_vector)
1177  );
1178 
1179  // We don't do SCALAR dofs when just projecting the boundary, so
1180  // we're done here.
1181 
1182  new_vector.close();
1183 
1184 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1185  if (is_adjoint == -1)
1186  this->get_dof_map().enforce_constraints_exactly(*this, &new_vector);
1187  else if (is_adjoint >= 0)
1189  is_adjoint);
1190 #else
1191  libmesh_ignore(is_adjoint);
1192 #endif
1193 }

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

◆ 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 1144 of file system_projection.C.

1151 {
1152  WrappedFunction<Number> f(*this, fptr, &parameters);
1153  WrappedFunction<Gradient> g(*this, gptr, &parameters);
1154  this->boundary_project_vector(b, variables, new_vector, &f, &g,
1155  is_adjoint);
1156 }

References fptr(), and gptr().

◆ broadcast_parameters()

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

Broadcasts parameters on processor proc_id to all processors.

Definition at line 600 of file rb_construction_base.C.

601 {
602  libmesh_assert_less (proc_id, this->n_processors());
603 
604  // create a copy of the current parameters
605  RBParameters current_parameters = get_parameters();
606 
607  // copy current_parameters to current_parameters_vector in order to broadcast
608  std::vector<Real> current_parameters_vector;
609 
610  for (const auto & pr : current_parameters)
611  current_parameters_vector.push_back(pr.second);
612 
613  // do the broadcast
614  this->comm().broadcast(current_parameters_vector, proc_id);
615 
616  // update the copy of the RBParameters object
617  unsigned int count = 0;
618  for (const auto & pr : current_parameters)
619  {
620  const std::string & param_name = pr.first;
621  current_parameters.set_value(param_name, current_parameters_vector[count]);
622  count++;
623  }
624 
625  // set the parameters globally
626  set_parameters(current_parameters);
627 }

◆ 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 583 of file rb_construction.C.

584 {
585  return libmesh_make_unique<DGFEMContext>(*this);
586 }

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

◆ 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 2018 of file rb_construction.C.

2019 {
2020  ZeroFunction<> zf;
2021 
2022  std::set<boundary_id_type> dirichlet_ids;
2023  std::vector<unsigned int> variables;
2024 
2025  // The DirichletBoundary constructor clones zf, so it's OK that zf is only in local scope
2026  return libmesh_make_unique<DirichletBoundary>(dirichlet_ids, variables, &zf);
2027 }

Referenced by SimpleRBConstruction::init_data().

◆ calculate_norm() [1/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 1378 of file system.C.

1381 {
1382  // This function must be run on all processors at once
1383  parallel_object_only();
1384 
1385  LOG_SCOPE ("calculate_norm()", "System");
1386 
1387  // Zero the norm before summation
1388  Real v_norm = 0.;
1389 
1390  if (norm.is_discrete())
1391  {
1392  //Check to see if all weights are 1.0 and all types are equal
1393  FEMNormType norm_type0 = norm.type(0);
1394  unsigned int check_var = 0, check_end = this->n_vars();
1395  for (; check_var != check_end; ++check_var)
1396  if ((norm.weight(check_var) != 1.0) || (norm.type(check_var) != norm_type0))
1397  break;
1398 
1399  //All weights were 1.0 so just do the full vector discrete norm
1400  if (check_var == this->n_vars())
1401  {
1402  if (norm_type0 == DISCRETE_L1)
1403  return v.l1_norm();
1404  if (norm_type0 == DISCRETE_L2)
1405  return v.l2_norm();
1406  if (norm_type0 == DISCRETE_L_INF)
1407  return v.linfty_norm();
1408  else
1409  libmesh_error_msg("Invalid norm_type0 = " << norm_type0);
1410  }
1411 
1412  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
1413  {
1414  // Skip any variables we don't need to integrate
1415  if (norm.weight(var) == 0.0)
1416  continue;
1417 
1418  v_norm += norm.weight(var) * discrete_var_norm(v, var, norm.type(var));
1419  }
1420 
1421  return v_norm;
1422  }
1423 
1424  // Localize the potentially parallel vector
1425  std::unique_ptr<NumericVector<Number>> local_v = NumericVector<Number>::build(this->comm());
1426  local_v->init(v.size(), true, SERIAL);
1427  v.localize (*local_v, _dof_map->get_send_list());
1428 
1429  // I'm not sure how best to mix Hilbert norms on some variables (for
1430  // which we'll want to square then sum then square root) with norms
1431  // like L_inf (for which we'll just want to take an absolute value
1432  // and then sum).
1433  bool using_hilbert_norm = true,
1434  using_nonhilbert_norm = true;
1435 
1436  // Loop over all variables
1437  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
1438  {
1439  // Skip any variables we don't need to integrate
1440  Real norm_weight_sq = norm.weight_sq(var);
1441  if (norm_weight_sq == 0.0)
1442  continue;
1443  Real norm_weight = norm.weight(var);
1444 
1445  // Check for unimplemented norms (rather than just returning 0).
1446  FEMNormType norm_type = norm.type(var);
1447  if ((norm_type==H1) ||
1448  (norm_type==H2) ||
1449  (norm_type==L2) ||
1450  (norm_type==H1_SEMINORM) ||
1451  (norm_type==H2_SEMINORM))
1452  {
1453  if (!using_hilbert_norm)
1454  libmesh_not_implemented();
1455  using_nonhilbert_norm = false;
1456  }
1457  else if ((norm_type==L1) ||
1458  (norm_type==L_INF) ||
1459  (norm_type==W1_INF_SEMINORM) ||
1460  (norm_type==W2_INF_SEMINORM))
1461  {
1462  if (!using_nonhilbert_norm)
1463  libmesh_not_implemented();
1464  using_hilbert_norm = false;
1465  }
1466  else
1467  libmesh_not_implemented();
1468 
1469  const FEType & fe_type = this->get_dof_map().variable_type(var);
1470 
1471  // Allow space for dims 0-3, even if we don't use them all
1472  std::vector<std::unique_ptr<FEBase>> fe_ptrs(4);
1473  std::vector<std::unique_ptr<QBase>> q_rules(4);
1474 
1475  const std::set<unsigned char> & elem_dims = _mesh.elem_dimensions();
1476 
1477  // Prepare finite elements for each dimension present in the mesh
1478  for (const auto & dim : elem_dims)
1479  {
1480  if (skip_dimensions && skip_dimensions->find(dim) != skip_dimensions->end())
1481  continue;
1482 
1483  // Construct quadrature and finite element objects
1484  q_rules[dim] = fe_type.default_quadrature_rule (dim);
1485  fe_ptrs[dim] = FEBase::build(dim, fe_type);
1486 
1487  // Attach quadrature rule to FE object
1488  fe_ptrs[dim]->attach_quadrature_rule (q_rules[dim].get());
1489  }
1490 
1491  std::vector<dof_id_type> dof_indices;
1492 
1493  // Begin the loop over the elements
1494  for (const auto & elem : this->get_mesh().active_local_element_ptr_range())
1495  {
1496  const unsigned int dim = elem->dim();
1497 
1498 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1499 
1500  // One way for implementing this would be to exchange the fe with the FEInterface- class.
1501  // However, it needs to be discussed whether integral-norms make sense for infinite elements.
1502  // or in which sense they could make sense.
1503  if (elem->infinite() )
1504  libmesh_not_implemented();
1505 
1506 #endif
1507 
1508  if (skip_dimensions && skip_dimensions->find(dim) != skip_dimensions->end())
1509  continue;
1510 
1511  FEBase * fe = fe_ptrs[dim].get();
1512  QBase * qrule = q_rules[dim].get();
1513  libmesh_assert(fe);
1514  libmesh_assert(qrule);
1515 
1516  const std::vector<Real> & JxW = fe->get_JxW();
1517  const std::vector<std::vector<Real>> * phi = nullptr;
1518  if (norm_type == H1 ||
1519  norm_type == H2 ||
1520  norm_type == L2 ||
1521  norm_type == L1 ||
1522  norm_type == L_INF)
1523  phi = &(fe->get_phi());
1524 
1525  const std::vector<std::vector<RealGradient>> * dphi = nullptr;
1526  if (norm_type == H1 ||
1527  norm_type == H2 ||
1528  norm_type == H1_SEMINORM ||
1529  norm_type == W1_INF_SEMINORM)
1530  dphi = &(fe->get_dphi());
1531 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1532  const std::vector<std::vector<RealTensor>> * d2phi = nullptr;
1533  if (norm_type == H2 ||
1534  norm_type == H2_SEMINORM ||
1535  norm_type == W2_INF_SEMINORM)
1536  d2phi = &(fe->get_d2phi());
1537 #endif
1538 
1539  fe->reinit (elem);
1540 
1541  this->get_dof_map().dof_indices (elem, dof_indices, var);
1542 
1543  const unsigned int n_qp = qrule->n_points();
1544 
1545  const unsigned int n_sf = cast_int<unsigned int>
1546  (dof_indices.size());
1547 
1548  // Begin the loop over the Quadrature points.
1549  for (unsigned int qp=0; qp<n_qp; qp++)
1550  {
1551  if (norm_type == L1)
1552  {
1553  Number u_h = 0.;
1554  for (unsigned int i=0; i != n_sf; ++i)
1555  u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
1556  v_norm += norm_weight *
1557  JxW[qp] * std::abs(u_h);
1558  }
1559 
1560  if (norm_type == L_INF)
1561  {
1562  Number u_h = 0.;
1563  for (unsigned int i=0; i != n_sf; ++i)
1564  u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
1565  v_norm = std::max(v_norm, norm_weight * std::abs(u_h));
1566  }
1567 
1568  if (norm_type == H1 ||
1569  norm_type == H2 ||
1570  norm_type == L2)
1571  {
1572  Number u_h = 0.;
1573  for (unsigned int i=0; i != n_sf; ++i)
1574  u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
1575  v_norm += norm_weight_sq *
1576  JxW[qp] * TensorTools::norm_sq(u_h);
1577  }
1578 
1579  if (norm_type == H1 ||
1580  norm_type == H2 ||
1581  norm_type == H1_SEMINORM)
1582  {
1583  Gradient grad_u_h;
1584  for (unsigned int i=0; i != n_sf; ++i)
1585  grad_u_h.add_scaled((*dphi)[i][qp], (*local_v)(dof_indices[i]));
1586  v_norm += norm_weight_sq *
1587  JxW[qp] * grad_u_h.norm_sq();
1588  }
1589 
1590  if (norm_type == W1_INF_SEMINORM)
1591  {
1592  Gradient grad_u_h;
1593  for (unsigned int i=0; i != n_sf; ++i)
1594  grad_u_h.add_scaled((*dphi)[i][qp], (*local_v)(dof_indices[i]));
1595  v_norm = std::max(v_norm, norm_weight * grad_u_h.norm());
1596  }
1597 
1598 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1599  if (norm_type == H2 ||
1600  norm_type == H2_SEMINORM)
1601  {
1602  Tensor hess_u_h;
1603  for (unsigned int i=0; i != n_sf; ++i)
1604  hess_u_h.add_scaled((*d2phi)[i][qp], (*local_v)(dof_indices[i]));
1605  v_norm += norm_weight_sq *
1606  JxW[qp] * hess_u_h.norm_sq();
1607  }
1608 
1609  if (norm_type == W2_INF_SEMINORM)
1610  {
1611  Tensor hess_u_h;
1612  for (unsigned int i=0; i != n_sf; ++i)
1613  hess_u_h.add_scaled((*d2phi)[i][qp], (*local_v)(dof_indices[i]));
1614  v_norm = std::max(v_norm, norm_weight * hess_u_h.norm());
1615  }
1616 #endif
1617  }
1618  }
1619  }
1620 
1621  if (using_hilbert_norm)
1622  {
1623  this->comm().sum(v_norm);
1624  v_norm = std::sqrt(v_norm);
1625  }
1626  else
1627  {
1628  this->comm().max(v_norm);
1629  }
1630 
1631  return v_norm;
1632 }

References libMesh::System::_dof_map, libMesh::System::_mesh, std::abs(), libMesh::TypeVector< T >::add_scaled(), libMesh::TypeTensor< T >::add_scaled(), 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::ReferenceElem::get(), libMesh::FEGenericBase< OutputType >::get_d2phi(), libMesh::System::get_dof_map(), libMesh::FEGenericBase< OutputType >::get_dphi(), libMesh::FEAbstract::get_JxW(), libMesh::System::get_mesh(), libMesh::FEGenericBase< OutputType >::get_phi(), 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 >::localize(), libMesh::QBase::n_points(), libMesh::System::n_vars(), std::norm(), libMesh::TypeVector< T >::norm(), libMesh::TypeTensor< T >::norm(), libMesh::TensorTools::norm_sq(), libMesh::TypeVector< T >::norm_sq(), libMesh::TypeTensor< T >::norm_sq(), libMesh::Real, libMesh::FEAbstract::reinit(), libMesh::SERIAL, libMesh::NumericVector< T >::size(), std::sqrt(), libMesh::DofMap::variable_type(), libMesh::W1_INF_SEMINORM, libMesh::W2_INF_SEMINORM, and libMesh::SystemNorm::weight().

◆ calculate_norm() [2/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 1356 of file system.C.

1360 {
1361  //short circuit to save time
1362  if (norm_type == DISCRETE_L1 ||
1363  norm_type == DISCRETE_L2 ||
1364  norm_type == DISCRETE_L_INF)
1365  return discrete_var_norm(v,var,norm_type);
1366 
1367  // Not a discrete norm
1368  std::vector<FEMNormType> norms(this->n_vars(), L2);
1369  std::vector<Real> weights(this->n_vars(), 0.0);
1370  norms[var] = norm_type;
1371  weights[var] = 1.0;
1372  Real val = this->calculate_norm(v, SystemNorm(norms, weights), skip_dimensions);
1373  return val;
1374 }

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::AdaptiveTimeSolver::calculate_norm(), libMesh::UnsteadySolver::du(), main(), and output_norms().

◆ 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 2231 of file rb_construction.C.

2232 {
2234 
2235  conv_flag = input_solver.get_converged_reason();
2236 
2237  if (conv_flag < 0)
2238  {
2239  std::stringstream err_msg;
2240  err_msg << "Convergence error. Error id: " << conv_flag;
2241  libmesh_error_msg(err_msg.str());
2242  }
2243 }

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(), libMesh::TransientRBConstruction::truth_solve(), libMesh::RBEIMConstruction::truth_solve(), libMesh::RBConstruction::truth_solve(), libMesh::TransientRBConstruction::update_residual_terms(), and libMesh::RBConstruction::update_residual_terms().

◆ clear()

void libMesh::RBConstruction::clear ( )
overridevirtualinherited

Clear all the data structures associated with the system.

Reimplemented from libMesh::RBConstructionBase< LinearImplicitSystem >.

Reimplemented in libMesh::TransientSystem< RBConstruction >, libMesh::RBEIMConstruction, and libMesh::TransientRBConstruction.

Definition at line 100 of file rb_construction.C.

101 {
102  LOG_SCOPE("clear()", "RBConstruction");
103 
104  Parent::clear();
105 
106  Aq_vector.clear();
107  Fq_vector.clear();
108  outputs_vector.clear();
109 
111  {
112  non_dirichlet_Aq_vector.clear();
113  non_dirichlet_Fq_vector.clear();
115  }
116 
117  // Also delete the Fq representors
118  Fq_representor.clear();
119 
120  // Set Fq_representor_innerprods_computed flag to false now
121  // that we've cleared the Fq representors
123 }

References libMesh::RBConstruction::Aq_vector, libMesh::RBConstructionBase< LinearImplicitSystem >::clear(), libMesh::RBConstruction::Fq_representor, libMesh::RBConstruction::Fq_representor_innerprods_computed, libMesh::RBConstruction::Fq_vector, libMesh::RBConstruction::non_dirichlet_Aq_vector, libMesh::RBConstruction::non_dirichlet_Fq_vector, libMesh::RBConstruction::non_dirichlet_outputs_vector, libMesh::RBConstruction::outputs_vector, and libMesh::RBConstruction::store_non_dirichlet_operators.

Referenced by libMesh::RBEIMConstruction::clear(), and libMesh::RBConstruction::~RBConstruction().

◆ comm()

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

Definition at line 94 of file parallel_object.h.

95  { return _communicator; }

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::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::EquationSystems::_read_impl(), 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(), libMesh::TransientRBConstruction::add_IC_to_RB_space(), libMesh::ImplicitSystem::add_matrix(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::DynaIO::add_spline_constraints(), libMesh::System::add_vector(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::TransientRBConstruction::allocate_data_structures(), libMesh::RBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::FEMSystem::assemble_qoi(), libMesh::MeshCommunication::assign_global_indices(), libMesh::DofMap::attach_matrix(), libMesh::MeshTools::Generation::build_extrusion(), 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::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::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), 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::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), DMlibMeshFunction(), DMlibMeshJacobian(), DMlibMeshSetSystem_libMesh(), DMVariableBounds_libMesh(), libMesh::DTKSolutionTransfer::DTKSolutionTransfer(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::TransientRBConstruction::enrich_RB_space(), libMesh::RBConstruction::enrich_RB_space(), libMesh::EpetraVector< T >::EpetraVector(), AssembleOptimization::equality_constraints(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::RBEIMConstruction::evaluate_mesh_function(), 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::DofMap::gather_constraints(), libMesh::MeshfreeInterpolation::gather_remote_data(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::DofMap::get_info(), libMesh::ImplicitSystem::get_linear_solver(), AssembleOptimization::inequality_constraints(), AssembleOptimization::inequality_constraints_jacobian(), libMesh::LocationMap< T >::init(), libMesh::TimeSolver::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::EigenSystem::init_matrices(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::RBEIMConstruction::initialize_rb_construction(), 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_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::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_preconditioner_apply(), libMesh::libmesh_petsc_snes_fd_residual(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_mffd_residual(), libMesh::libmesh_petsc_snes_postcheck(), 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(), 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_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(), libMesh::TransientRBConstruction::mass_matrix_scaled_matvec(), libMesh::FEMSystem::mesh_position_set(), LinearElasticityWithContact::move_mesh(), libMesh::DistributedMesh::n_active_elem(), libMesh::MeshTools::n_active_levels(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::DofMap::n_constrained_dofs(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::CondensedEigenSystem::n_global_non_condensed_dofs(), libMesh::MeshTools::n_levels(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::MeshTools::n_p_levels(), libMesh::BoundaryInfo::n_shellface_conds(), 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::MeshTools::paranoid_n_levels(), libMesh::petsc_auto_fieldsplit(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::DofMap::print_dof_constraints(), FEMParameters::read(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::System::read_header(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::System::read_legacy_data(), libMesh::TransientRBConstruction::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::MeshRefinement::refine_and_coarsen_elements(), libMesh::DistributedMesh::renumber_dof_objects(), LinearElasticityWithContact::residual_and_jacobian(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), libMesh::DofMap::scatter_constraints(), libMesh::CheckpointIO::select_split_config(), libMesh::TransientRBConstruction::set_error_temporal_data(), libMesh::RBEIMConstruction::set_explicit_sys_subvector(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::PetscDiffSolver::setup_petsc_data(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::split_mesh(), libMesh::BoundaryInfo::sync(), libMesh::MeshRefinement::test_level_one(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), libMesh::MeshRefinement::test_unflagged(), SystemsTest::testBlockRestrictedVarNDofs(), PointLocatorTest::testLocator(), BoundaryInfoTest::testMesh(), SystemsTest::testProjectCubeWithMeshFunction(), CheckpointIOTest::testSplitter(), libMesh::MeshTools::total_weight(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::RBEIMConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_RB_system_matrices(), libMesh::RBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_residual_terms(), libMesh::RBConstruction::update_residual_terms(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::VTKIO::write_nodal_data(), libMesh::RBEvaluation::write_out_vectors(), libMesh::TransientRBConstruction::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().

◆ 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 514 of file system.C.

517 {
518  // we do not care for matrices, but for vectors
520  libmesh_assert (other_system._is_initialized);
521 
522  if (verbose)
523  {
524  libMesh::out << " Systems \"" << _sys_name << "\"" << std::endl;
525  libMesh::out << " comparing matrices not supported." << std::endl;
526  libMesh::out << " comparing names...";
527  }
528 
529  // compare the name: 0 means identical
530  const int name_result = _sys_name.compare(other_system.name());
531  if (verbose)
532  {
533  if (name_result == 0)
534  libMesh::out << " identical." << std::endl;
535  else
536  libMesh::out << " names not identical." << std::endl;
537  libMesh::out << " comparing solution vector...";
538  }
539 
540 
541  // compare the solution: -1 means identical
542  const int solu_result = solution->compare (*other_system.solution.get(),
543  threshold);
544 
545  if (verbose)
546  {
547  if (solu_result == -1)
548  libMesh::out << " identical up to threshold." << std::endl;
549  else
550  libMesh::out << " first difference occurred at index = "
551  << solu_result << "." << std::endl;
552  }
553 
554 
555  // safety check, whether we handle at least the same number
556  // of vectors
557  std::vector<int> ov_result;
558 
559  if (this->n_vectors() != other_system.n_vectors())
560  {
561  if (verbose)
562  {
563  libMesh::out << " Fatal difference. This system handles "
564  << this->n_vectors() << " add'l vectors," << std::endl
565  << " while the other system handles "
566  << other_system.n_vectors()
567  << " add'l vectors." << std::endl
568  << " Aborting comparison." << std::endl;
569  }
570  return false;
571  }
572  else if (this->n_vectors() == 0)
573  {
574  // there are no additional vectors...
575  ov_result.clear ();
576  }
577  else
578  {
579  // compare other vectors
580  for (auto & pr : _vectors)
581  {
582  if (verbose)
583  libMesh::out << " comparing vector \""
584  << pr.first << "\" ...";
585 
586  // assume they have the same name
587  const NumericVector<Number> & other_system_vector =
588  other_system.get_vector(pr.first);
589 
590  ov_result.push_back(pr.second->compare (other_system_vector,
591  threshold));
592 
593  if (verbose)
594  {
595  if (ov_result[ov_result.size()-1] == -1)
596  libMesh::out << " identical up to threshold." << std::endl;
597  else
598  libMesh::out << " first difference occurred at" << std::endl
599  << " index = " << ov_result[ov_result.size()-1] << "." << std::endl;
600  }
601  }
602  } // finished comparing additional vectors
603 
604 
605  bool overall_result;
606 
607  // sum up the results
608  if ((name_result==0) && (solu_result==-1))
609  {
610  if (ov_result.size()==0)
611  overall_result = true;
612  else
613  {
614  bool ov_identical;
615  unsigned int n = 0;
616  do
617  {
618  ov_identical = (ov_result[n]==-1);
619  n++;
620  }
621  while (ov_identical && n<ov_result.size());
622  overall_result = ov_identical;
623  }
624  }
625  else
626  overall_result = false;
627 
628  if (verbose)
629  {
630  libMesh::out << " finished comparisons, ";
631  if (overall_result)
632  libMesh::out << "found no differences." << std::endl << std::endl;
633  else
634  libMesh::out << "found differences." << std::endl << std::endl;
635  }
636 
637  return overall_result;
638 }

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.

Referenced by libMesh::EquationSystems::compare().

◆ 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 1730 of file rb_construction.C.

1731 {
1732 
1733  // Skip calculations if we've already computed the Fq_representors
1735  {
1736  // Only log if we get to here
1737  LOG_SCOPE("compute_Fq_representor_innerprods()", "RBConstruction");
1738 
1739  for (unsigned int q_f=0; q_f<get_rb_theta_expansion().get_n_F_terms(); q_f++)
1740  {
1741  if (!Fq_representor[q_f])
1742  {
1744  Fq_representor[q_f]->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
1745  }
1746 
1747  libmesh_assert(Fq_representor[q_f]->size() == this->n_dofs() &&
1748  Fq_representor[q_f]->local_size() == this->n_local_dofs() );
1749 
1750  rhs->zero();
1751  rhs->add(1., *get_Fq(q_f));
1752 
1753  if (!is_quiet())
1754  libMesh::out << "Starting solve q_f=" << q_f
1755  << " in RBConstruction::update_residual_terms() at "
1756  << Utility::get_timestamp() << std::endl;
1757 
1759 
1760  if (assert_convergence)
1762 
1763  if (!is_quiet())
1764  {
1765  libMesh::out << "Finished solve q_f=" << q_f
1766  << " in RBConstruction::update_residual_terms() at "
1767  << Utility::get_timestamp() << std::endl;
1768 
1770  << " iterations, final residual "
1771  << this->final_linear_residual() << std::endl;
1772  }
1773 
1774  *Fq_representor[q_f] = *solution;
1775  }
1776 
1777  if (compute_inner_products)
1778  {
1779  unsigned int q=0;
1780 
1781  for (unsigned int q_f1=0; q_f1<get_rb_theta_expansion().get_n_F_terms(); q_f1++)
1782  {
1784 
1785  for (unsigned int q_f2=q_f1; q_f2<get_rb_theta_expansion().get_n_F_terms(); q_f2++)
1786  {
1788 
1789  q++;
1790  }
1791  }
1792  } // end if (compute_inner_products)
1793 
1795  }
1796 
1798 }

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().

◆ 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 1395 of file rb_construction.C.

1396 {
1397  LOG_SCOPE("compute_max_error_bound()", "RBConstruction");
1398 
1399  // Treat the case with no parameters in a special way
1400  if (get_n_params() == 0)
1401  {
1402  Real max_val;
1403  if (std::numeric_limits<Real>::has_infinity)
1404  {
1405  max_val = std::numeric_limits<Real>::infinity();
1406  }
1407  else
1408  {
1409  max_val = std::numeric_limits<Real>::max();
1410  }
1411 
1412  // Make sure we do at least one solve, but otherwise return a zero error bound
1413  // when we have no parameters
1414  return (get_rb_evaluation().get_n_basis_functions() == 0) ? max_val : 0.;
1415  }
1416 
1418 
1419  // keep track of the maximum error
1420  unsigned int max_err_index = 0;
1421  Real max_err = 0.;
1422 
1424  for (unsigned int i=0; i<get_local_n_training_samples(); i++)
1425  {
1426  // Load training parameter i, this is only loaded
1427  // locally since the RB solves are local.
1428  set_params_from_training_set( first_index+i );
1429 
1431 
1432  if (training_error_bounds[i] > max_err)
1433  {
1434  max_err_index = i;
1435  max_err = training_error_bounds[i];
1436  }
1437  }
1438 
1439  std::pair<numeric_index_type, Real> error_pair(first_index+max_err_index, max_err);
1440  get_global_max_error_pair(this->comm(),error_pair);
1441 
1442  // If we have a serial training set (i.e. a training set that is the same on all processors)
1443  // just set the parameters on all processors
1444  if (serial_training_set)
1445  {
1446  set_params_from_training_set( error_pair.first );
1447  }
1448  // otherwise, broadcast the parameter that produced the maximum error
1449  else
1450  {
1451  unsigned int root_id=0;
1452  if ((get_first_local_training_index() <= error_pair.first) &&
1453  (error_pair.first < get_last_local_training_index()))
1454  {
1455  set_params_from_training_set( error_pair.first );
1456  root_id = this->processor_id();
1457  }
1458 
1459  this->comm().sum(root_id); // root_id is only non-zero on one processor
1460  broadcast_parameters(root_id);
1461  }
1462 
1463  return error_pair.second;
1464 }

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_RB_error_bound(), libMesh::RBConstruction::get_rb_evaluation(), libMesh::ParallelObject::processor_id(), libMesh::Real, libMesh::RBConstructionBase< LinearImplicitSystem >::serial_training_set, libMesh::RBConstructionBase< LinearImplicitSystem >::set_params_from_training_set(), and libMesh::RBConstruction::training_error_bounds.

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

◆ 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 1635 of file rb_construction.C.

1636 {
1637  // Skip calculations if we've already computed the output dual norms
1639  {
1640  // Short circuit if we don't have any outputs
1641  if (get_rb_theta_expansion().get_n_outputs() == 0)
1642  {
1644  return;
1645  }
1646 
1647  // Only log if we get to here
1648  LOG_SCOPE("compute_output_dual_innerprods()", "RBConstruction");
1649 
1650  libMesh::out << "Compute output dual inner products" << std::endl;
1651 
1652  // Find out the largest value of Q_l
1653  unsigned int max_Q_l = 0;
1654  for (unsigned int n=0; n<get_rb_theta_expansion().get_n_outputs(); n++)
1655  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;
1656 
1657  std::vector<std::unique_ptr<NumericVector<Number>>> L_q_representor(max_Q_l);
1658  for (unsigned int q=0; q<max_Q_l; q++)
1659  {
1660  L_q_representor[q] = NumericVector<Number>::build(this->comm());
1661  L_q_representor[q]->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
1662  }
1663 
1664  for (unsigned int n=0; n<get_rb_theta_expansion().get_n_outputs(); n++)
1665  {
1666  for (unsigned int q_l=0; q_l<get_rb_theta_expansion().get_n_output_terms(n); q_l++)
1667  {
1668  rhs->zero();
1669  rhs->add(1., *get_output_vector(n,q_l));
1670 
1671  if (!is_quiet())
1672  libMesh::out << "Starting solve n=" << n << ", q_l=" << q_l
1673  << " in RBConstruction::compute_output_dual_innerprods() at "
1674  << Utility::get_timestamp() << std::endl;
1675 
1676  // Use the main linear solver here instead of the inner_product solver, since
1677  // get_matrix_for_output_dual_solves() may not return the inner product matrix.
1679 
1680  // We possibly perform multiple solves here with the same matrix, hence
1681  // set reuse_preconditioner(true) (and set it back to false again below
1682  // at the end of this function).
1683  linear_solver->reuse_preconditioner(true);
1684 
1685  if (assert_convergence)
1687 
1688  if (!is_quiet())
1689  {
1690  libMesh::out << "Finished solve n=" << n << ", q_l=" << q_l
1691  << " in RBConstruction::compute_output_dual_innerprods() at "
1692  << Utility::get_timestamp() << std::endl;
1693 
1695  << " iterations, final residual "
1696  << this->final_linear_residual() << std::endl;
1697  }
1698 
1699  *L_q_representor[q_l] = *solution;
1700  }
1701 
1702  unsigned int q=0;
1703  for (unsigned int q_l1=0; q_l1<get_rb_theta_expansion().get_n_output_terms(n); q_l1++)
1704  {
1706 
1707  for (unsigned int q_l2=q_l1; q_l2<get_rb_theta_expansion().get_n_output_terms(n); q_l2++)
1708  {
1709  output_dual_innerprods[n][q] = L_q_representor[q_l2]->dot(*inner_product_storage_vector);
1710  libMesh::out << "output_dual_innerprods[" << n << "][" << q << "] = " << output_dual_innerprods[n][q] << std::endl;
1711 
1712  q++;
1713  }
1714  }
1715  }
1716 
1717  // We may not need to use linear_solver again (e.g. this would happen if we use
1718  // extra_linear_solver for the truth_solves). As a result, let's clear linear_solver
1719  // to release any memory it may be taking up. If we do need it again, it will
1720  // be initialized when necessary.
1721  linear_solver->clear();
1722  linear_solver->reuse_preconditioner(false);
1723 
1725  }
1726 
1728 }

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::LinearImplicitSystem::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().

◆ 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 1819 of file rb_construction.C.

1820 {
1821  LOG_SCOPE("compute_residual_dual_norm_slow()", "RBConstruction");
1822 
1823  // Put the residual in rhs in order to compute the norm of the Riesz representor
1824  // Note that this only works in serial since otherwise each processor will
1825  // have a different parameter value during the Greedy training.
1826 
1827  std::unique_ptr<NumericVector<Number>> RB_sol = NumericVector<Number>::build(comm());
1828  RB_sol->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
1829 
1830  std::unique_ptr<NumericVector<Number>> temp = NumericVector<Number>::build(comm());
1831  temp->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
1832 
1833  for (unsigned int i=0; i<N; i++)
1834  {
1835  RB_sol->add(get_rb_evaluation().RB_solution(i), get_rb_evaluation().get_basis_function(i));
1836  }
1837 
1838  this->truth_assembly();
1839  matrix->vector_mult(*temp, *RB_sol);
1840  rhs->add(-1., *temp);
1841 
1842  // Then solve to get the Reisz representor
1843  matrix->zero();
1845 
1848  Number slow_residual_norm_sq = solution->dot(*inner_product_storage_vector);
1849 
1850  return std::sqrt( libmesh_real(slow_residual_norm_sq) );
1851 }

References libMesh::SparseMatrix< T >::add(), libMesh::NumericVector< T >::add(), libMesh::NumericVector< T >::build(), libMesh::ParallelObject::comm(), 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(), std::sqrt(), libMesh::RBConstruction::truth_assembly(), libMesh::SparseMatrix< T >::vector_mult(), and libMesh::SparseMatrix< T >::zero().

◆ current_solution()

Number libMesh::System::current_solution ( const dof_id_type  global_dof_number) const
inherited

◆ deactivate()

void libMesh::System::deactivate ( )
inlineinherited

Deactivates the system.

Only active systems are solved.

Definition at line 2131 of file system.h.

2132 {
2133  _active = false;
2134 }

References libMesh::System::_active.

◆ detach_shell_matrix()

void libMesh::LinearImplicitSystem::detach_shell_matrix ( )
inlineinherited

Detaches a shell matrix.

Same as attach_shell_matrix(nullptr).

Definition at line 185 of file linear_implicit_system.h.

185 { attach_shell_matrix(nullptr); }

References libMesh::LinearImplicitSystem::attach_shell_matrix().

Referenced by main().

◆ 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 293 of file implicit_system.C.

293  {
294  this->assemble_before_solve = true;
295  this->get_linear_solver()->reuse_preconditioner(false);
296 }

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

◆ disable_print_counter_info() [1/2]

void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

Definition at line 106 of file reference_counter.C.

107 {
108  _enable_print_counter = false;
109  return;
110 }

References libMesh::ReferenceCounter::_enable_print_counter.

Referenced by libMesh::LibMeshInit::LibMeshInit().

◆ disable_print_counter_info() [2/2]

void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

Definition at line 106 of file reference_counter.C.

107 {
108  _enable_print_counter = false;
109  return;
110 }

References libMesh::ReferenceCounter::_enable_print_counter.

Referenced by libMesh::LibMeshInit::LibMeshInit().

◆ discrete_var_norm()

Real libMesh::System::discrete_var_norm ( const NumericVector< Number > &  v,
unsigned int  var,
FEMNormType  norm_type 
) const
privateinherited

Finds the discrete norm for the entries in the vector corresponding to Dofs associated with var.

Definition at line 1337 of file system.C.

1340 {
1341  std::set<dof_id_type> var_indices;
1342  local_dof_indices(var, var_indices);
1343 
1344  if (norm_type == DISCRETE_L1)
1345  return v.subset_l1_norm(var_indices);
1346  if (norm_type == DISCRETE_L2)
1347  return v.subset_l2_norm(var_indices);
1348  if (norm_type == DISCRETE_L_INF)
1349  return v.subset_linfty_norm(var_indices);
1350  else
1351  libmesh_error_msg("Invalid norm_type = " << norm_type);
1352 }

References libMesh::DISCRETE_L1, libMesh::DISCRETE_L2, libMesh::DISCRETE_L_INF, libMesh::System::local_dof_indices(), libMesh::NumericVector< T >::subset_l1_norm(), libMesh::NumericVector< T >::subset_l2_norm(), and libMesh::NumericVector< T >::subset_linfty_norm().

Referenced by libMesh::System::calculate_norm().

◆ 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 100 of file reference_counter.C.

101 {
102  _enable_print_counter = true;
103  return;
104 }

References libMesh::ReferenceCounter::_enable_print_counter.

◆ 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 100 of file reference_counter.C.

101 {
102  _enable_print_counter = true;
103  return;
104 }

References libMesh::ReferenceCounter::_enable_print_counter.

◆ 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 1134 of file rb_construction.C.

1135 {
1136  LOG_SCOPE("enrich_basis_from_rhs_terms()", "RBConstruction");
1137 
1138  // initialize rb_eval's parameters
1140 
1141  // possibly resize data structures according to Nmax
1142  if (resize_rb_eval_data)
1143  {
1145  }
1146 
1147  libMesh::out << std::endl << "---- Enriching basis from rhs terms ----" << std::endl;
1148 
1149  truth_assembly();
1150 
1151  for (unsigned int q_f=0; q_f<get_rb_theta_expansion().get_n_F_terms(); q_f++)
1152  {
1153  libMesh::out << std::endl << "Performing truth solve with rhs from rhs term " << q_f << std::endl;
1154 
1155  *rhs = *get_Fq(q_f);
1156 
1157  if (rhs->l2_norm() == 0)
1158  {
1159  // Skip enrichment if the rhs is zero
1160  continue;
1161  }
1162 
1163  // truth_assembly assembles into matrix and rhs, so use those for the solve
1164  if (extra_linear_solver)
1165  {
1166  // If extra_linear_solver has been initialized, then we use it for the
1167  // truth solves.
1169 
1170  if (assert_convergence)
1172  }
1173  else
1174  {
1176 
1177  if (assert_convergence)
1179  }
1180 
1181  // Call user-defined post-processing routines on the truth solution.
1183 
1184  // Add orthogonal part of the snapshot to the RB space
1185  libMesh::out << "Enriching the RB space" << std::endl;
1186  enrich_RB_space();
1187 
1188  update_system();
1189  }
1190 }

References libMesh::RBConstruction::assert_convergence, libMesh::RBConstruction::check_convergence(), libMesh::RBConstruction::enrich_RB_space(), libMesh::RBConstruction::extra_linear_solver, libMesh::RBConstruction::get_Fq(), libMesh::LinearImplicitSystem::get_linear_solver(), 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::out, libMesh::RBConstruction::post_process_truth_solution(), libMesh::RBEvaluation::resize_data_structures(), libMesh::ExplicitSystem::rhs, libMesh::RBConstruction::solve_for_matrix_and_rhs(), libMesh::RBConstruction::truth_assembly(), and libMesh::RBConstruction::update_system().

◆ enrich_RB_space()

void libMesh::RBConstruction::enrich_RB_space ( )
protectedvirtualinherited

Add a new basis function to the RB space.

This is called during train_reduced_basis.

Reimplemented in libMesh::TransientRBConstruction, and libMesh::RBEIMConstruction.

Definition at line 1316 of file rb_construction.C.

1317 {
1318  LOG_SCOPE("enrich_RB_space()", "RBConstruction");
1319 
1320  auto new_bf = NumericVector<Number>::build(this->comm());
1321  new_bf->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
1322  *new_bf = *solution;
1323 
1324  for (unsigned int index=0; index<get_rb_evaluation().get_n_basis_functions(); index++)
1325  {
1327 
1328  Number scalar =
1329  inner_product_storage_vector->dot(get_rb_evaluation().get_basis_function(index));
1330  new_bf->add(-scalar, get_rb_evaluation().get_basis_function(index));
1331  }
1332 
1333  // Normalize new_bf
1335  Number new_bf_norm = std::sqrt( inner_product_storage_vector->dot(*new_bf) );
1336 
1337  if (new_bf_norm == 0.)
1338  {
1339  new_bf->zero(); // avoid potential nan's
1340  }
1341  else
1342  {
1343  new_bf->scale(1./new_bf_norm);
1344  }
1345 
1346  // load the new basis function into the basis_functions vector.
1347  get_rb_evaluation().basis_functions.emplace_back( std::move(new_bf) );
1348 }

References libMesh::RBEvaluation::basis_functions, 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::RBConstructionBase< LinearImplicitSystem >::inner_product_storage_vector, libMesh::System::n_dofs(), libMesh::System::n_local_dofs(), libMesh::PARALLEL, libMesh::System::solution, std::sqrt(), and libMesh::SparseMatrix< T >::vector_mult().

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

◆ 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 796 of file implicit_system.C.

799 {
800  ParameterVector & parameters =
801  const_cast<ParameterVector &>(parameters_in);
802 
803  const unsigned int Np = cast_int<unsigned int>
804  (parameters.size());
805  const unsigned int Nq = this->n_qois();
806 
807  // An introduction to the problem:
808  //
809  // Residual R(u(p),p) = 0
810  // partial R / partial u = J = system matrix
811  //
812  // This implies that:
813  // d/dp(R) = 0
814  // (partial R / partial p) +
815  // (partial R / partial u) * (partial u / partial p) = 0
816 
817  // We first solve for (partial u / partial p) for each parameter:
818  // J * (partial u / partial p) = - (partial R / partial p)
819 
820  this->sensitivity_solve(parameters);
821 
822  // Get ready to fill in sensitivities:
823  sensitivities.allocate_data(qoi_indices, *this, parameters);
824 
825  // We use the identity:
826  // dq/dp = (partial q / partial p) + (partial q / partial u) *
827  // (partial u / partial p)
828 
829  // We get (partial q / partial u) from the user
830  this->assemble_qoi_derivative(qoi_indices,
831  /* include_liftfunc = */ true,
832  /* apply_constraints = */ false);
833 
834  // We don't need these to be closed() in this function, but libMesh
835  // standard practice is to have them closed() by the time the
836  // function exits
837  for (auto i : IntRange<unsigned int>(0, this->n_qois()))
838  if (qoi_indices.has_index(i))
839  this->get_adjoint_rhs(i).close();
840 
841  for (unsigned int j=0; j != Np; ++j)
842  {
843  // We currently get partial derivatives via central differencing
844 
845  // (partial q / partial p) ~= (q(p+dp)-q(p-dp))/(2*dp)
846 
847  Number old_parameter = *parameters[j];
848 
849  const Real delta_p =
850  TOLERANCE * std::max(std::abs(old_parameter), 1e-3);
851 
852  *parameters[j] = old_parameter - delta_p;
853  this->assemble_qoi(qoi_indices);
854  std::vector<Number> qoi_minus = this->qoi;
855 
856  *parameters[j] = old_parameter + delta_p;
857  this->assemble_qoi(qoi_indices);
858  std::vector<Number> & qoi_plus = this->qoi;
859 
860  std::vector<Number> partialq_partialp(Nq, 0);
861  for (unsigned int i=0; i != Nq; ++i)
862  if (qoi_indices.has_index(i))
863  partialq_partialp[i] = (qoi_plus[i] - qoi_minus[i]) / (2.*delta_p);
864 
865  // Don't leave the parameter changed
866  *parameters[j] = old_parameter;
867 
868  for (unsigned int i=0; i != Nq; ++i)
869  if (qoi_indices.has_index(i))
870  sensitivities[i][j] = partialq_partialp[i] +
871  this->get_adjoint_rhs(i).dot(this->get_sensitivity_solution(j));
872  }
873 
874  // All parameters have been reset.
875  // We didn't cache the original rhs or matrix for memory reasons,
876  // but we can restore them to a state consistent solution -
877  // principle of least surprise.
878  this->assembly(true, true);
879  this->rhs->close();
880  this->matrix->close();
881  this->assemble_qoi(qoi_indices);
882 }

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

◆ generate_training_parameters_deterministic()

void libMesh::RBConstructionBase< LinearImplicitSystem >::generate_training_parameters_deterministic ( const Parallel::Communicator &  communicator,
std::map< std::string, bool >  log_param_scale,
std::map< std::string, std::unique_ptr< NumericVector< Number >>> &  training_parameters_in,
unsigned int  n_training_samples_in,
const RBParameters min_parameters,
const RBParameters max_parameters,
bool  serial_training_set = false 
)
staticprotectedinherited

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.

Definition at line 412 of file rb_construction_base.C.

419 {
420  libmesh_assert_equal_to ( min_parameters.n_parameters(), max_parameters.n_parameters() );
421  const unsigned int num_params = min_parameters.n_parameters();
422 
423  if (num_params == 0)
424  return;
425 
426  if (num_params > 2)
427  {
428  libMesh::out << "ERROR: Deterministic training sample generation "
429  << " not implemented for more than two parameters." << std::endl;
430  libmesh_not_implemented();
431  }
432 
433  // Clear training_parameters_in (but don't remove existing keys!)
434  for (auto & pr : training_parameters_in)
435  pr.second.reset(nullptr);
436 
437  // Initialize training_parameters_in
438  for (const auto & pr : min_parameters)
439  {
440  const std::string & param_name = pr.first;
441  training_parameters_in[param_name] = NumericVector<Number>::build(communicator);
442 
443  if (!serial_training_set)
444  {
445  // Calculate the number of training parameters local to this processor
446  unsigned int n_local_training_samples;
447  unsigned int quotient = n_training_samples_in/communicator.size();
448  unsigned int remainder = n_training_samples_in%communicator.size();
449  if (communicator.rank() < remainder)
450  n_local_training_samples = (quotient + 1);
451  else
452  n_local_training_samples = quotient;
453 
454  training_parameters_in[param_name]->init(n_training_samples_in, n_local_training_samples, false, PARALLEL);
455  }
456  else
457  {
458  training_parameters_in[param_name]->init(n_training_samples_in, false, SERIAL);
459  }
460  }
461 
462  if (num_params == 1)
463  {
464  NumericVector<Number> * training_vector = training_parameters_in.begin()->second.get();
465  bool use_log_scaling = log_param_scale.begin()->second;
466  Real min_param = min_parameters.begin()->second;
467  Real max_param = max_parameters.begin()->second;
468 
469  numeric_index_type first_index = training_vector->first_local_index();
470  for (auto i : IntRange<numeric_index_type>(0, training_vector->local_size()))
471  {
472  numeric_index_type index = first_index+i;
473  if (use_log_scaling)
474  {
475  Real epsilon = 1.e-6; // Prevent rounding errors triggering asserts
476  Real log_min = log10(min_param + epsilon);
477  Real log_range = log10( (max_param-epsilon) / (min_param+epsilon) );
478  Real step_size = log_range /
479  std::max((unsigned int)1,(n_training_samples_in-1));
480 
481  if (index<(n_training_samples_in-1))
482  {
483  training_vector->set(index, pow(10., log_min + index*step_size ));
484  }
485  else
486  {
487  // due to rounding error, the last parameter can be slightly
488  // bigger than max_parameters, hence snap back to the max
489  training_vector->set(index, max_param);
490  }
491  }
492  else
493  {
494  // Generate linearly scaled training parameters
495  Real step_size = (max_param - min_param) /
496  std::max((unsigned int)1,(n_training_samples_in-1));
497  training_vector->set(index, index*step_size + min_param);
498  }
499  }
500  }
501 
502 
503  // This is for two parameters
504  if (num_params == 2)
505  {
506  // First make sure n_training_samples_in is a square number
507  unsigned int n_training_parameters_per_var = static_cast<unsigned int>( std::sqrt(static_cast<Real>(n_training_samples_in)) );
508  if ((n_training_parameters_per_var*n_training_parameters_per_var) != n_training_samples_in)
509  libmesh_error_msg("Error: Number of training parameters = " \
510  << n_training_samples_in \
511  << ".\n" \
512  << "Deterministic training set generation with two parameters requires\n " \
513  << "the number of training parameters to be a perfect square.");
514 
515  // make a matrix to store all the parameters, put them in vector form afterwards
516  std::vector<std::vector<Real>> training_parameters_matrix(num_params);
517 
518  unsigned int i = 0;
519  for (const auto & pr : min_parameters)
520  {
521  const std::string & param_name = pr.first;
522  Real min_param = pr.second;
523  bool use_log_scaling = log_param_scale[param_name];
524  Real max_param = max_parameters.get_value(param_name);
525 
526  training_parameters_matrix[i].resize(n_training_parameters_per_var);
527 
528  for (unsigned int j=0; j<n_training_parameters_per_var; j++)
529  {
530  // Generate log10 scaled training parameters
531  if (use_log_scaling)
532  {
533  Real epsilon = 1.e-6; // Prevent rounding errors triggering asserts
534  Real log_min = log10(min_param + epsilon);
535  Real log_range = log10( (max_param-epsilon) / (min_param+epsilon) );
536  Real step_size = log_range /
537  std::max((unsigned int)1,(n_training_parameters_per_var-1));
538 
539  if (j<(n_training_parameters_per_var-1))
540  {
541  training_parameters_matrix[i][j] = pow(10., log_min + j*step_size );
542  }
543  else
544  {
545  // due to rounding error, the last parameter can be slightly
546  // bigger than max_parameters, hence snap back to the max
547  training_parameters_matrix[i][j] = max_param;
548  }
549  }
550  else
551  {
552  // Generate linearly scaled training parameters
553  Real step_size = (max_param - min_param) /
554  std::max((unsigned int)1,(n_training_parameters_per_var-1));
555  training_parameters_matrix[i][j] = j*step_size + min_param;
556  }
557 
558  }
559  i++;
560  }
561 
562  // now load into training_samples_in:
563  std::map<std::string, std::unique_ptr<NumericVector<Number>>>::iterator new_it = training_parameters_in.begin();
564 
565  NumericVector<Number> * training_vector_0 = new_it->second.get();
566  ++new_it;
567  NumericVector<Number> * training_vector_1 = new_it->second.get();
568 
569  for (unsigned int index1=0; index1<n_training_parameters_per_var; index1++)
570  {
571  for (unsigned int index2=0; index2<n_training_parameters_per_var; index2++)
572  {
573  unsigned int index = index1*n_training_parameters_per_var + index2;
574 
575  if ((training_vector_0->first_local_index() <= index) &&
576  (index < training_vector_0->last_local_index()))
577  {
578  training_vector_0->set(index, training_parameters_matrix[0][index1]);
579  training_vector_1->set(index, training_parameters_matrix[1][index2]);
580  }
581  }
582  }
583 
584  // libMesh::out << "n_training_samples = " << n_training_samples_in << std::endl;
585  // for (unsigned int index=0; index<n_training_samples_in; index++)
586  // {
587  // libMesh::out << "training parameters for index="<<index<<":"<<std::endl;
588  // for (unsigned int param=0; param<num_params; param++)
589  // {
590  // libMesh::out << " " << (*training_parameters_in[param])(index);
591  // }
592  // libMesh::out << std::endl << std::endl;
593  // }
594 
595  }
596 }

◆ generate_training_parameters_random()

void libMesh::RBConstructionBase< LinearImplicitSystem >::generate_training_parameters_random ( const Parallel::Communicator &  communicator,
std::map< std::string, bool >  log_param_scale,
std::map< std::string, std::unique_ptr< NumericVector< Number >>> &  training_parameters_in,
unsigned int  n_training_samples_in,
const RBParameters min_parameters,
const RBParameters max_parameters,
int  training_parameters_random_seed = -1,
bool  serial_training_set = false 
)
staticprotectedinherited

Static helper function for generating a randomized set of parameters.

Definition at line 300 of file rb_construction_base.C.

308 {
309  libmesh_assert_equal_to ( min_parameters.n_parameters(), max_parameters.n_parameters() );
310  const unsigned int num_params = min_parameters.n_parameters();
311 
312  // Clear training_parameters_in
313  training_parameters_in.clear();
314 
315  if (num_params == 0)
316  return;
317 
319  {
320  if (!serial_training_set)
321  {
322  // seed the random number generator with the system time
323  // and the processor ID so that the seed is different
324  // on different processors
325  std::srand( static_cast<unsigned>( std::time(0)*(1+communicator.rank()) ));
326  }
327  else
328  {
329  // seed the random number generator with the system time
330  // only so that the seed is the same on all processors
331  //
332  // Note that we broadcast the time on processor 0 to make
333  // sure all processors agree.
334  unsigned int current_time = static_cast<unsigned>( std::time(0) );
335  communicator.broadcast(current_time, 0);
336  std::srand(current_time);
337  }
338  }
339  else
340  {
341  if (!serial_training_set)
342  {
343  // seed the random number generator with the provided value
344  // and the processor ID so that the seed is different
345  // on different processors
346  std::srand( static_cast<unsigned>( training_parameters_random_seed*(1+communicator.rank()) ));
347  }
348  else
349  {
350  // seed the random number generator with the provided value
351  // so that the seed is the same on all processors
352  std::srand( static_cast<unsigned>( training_parameters_random_seed ));
353  }
354  }
355 
356  // initialize training_parameters_in
357  for (const auto & pr : min_parameters)
358  {
359  const std::string & param_name = pr.first;
360  training_parameters_in[param_name] = NumericVector<Number>::build(communicator);
361 
362  if (!serial_training_set)
363  {
364  // Calculate the number of training parameters local to this processor
365  unsigned int n_local_training_samples;
366  unsigned int quotient = n_training_samples_in/communicator.size();
367  unsigned int remainder = n_training_samples_in%communicator.size();
368  if (communicator.rank() < remainder)
369  n_local_training_samples = (quotient + 1);
370  else
371  n_local_training_samples = quotient;
372 
373  training_parameters_in[param_name]->init(n_training_samples_in, n_local_training_samples, false, PARALLEL);
374  }
375  else
376  {
377  training_parameters_in[param_name]->init(n_training_samples_in, false, SERIAL);
378  }
379  }
380 
381  // finally, set the values
382  for (auto & pr : training_parameters_in)
383  {
384  const std::string & param_name = pr.first;
385  NumericVector<Number> * training_vector = pr.second.get();
386 
387  numeric_index_type first_index = training_vector->first_local_index();
388  for (auto i : IntRange<numeric_index_type>(0, training_vector->local_size()))
389  {
390  numeric_index_type index = first_index + i;
391  Real random_number = static_cast<Real>(std::rand()) / RAND_MAX; // in range [0,1]
392 
393  // Generate log10 scaled training parameters
394  if (log_param_scale[param_name])
395  {
396  Real log_min = log10(min_parameters.get_value(param_name));
397  Real log_range = log10(max_parameters.get_value(param_name) / min_parameters.get_value(param_name));
398 
399  training_vector->set(index, pow(10., log_min + random_number*log_range ) );
400  }
401  // Generate linearly scaled training parameters
402  else
403  {
404  training_vector->set(index, random_number*(max_parameters.get_value(param_name) - min_parameters.get_value(param_name))
405  + min_parameters.get_value(param_name));
406  }
407  }
408  }
409 }

◆ get_abs_training_tolerance()

Real libMesh::RBConstruction::get_abs_training_tolerance ( )
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 1019 of file system.C.

1020 {
1021  std::ostringstream adjoint_rhs_name;
1022  adjoint_rhs_name << "adjoint_rhs" << i;
1023 
1024  return this->get_vector(adjoint_rhs_name.str());
1025 }

References libMesh::System::get_vector().

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().

◆ 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 1029 of file system.C.

1030 {
1031  std::ostringstream adjoint_rhs_name;
1032  adjoint_rhs_name << "adjoint_rhs" << i;
1033 
1034  return this->get_vector(adjoint_rhs_name.str());
1035 }

References libMesh::System::get_vector().

◆ get_adjoint_solution() [1/2]

NumericVector< Number > & libMesh::System::get_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.

Definition at line 957 of file system.C.

958 {
959  std::ostringstream adjoint_name;
960  adjoint_name << "adjoint_solution" << i;
961 
962  return this->get_vector(adjoint_name.str());
963 }

References libMesh::System::get_vector().

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::ImplicitSystem::adjoint_solve(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), main(), HeatSystem::perturb_accumulate_residuals(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), and libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().

◆ 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 967 of file system.C.

968 {
969  std::ostringstream adjoint_name;
970  adjoint_name << "adjoint_solution" << i;
971 
972  return this->get_vector(adjoint_name.str());
973 }

References libMesh::System::get_vector().

◆ get_all_matrices()

void libMesh::RBConstruction::get_all_matrices ( std::map< std::string, SparseMatrix< Number > * > &  all_matrices)
virtualinherited

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

Reimplemented in libMesh::TransientRBConstruction.

Definition at line 1952 of file rb_construction.C.

1953 {
1954  all_matrices.clear();
1955 
1956  all_matrices["inner_product"] = get_inner_product_matrix();
1957 
1959  {
1960  all_matrices["non_dirichlet_inner_product"] = get_non_dirichlet_inner_product_matrix();
1961  }
1962 
1963  for (unsigned int q_a=0; q_a<get_rb_theta_expansion().get_n_A_terms(); q_a++)
1964  {
1965  std::stringstream matrix_name;
1966  matrix_name << "A" << q_a;
1967  all_matrices[matrix_name.str()] = get_Aq(q_a);
1968 
1970  {
1971  matrix_name << "_non_dirichlet";
1972  all_matrices[matrix_name.str()] = get_non_dirichlet_Aq(q_a);
1973  }
1974  }
1975 }

References libMesh::RBConstruction::get_Aq(), libMesh::RBConstruction::get_inner_product_matrix(), libMesh::RBThetaExpansion::get_n_A_terms(), libMesh::RBConstruction::get_non_dirichlet_Aq(), libMesh::RBConstruction::get_non_dirichlet_inner_product_matrix(), libMesh::RBConstruction::get_rb_theta_expansion(), and libMesh::RBConstruction::store_non_dirichlet_operators.

Referenced by libMesh::TransientRBConstruction::get_all_matrices().

◆ 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 1240 of file system.C.

1241 {
1242  all_variable_numbers.resize(n_vars());
1243 
1244  // Make sure the variable exists
1245  std::map<std::string, unsigned short int>::const_iterator
1246  it = _variable_numbers.begin();
1247  std::map<std::string, unsigned short int>::const_iterator
1248  it_end = _variable_numbers.end();
1249 
1250  unsigned int count = 0;
1251  for ( ; it != it_end; ++it)
1252  {
1253  all_variable_numbers[count] = it->second;
1254  count++;
1255  }
1256 }

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

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

◆ 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 1977 of file rb_construction.C.

1978 {
1979  all_vectors.clear();
1980 
1981  get_output_vectors(all_vectors);
1982 
1983  for (unsigned int q_f=0; q_f<get_rb_theta_expansion().get_n_F_terms(); q_f++)
1984  {
1985  std::stringstream F_vector_name;
1986  F_vector_name << "F" << q_f;
1987  all_vectors[F_vector_name.str()] = get_Fq(q_f);
1988 
1990  {
1991  F_vector_name << "_non_dirichlet";
1992  all_vectors[F_vector_name.str()] = get_non_dirichlet_Fq(q_f);
1993  }
1994  }
1995 }

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.

◆ get_Aq()

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

◆ 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 433 of file rb_parametrized.C.

434 {
435  if (list_of_values.empty())
436  libmesh_error_msg("Error: list_of_values is empty.");
437 
438  Real min_distance = std::numeric_limits<Real>::max();
439  Real closest_val = 0.;
440  for (const auto & current_value : list_of_values)
441  {
442  Real distance = std::abs(value - current_value);
443  if (distance < min_distance)
444  {
445  min_distance = distance;
446  closest_val = current_value;
447  }
448  }
449 
450  return closest_val;
451 }

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

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

◆ 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 2245 of file rb_construction.C.

2246 {
2247  return assert_convergence;
2248 }

References libMesh::RBConstruction::assert_convergence.

◆ 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 417 of file rb_construction.h.

417 { return delta_N; }

References libMesh::RBConstruction::delta_N.

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

◆ 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_deterministic_training_parameter_repeats()

unsigned int libMesh::RBConstructionBase< LinearImplicitSystem >::get_deterministic_training_parameter_repeats ( ) const
inherited

Get the number of times each sample of the deterministic training parameter is repeated.

◆ get_discrete_parameter_values()

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

◆ get_dof_map() [1/2]

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

Definition at line 2107 of file system.h.

2108 {
2109  return *_dof_map;
2110 }

References libMesh::System::_dof_map.

◆ get_dof_map() [2/2]

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

Definition at line 2099 of file system.h.

2100 {
2101  return *_dof_map;
2102 }

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::HPCoarsenTest::add_projection(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::ImplicitSystem::adjoint_solve(), libMesh::NewmarkSolver::advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), libMesh::EquationSystems::allgather(), libMesh::TransientRBConstruction::allocate_data_structures(), libMesh::RBConstruction::allocate_data_structures(), assemble(), LinearElasticity::assemble(), assemble_1D(), AssembleOptimization::assemble_A_and_F(), assemble_and_solve(), assemble_biharmonic(), assemble_elasticity(), assemble_ellipticdg(), assemble_helmholtz(), assemble_laplace(), assemble_mass(), assemble_matrices(), assemble_matrix_and_rhs(), assemble_poisson(), assemble_SchroedingerEquation(), assemble_shell(), assemble_stokes(), assemble_wave(), libMesh::EquationSystems::build_discontinuous_solution_vector(), 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(), LinearElasticityWithContact::compute_stresses(), LinearElasticity::compute_stresses(), compute_stresses(), LargeDeformationElasticity::compute_stresses(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), MyConstraint::constrain(), libMesh::ExodusII_IO::copy_scalar_solution(), DMCreateDomainDecomposition_libMesh(), DMCreateFieldDecomposition_libMesh(), DMlibMeshFunction(), DMlibMeshJacobian(), DMlibMeshSetSystem_libMesh(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::RBEIMAssembly::evaluate_basis_function(), libMesh::System::get_info(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::SecondOrderUnsteadySolver::init_data(), libMesh::UnsteadySolver::init_data(), HeatSystem::init_data(), SimpleRBConstruction::init_data(), LaplaceSystem::init_dirichlet_bcs(), libMesh::RBEIMConstruction::init_dof_map_between_systems(), libMesh::EigenSystem::init_matrices(), libMesh::ImplicitSystem::init_matrices(), libMesh::CondensedEigenSystem::initialize_condensed_dofs(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::RBEIMAssembly::initialize_fe(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::RBEIMConstruction::initialize_rb_construction(), LaplaceYoung::jacobian(), LargeDeformationElasticity::jacobian(), 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::RBSCMConstruction::perform_SCM_greedy(), 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::RBEIMAssembly::RBEIMAssembly(), libMesh::RBEIMConstruction::RBEIMConstruction(), libMesh::System::re_update(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::SecondOrderUnsteadySolver::reinit(), libMesh::UnsteadySolver::reinit(), libMesh::EigenSystem::reinit(), libMesh::ImplicitSystem::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(), FETest< order, family, elem_type >::setUp(), SolidSystem::side_time_derivative(), libMesh::NewtonSolver::solve(), libMesh::PetscDiffSolver::solve(), libMesh::RBConstruction::solve_for_matrix_and_rhs(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), SystemsTest::testBlockRestrictedVarNDofs(), DofMapTest::testConstraintLoopDetection(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), EquationSystemsTest::testDisableDefaultGhosting(), SystemsTest::testDofCouplingWithVarGroups(), DofMapTest::testDofOwner(), MeshInputTest::testDynaReadPatch(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), SystemsTest::testProjectCubeWithMeshFunction(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), BoundaryInfoTest::testShellFaceConstraints(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), libMesh::RBEIMConstruction::truth_solve(), libMesh::RBEIMConstruction::update_RB_system_matrices(), 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().

◆ get_equation_systems() [1/2]

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

Definition at line 725 of file system.h.

725 { return _equation_systems; }

References libMesh::System::_equation_systems.

◆ get_equation_systems() [2/2]

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

Definition at line 720 of file system.h.

720 { return _equation_systems; }

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::AdjointRefinementEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::find_squared_element_error(), libMesh::RBEIMConstruction::get_explicit_system(), libMesh::ImplicitSystem::get_linear_solve_parameters(), SolidSystem::init_data(), HeatSystem::init_data(), libMesh::FrequencySystem::init_data(), libMesh::RBEIMConstruction::init_data(), libMesh::RBEIMConstruction::initialize_rb_construction(), LaplaceYoung::jacobian(), libMesh::RBSCMConstruction::load_matrix_B(), LinearElasticityWithContact::move_mesh(), libMesh::FrequencySystem::n_frequencies(), libMesh::RBSCMConstruction::perform_SCM_greedy(), libMesh::RBEIMConstruction::plot_parametrized_functions_in_training_set(), libMesh::System::point_gradient(), libMesh::System::point_value(), LaplaceYoung::residual(), LinearElasticityWithContact::residual_and_jacobian(), 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::CondensedEigenSystem::solve(), libMesh::EigenSystem::solve(), libMesh::FrequencySystem::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::RBConstruction::solve_for_matrix_and_rhs(), MeshFunctionTest::test_p_level(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::DirectSolutionTransfer::transfer(), libMesh::DTKSolutionTransfer::transfer(), libMesh::TransientRBConstruction::truth_solve(), libMesh::RBEIMConstruction::truth_solve(), libMesh::RBConstruction::truth_solve(), and libMesh::WrappedFunction< Output >::WrappedFunction().

◆ 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 116 of file rb_construction_base.C.

117 {
119  return training_parameters.begin()->second->first_local_index();
120 }

◆ get_Fq()

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

◆ 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 85 of file rb_construction_base.C.

87 {
88  // Set error_pair.second to the maximum global value and also
89  // find which processor contains the maximum value
90  unsigned int proc_ID_index;
91  communicator.maxloc(error_pair.second, proc_ID_index);
92 
93  // Then broadcast error_pair.first from proc_ID_index
94  communicator.broadcast(error_pair.first, proc_ID_index);
95 }

◆ 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 1234 of file rb_construction.C.

1235 {
1236  if (i >= get_rb_evaluation().greedy_param_list.size())
1237  libmesh_error_msg("Error: Argument in RBConstruction::get_greedy_parameter is too large.");
1238 
1240 }

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

◆ 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.

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 & pr : _counts)
59  {
60  const std::string name(pr.first);
61  const unsigned int creations = pr.second.first;
62  const unsigned int destructions = pr.second.second;
63 
64  oss << "| " << name << " reference count information:\n"
65  << "| Creations: " << creations << '\n'
66  << "| Destructions: " << destructions << '\n';
67  }
68 
69  oss << " ---------------------------------------------------------------------------- \n";
70 
71  return oss.str();
72 
73 #else
74 
75  return "";
76 
77 #endif
78 }

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

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

◆ 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.

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 & pr : _counts)
59  {
60  const std::string name(pr.first);
61  const unsigned int creations = pr.second.first;
62  const unsigned int destructions = pr.second.second;
63 
64  oss << "| " << name << " reference count information:\n"
65  << "| Creations: " << creations << '\n'
66  << "| Destructions: " << destructions << '\n';
67  }
68 
69  oss << " ---------------------------------------------------------------------------- \n";
70 
71  return oss.str();
72 
73 #else
74 
75  return "";
76 
77 #endif
78 }

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

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

◆ get_info() [3/3]

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

Definition at line 1636 of file system.C.

1637 {
1638  std::ostringstream oss;
1639 
1640 
1641  const std::string & sys_name = this->name();
1642 
1643  oss << " System #" << this->number() << ", \"" << sys_name << "\"\n"
1644  << " Type \"" << this->system_type() << "\"\n"
1645  << " Variables=";
1646 
1647  for (auto vg : IntRange<unsigned int>(0, this->n_variable_groups()))
1648  {
1649  const VariableGroup & vg_description (this->variable_group(vg));
1650 
1651  if (vg_description.n_variables() > 1) oss << "{ ";
1652  for (auto vn : IntRange<unsigned int>(0, vg_description.n_variables()))
1653  oss << "\"" << vg_description.name(vn) << "\" ";
1654  if (vg_description.n_variables() > 1) oss << "} ";
1655  }
1656 
1657  oss << '\n';
1658 
1659  oss << " Finite Element Types=";
1660 #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
1661  for (auto vg : IntRange<unsigned int>(0, this->n_variable_groups()))
1662  oss << "\""
1663  << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().family)
1664  << "\" ";
1665 #else
1666  for (auto vg : IntRange<unsigned int>(0, this->n_variable_groups()))
1667  {
1668  oss << "\""
1669  << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().family)
1670  << "\", \""
1671  << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().radial_family)
1672  << "\" ";
1673  }
1674 
1675  oss << '\n' << " Infinite Element Mapping=";
1676  for (auto vg : IntRange<unsigned int>(0, this->n_variable_groups()))
1677  oss << "\""
1678  << Utility::enum_to_string<InfMapType>(this->get_dof_map().variable_group(vg).type().inf_map)
1679  << "\" ";
1680 #endif
1681 
1682  oss << '\n';
1683 
1684  oss << " Approximation Orders=";
1685  for (auto vg : IntRange<unsigned int>(0, this->n_variable_groups()))
1686  {
1687 #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
1688  oss << "\""
1689  << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().order)
1690  << "\" ";
1691 #else
1692  oss << "\""
1693  << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().order)
1694  << "\", \""
1695  << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().radial_order)
1696  << "\" ";
1697 #endif
1698  }
1699 
1700  oss << '\n';
1701 
1702  oss << " n_dofs()=" << this->n_dofs() << '\n';
1703  oss << " n_local_dofs()=" << this->n_local_dofs() << '\n';
1704 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1705  oss << " n_constrained_dofs()=" << this->n_constrained_dofs() << '\n';
1706  oss << " n_local_constrained_dofs()=" << this->n_local_constrained_dofs() << '\n';
1707 #endif
1708 
1709  oss << " " << "n_vectors()=" << this->n_vectors() << '\n';
1710  oss << " " << "n_matrices()=" << this->n_matrices() << '\n';
1711  // oss << " " << "n_additional_matrices()=" << this->n_additional_matrices() << '\n';
1712 
1713  oss << this->get_dof_map().get_info();
1714 
1715  return oss.str();
1716 }

References libMesh::FEType::family, libMesh::System::get_dof_map(), libMesh::DofMap::get_info(), 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::System::system_type(), libMesh::Variable::type(), libMesh::DofMap::variable_group(), and libMesh::System::variable_group().

◆ get_inner_product_assembly()

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

Definition at line 385 of file rb_construction.C.

386 {
388  libmesh_error_msg("Error: inner_product_assembly not available since we're using energy inner-product");
389 
391  libmesh_error_msg("Error: inner_product_assembly hasn't been initialized yet");
392 
393  return *inner_product_assembly;
394 }

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

◆ get_inner_product_matrix()

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 1853 of file rb_construction.C.

1854 {
1855  return inner_product_matrix.get();
1856 }

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().

◆ 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 123 of file rb_construction_base.C.

124 {
126  return training_parameters.begin()->second->last_local_index();
127 }

◆ 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 1410 of file implicit_system.C.

1411 {
1412  return std::make_pair(this->get_equation_systems().parameters.get<unsigned int>("linear solver maximum iterations"),
1413  this->get_equation_systems().parameters.get<Real>("linear solver tolerance"));
1414 }

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

Referenced by libMesh::ImplicitSystem::adjoint_solve(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve(), and libMesh::ImplicitSystem::weighted_sensitivity_solve().

◆ get_linear_solver()

LinearSolver< Number > * libMesh::LinearImplicitSystem::get_linear_solver ( ) const
overridevirtualinherited

◆ 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 109 of file rb_construction_base.C.

110 {
112  return training_parameters.begin()->second->local_size();
113 }

◆ get_matrix() [1/2]

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

None of these matrices is involved in the solution process. Access is only granted when the matrix is already properly initialized.

Definition at line 269 of file implicit_system.C.

270 {
271  return *(libmesh_map_find(_matrices, mat_name));
272 }

References libMesh::ImplicitSystem::_matrices.

◆ get_matrix() [2/2]

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

None of these matrices is involved in the solution process. Access is only granted when the matrix is already properly initialized.

Definition at line 262 of file implicit_system.C.

263 {
264  return *(libmesh_map_find(_matrices, mat_name));
265 }

References libMesh::ImplicitSystem::_matrices.

Referenced by add_M_C_K_helmholtz(), assemble(), assemble_helmholtz(), libMesh::NewmarkSystem::compute_matrix(), main(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), libMesh::EigenTimeSolver::solve(), and libMesh::NewmarkSystem::update_rhs().

◆ get_matrix_for_output_dual_solves()

SparseMatrix< Number > & libMesh::RBConstruction::get_matrix_for_output_dual_solves ( )
protectedvirtualinherited

Return the matrix for the output residual dual norm solves.

By default we use the inner product matrix for steady state problems.

Reimplemented in libMesh::TransientRBConstruction.

Definition at line 1630 of file rb_construction.C.

1631 {
1632  return *inner_product_matrix;
1633 }

References libMesh::RBConstruction::inner_product_matrix.

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

◆ get_mesh() [1/2]

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

Definition at line 2091 of file system.h.

2092 {
2093  return _mesh;
2094 }

References libMesh::System::_mesh.

◆ get_mesh() [2/2]

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

Definition at line 2083 of file system.h.

2084 {
2085  return _mesh;
2086 }

References libMesh::System::_mesh.

Referenced by libMesh::ExactSolution::_compute_error(), LinearElasticityWithContact::add_contact_edge_elements(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::HPCoarsenTest::add_projection(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), AssembleOptimization::assemble_A_and_F(), libMesh::FEMSystem::assemble_qoi(), libMesh::FEMSystem::assemble_qoi_derivative(), libMesh::FEMSystem::assembly(), AssemblyA0::boundary_assembly(), AssemblyF0::boundary_assembly(), AssemblyA1::boundary_assembly(), AssemblyF1::boundary_assembly(), AssemblyF2::boundary_assembly(), AssemblyA2::boundary_assembly(), libMesh::System::calculate_norm(), compute_jacobian(), compute_residual(), LinearElasticityWithContact::compute_stresses(), DMCreateDomainDecomposition_libMesh(), DMCreateFieldDecomposition_libMesh(), DMlibMeshSetSystem_libMesh(), SolidSystem::element_time_derivative(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::GenericProjector(), LinearElasticityWithContact::get_least_and_max_gap_function(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), SolidSystem::init_data(), libMesh::System::init_data(), libMesh::RBEIMConstruction::init_dof_map_between_systems(), libMesh::EigenSystem::init_matrices(), libMesh::ImplicitSystem::init_matrices(), LinearElasticityWithContact::initialize_contact_load_paths(), libMesh::RBEIMAssembly::initialize_fe(), libMesh::System::local_dof_indices(), libMesh::DofMap::max_constraint_error(), libMesh::FEMSystem::mesh_position_get(), libMesh::FEMSystem::mesh_position_set(), LinearElasticityWithContact::move_mesh(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::petsc_auto_fieldsplit(), libMesh::RBEIMConstruction::plot_parametrized_functions_in_training_set(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::FEMSystem::postprocess(), 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::EigenSystem::reinit(), libMesh::ImplicitSystem::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(), SolidSystem::side_time_derivative(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::BoundaryVolumeSolutionTransfer::transfer(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), libMesh::BoundaryVolumeSolutionTransfer::transfer_volume_boundary(), libMesh::TransientRBConstruction::truth_solve(), libMesh::RBEIMConstruction::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().

◆ get_n_continuous_params()

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

Get the number of continuous parameters.

Definition at line 125 of file rb_parametrized.C.

126 {
128  libmesh_error_msg("Error: parameters not initialized in RBParametrized::get_n_continuous_params");
129 
131 
132  return static_cast<unsigned int>(get_n_params() - get_n_discrete_params());
133 }

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().

◆ get_n_discrete_params()

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

Get the number of discrete parameters.

Definition at line 135 of file rb_parametrized.C.

136 {
138  libmesh_error_msg("Error: parameters not initialized in RBParametrized::get_n_discrete_params");
139 
140  return cast_int<unsigned int>
142 }

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().

◆ get_n_params()

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

◆ get_n_training_samples()

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

Get the total number of training samples.

Definition at line 98 of file rb_construction_base.C.

99 {
101 
102  if (training_parameters.empty())
103  return 0;
104 
105  return training_parameters.begin()->second->size();
106 }

◆ get_Nmax()

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

◆ 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 1884 of file rb_construction.C.

1885 {
1887  libmesh_error_msg("Error: Must have store_non_dirichlet_operators==true to access non_dirichlet_Aq.");
1888 
1889  if (q >= get_rb_theta_expansion().get_n_A_terms())
1890  libmesh_error_msg("Error: We must have q < Q_a in get_Aq.");
1891 
1892  return non_dirichlet_Aq_vector[q].get();
1893 }

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().

◆ 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 1895 of file rb_construction.C.

1896 {
1898  {
1899  return get_non_dirichlet_Aq(q);
1900  }
1901 
1902  return get_Aq(q);
1903 }

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().

◆ 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 1913 of file rb_construction.C.

1914 {
1916  libmesh_error_msg("Error: Must have store_non_dirichlet_operators==true to access non_dirichlet_Fq.");
1917 
1918  if (q >= get_rb_theta_expansion().get_n_F_terms())
1919  libmesh_error_msg("Error: We must have q < Q_f in get_Fq.");
1920 
1921  return non_dirichlet_Fq_vector[q].get();
1922 }

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().

◆ 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 1924 of file rb_construction.C.

1925 {
1927  {
1928  return get_non_dirichlet_Fq(q);
1929  }
1930 
1931  return get_Fq(q);
1932 }

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().

◆ get_non_dirichlet_inner_product_matrix()

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 1858 of file rb_construction.C.

1859 {
1861  libmesh_error_msg("Error: Must have store_non_dirichlet_operators==true to access non_dirichlet_inner_product_matrix.");
1862 
1864 }

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().

◆ get_non_dirichlet_inner_product_matrix_if_avail()

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

◆ 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 1943 of file rb_construction.C.

1944 {
1945  if ((n >= get_rb_theta_expansion().get_n_outputs()) || (q_l >= get_rb_theta_expansion().get_n_output_terms(n)))
1946  libmesh_error_msg("Error: We must have n < n_outputs and " \
1947  << "q_l < get_rb_theta_expansion().get_n_output_terms(n) in get_non_dirichlet_output_vector.");
1948 
1949  return non_dirichlet_outputs_vector[n][q_l].get();
1950 }

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().

◆ get_normalize_rb_bound_in_greedy()

bool libMesh::RBConstruction::get_normalize_rb_bound_in_greedy ( )
inlineinherited

◆ 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 1934 of file rb_construction.C.

1935 {
1936  if ((n >= get_rb_theta_expansion().get_n_outputs()) || (q_l >= get_rb_theta_expansion().get_n_output_terms(n)))
1937  libmesh_error_msg("Error: We must have n < n_outputs and " \
1938  << "q_l < get_rb_theta_expansion().get_n_output_terms(n) in get_output_vector.");
1939 
1940  return outputs_vector[n][q_l].get();
1941 }

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(), libMesh::TransientRBConstruction::truth_solve(), libMesh::RBConstruction::truth_solve(), and libMesh::RBConstruction::update_RB_system_matrices().

◆ 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 1997 of file rb_construction.C.

1998 {
1999  output_vectors.clear();
2000 
2001  for (unsigned int n=0; n<get_rb_theta_expansion().get_n_outputs(); n++)
2002  for (unsigned int q_l=0; q_l<get_rb_theta_expansion().get_n_output_terms(n); q_l++)
2003  {
2004  std::stringstream output_name;
2005  output_name << "output_" << n << "_"<< q_l;
2006  output_vectors[output_name.str()] = get_output_vector(n,q_l);
2007 
2009  {
2010  output_name << "_non_dirichlet";
2011  output_vectors[output_name.str()] = get_non_dirichlet_output_vector(n,q_l);
2012  }
2013  }
2014 }

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().

◆ 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 198 of file rb_parametrized.C.

199 {
201  libmesh_error_msg("Error: parameters not initialized in RBParametrized::get_parameter_max");
202 
203  return parameters_max.get_value(param_name);
204 }

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

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

◆ 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 190 of file rb_parametrized.C.

191 {
193  libmesh_error_msg("Error: parameters not initialized in RBParametrized::get_parameter_min");
194 
195  return parameters_min.get_value(param_name);
196 }

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

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

◆ get_parameter_names()

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

Get a set that stores the parameter names.

Definition at line 144 of file rb_parametrized.C.

145 {
147  libmesh_error_msg("Error: parameters not initialized in RBParametrized::get_parameter_names");
148 
149  std::set<std::string> parameter_names;
150  parameters_min.get_parameter_names(parameter_names);
151 
152  return parameter_names;
153 }

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

Referenced by libMesh::RBDataSerialization::add_parameter_ranges_to_builder().

◆ get_parameters()

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

Get the current parameters.

Definition at line 166 of file rb_parametrized.C.

167 {
169  libmesh_error_msg("Error: parameters not initialized in RBParametrized::get_current_parameters");
170 
171  return parameters;
172 }

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

Referenced by libMesh::TransientRBConstruction::add_scaled_mass_matrix(), libMesh::TransientRBEvaluation::cache_online_residual_terms(), libMesh::RBEIMConstruction::compute_best_fit_error(), libMesh::RBEvaluation::compute_residual_dual_norm(), libMesh::RBSCMConstruction::compute_SCM_bounds_on_training_set(), libMesh::RBSCMConstruction::enrich_C_J(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::RBEIMTheta::evaluate(), libMesh::RBEIMEvaluation::evaluate_parametrized_function(), 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::RBSCMEvaluation::legacy_read_offline_data_from_files(), libMesh::TransientRBConstruction::mass_matrix_scaled_matvec(), libMesh::RBSCMConstruction::print_info(), libMesh::RBConstruction::print_info(), libMesh::RBParametrized::print_parameters(), libMesh::RBSCMConstruction::process_parameters_file(), libMesh::TransientRBEvaluation::rb_solve(), libMesh::RBEvaluation::rb_solve(), libMesh::RBEIMEvaluation::rb_solve(), libMesh::RBSCMEvaluation::save_current_parameters(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::TransientRBConstruction::truth_solve(), libMesh::RBEIMConstruction::truth_solve(), libMesh::RBConstruction::truth_solve(), libMesh::TransientRBEvaluation::uncached_compute_residual_dual_norm(), and libMesh::RBConstruction::update_greedy_param_list().

◆ 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 182 of file rb_parametrized.C.

183 {
185  libmesh_error_msg("Error: parameters not initialized in RBParametrized::get_parameters_max");
186 
187  return parameters_max;
188 }

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::RBConstruction::set_rb_construction_parameters(), and libMesh::RBParametrized::write_parameter_ranges_to_file().

◆ 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 174 of file rb_parametrized.C.

175 {
177  libmesh_error_msg("Error: parameters not initialized in RBParametrized::get_parameters_min");
178 
179  return parameters_min;
180 }

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::RBConstruction::set_rb_construction_parameters(), and libMesh::RBParametrized::write_parameter_ranges_to_file().

◆ get_params_from_training_set()

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

Return the RBParameters in index index of training set.

Definition at line 136 of file rb_construction_base.C.

137 {
139 
140  libmesh_assert( (this->get_first_local_training_index() <= index) &&
141  (index < this->get_last_local_training_index()) );
142 
143  RBParameters params;
144  for (const auto & pr : training_parameters)
145  {
146  const std::string & param_name = pr.first;
147  Real param_value = libmesh_real((*(pr.second))(index));
148  params.set_value(param_name, param_value);
149  }
150 
151  // Add potential extra values
152  const auto & mine = get_parameters();
153  for (const auto & pr : as_range(mine.extra_begin(), mine.extra_end()))
154  params.set_extra_value(pr.first, pr.second);
155 
156  return params;
157 }

◆ get_rb_assembly_expansion()

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

Definition at line 371 of file rb_construction.C.

372 {
374  libmesh_error_msg("Error: RBAssemblyExpansion object hasn't been initialized yet");
375 
376  return *rb_assembly_expansion;
377 }

References libMesh::RBConstruction::rb_assembly_expansion.

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

◆ 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.

Reimplemented in libMesh::RBEIMConstruction.

Definition at line 1356 of file rb_construction.C.

1357 {
1359 
1360  Real error_bound = get_rb_evaluation().rb_solve(get_rb_evaluation().get_n_basis_functions());
1361 
1363  {
1364  Real error_bound_normalization = get_rb_evaluation().get_error_bound_normalization();
1365 
1366  if ((error_bound < abs_training_tolerance) ||
1367  (error_bound_normalization < abs_training_tolerance))
1368  {
1369  // We don't want to normalize this error bound if the bound or the
1370  // normalization value are below the absolute tolerance. Hence do nothing
1371  // in this case.
1372  }
1373  else
1374  error_bound /= error_bound_normalization;
1375  }
1376 
1377  return error_bound;
1378 }

References libMesh::RBConstruction::abs_training_tolerance, libMesh::RBEvaluation::get_error_bound_normalization(), libMesh::RBParametrized::get_parameters(), 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().

◆ get_rb_evaluation()

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

Get a reference to the RBEvaluation object.

Definition at line 175 of file rb_construction.C.

176 {
177  if (!rb_eval)
178  libmesh_error_msg("Error: RBEvaluation object hasn't been initialized yet");
179 
180  return *rb_eval;
181 }

References libMesh::RBConstruction::rb_eval.

Referenced by libMesh::TransientRBConstruction::add_IC_to_RB_space(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::RBEIMConstruction::compute_best_fit_error(), 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(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::TransientRBConstruction::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::RBEIMConstruction::initialize_eim_assembly_objects(), libMesh::RBEIMConstruction::initialize_parametrized_functions_in_training_set(), libMesh::RBEIMConstruction::load_basis_function(), libMesh::RBConstruction::load_basis_function(), libMesh::RBEIMConstruction::load_rb_solution(), libMesh::RBConstruction::load_rb_solution(), libMesh::TransientRBConstruction::load_rb_solution(), main(), libMesh::RBConstruction::print_basis_function_orthogonality(), libMesh::TransientRBConstruction::process_parameters_file(), libMesh::RBEIMAssembly::RBEIMAssembly(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::recompute_all_residual_terms(), libMesh::TransientRBConstruction::set_error_temporal_data(), libMesh::RBConstruction::train_reduced_basis(), libMesh::RBEIMConstruction::truth_solve(), libMesh::RBConstruction::update_greedy_param_list(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::RBEIMConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_RB_system_matrices(), libMesh::RBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_residual_terms(), libMesh::RBConstruction::update_residual_terms(), libMesh::TransientRBConstruction::write_riesz_representors_to_files(), and libMesh::RBConstruction::write_riesz_representors_to_files().

◆ get_rb_theta_expansion()

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

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

Definition at line 188 of file rb_construction.C.

189 {
191 }

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

Referenced by libMesh::RBConstruction::add_scaled_Aq(), libMesh::TransientRBConstruction::add_scaled_mass_matrix(), libMesh::TransientRBConstruction::allocate_data_structures(), libMesh::RBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::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(), libMesh::TransientRBConstruction::assemble_Mq_matrix(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::enrich_basis_from_rhs_terms(), libMesh::TransientRBConstruction::get_all_matrices(), libMesh::RBConstruction::get_all_matrices(), libMesh::RBConstruction::get_all_vectors(), libMesh::RBConstruction::get_Aq(), libMesh::RBConstruction::get_Fq(), libMesh::TransientRBConstruction::get_M_q(), libMesh::RBConstruction::get_non_dirichlet_Aq(), libMesh::RBConstruction::get_non_dirichlet_Fq(), libMesh::TransientRBConstruction::get_non_dirichlet_M_q(), libMesh::RBConstruction::get_non_dirichlet_output_vector(), libMesh::RBConstruction::get_output_vector(), libMesh::RBConstruction::get_output_vectors(), libMesh::TransientRBConstruction::initialize_rb_construction(), libMesh::RBConstruction::initialize_rb_construction(), libMesh::TransientRBConstruction::mass_matrix_scaled_matvec(), libMesh::TransientRBConstruction::print_info(), libMesh::RBConstruction::print_info(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::TransientRBConstruction::truth_solve(), libMesh::RBConstruction::truth_solve(), libMesh::TransientRBConstruction::update_RB_system_matrices(), libMesh::RBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_residual_terms(), and libMesh::RBConstruction::update_residual_terms().

◆ get_rel_training_tolerance()

Real libMesh::RBConstruction::get_rel_training_tolerance ( )
inlineinherited

◆ 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 1049 of file system.C.

1050 {
1051  std::ostringstream sensitivity_rhs_name;
1052  sensitivity_rhs_name << "sensitivity_rhs" << i;
1053 
1054  return this->get_vector(sensitivity_rhs_name.str());
1055 }

References libMesh::System::get_vector().

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

◆ 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 1059 of file system.C.

1060 {
1061  std::ostringstream sensitivity_rhs_name;
1062  sensitivity_rhs_name << "sensitivity_rhs" << i;
1063 
1064  return this->get_vector(sensitivity_rhs_name.str());
1065 }

References libMesh::System::get_vector().

◆ 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 904 of file system.C.

905 {
906  std::ostringstream sensitivity_name;
907  sensitivity_name << "sensitivity_solution" << i;
908 
909  return this->get_vector(sensitivity_name.str());
910 }

References libMesh::System::get_vector().

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

◆ 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 914 of file system.C.

915 {
916  std::ostringstream sensitivity_name;
917  sensitivity_name << "sensitivity_solution" << i;
918 
919  return this->get_vector(sensitivity_name.str());
920 }

References libMesh::System::get_vector().

◆ 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 191 of file linear_implicit_system.h.

191 { return _shell_matrix; }

References libMesh::LinearImplicitSystem::_shell_matrix.

◆ get_vector() [1/4]

NumericVector< Number > & libMesh::System::get_vector ( const std::string &  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 781 of file system.C.

782 {
783  return *(libmesh_map_find(_vectors, vec_name));
784 }

References libMesh::System::_vectors.

◆ get_vector() [2/4]

const NumericVector< Number > & libMesh::System::get_vector ( const std::string &  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 774 of file system.C.

775 {
776  return *(libmesh_map_find(_vectors, vec_name));
777 }

References libMesh::System::_vectors.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), add_M_C_K_helmholtz(), 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::SecondOrderUnsteadySolver::reinit(), libMesh::UnsteadySolver::reinit(), libMesh::MemorySolutionHistory::retrieve(), libMesh::UnsteadySolver::retrieve_timestep(), libMesh::TwostepTimeSolver::solve(), libMesh::FrequencySystem::solve(), libMesh::NewmarkSystem::update_rhs(), and libMesh::NewmarkSystem::update_u_v_a().

◆ get_vector() [3/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 804 of file system.C.

805 {
807  vectors_iterator v_end = vectors_end();
808  unsigned int num = 0;
809  while ((num<vec_num) && (v!=v_end))
810  {
811  num++;
812  ++v;
813  }
814  libmesh_assert (v != v_end);
815  return *(v->second);
816 }

References libMesh::libmesh_assert(), libMesh::System::vectors_begin(), and libMesh::System::vectors_end().

◆ get_vector() [4/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 788 of file system.C.

789 {
792  unsigned int num = 0;
793  while ((num<vec_num) && (v!=v_end))
794  {
795  num++;
796  ++v;
797  }
798  libmesh_assert (v != v_end);
799  return *(v->second);
800 }

References libMesh::libmesh_assert(), libMesh::System::vectors_begin(), and libMesh::System::vectors_end().

◆ 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 989 of file system.C.

990 {
991  std::ostringstream adjoint_name;
992  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
993 
994  return this->get_vector(adjoint_name.str());
995 }

References libMesh::System::get_vector().

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

◆ 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 999 of file system.C.

1000 {
1001  std::ostringstream adjoint_name;
1002  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
1003 
1004  return this->get_vector(adjoint_name.str());
1005 }

References libMesh::System::get_vector().

◆ 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 931 of file system.C.

932 {
933  return this->get_vector("weighted_sensitivity_solution");
934 }

References libMesh::System::get_vector().

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

◆ 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 938 of file system.C.

939 {
940  return this->get_vector("weighted_sensitivity_solution");
941 }

References libMesh::System::get_vector().

◆ greedy_termination_test()

bool libMesh::RBConstruction::greedy_termination_test ( Real  abs_greedy_error,
Real  initial_greedy_error,
int  count 
)
protectedvirtualinherited

Function that indicates when to terminate the Greedy basis training.

Override in subclasses to specialize.

Reimplemented in libMesh::TransientRBConstruction.

Definition at line 1192 of file rb_construction.C.

1195 {
1196  if (abs_greedy_error < this->abs_training_tolerance)
1197  {
1198  libMesh::out << "Absolute error tolerance reached." << std::endl;
1199  return true;
1200  }
1201 
1202  Real rel_greedy_error = abs_greedy_error/initial_error;
1203  if (rel_greedy_error < this->rel_training_tolerance)
1204  {
1205  libMesh::out << "Relative error tolerance reached." << std::endl;
1206  return true;
1207  }
1208 
1209  RBEvaluation & rbe = get_rb_evaluation();
1210 
1211  if (rbe.get_n_basis_functions() >= this->get_Nmax())
1212  {
1213  libMesh::out << "Maximum number of basis functions reached: Nmax = "
1214  << get_Nmax() << std::endl;
1215  return true;
1216  }
1217 
1219  for (auto & plist : rbe.greedy_param_list)
1220  if (plist == get_parameters())
1221  {
1222  libMesh::out << "Exiting greedy because the same parameters were selected twice" << std::endl;
1223  return true;
1224  }
1225 
1226  return false;
1227 }

References libMesh::RBConstruction::abs_training_tolerance, libMesh::RBConstruction::exit_on_repeated_greedy_parameters, libMesh::RBEvaluation::get_n_basis_functions(), libMesh::RBConstruction::get_Nmax(), libMesh::RBParametrized::get_parameters(), libMesh::RBConstruction::get_rb_evaluation(), libMesh::RBEvaluation::greedy_param_list, libMesh::out, libMesh::Real, and libMesh::RBConstruction::rel_training_tolerance.

Referenced by libMesh::TransientRBConstruction::greedy_termination_test(), and libMesh::RBConstruction::train_reduced_basis().

◆ has_variable()

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

Definition at line 1225 of file system.C.

1226 {
1227  return _variable_numbers.count(var);
1228 }

References libMesh::System::_variable_numbers.

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

◆ have_matrix()

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

Definition at line 439 of file implicit_system.h.

440 {
441  return (_matrices.count(mat_name));
442 }

References libMesh::ImplicitSystem::_matrices.

Referenced by libMesh::ImplicitSystem::add_matrix(), and libMesh::EigenTimeSolver::init().

◆ have_vector()

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

Definition at line 2275 of file system.h.

2276 {
2277  return (_vectors.count(vec_name));
2278 }

References libMesh::System::_vectors.

Referenced by libMesh::System::add_vector().

◆ 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 1712 of file system.h.

1712 { return _hide_output; }

References libMesh::System::_hide_output.

◆ 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 2251 of file system.h.

2252 {
2254 }

References libMesh::System::_identify_variable_groups.

Referenced by libMesh::System::add_variable().

◆ identify_variable_groups() [2/2]

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

Toggle automatic VariableGroup identification.

Definition at line 2259 of file system.h.

2260 {
2262 }

References libMesh::System::_identify_variable_groups.

◆ increment_constructor_count() [1/2]

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

Increments the construction counter.

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

Definition at line 181 of file reference_counter.h.

182 {
183  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
184  std::pair<unsigned int, unsigned int> & p = _counts[name];
185 
186  p.first++;
187 }

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

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

◆ increment_constructor_count() [2/2]

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

Increments the construction counter.

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

Definition at line 181 of file reference_counter.h.

182 {
183  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
184  std::pair<unsigned int, unsigned int> & p = _counts[name];
185 
186  p.first++;
187 }

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

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

◆ increment_destructor_count() [1/2]

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

Increments the destruction counter.

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

Definition at line 194 of file reference_counter.h.

195 {
196  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
197  std::pair<unsigned int, unsigned int> & p = _counts[name];
198 
199  p.second++;
200 }

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

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

◆ increment_destructor_count() [2/2]

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

Increments the destruction counter.

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

Definition at line 194 of file reference_counter.h.

195 {
196  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
197  std::pair<unsigned int, unsigned int> & p = _counts[name];
198 
199  p.second++;
200 }

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

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

◆ init()

void libMesh::System::init ( )
inherited

Initializes degrees of freedom on the current mesh.

Sets the

Definition at line 237 of file system.C.

238 {
239  // Calling init() twice on the same system currently works evil
240  // magic, whether done directly or via EquationSystems::read()
241  libmesh_assert(!this->is_initialized());
242 
243  // First initialize any required data:
244  // either only the basic System data
245  if (_basic_system_only)
247  // or all the derived class' data too
248  else
249  this->init_data();
250 
251  // If no variables have been added to this system
252  // don't do anything
253  if (!this->n_vars())
254  return;
255 
256  // Then call the user-provided initialization function
257  this->user_initialization();
258 }

References libMesh::System::_basic_system_only, libMesh::System::init_data(), libMesh::System::is_initialized(), libMesh::libmesh_assert(), libMesh::System::n_vars(), and libMesh::System::user_initialization().

◆ init_context()

virtual void ElasticityRBConstruction::init_context ( FEMContext c)
inlinevirtual

Pre-request all relevant element data.

Reimplemented from libMesh::RBConstruction.

Definition at line 106 of file rb_classes.h.

107  {
108  // For efficiency, we should prerequest all
109  // the data we will need to build the
110  // linear system before doing an element loop.
111  FEBase * elem_fe = nullptr;
112  c.get_element_fe(u_var, elem_fe);
113 
114  elem_fe->get_JxW();
115  elem_fe->get_phi();
116  elem_fe->get_dphi();
117  }

References libMesh::FEGenericBase< OutputType >::get_dphi(), libMesh::FEMContext::get_element_fe(), libMesh::FEAbstract::get_JxW(), and libMesh::FEGenericBase< OutputType >::get_phi().

◆ init_data()

virtual void ElasticityRBConstruction::init_data ( )
inlinevirtual

Initialize data structures.

Reimplemented from libMesh::RBConstructionBase< LinearImplicitSystem >.

Definition at line 76 of file rb_classes.h.

77  {
78  u_var = this->add_variable("u", FIRST);
79  v_var = this->add_variable("v", FIRST);
80  w_var = this->add_variable("w", FIRST);
81 
82  // Generate a DirichletBoundary object
84 
85  // Set the Dirichlet boundary condition
86  dirichlet_bc->b.insert(BOUNDARY_ID_MIN_X); // Dirichlet boundary at x=0
87  dirichlet_bc->variables.push_back(u_var);
88  dirichlet_bc->variables.push_back(v_var);
89  dirichlet_bc->variables.push_back(w_var);
90 
91  // Attach dirichlet_bc (must do this _before_ Parent::init_data)
93 
95 
96  // Set the rb_assembly_expansion for this Construction object
98 
99  // We need to define an inner product matrix for this problem
101  }

References libMesh::FIRST.

◆ init_matrices()

void libMesh::ImplicitSystem::init_matrices ( )
protectedvirtualinherited

Initializes the matrices associated with this system.

Definition at line 105 of file implicit_system.C.

106 {
108 
109  // Check for quick return in case the system matrix
110  // (and by extension all the matrices) has already
111  // been initialized
112  if (matrix->initialized())
113  return;
114 
115  // Get a reference to the DofMap
116  DofMap & dof_map = this->get_dof_map();
117 
118  // no chance to add other matrices
119  _can_add_matrices = false;
120 
121  // Tell the matrices about the dof map, and vice versa
122  for (auto & pr : _matrices)
123  {
124  SparseMatrix<Number> & m = *(pr.second);
125  libmesh_assert (!m.initialized());
126 
127  // We want to allow repeated init() on systems, but we don't
128  // want to attach the same matrix to the DofMap twice
129  if (!dof_map.is_attached(m))
130  dof_map.attach_matrix (m);
131  }
132 
133  // Compute the sparsity pattern for the current
134  // mesh and DOF distribution. This also updates
135  // additional matrices, \p DofMap now knows them
136  dof_map.compute_sparsity (this->get_mesh());
137 
138  // Initialize matrices
139  for (auto & pr : _matrices)
140  pr.second->init ();
141 
142  // Set the additional matrices to 0.
143  for (auto & pr : _matrices)
144  pr.second->zero ();
145 }

References libMesh::ImplicitSystem::_can_add_matrices, libMesh::ImplicitSystem::_matrices, 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::ImplicitSystem::matrix.

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

◆ 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.

Definition at line 60 of file rb_parametrized.C.

63 {
64  // Check that the min/max vectors are valid
65  {
66  const std::string err_string = "Error: Invalid mu_min/mu_max in RBParameters constructor.";
67  bool valid_min_max = (mu_min_in.n_parameters() == mu_max_in.n_parameters());
68  if (!valid_min_max)
69  libmesh_error_msg(err_string);
70 
71  else
72  {
73  for (const auto & pr : mu_min_in)
74  {
75  const std::string & param_name = pr.first;
76  if (mu_min_in.get_value(param_name) > mu_max_in.get_value(param_name))
77  libmesh_error_msg(err_string);
78  }
79  }
80  }
81 
82  parameters_min = mu_min_in;
83  parameters_max = mu_max_in;
84 
85  // Add in min/max values due to the discrete parameters
86  for (const auto & pr : discrete_parameter_values)
87  {
88  if (pr.second.empty())
89  libmesh_error_msg("Error: List of discrete parameters for " << pr.first << " is empty.");
90 
91  Real min_val = *std::min_element(pr.second.begin(), pr.second.end());
92  Real max_val = *std::max_element(pr.second.begin(), pr.second.end());
93 
94  libmesh_assert_less_equal(min_val,max_val);
95 
96  parameters_min.set_value(pr.first, min_val);
97  parameters_max.set_value(pr.first, max_val);
98  }
99 
100  _discrete_parameter_values = discrete_parameter_values;
101 
102  parameters_initialized = true;
103 
104  // Initialize the current parameters to parameters_min
106 }

References libMesh::RBParametrized::_discrete_parameter_values, libMesh::RBParameters::get_value(), libMesh::RBParameters::n_parameters(), 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::RBEIMConstruction::initialize_parametrized_functions_in_training_set(), libMesh::RBDataDeserialization::load_parameter_ranges(), libMesh::RBSCMConstruction::perform_SCM_greedy(), libMesh::RBSCMConstruction::process_parameters_file(), libMesh::RBParametrized::read_parameter_data_from_files(), libMesh::RBConstruction::set_rb_construction_parameters(), and libMesh::RBConstruction::train_reduced_basis().

◆ 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 108 of file rb_parametrized.C.

109 {
110  initialize_parameters(rb_parametrized.get_parameters_min(),
111  rb_parametrized.get_parameters_max(),
112  rb_parametrized.get_discrete_parameter_values());
113 }

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

◆ initialize_rb_construction()

void libMesh::RBConstruction::initialize_rb_construction ( bool  skip_matrix_assembly = false,
bool  skip_vector_assembly = false 
)
virtualinherited

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.

We can optionally skip the matrix or vector assembly steps by setting skip_matrix_assembly = true, or skip_vector_assembly = true, respectively.

Reimplemented in libMesh::RBEIMConstruction, and libMesh::TransientRBConstruction.

Definition at line 419 of file rb_construction.C.

421 {
422  if (!skip_matrix_assembly && !skip_vector_assembly)
423  {
424  // Check that the theta and assembly objects are consistently sized
425  libmesh_assert_equal_to (get_rb_theta_expansion().get_n_A_terms(), get_rb_assembly_expansion().get_n_A_terms());
426  libmesh_assert_equal_to (get_rb_theta_expansion().get_n_F_terms(), get_rb_assembly_expansion().get_n_F_terms());
427  libmesh_assert_equal_to (get_rb_theta_expansion().get_n_outputs(), get_rb_assembly_expansion().get_n_outputs());
428  for (unsigned int i=0; i<get_rb_theta_expansion().get_n_outputs(); i++)
429  {
430  libmesh_assert_equal_to (get_rb_theta_expansion().get_n_output_terms(i),
431  get_rb_assembly_expansion().get_n_output_terms(i));
432  }
433  }
434 
435  // Perform the initialization
437  assemble_affine_expansion(skip_matrix_assembly, skip_vector_assembly);
438 
439  // inner_product_solver performs solves with the same matrix every time
440  // hence we can set reuse_preconditioner(true).
441  inner_product_solver->reuse_preconditioner(true);
442 
443  // The primary solver is used for truth solves and other solves that
444  // require different matrices, so set reuse_preconditioner(false).
446 
447 }

References libMesh::RBConstruction::allocate_data_structures(), libMesh::RBConstruction::assemble_affine_expansion(), libMesh::LinearImplicitSystem::get_linear_solver(), libMesh::RBThetaExpansion::get_n_outputs(), libMesh::RBConstruction::get_rb_assembly_expansion(), libMesh::RBConstruction::get_rb_theta_expansion(), libMesh::RBConstruction::inner_product_solver, and libMesh::LinearSolver< T >::reuse_preconditioner().

Referenced by libMesh::TransientRBConstruction::initialize_rb_construction(), libMesh::RBEIMConstruction::initialize_rb_construction(), and main().

◆ initialize_training_parameters()

void libMesh::RBConstructionBase< LinearImplicitSystem >::initialize_training_parameters ( const RBParameters mu_min,
const RBParameters mu_max,
unsigned int  n_training_parameters,
std::map< std::string, bool >  log_param_scale,
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.

Definition at line 181 of file rb_construction_base.C.

186 {
187  if(!is_quiet())
188  {
189  // Print out some info about the training set initialization
190  libMesh::out << "Initializing training parameters with "
191  << (deterministic ? "deterministic " : "random " )
192  << "training set..." << std::endl;
193 
194  for (const auto & pr : log_param_scale)
195  libMesh::out << "Parameter "
196  << pr.first
197  << ": log scaling = "
198  << pr.second
199  << std::endl;
200 
201  libMesh::out << std::endl;
202  }
203 
204  if (deterministic)
205  {
207  log_param_scale,
209  n_training_samples,
210  mu_min,
211  mu_max,
213  }
214  else
215  {
216  // Generate random training samples for all parameters
218  log_param_scale,
220  n_training_samples,
221  mu_min,
222  mu_max,
225  }
226 
227  // For each parameter that only allows discrete values, we "snap" to the nearest
228  // allowable discrete value
229  if (get_n_discrete_params() > 0)
230  {
231  for (const auto & pr : training_parameters)
232  {
233  const std::string & param_name = pr.first;
234  if (is_discrete_parameter(param_name))
235  {
236  std::vector<Real> discrete_values =
237  get_discrete_parameter_values().find(param_name)->second;
238 
239  NumericVector<Number> * training_vector = pr.second.get();
240 
241  for (numeric_index_type index=training_vector->first_local_index();
242  index<training_vector->last_local_index();
243  index++)
244  {
245  Real value = libmesh_real((*training_vector)(index));
246  Real nearest_discrete_value = get_closest_value(value, discrete_values);
247  training_vector->set(index, nearest_discrete_value);
248  }
249  }
250  }
251  }
252 
254 }

◆ is_adjoint_already_solved()

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

◆ is_discrete_parameter()

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

Is parameter mu_name discrete?

Definition at line 373 of file rb_parametrized.C.

374 {
376  libmesh_error_msg("Error: parameters not initialized in RBParametrized::is_discrete_parameter");
377 
378  return (_discrete_parameter_values.find(mu_name) != _discrete_parameter_values.end());
379 }

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

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

◆ is_initialized()

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

Definition at line 2139 of file system.h.

2140 {
2141  return _is_initialized;
2142 }

References libMesh::System::_is_initialized.

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

◆ is_quiet()

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

Is the system in quiet mode?

Definition at line 98 of file rb_construction_base.h.

99  { return this->quiet_mode; }

◆ 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 183 of file rb_construction.C.

184 {
185  return (rb_eval != nullptr);
186 }

References libMesh::RBConstruction::rb_eval.

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

◆ is_value_in_list()

bool libMesh::RBParametrized::is_value_in_list ( Real  value,
const std::vector< Real > &  list_of_values,
Real  tol 
)
staticprivateinherited

Helper function to check if the specified value is in the list of values (within a tolerance given by tol).

Definition at line 453 of file rb_parametrized.C.

454 {
455  Real closest_value = get_closest_value(value, list_of_values);
456 
457  // Check if relative tolerance is satisfied
458  Real rel_error = std::abs(value - closest_value) / std::abs(value);
459  if (rel_error <= tol)
460  {
461  return true;
462  }
463 
464  // If relative tolerance isn't satisfied, we should still check an absolute
465  // error, since relative tolerance can be misleading if value is close to zero
466  Real abs_error = std::abs(value - closest_value);
467  return (abs_error <= tol);
468 }

References std::abs(), libMesh::RBParametrized::get_closest_value(), libMesh::Real, and value.

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

◆ load_basis_function()

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

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

Reimplemented in libMesh::RBEIMConstruction.

Definition at line 1305 of file rb_construction.C.

1306 {
1307  LOG_SCOPE("load_basis_function()", "RBConstruction");
1308 
1309  libmesh_assert_less (i, get_rb_evaluation().get_n_basis_functions());
1310 
1312 
1313  this->update();
1314 }

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

Referenced by main().

◆ load_rb_solution()

void libMesh::RBConstruction::load_rb_solution ( )
virtualinherited

Load the RB solution from the most recent solve with rb_eval into this system's solution vector.

Reimplemented in libMesh::TransientRBConstruction, and libMesh::RBEIMConstruction.

Definition at line 1800 of file rb_construction.C.

1801 {
1802  LOG_SCOPE("load_rb_solution()", "RBConstruction");
1803 
1804  solution->zero();
1805 
1806  if (get_rb_evaluation().RB_solution.size() > get_rb_evaluation().get_n_basis_functions())
1807  libmesh_error_msg("ERROR: System contains " << get_rb_evaluation().get_n_basis_functions() << " basis functions." \
1808  << " RB_solution vector constains " << get_rb_evaluation().RB_solution.size() << " entries." \
1809  << " RB_solution in RBConstruction::load_rb_solution is too long!");
1810 
1811  for (auto i : IntRange<unsigned int>(0, get_rb_evaluation().RB_solution.size()))
1812  solution->add(get_rb_evaluation().RB_solution(i), get_rb_evaluation().get_basis_function(i));
1813 
1814  update();
1815 }

References libMesh::RBEvaluation::get_n_basis_functions(), libMesh::RBConstruction::get_rb_evaluation(), libMesh::RBEvaluation::RB_solution, libMesh::DenseVector< T >::size(), libMesh::System::solution, and libMesh::System::update().

Referenced by main().

◆ load_training_set()

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

Overwrite the training parameters with new_training_set.

Definition at line 257 of file rb_construction_base.C.

258 {
259  // First, make sure that an initial training set has already been
260  // generated
262  libmesh_error_msg("Error: load_training_set cannot be used to initialize parameters");
263 
264  // Make sure that the training set has the correct number of parameters
265  if (new_training_set.size() != get_n_params())
266  libmesh_error_msg("Error: Incorrect number of parameters in load_training_set.");
267 
268  // Delete the training set vectors (but don't remove the existing keys!)
269  for (auto & pr : training_parameters)
270  pr.second.reset(nullptr);
271 
272  // Get the number of local and global training parameters
273  numeric_index_type n_local_training_samples =
274  cast_int<numeric_index_type>(new_training_set.begin()->second.size());
275  numeric_index_type n_global_training_samples = n_local_training_samples;
276  this->comm().sum(n_global_training_samples);
277 
278  for (auto & pr : training_parameters)
279  {
280  pr.second = NumericVector<Number>::build(this->comm());
281  pr.second->init(n_global_training_samples, n_local_training_samples, false, PARALLEL);
282  }
283 
284  for (auto & pr : training_parameters)
285  {
286  const std::string & param_name = pr.first;
287  NumericVector<Number> * training_vector = pr.second.get();
288 
289  numeric_index_type first_index = training_vector->first_local_index();
290  for (numeric_index_type i=0; i<n_local_training_samples; i++)
291  {
292  numeric_index_type index = first_index + i;
293  training_vector->set(index, new_training_set[param_name][i]);
294  }
295  }
296 }

◆ 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 1259 of file system.C.

1261 {
1262  // Make sure the set is clear
1263  var_indices.clear();
1264 
1265  std::vector<dof_id_type> dof_indices;
1266 
1267  const dof_id_type
1268  first_local = this->get_dof_map().first_dof(),
1269  end_local = this->get_dof_map().end_dof();
1270 
1271  // Begin the loop over the elements
1272  for (const auto & elem : this->get_mesh().active_local_element_ptr_range())
1273  {
1274  this->get_dof_map().dof_indices (elem, dof_indices, var);
1275 
1276  for (dof_id_type dof : dof_indices)
1277  //If the dof is owned by the local processor
1278  if (first_local <= dof && dof < end_local)
1279  var_indices.insert(dof);
1280  }
1281 
1282  // we may have missed assigning DOFs to nodes that we own
1283  // but to which we have no connected elements matching our
1284  // variable restriction criterion. this will happen, for example,
1285  // if variable V is restricted to subdomain S. We may not own
1286  // any elements which live in S, but we may own nodes which are
1287  // *connected* to elements which do.
1288  for (const auto & node : this->get_mesh().local_node_ptr_range())
1289  {
1290  libmesh_assert(node);
1291  this->get_dof_map().dof_indices (node, dof_indices, var);
1292  for (auto dof : dof_indices)
1293  if (first_local <= dof && dof < end_local)
1294  var_indices.insert(dof);
1295  }
1296 }

References libMesh::DofMap::dof_indices(), libMesh::DofMap::end_dof(), libMesh::DofMap::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().

◆ 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 2267 of file system.h.

2268 {
2269  return this->n_dofs() - this->n_constrained_dofs();
2270 }

References libMesh::System::n_constrained_dofs(), and libMesh::System::n_dofs().

◆ 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 2171 of file system.h.

2172 {
2173  if (_variables.empty())
2174  return 0;
2175 
2176  const Variable & last = _variables.back();
2177  return last.first_scalar_number() + last.n_components();
2178 }

References libMesh::System::_variables, libMesh::Variable::first_scalar_number(), and libMesh::Variable::n_components().

Referenced by libMesh::System::add_variables().

◆ 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 157 of file system.C.

158 {
159 #ifdef LIBMESH_ENABLE_CONSTRAINTS
160 
161  return _dof_map->n_constrained_dofs();
162 
163 #else
164 
165  return 0;
166 
167 #endif
168 }

References libMesh::System::_dof_map.

Referenced by libMesh::System::get_info(), libMesh::System::n_active_dofs(), and BoundaryInfoTest::testShellFaceConstraints().

◆ n_dofs()

dof_id_type libMesh::System::n_dofs ( ) const
inherited
Returns
The number of degrees of freedom in the system

Definition at line 150 of file system.C.

151 {
152  return _dof_map->n_dofs();
153 }

References libMesh::System::_dof_map.

Referenced by libMesh::TransientRBConstruction::add_IC_to_RB_space(), libMesh::System::add_vector(), libMesh::TransientRBConstruction::allocate_data_structures(), libMesh::RBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::TransientRBConstruction::enrich_RB_space(), libMesh::RBConstruction::enrich_RB_space(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::System::get_info(), libMesh::SecondOrderUnsteadySolver::init_data(), libMesh::UnsteadySolver::init_data(), libMesh::System::init_data(), libMesh::RBEIMConstruction::init_dof_map_between_systems(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::RBEIMConstruction::initialize_rb_construction(), main(), libMesh::TransientRBConstruction::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::RBEIMAssembly::RBEIMAssembly(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::System::read_legacy_data(), libMesh::TransientRBConstruction::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(), libMesh::TransientRBConstruction::set_error_temporal_data(), libMesh::RBEIMConstruction::set_explicit_sys_subvector(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), SystemsTest::testProjectCubeWithMeshFunction(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::RBEIMConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_RB_system_matrices(), libMesh::RBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_residual_terms(), and libMesh::RBConstruction::update_residual_terms().

◆ n_linear_iterations()

unsigned int libMesh::LinearImplicitSystem::n_linear_iterations ( ) const
inlineinherited

◆ 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 172 of file system.C.

173 {
174 #ifdef LIBMESH_ENABLE_CONSTRAINTS
175 
176  return _dof_map->n_local_constrained_dofs();
177 
178 #else
179 
180  return 0;
181 
182 #endif
183 }

References libMesh::System::_dof_map.

Referenced by libMesh::System::get_info().

◆ 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 187 of file system.C.

188 {
189  return _dof_map->n_dofs_on_processor (this->processor_id());
190 }

References libMesh::System::_dof_map, and libMesh::ParallelObject::processor_id().

Referenced by libMesh::TransientRBConstruction::add_IC_to_RB_space(), libMesh::System::add_vector(), libMesh::TransientRBConstruction::allocate_data_structures(), libMesh::RBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::PetscDMWrapper::build_section(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::TransientRBConstruction::enrich_RB_space(), libMesh::RBConstruction::enrich_RB_space(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::System::get_info(), libMesh::SecondOrderUnsteadySolver::init_data(), libMesh::UnsteadySolver::init_data(), libMesh::System::init_data(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::RBEIMConstruction::initialize_rb_construction(), main(), libMesh::TransientRBConstruction::mass_matrix_scaled_matvec(), libMesh::RBEIMAssembly::RBEIMAssembly(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::TransientRBConstruction::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(), libMesh::TransientRBConstruction::set_error_temporal_data(), MeshFunctionTest::test_p_level(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::TransientRBConstruction::update_RB_system_matrices(), libMesh::RBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_residual_terms(), and libMesh::RBConstruction::update_residual_terms().

◆ n_matrices()

unsigned int libMesh::ImplicitSystem::n_matrices ( ) const
inlineoverridevirtualinherited
Returns
The number of matrices handled by this system

Reimplemented from libMesh::System.

Definition at line 446 of file implicit_system.h.

447 {
448  return cast_int<unsigned int>(_matrices.size());
449 }

References libMesh::ImplicitSystem::_matrices.

◆ 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 83 of file reference_counter.h.

84  { return _n_objects; }

References libMesh::ReferenceCounter::_n_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 83 of file reference_counter.h.

84  { return _n_objects; }

References libMesh::ReferenceCounter::_n_objects.

◆ n_processors()

processor_id_type libMesh::ParallelObject::n_processors ( ) const
inlineinherited
Returns
The number of processors in the group.

Definition at line 100 of file parallel_object.h.

101  { return cast_int<processor_id_type>(_communicator.size()); }

References libMesh::ParallelObject::_communicator.

Referenced by 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::LaplaceMeshSmoother::allgather_graph(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::FEMSystem::assembly(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::DistributedMesh::clear(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::EnsightIO::EnsightIO(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::Nemesis_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::partition(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::DofMap::prepare_send_list(), 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(), OverlappingFunctorTest::run_partitioner_test(), libMesh::DofMap::scatter_constraints(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), CheckpointIOTest::testSplitter(), WriteVecAndScalar::testWrite(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::VTKIO::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().

◆ n_qois()

unsigned int libMesh::System::n_qois ( ) const
inlineinherited

◆ 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 2163 of file system.h.

2164 {
2165  return cast_int<unsigned int>(_variable_groups.size());
2166 }

References libMesh::System::_variable_groups.

Referenced by libMesh::System::add_variable(), libMesh::FEMSystem::assembly(), libMesh::System::get_info(), and libMesh::System::init_data().

◆ n_vars()

unsigned int libMesh::System::n_vars ( ) const
inlineinherited
Returns
The number of variables in the system

Definition at line 2155 of file system.h.

2156 {
2157  return cast_int<unsigned int>(_variables.size());
2158 }

References libMesh::System::_variables.

Referenced by 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::FEMContext::attach_quadrature_rules(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::PetscDMWrapper::build_section(), libMesh::System::calculate_norm(), LinearElasticityWithContact::compute_stresses(), LinearElasticity::compute_stresses(), compute_stresses(), LargeDeformationElasticity::compute_stresses(), libMesh::DGFEMContext::DGFEMContext(), libMesh::DiffContext::DiffContext(), libMesh::RBEIMConstruction::enrich_RB_space(), 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::System::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::FEMSystem::init_context(), libMesh::RBEIMConstruction::init_context_with_sys(), libMesh::RBEIMConstruction::init_dof_map_between_systems(), libMesh::FEMContext::init_internal_data(), libMesh::DifferentiablePhysics::init_physics(), AssemblyA0::interior_assembly(), AssemblyA1::interior_assembly(), AssemblyA2::interior_assembly(), main(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), output_norms(), libMesh::petsc_auto_fieldsplit(), libMesh::FEMContext::pre_fe_reinit(), 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::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::RBEIMConstruction::truth_solve(), libMesh::RBEIMConstruction::update_RB_system_matrices(), 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().

◆ 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 2283 of file system.h.

2284 {
2285  return cast_int<unsigned int>(_vectors.size());
2286 }

References libMesh::System::_vectors.

Referenced by libMesh::ExplicitSystem::add_system_rhs(), libMesh::System::compare(), libMesh::System::get_info(), main(), and libMesh::System::write_header().

◆ name()

const std::string & libMesh::System::name ( ) const
inlineinherited

◆ number()

unsigned int libMesh::System::number ( ) const
inlineinherited

◆ 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 2100 of file system.C.

2104 {
2105  // This function must be called on every processor; there's no
2106  // telling where in the partition p falls.
2107  parallel_object_only();
2108 
2109  // And every processor had better agree about which point we're
2110  // looking for
2111 #ifndef NDEBUG
2112  libmesh_assert(this->comm().verify(p(0)));
2113 #if LIBMESH_DIM > 1
2114  libmesh_assert(this->comm().verify(p(1)));
2115 #endif
2116 #if LIBMESH_DIM > 2
2117  libmesh_assert(this->comm().verify(p(2)));
2118 #endif
2119 #endif // NDEBUG
2120 
2121  // Get a reference to the mesh object associated with the system object that calls this function
2122  const MeshBase & mesh = this->get_mesh();
2123 
2124  // Use an existing PointLocator or create a new one
2125  std::unique_ptr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2126  PointLocatorBase & locator = *locator_ptr;
2127 
2128  if (!insist_on_success || !mesh.is_serial())
2129  locator.enable_out_of_mesh_mode();
2130 
2131  // Get a pointer to an element that contains p and allows us to
2132  // evaluate var
2133  const std::set<subdomain_id_type> & raw_subdomains =
2134  this->variable(var).active_subdomains();
2135  const std::set<subdomain_id_type> * implicit_subdomains =
2136  raw_subdomains.empty() ? nullptr : &raw_subdomains;
2137  const Elem * e = locator(p, implicit_subdomains);
2138 
2139  Gradient grad_u;
2140 
2141  if (e && this->get_dof_map().is_evaluable(*e, var))
2142  grad_u = point_gradient(var, p, *e, sol);
2143 
2144  // If I have an element containing p, then let's let everyone know
2145  processor_id_type lowest_owner =
2146  (e && (e->processor_id() == this->processor_id())) ?
2147  this->processor_id() : this->n_processors();
2148  this->comm().min(lowest_owner);
2149 
2150  // Everybody should get their value from a processor that was able
2151  // to compute it.
2152  // If nobody admits owning the point, we may have a problem.
2153  if (lowest_owner != this->n_processors())
2154  this->comm().broadcast(grad_u, lowest_owner);
2155  else
2156  libmesh_assert(!insist_on_success);
2157 
2158  return grad_u;
2159 }

References libMesh::Variable::active_subdomains(), libMesh::ParallelObject::comm(), libMesh::PointLocatorBase::enable_out_of_mesh_mode(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::libmesh_assert(), mesh, 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().

◆ 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 2162 of file system.C.

2166 {
2167  // Ensuring that the given point is really in the element is an
2168  // expensive assert, but as long as debugging is turned on we might
2169  // as well try to catch a particularly nasty potential error
2170  libmesh_assert (e.contains_point(p));
2171 
2172  if (!sol)
2173  sol = this->current_local_solution.get();
2174 
2175  // Get the dof map to get the proper indices for our computation
2176  const DofMap & dof_map = this->get_dof_map();
2177 
2178  // write the element dimension into a separate variable.
2179  const unsigned int dim = e.dim();
2180 
2181  // Make sure we can evaluate on this element.
2182  libmesh_assert (dof_map.is_evaluable(e, var));
2183 
2184  // Need dof_indices for phi[i][j]
2185  std::vector<dof_id_type> dof_indices;
2186 
2187  // Fill in the dof_indices for our element
2188  dof_map.dof_indices (&e, dof_indices, var);
2189 
2190  // Get the no of dofs associated with this point
2191  const unsigned int num_dofs = cast_int<unsigned int>
2192  (dof_indices.size());
2193 
2194  FEType fe_type = dof_map.variable_type(var);
2195 
2196  // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h.
2197  Point coor = FEMap::inverse_map(dim, &e, p);
2198 
2199  // get the shape function value via the FEInterface to also handle the case
2200  // of infinite elements correcly, the shape function is not fe->phi().
2201  FEComputeData fe_data(this->get_equation_systems(), coor);
2202  fe_data.enable_derivative();
2203  FEInterface::compute_data(dim, fe_type, &e, fe_data);
2204 
2205  // Get ready to accumulate a gradient
2206  Gradient grad_u;
2207 
2208  for (unsigned int l=0; l<num_dofs; l++)
2209  {
2210  // Chartesian coordinates have allways LIBMESH_DIM entries,
2211  // local coordinates have as many coordinates as the element has.
2212  for (std::size_t v=0; v<dim; v++)
2213  for (std::size_t xyz=0; xyz<LIBMESH_DIM; xyz++)
2214  {
2215  // FIXME: this needs better syntax: It is matrix-vector multiplication.
2216  grad_u(xyz) += fe_data.local_transform[v][xyz]
2217  * fe_data.dshape[l](v)
2218  * (*sol)(dof_indices[l]);
2219  }
2220  }
2221 
2222  return grad_u;
2223 }

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().

◆ 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 2227 of file system.C.

2228 {
2229  libmesh_assert(e);
2230  return this->point_gradient(var, p, *e);
2231 }

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

◆ 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 2235 of file system.C.

2236 {
2237  return this->point_gradient(var, p, true, sol);
2238 }

References libMesh::System::point_gradient().

◆ 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 2244 of file system.C.

2248 {
2249  // This function must be called on every processor; there's no
2250  // telling where in the partition p falls.
2251  parallel_object_only();
2252 
2253  // And every processor had better agree about which point we're
2254  // looking for
2255 #ifndef NDEBUG
2256  libmesh_assert(this->comm().verify(p(0)));
2257 #if LIBMESH_DIM > 1
2258  libmesh_assert(this->comm().verify(p(1)));
2259 #endif
2260 #if LIBMESH_DIM > 2
2261  libmesh_assert(this->comm().verify(p(2)));
2262 #endif
2263 #endif // NDEBUG
2264 
2265  // Get a reference to the mesh object associated with the system object that calls this function
2266  const MeshBase & mesh = this->get_mesh();
2267 
2268  // Use an existing PointLocator or create a new one
2269  std::unique_ptr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2270  PointLocatorBase & locator = *locator_ptr;
2271 
2272  if (!insist_on_success || !mesh.is_serial())
2273  locator.enable_out_of_mesh_mode();
2274 
2275  // Get a pointer to an element that contains p and allows us to
2276  // evaluate var
2277  const std::set<subdomain_id_type> & raw_subdomains =
2278  this->variable(var).active_subdomains();
2279  const std::set<subdomain_id_type> * implicit_subdomains =
2280  raw_subdomains.empty() ? nullptr : &raw_subdomains;
2281  const Elem * e = locator(p, implicit_subdomains);
2282 
2283  Tensor hess_u;
2284 
2285  if (e && this->get_dof_map().is_evaluable(*e, var))
2286  hess_u = point_hessian(var, p, *e, sol);
2287 
2288  // If I have an element containing p, then let's let everyone know
2289  processor_id_type lowest_owner =
2290  (e && (e->processor_id() == this->processor_id())) ?
2291  this->processor_id() : this->n_processors();
2292  this->comm().min(lowest_owner);
2293 
2294  // Everybody should get their value from a processor that was able
2295  // to compute it.
2296  // If nobody admits owning the point, we may have a problem.
2297  if (lowest_owner != this->n_processors())
2298  this->comm().broadcast(hess_u, lowest_owner);
2299  else
2300  libmesh_assert(!insist_on_success);
2301 
2302  return hess_u;
2303 }

References libMesh::Variable::active_subdomains(), libMesh::ParallelObject::comm(), libMesh::PointLocatorBase::enable_out_of_mesh_mode(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::libmesh_assert(), mesh, libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), and libMesh::System::variable().

Referenced by libMesh::System::point_hessian().

◆ 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 2305 of file system.C.

2309 {
2310  // Ensuring that the given point is really in the element is an
2311  // expensive assert, but as long as debugging is turned on we might
2312  // as well try to catch a particularly nasty potential error
2313  libmesh_assert (e.contains_point(p));
2314 
2315  if (!sol)
2316  sol = this->current_local_solution.get();
2317 
2318 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
2319  if (e.infinite())
2320  libmesh_not_implemented();
2321 #endif
2322 
2323  // Get the dof map to get the proper indices for our computation
2324  const DofMap & dof_map = this->get_dof_map();
2325 
2326  // Make sure we can evaluate on this element.
2327  libmesh_assert (dof_map.is_evaluable(e, var));
2328 
2329  // Need dof_indices for phi[i][j]
2330  std::vector<dof_id_type> dof_indices;
2331 
2332  // Fill in the dof_indices for our element
2333  dof_map.dof_indices (&e, dof_indices, var);
2334 
2335  // Get the no of dofs associated with this point
2336  const unsigned int num_dofs = cast_int<unsigned int>
2337  (dof_indices.size());
2338 
2339  FEType fe_type = dof_map.variable_type(var);
2340 
2341  // Build a FE again so we can calculate u(p)
2342  std::unique_ptr<FEBase> fe (FEBase::build(e.dim(), fe_type));
2343 
2344  // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h
2345  // Build a vector of point co-ordinates to send to reinit
2346  std::vector<Point> coor(1, FEMap::inverse_map(e.dim(), &e, p));
2347 
2348  // Get the values of the shape function derivatives
2349  const std::vector<std::vector<RealTensor>> & d2phi = fe->get_d2phi();
2350 
2351  // Reinitialize the element and compute the shape function values at coor
2352  fe->reinit (&e, &coor);
2353 
2354  // Get ready to accumulate a hessian
2355  Tensor hess_u;
2356 
2357  for (unsigned int l=0; l<num_dofs; l++)
2358  {
2359  hess_u.add_scaled (d2phi[l][0], (*sol)(dof_indices[l]));
2360  }
2361 
2362  return hess_u;
2363 }

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().

◆ 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 2367 of file system.C.

2368 {
2369  libmesh_assert(e);
2370  return this->point_hessian(var, p, *e);
2371 }

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

◆ 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 2375 of file system.C.

2376 {
2377  return this->point_hessian(var, p, true, sol);
2378 }

References libMesh::System::point_hessian().

◆ 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 1971 of file system.C.

1975 {
1976  // This function must be called on every processor; there's no
1977  // telling where in the partition p falls.
1978  parallel_object_only();
1979 
1980  // And every processor had better agree about which point we're
1981  // looking for
1982 #ifndef NDEBUG
1983  libmesh_assert(this->comm().verify(p(0)));
1984 #if LIBMESH_DIM > 1
1985  libmesh_assert(this->comm().verify(p(1)));
1986 #endif
1987 #if LIBMESH_DIM > 2
1988  libmesh_assert(this->comm().verify(p(2)));
1989 #endif
1990 #endif // NDEBUG
1991 
1992  // Get a reference to the mesh object associated with the system object that calls this function
1993  const MeshBase & mesh = this->get_mesh();
1994 
1995  // Use an existing PointLocator or create a new one
1996  std::unique_ptr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
1997  PointLocatorBase & locator = *locator_ptr;
1998 
1999  if (!insist_on_success || !mesh.is_serial())
2000  locator.enable_out_of_mesh_mode();
2001 
2002  // Get a pointer to an element that contains p and allows us to
2003  // evaluate var
2004  const std::set<subdomain_id_type> & raw_subdomains =
2005  this->variable(var).active_subdomains();
2006  const std::set<subdomain_id_type> * implicit_subdomains =
2007  raw_subdomains.empty() ? nullptr : &raw_subdomains;
2008  const Elem * e = locator(p, implicit_subdomains);
2009 
2010  Number u = 0;
2011 
2012  if (e && this->get_dof_map().is_evaluable(*e, var))
2013  u = point_value(var, p, *e, sol);
2014 
2015  // If I have an element containing p, then let's let everyone know
2016  processor_id_type lowest_owner =
2017  (e && (e->processor_id() == this->processor_id())) ?
2018  this->processor_id() : this->n_processors();
2019  this->comm().min(lowest_owner);
2020 
2021  // Everybody should get their value from a processor that was able
2022  // to compute it.
2023  // If nobody admits owning the point, we have a problem.
2024  if (lowest_owner != this->n_processors())
2025  this->comm().broadcast(u, lowest_owner);
2026  else
2027  libmesh_assert(!insist_on_success);
2028 
2029  return u;
2030 }

References libMesh::Variable::active_subdomains(), libMesh::ParallelObject::comm(), libMesh::PointLocatorBase::enable_out_of_mesh_mode(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::libmesh_assert(), mesh, 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(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), MeshInputTest::testExodusCopyElementSolution(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), SystemsTest::testProjectCubeWithMeshFunction(), and EquationSystemsTest::testRepartitionThenReinit().

◆ 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 2032 of file system.C.

2036 {
2037  // Ensuring that the given point is really in the element is an
2038  // expensive assert, but as long as debugging is turned on we might
2039  // as well try to catch a particularly nasty potential error
2040  libmesh_assert (e.contains_point(p));
2041 
2042  if (!sol)
2043  sol = this->current_local_solution.get();
2044 
2045  // Get the dof map to get the proper indices for our computation
2046  const DofMap & dof_map = this->get_dof_map();
2047 
2048  // Make sure we can evaluate on this element.
2049  libmesh_assert (dof_map.is_evaluable(e, var));
2050 
2051  // Need dof_indices for phi[i][j]
2052  std::vector<dof_id_type> dof_indices;
2053 
2054  // Fill in the dof_indices for our element
2055  dof_map.dof_indices (&e, dof_indices, var);
2056 
2057  // Get the no of dofs associated with this point
2058  const unsigned int num_dofs = cast_int<unsigned int>
2059  (dof_indices.size());
2060 
2061  FEType fe_type = dof_map.variable_type(var);
2062 
2063  // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h.
2064  Point coor = FEMap::inverse_map(e.dim(), &e, p);
2065 
2066  // get the shape function value via the FEInterface to also handle the case
2067  // of infinite elements correcly, the shape function is not fe->phi().
2068  FEComputeData fe_data(this->get_equation_systems(), coor);
2069  FEInterface::compute_data(e.dim(), fe_type, &e, fe_data);
2070 
2071  // Get ready to accumulate a value
2072  Number u = 0;
2073 
2074  for (unsigned int l=0; l<num_dofs; l++)
2075  {
2076  u += fe_data.shape[l] * (*sol)(dof_indices[l]);
2077  }
2078 
2079  return u;
2080 }

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().

◆ 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 2084 of file system.C.

2085 {
2086  libmesh_assert(e);
2087  return this->point_value(var, p, *e);
2088 }

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

◆ 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 2092 of file system.C.

2093 {
2094  return this->point_value(var, p, true, sol);
2095 }

References libMesh::System::point_value().

◆ 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 641 of file rb_construction.h.

641 {}

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

◆ 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 651 of file rb_construction.h.

651 {}

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

◆ print_basis_function_orthogonality()

void libMesh::RBConstruction::print_basis_function_orthogonality ( )
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 348 of file rb_construction.C.

349 {
350  std::unique_ptr<NumericVector<Number>> temp = solution->clone();
351 
352  for (unsigned int i=0; i<get_rb_evaluation().get_n_basis_functions(); i++)
353  {
354  for (unsigned int j=0; j<get_rb_evaluation().get_n_basis_functions(); j++)
355  {
357  Number value = temp->dot( get_rb_evaluation().get_basis_function(i) );
358 
359  libMesh::out << value << " ";
360  }
361  libMesh::out << std::endl;
362  }
363  libMesh::out << std::endl;
364 }

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().

◆ print_discrete_parameter_values()

void libMesh::RBParametrized::print_discrete_parameter_values ( ) const
inherited

Print out all the discrete parameter values.

Definition at line 389 of file rb_parametrized.C.

390 {
391  for (const auto & pr : get_discrete_parameter_values())
392  {
393  libMesh::out << "Discrete parameter " << pr.first << ", values: ";
394 
395  const std::vector<Real> & values = pr.second;
396  for (const auto & value : values)
397  libMesh::out << value << " ";
398  libMesh::out << std::endl;
399  }
400 }

References libMesh::RBParametrized::get_discrete_parameter_values(), libMesh::out, and value.

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

◆ print_info() [1/3]

void libMesh::RBConstruction::print_info ( )
virtualinherited

Print out info that describes the current setup of this RBConstruction.

Reimplemented in libMesh::TransientRBConstruction, and libMesh::RBEIMConstruction.

Definition at line 312 of file rb_construction.C.

313 {
314  // Print out info that describes the current setup
315  libMesh::out << std::endl << "RBConstruction parameters:" << std::endl;
316  libMesh::out << "system name: " << this->name() << std::endl;
317  libMesh::out << "Nmax: " << Nmax << std::endl;
318  libMesh::out << "Greedy relative error tolerance: " << get_rel_training_tolerance() << std::endl;
319  libMesh::out << "Greedy absolute error tolerance: " << get_abs_training_tolerance() << std::endl;
320  libMesh::out << "Do we normalize RB error bound in greedy? " << get_normalize_rb_bound_in_greedy() << std::endl;
322  {
323  libMesh::out << "Aq operators attached: " << get_rb_theta_expansion().get_n_A_terms() << std::endl;
324  libMesh::out << "Fq functions attached: " << get_rb_theta_expansion().get_n_F_terms() << std::endl;
325  libMesh::out << "n_outputs: " << get_rb_theta_expansion().get_n_outputs() << std::endl;
326  for (unsigned int n=0; n<get_rb_theta_expansion().get_n_outputs(); n++)
327  libMesh::out << "output " << n << ", Q_l = " << get_rb_theta_expansion().get_n_output_terms(n) << std::endl;
328  }
329  else
330  {
331  libMesh::out << "RBThetaExpansion member is not set yet" << std::endl;
332  }
333  libMesh::out << "Number of parameters: " << get_n_params() << std::endl;
334  for (const auto & pr : get_parameters())
335  if (!is_discrete_parameter(pr.first))
336  {
337  libMesh::out << "Parameter " << pr.first
338  << ": Min = " << get_parameter_min(pr.first)
339  << ", Max = " << get_parameter_max(pr.first) << std::endl;
340  }
341 
343  libMesh::out << "n_training_samples: " << get_n_training_samples() << std::endl;
344  libMesh::out << "quiet mode? " << is_quiet() << std::endl;
345  libMesh::out << std::endl;
346 }

References libMesh::RBConstruction::get_abs_training_tolerance(), libMesh::RBThetaExpansion::get_n_A_terms(), libMesh::RBThetaExpansion::get_n_F_terms(), libMesh::RBThetaExpansion::get_n_output_terms(), libMesh::RBThetaExpansion::get_n_outputs(), libMesh::RBParametrized::get_n_params(), libMesh::RBConstructionBase< LinearImplicitSystem >::get_n_training_samples(), libMesh::RBConstruction::get_normalize_rb_bound_in_greedy(), libMesh::RBParametrized::get_parameter_max(), libMesh::RBParametrized::get_parameter_min(), libMesh::RBParametrized::get_parameters(), libMesh::RBConstruction::get_rb_theta_expansion(), libMesh::RBConstruction::get_rel_training_tolerance(), libMesh::RBParametrized::is_discrete_parameter(), libMesh::RBConstructionBase< LinearImplicitSystem >::is_quiet(), libMesh::RBConstruction::is_rb_eval_initialized(), libMesh::System::name(), libMesh::RBConstruction::Nmax, libMesh::out, and libMesh::RBParametrized::print_discrete_parameter_values().

Referenced by main(), libMesh::RBEIMConstruction::print_info(), and libMesh::TransientRBConstruction::print_info().

◆ print_info() [2/3]

void libMesh::ReferenceCounter::print_info ( std::ostream &  out = libMesh::out)
staticinherited

Prints the reference information, by default to libMesh::out.

Definition at line 87 of file reference_counter.C.

88 {
90  out_stream << ReferenceCounter::get_info();
91 }

References libMesh::ReferenceCounter::_enable_print_counter, and libMesh::ReferenceCounter::get_info().

◆ print_info() [3/3]

void libMesh::ReferenceCounter::print_info ( std::ostream &  out = libMesh::out)
staticinherited

Prints the reference information, by default to libMesh::out.

Definition at line 87 of file reference_counter.C.

88 {
90  out_stream << ReferenceCounter::get_info();
91 }

References libMesh::ReferenceCounter::_enable_print_counter, and libMesh::ReferenceCounter::get_info().

◆ print_parameters()

void libMesh::RBParametrized::print_parameters ( ) const
inherited

Print the current parameters.

Definition at line 206 of file rb_parametrized.C.

207 {
209  libmesh_error_msg("Error: parameters not initialized in RBParametrized::print_current_parameters");
210 
211  get_parameters().print();
212 }

References libMesh::RBParametrized::get_parameters(), libMesh::RBParametrized::parameters_initialized, and libMesh::RBParameters::print().

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

◆ process_parameters_file()

void libMesh::RBConstruction::process_parameters_file ( const std::string &  parameters_filename)
virtualinherited

Read in from the file specified by parameters_filename and set the this system's member variables accordingly.

Reimplemented in libMesh::TransientRBConstruction, and libMesh::RBEIMConstruction.

Definition at line 193 of file rb_construction.C.

194 {
195  // First read in data from input_filename
196  GetPot infile(parameters_filename);
197 
198  const unsigned int n_training_samples = infile("n_training_samples",0);
199  const bool deterministic_training = infile("deterministic_training",false);
200  unsigned int training_parameters_random_seed_in =
201  static_cast<unsigned int>(-1);
202  training_parameters_random_seed_in = infile("training_parameters_random_seed",
203  training_parameters_random_seed_in);
204  const bool quiet_mode_in = infile("quiet_mode", quiet_mode);
205  const unsigned int Nmax_in = infile("Nmax", Nmax);
206  const Real rel_training_tolerance_in = infile("rel_training_tolerance",
208  const Real abs_training_tolerance_in = infile("abs_training_tolerance",
210 
211  // Initialize value to false, let the input file value override.
212  const bool normalize_rb_bound_in_greedy_in = infile("normalize_rb_bound_in_greedy",
213  false);
214 
215  // Read in the parameters from the input file too
216  unsigned int n_continuous_parameters = infile.vector_variable_size("parameter_names");
217  RBParameters mu_min_in;
218  RBParameters mu_max_in;
219  for (unsigned int i=0; i<n_continuous_parameters; i++)
220  {
221  // Read in the parameter names
222  std::string param_name = infile("parameter_names", "NONE", i);
223 
224  {
225  Real min_val = infile(param_name, 0., 0);
226  mu_min_in.set_value(param_name, min_val);
227  }
228 
229  {
230  Real max_val = infile(param_name, 0., 1);
231  mu_max_in.set_value(param_name, max_val);
232  }
233  }
234 
235  std::map<std::string, std::vector<Real>> discrete_parameter_values_in;
236 
237  unsigned int n_discrete_parameters = infile.vector_variable_size("discrete_parameter_names");
238  for (unsigned int i=0; i<n_discrete_parameters; i++)
239  {
240  std::string param_name = infile("discrete_parameter_names", "NONE", i);
241 
242  unsigned int n_vals_for_param = infile.vector_variable_size(param_name);
243  std::vector<Real> vals_for_param(n_vals_for_param);
244  for (auto j : IntRange<unsigned int>(0, vals_for_param.size()))
245  vals_for_param[j] = infile(param_name, 0., j);
246 
247  discrete_parameter_values_in[param_name] = vals_for_param;
248  }
249 
250  std::map<std::string,bool> log_scaling_in;
251  // For now, just set all entries to false.
252  // TODO: Implement a decent way to specify log-scaling true/false
253  // in the input text file
254  for (const auto & pr : mu_min_in)
255  log_scaling_in[pr.first] = false;
256 
257  // Set the parameters that have been read in
258  set_rb_construction_parameters(n_training_samples,
259  deterministic_training,
260  training_parameters_random_seed_in,
261  quiet_mode_in,
262  Nmax_in,
263  rel_training_tolerance_in,
264  abs_training_tolerance_in,
265  normalize_rb_bound_in_greedy_in,
266  mu_min_in,
267  mu_max_in,
268  discrete_parameter_values_in,
269  log_scaling_in);
270 }

References libMesh::RBConstruction::abs_training_tolerance, libMesh::RBConstruction::Nmax, libMesh::RBConstructionBase< LinearImplicitSystem >::quiet_mode, libMesh::Real, libMesh::RBConstruction::rel_training_tolerance, libMesh::RBConstruction::set_rb_construction_parameters(), and libMesh::RBParameters::set_value().

Referenced by main(), libMesh::RBEIMConstruction::process_parameters_file(), and libMesh::TransientRBConstruction::process_parameters_file().

◆ processor_id()

processor_id_type libMesh::ParallelObject::processor_id ( ) const
inlineinherited
Returns
The rank of this processor in the group.

Definition at line 106 of file parallel_object.h.

107  { return cast_int<processor_id_type>(_communicator.rank()); }

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::EquationSystems::_read_impl(), 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::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::FEMSystem::assembly(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::DistributedMesh::clear(), 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_scalar_solution(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::ExodusII_IO_Helper::create(), libMesh::DistributedMesh::delete_elem(), libMesh::DistributedMesh::delete_node(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DistributedMesh::DistributedMesh(), libMesh::DofMap::end_dof(), libMesh::DofMap::end_old_dof(), libMesh::EnsightIO::EnsightIO(), libMesh::RBEIMConstruction::evaluate_mesh_function(), libMesh::MeshFunction::find_element(), libMesh::MeshFunction::find_elements(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::DofMap::first_dof(), libMesh::DofMap::first_old_dof(), 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::DofMap::get_info(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), libMesh::DofMap::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::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), 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::DofMap::last_dof(), libMesh::TransientRBEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEIMEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEvaluation::legacy_write_offline_data_to_files(), libMesh::RBSCMEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEIMEvaluation::legacy_write_out_interpolation_points_elem(), 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::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::DofMap::n_local_dofs(), libMesh::System::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::SparsityPattern::Build::operator()(), libMesh::DistributedMesh::own_node(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::DofMap::print_dof_constraints(), 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::ExodusII_IO_Helper::read_elem_num_map(), libMesh::ExodusII_IO_Helper::read_global_values(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::System::read_header(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::System::read_legacy_data(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::System::read_parallel_data(), libMesh::TransientRBConstruction::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::DistributedMesh::renumber_dof_objects(), libMesh::DofMap::scatter_constraints(), libMesh::CheckpointIO::select_split_config(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::LaplaceMeshSmoother::smooth(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), MeshInputTest::testDynaReadElem(), MeshInputTest::testDynaReadPatch(), MeshInputTest::testExodusCopyElementSolution(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), BoundaryInfoTest::testShellFaceConstraints(), CheckpointIOTest::testSplitter(), WriteVecAndScalar::testWrite(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::Parallel::Packing< Node * >::unpack(), libMesh::Parallel::Packing< Elem * >::unpack(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::DTKAdapter::update_variable_values(), 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::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::VTKIO::write_nodal_data(), libMesh::UCDIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::ExodusII_IO_Helper::write_nodal_values(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::RBEvaluation::write_out_vectors(), 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().

◆ project_solution() [1/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. If non-default Parameters are to be used, they can be provided in the parameters argument.

Definition at line 963 of file system_projection.C.

965 {
966  this->project_vector(*solution, f, g);
967 
968  solution->localize(*current_local_solution, _dof_map->get_send_list());
969 }

◆ project_solution() [2/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. If non-default Parameters are to be used, they can be provided in the parameters argument.

Definition at line 950 of file system_projection.C.

952 {
953  this->project_vector(*solution, f, g);
954 
955  solution->localize(*current_local_solution, _dof_map->get_send_list());
956 }

Referenced by init_sys(), initialize(), main(), FETest< order, family, elem_type >::setUp(), SlitMeshRefinedSystemTest::setUp(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), MeshInputTest::testExodusCopyElementSolution(), SystemsTest::testProjectCubeWithMeshFunction(), EquationSystemsTest::testRepartitionThenReinit(), and libMesh::MeshfreeSolutionTransfer::transfer().

◆ 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 936 of file system_projection.C.

939 {
940  WrappedFunction<Number> f(*this, fptr, &parameters);
941  WrappedFunction<Gradient> g(*this, gptr, &parameters);
942  this->project_solution(&f, &g);
943 }

References fptr(), and gptr().

◆ 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 802 of file system.h.

803  { return _solution_projection; }

References libMesh::System::_solution_projection.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), and libMesh::MemorySolutionHistory::store().

◆ project_vector() [1/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 270 of file system_projection.C.

273 {
274  LOG_SCOPE ("project_vector(old,new)", "System");
275 
282  new_v.clear();
283 
284 #ifdef LIBMESH_ENABLE_AMR
285 
286  // Resize the new vector and get a serial version.
287  NumericVector<Number> * new_vector_ptr = nullptr;
288  std::unique_ptr<NumericVector<Number>> new_vector_built;
289  NumericVector<Number> * local_old_vector;
290  std::unique_ptr<NumericVector<Number>> local_old_vector_built;
291  const NumericVector<Number> * old_vector_ptr = nullptr;
292 
293  ConstElemRange active_local_elem_range
294  (this->get_mesh().active_local_elements_begin(),
295  this->get_mesh().active_local_elements_end());
296 
297  // If the old vector was uniprocessor, make the new
298  // vector uniprocessor
299  if (old_v.type() == SERIAL)
300  {
301  new_v.init (this->n_dofs(), false, SERIAL);
302  new_vector_ptr = &new_v;
303  old_vector_ptr = &old_v;
304  }
305 
306  // Otherwise it is a parallel, distributed vector, which
307  // we need to localize.
308  else if (old_v.type() == PARALLEL)
309  {
310  // Build a send list for efficient localization
311  BuildProjectionList projection_list(*this);
312  Threads::parallel_reduce (active_local_elem_range,
313  projection_list);
314 
315  // Create a sorted, unique send_list
316  projection_list.unique();
317 
318  new_v.init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
319  new_vector_built = NumericVector<Number>::build(this->comm());
320  local_old_vector_built = NumericVector<Number>::build(this->comm());
321  new_vector_ptr = new_vector_built.get();
322  local_old_vector = local_old_vector_built.get();
323  new_vector_ptr->init(this->n_dofs(), false, SERIAL);
324  local_old_vector->init(old_v.size(), false, SERIAL);
325  old_v.localize(*local_old_vector, projection_list.send_list);
326  local_old_vector->close();
327  old_vector_ptr = local_old_vector;
328  }
329  else if (old_v.type() == GHOSTED)
330  {
331  // Build a send list for efficient localization
332  BuildProjectionList projection_list(*this);
333  Threads::parallel_reduce (active_local_elem_range,
334  projection_list);
335 
336  // Create a sorted, unique send_list
337  projection_list.unique();
338 
339  new_v.init (this->n_dofs(), this->n_local_dofs(),
340  this->get_dof_map().get_send_list(), false, GHOSTED);
341 
342  local_old_vector_built = NumericVector<Number>::build(this->comm());
343  new_vector_ptr = &new_v;
344  local_old_vector = local_old_vector_built.get();
345  local_old_vector->init(old_v.size(), old_v.local_size(),
346  projection_list.send_list, false, GHOSTED);
347  old_v.localize(*local_old_vector, projection_list.send_list);
348  local_old_vector->close();
349  old_vector_ptr = local_old_vector;
350  }
351  else // unknown old_v.type()
352  libmesh_error_msg("ERROR: Unknown old_v.type() == " << old_v.type());
353 
354  // Note that the above will have zeroed the new_vector.
355  // Just to be sure, assert that new_vector_ptr and old_vector_ptr
356  // were successfully set before trying to deref them.
357  libmesh_assert(new_vector_ptr);
358  libmesh_assert(old_vector_ptr);
359 
360  NumericVector<Number> & new_vector = *new_vector_ptr;
361  const NumericVector<Number> & old_vector = *old_vector_ptr;
362 
363  const unsigned int n_variables = this->n_vars();
364 
365  if (n_variables)
366  {
367  std::vector<unsigned int> vars(n_variables);
368  std::iota(vars.begin(), vars.end(), 0);
369 
370  // Use a typedef to make the calling sequence for parallel_for() a bit more readable
371  typedef
372  GenericProjector<OldSolutionValue<Number, &FEMContext::point_value>,
373  OldSolutionValue<Gradient, &FEMContext::point_gradient>,
374  Number, VectorSetAction<Number>> FEMProjector;
375 
376  OldSolutionValue<Number, &FEMContext::point_value> f(*this, old_vector);
377  OldSolutionValue<Gradient, &FEMContext::point_gradient> g(*this, old_vector);
378  VectorSetAction<Number> setter(new_vector);
379 
380  FEMProjector projector(*this, f, &g, setter, vars);
381  projector.project(active_local_elem_range);
382 
383  // Copy the SCALAR dofs from old_vector to new_vector
384  // Note: We assume that all SCALAR dofs are on the
385  // processor with highest ID
386  if (this->processor_id() == (this->n_processors()-1))
387  {
388  const DofMap & dof_map = this->get_dof_map();
389  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
390  if (this->variable(var).type().family == SCALAR)
391  {
392  // We can just map SCALAR dofs directly across
393  std::vector<dof_id_type> new_SCALAR_indices, old_SCALAR_indices;
394  dof_map.SCALAR_dof_indices (new_SCALAR_indices, var, false);
395  dof_map.SCALAR_dof_indices (old_SCALAR_indices, var, true);
396  for (auto i : index_range(new_SCALAR_indices))
397  new_vector.set(new_SCALAR_indices[i], old_vector(old_SCALAR_indices[i]));
398  }
399  }
400  }
401 
402  new_vector.close();
403 
404  // If the old vector was serial, we probably need to send our values
405  // to other processors
406  //
407  // FIXME: I'm not sure how to make a NumericVector do that without
408  // creating a temporary parallel vector to use localize! - RHS
409  if (old_v.type() == SERIAL)
410  {
411  std::unique_ptr<NumericVector<Number>> dist_v = NumericVector<Number>::build(this->comm());
412  dist_v->init(this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
413  dist_v->close();
414 
415  for (auto i : IntRange<dof_id_type>(0, dist_v->size()))
416  if (new_vector(i) != 0.0)
417  dist_v->set(i, new_vector(i));
418 
419  dist_v->close();
420 
421  dist_v->localize (new_v, this->get_dof_map().get_send_list());
422  new_v.close();
423  }
424  // If the old vector was parallel, we need to update it
425  // and free the localized copies
426  else if (old_v.type() == PARALLEL)
427  {
428  // We may have to set dof values that this processor doesn't
429  // own in certain special cases, like LAGRANGE FIRST or
430  // HERMITE THIRD elements on second-order meshes
431  for (auto i : IntRange<dof_id_type>(0, new_v.size()))
432  if (new_vector(i) != 0.0)
433  new_v.set(i, new_vector(i));
434  new_v.close();
435  }
436 
437  if (is_adjoint == -1)
438  this->get_dof_map().enforce_constraints_exactly(*this, &new_v);
439  else if (is_adjoint >= 0)
441  is_adjoint);
442 
443 #else
444 
445  // AMR is disabled: simply copy the vector
446  new_v = old_v;
447 
448  libmesh_ignore(is_adjoint);
449 
450 #endif // #ifdef LIBMESH_ENABLE_AMR
451 }

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(), 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(), and libMesh::BuildProjectionList::unique().

◆ project_vector() [2/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 252 of file system_projection.C.

254 {
255  // Create a copy of the vector, which currently
256  // contains the old data.
257  std::unique_ptr<NumericVector<Number>>
258  old_vector (vector.clone());
259 
260  // Project the old vector to the new vector
261  this->project_vector (*old_vector, vector, is_adjoint);
262 }

References libMesh::NumericVector< T >::clone().

◆ project_vector() [3/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. If non-default Parameters are to be used, they can be provided in the parameters argument.

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

Definition at line 1017 of file system_projection.C.

1021 {
1022  LOG_SCOPE ("project_fem_vector()", "System");
1023 
1024  libmesh_assert (f);
1025 
1026  ConstElemRange active_local_range
1027  (this->get_mesh().active_local_elements_begin(),
1028  this->get_mesh().active_local_elements_end() );
1029 
1030  VectorSetAction<Number> setter(new_vector);
1031 
1032  const unsigned int n_variables = this->n_vars();
1033 
1034  std::vector<unsigned int> vars(n_variables);
1035  std::iota(vars.begin(), vars.end(), 0);
1036 
1037  // Use a typedef to make the calling sequence for parallel_for() a bit more readable
1038  typedef
1039  GenericProjector<FEMFunctionWrapper<Number>, FEMFunctionWrapper<Gradient>,
1040  Number, VectorSetAction<Number>> FEMProjector;
1041 
1042  FEMFunctionWrapper<Number> fw(*f);
1043 
1044  if (g)
1045  {
1046  FEMFunctionWrapper<Gradient> gw(*g);
1047 
1048  FEMProjector projector(*this, fw, &gw, setter, vars);
1049  projector.project(active_local_range);
1050  }
1051  else
1052  {
1053  FEMProjector projector(*this, fw, nullptr, setter, vars);
1054  projector.project(active_local_range);
1055  }
1056 
1057  // Also, load values into the SCALAR dofs
1058  // Note: We assume that all SCALAR dofs are on the
1059  // processor with highest ID
1060  if (this->processor_id() == (this->n_processors()-1))
1061  {
1062  // FIXME: Do we want to first check for SCALAR vars before building this? [PB]
1063  FEMContext context( *this );
1064 
1065  const DofMap & dof_map = this->get_dof_map();
1066  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
1067  if (this->variable(var).type().family == SCALAR)
1068  {
1069  // FIXME: We reinit with an arbitrary element in case the user
1070  // doesn't override FEMFunctionBase::component. Is there
1071  // any use case we're missing? [PB]
1072  context.pre_fe_reinit(*this, *(this->get_mesh().active_local_elements_begin()));
1073 
1074  std::vector<dof_id_type> SCALAR_indices;
1075  dof_map.SCALAR_dof_indices (SCALAR_indices, var);
1076  const unsigned int n_SCALAR_dofs =
1077  cast_int<unsigned int>(SCALAR_indices.size());
1078 
1079  for (unsigned int i=0; i<n_SCALAR_dofs; i++)
1080  {
1081  const dof_id_type global_index = SCALAR_indices[i];
1082  const unsigned int component_index =
1083  this->variable_scalar_number(var,i);
1084 
1085  new_vector.set(global_index, f->component(context, component_index, Point(), this->time));
1086  }
1087  }
1088  }
1089 
1090  new_vector.close();
1091 
1092 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1093  if (is_adjoint == -1)
1094  this->get_dof_map().enforce_constraints_exactly(*this, &new_vector);
1095  else if (is_adjoint >= 0)
1097  is_adjoint);
1098 #else
1099  libmesh_ignore(is_adjoint);
1100 #endif
1101 }

References libMesh::NumericVector< T >::close(), libMesh::FEMFunctionBase< Output >::component(), libMesh::Utility::iota(), libMesh::libmesh_assert(), libMesh::libmesh_ignore(), n_vars, libMesh::FEMContext::pre_fe_reinit(), libMesh::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), and libMesh::NumericVector< T >::set().

◆ project_vector() [4/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. If non-default Parameters are to be used, they can be provided in the parameters argument.

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

Definition at line 991 of file system_projection.C.

995 {
996  LOG_SCOPE ("project_vector(FunctionBase)", "System");
997 
998  libmesh_assert(f);
999 
1000  WrappedFunctor<Number> f_fem(*f);
1001 
1002  if (g)
1003  {
1004  WrappedFunctor<Gradient> g_fem(*g);
1005 
1006  this->project_vector(new_vector, &f_fem, &g_fem, is_adjoint);
1007  }
1008  else
1009  this->project_vector(new_vector, &f_fem, nullptr, is_adjoint);
1010 }

References libMesh::libmesh_assert().

Referenced by main(), libMesh::NewmarkSolver::project_initial_accel(), libMesh::SecondOrderUnsteadySolver::project_initial_rate(), and libMesh::System::restrict_vectors().

◆ project_vector() [5/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 976 of file system_projection.C.

981 {
982  WrappedFunction<Number> f(*this, fptr, &parameters);
983  WrappedFunction<Gradient> g(*this, gptr, &parameters);
984  this->project_vector(new_vector, &f, &g, is_adjoint);
985 }

References fptr(), and gptr().

◆ 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 870 of file system_projection.C.

871 {
872  LOG_SCOPE ("projection_matrix()", "System");
873 
874  const unsigned int n_variables = this->n_vars();
875 
876  if (n_variables)
877  {
878  ConstElemRange active_local_elem_range
879  (this->get_mesh().active_local_elements_begin(),
880  this->get_mesh().active_local_elements_end());
881 
882  std::vector<unsigned int> vars(n_variables);
883  std::iota(vars.begin(), vars.end(), 0);
884 
885  // Use a typedef to make the calling sequence for parallel_for() a bit more readable
886  typedef OldSolutionCoefs<Real, &FEMContext::point_value> OldSolutionValueCoefs;
887  typedef OldSolutionCoefs<RealGradient, &FEMContext::point_gradient> OldSolutionGradientCoefs;
888 
889  typedef
890  GenericProjector<OldSolutionValueCoefs,
891  OldSolutionGradientCoefs,
892  DynamicSparseNumberArray<Real,dof_id_type>,
893  MatrixFillAction<Real, Number> > ProjMatFiller;
894 
895  OldSolutionValueCoefs f(*this);
896  OldSolutionGradientCoefs g(*this);
897  MatrixFillAction<Real, Number> setter(proj_mat);
898 
899  ProjMatFiller mat_filler(*this, f, &g, setter, vars);
900  mat_filler.project(active_local_elem_range);
901 
902  // Set the SCALAR dof transfer entries too.
903  // Note: We assume that all SCALAR dofs are on the
904  // processor with highest ID
905  if (this->processor_id() == (this->n_processors()-1))
906  {
907  const DofMap & dof_map = this->get_dof_map();
908  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
909  if (this->variable(var).type().family == SCALAR)
910  {
911  // We can just map SCALAR dofs directly across
912  std::vector<dof_id_type> new_SCALAR_indices, old_SCALAR_indices;
913  dof_map.SCALAR_dof_indices (new_SCALAR_indices, var, false);
914  dof_map.SCALAR_dof_indices (old_SCALAR_indices, var, true);
915  const unsigned int new_n_dofs =
916  cast_int<unsigned int>(new_SCALAR_indices.size());
917 
918  for (unsigned int i=0; i<new_n_dofs; i++)
919  {
920  proj_mat.set( new_SCALAR_indices[i],
921  old_SCALAR_indices[i], 1);
922  }
923  }
924  }
925  }
926 }

References libMesh::Utility::iota(), n_vars, libMesh::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), and libMesh::SparseMatrix< T >::set().

Referenced by libMesh::PetscDMWrapper::init_and_attach_petscdm(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), and SystemsTest::testProjectMatrix3D().

◆ prolong_vectors()

void libMesh::System::prolong_vectors ( )
virtualinherited

Prolong vectors after the mesh has refined.

Definition at line 380 of file system.C.

381 {
382 #ifdef LIBMESH_ENABLE_AMR
383  // Currently project_vector handles both restriction and prolongation
384  this->restrict_vectors();
385 #endif
386 }

References libMesh::System::restrict_vectors().

Referenced by libMesh::EquationSystems::reinit_solutions().

◆ 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 1091 of file implicit_system.C.

1094 {
1095  // We currently get partial derivatives via finite differencing
1096  const Real delta_p = TOLERANCE;
1097 
1098  ParameterVector & parameters =
1099  const_cast<ParameterVector &>(parameters_in);
1100 
1101  // We'll use one temporary vector for matrix-vector-vector products
1102  std::unique_ptr<NumericVector<Number>> tempvec = this->solution->zero_clone();
1103 
1104  // And another temporary vector to hold a copy of the true solution
1105  // so we can safely perturb this->solution.
1106  std::unique_ptr<NumericVector<Number>> oldsolution = this->solution->clone();
1107 
1108  const unsigned int Np = cast_int<unsigned int>
1109  (parameters.size());
1110  const unsigned int Nq = this->n_qois();
1111 
1112  // For each quantity of interest q, the parameter sensitivity
1113  // Hessian is defined as q''_{kl} = {d^2 q}/{d p_k d p_l}.
1114  //
1115  // We calculate it from values and partial derivatives of the
1116  // quantity of interest function Q, solution u, adjoint solution z,
1117  // and residual R, as:
1118  //
1119  // q''_{kl} =
1120  // Q''_{kl} + Q''_{uk}(u)*u'_l + Q''_{ul}(u) * u'_k +
1121  // Q''_{uu}(u)*u'_k*u'_l -
1122  // R''_{kl}(u,z) -
1123  // R''_{uk}(u,z)*u'_l - R''_{ul}(u,z)*u'_k -
1124  // R''_{uu}(u,z)*u'_k*u'_l
1125  //
1126  // See the adjoints model document for more details.
1127 
1128  // We first do an adjoint solve to get z for each quantity of
1129  // interest
1130  // if we havent already or dont have an initial condition for the adjoint
1131  if (!this->is_adjoint_already_solved())
1132  {
1133  this->adjoint_solve(qoi_indices);
1134  }
1135 
1136  // And a sensitivity solve to get u_k for each parameter
1137  this->sensitivity_solve(parameters);
1138 
1139  // Get ready to fill in second derivatives:
1140  sensitivities.allocate_hessian_data(qoi_indices, *this, parameters);
1141 
1142  for (unsigned int k=0; k != Np; ++k)
1143  {
1144  Number old_parameterk = *parameters[k];
1145 
1146  // The Hessian is symmetric, so we just calculate the lower
1147  // triangle and the diagonal, and we get the upper triangle from
1148  // the transpose of the lower
1149 
1150  for (unsigned int l=0; l != k+1; ++l)
1151  {
1152  // The second partial derivatives with respect to parameters
1153  // are all calculated via a central finite difference
1154  // stencil:
1155  // F''_{kl} ~= (F(p+dp*e_k+dp*e_l) - F(p+dp*e_k-dp*e_l) -
1156  // F(p-dp*e_k+dp*e_l) + F(p-dp*e_k-dp*e_l))/(4*dp^2)
1157  // We will add Q''_{kl}(u) and subtract R''_{kl}(u,z) at the
1158  // same time.
1159  //
1160  // We have to be careful with the perturbations to handle
1161  // the k=l case
1162 
1163  Number old_parameterl = *parameters[l];
1164 
1165  *parameters[k] += delta_p;
1166  *parameters[l] += delta_p;
1167  this->assemble_qoi(qoi_indices);
1168  this->assembly(true, false, true);
1169  this->rhs->close();
1170  std::vector<Number> partial2q_term = this->qoi;
1171  std::vector<Number> partial2R_term(this->n_qois());
1172  for (unsigned int i=0; i != Nq; ++i)
1173  if (qoi_indices.has_index(i))
1174  partial2R_term[i] = this->rhs->dot(this->get_adjoint_solution(i));
1175 
1176  *parameters[l] -= 2.*delta_p;
1177  this->assemble_qoi(qoi_indices);
1178  this->assembly(true, false, true);
1179  this->rhs->close();
1180  for (unsigned int i=0; i != Nq; ++i)
1181  if (qoi_indices.has_index(i))
1182  {
1183  partial2q_term[i] -= this->qoi[i];
1184  partial2R_term[i] -= this->rhs->dot(this->get_adjoint_solution(i));
1185  }
1186 
1187  *parameters[k] -= 2.*delta_p;
1188  this->assemble_qoi(qoi_indices);
1189  this->assembly(true, false, true);
1190  this->rhs->close();
1191  for (unsigned int i=0; i != Nq; ++i)
1192  if (qoi_indices.has_index(i))
1193  {
1194  partial2q_term[i] += this->qoi[i];
1195  partial2R_term[i] += this->rhs->dot(this->get_adjoint_solution(i));
1196  }
1197 
1198  *parameters[l] += 2.*delta_p;
1199  this->assemble_qoi(qoi_indices);
1200  this->assembly(true, false, true);
1201  this->rhs->close();
1202  for (unsigned int i=0; i != Nq; ++i)
1203  if (qoi_indices.has_index(i))
1204  {
1205  partial2q_term[i] -= this->qoi[i];
1206  partial2R_term[i] -= this->rhs->dot(this->get_adjoint_solution(i));
1207  partial2q_term[i] /= (4. * delta_p * delta_p);
1208  partial2R_term[i] /= (4. * delta_p * delta_p);
1209  }
1210 
1211  for (unsigned int i=0; i != Nq; ++i)
1212  if (qoi_indices.has_index(i))
1213  {
1214  Number current_terms = partial2q_term[i] - partial2R_term[i];
1215  sensitivities.second_derivative(i,k,l) += current_terms;
1216  if (k != l)
1217  sensitivities.second_derivative(i,l,k) += current_terms;
1218  }
1219 
1220  // Don't leave the parameters perturbed
1221  *parameters[l] = old_parameterl;
1222  *parameters[k] = old_parameterk;
1223  }
1224 
1225  // We get (partial q / partial u) and
1226  // (partial R / partial u) from the user, but centrally
1227  // difference to get q_uk and R_uk terms:
1228  // (partial^2 q / partial u partial k)
1229  // q_uk*u'_l = (q_u(p+dp*e_k)*u'_l - q_u(p-dp*e_k)*u'_l)/(2*dp)
1230  // 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)
1231  //
1232  // To avoid creating Nq temporary vectors, we add these
1233  // subterms to the sensitivities output one by one.
1234  //
1235  // FIXME: this is probably a bad order of operations for
1236  // controlling floating point error.
1237 
1238  *parameters[k] = old_parameterk + delta_p;
1239  this->assembly(false, true);
1240  this->matrix->close();
1241  this->assemble_qoi_derivative(qoi_indices,
1242  /* include_liftfunc = */ true,
1243  /* apply_constraints = */ false);
1244 
1245  for (unsigned int l=0; l != Np; ++l)
1246  {
1247  this->matrix->vector_mult(*tempvec, this->get_sensitivity_solution(l));
1248  for (unsigned int i=0; i != Nq; ++i)
1249  if (qoi_indices.has_index(i))
1250  {
1251  this->get_adjoint_rhs(i).close();
1252  Number current_terms =
1253  (this->get_adjoint_rhs(i).dot(this->get_sensitivity_solution(l)) -
1254  tempvec->dot(this->get_adjoint_solution(i))) / (2.*delta_p);
1255  sensitivities.second_derivative(i,k,l) += current_terms;
1256 
1257  // We use the _uk terms twice; symmetry lets us reuse
1258  // these calculations for the _ul terms.
1259 
1260  sensitivities.second_derivative(i,l,k) += current_terms;
1261  }
1262  }
1263 
1264  *parameters[k] = old_parameterk - delta_p;
1265  this->assembly(false, true);
1266  this->matrix->close();
1267  this->assemble_qoi_derivative(qoi_indices,
1268  /* include_liftfunc = */ true,
1269  /* apply_constraints = */ false);
1270 
1271  for (unsigned int l=0; l != Np; ++l)
1272  {
1273  this->matrix->vector_mult(*tempvec, this->get_sensitivity_solution(l));
1274  for (unsigned int i=0; i != Nq; ++i)
1275  if (qoi_indices.has_index(i))
1276  {
1277  this->get_adjoint_rhs(i).close();
1278  Number current_terms =
1279  (-this->get_adjoint_rhs(i).dot(this->get_sensitivity_solution(l)) +
1280  tempvec->dot(this->get_adjoint_solution(i))) / (2.*delta_p);
1281  sensitivities.second_derivative(i,k,l) += current_terms;
1282 
1283  // We use the _uk terms twice; symmetry lets us reuse
1284  // these calculations for the _ul terms.
1285 
1286  sensitivities.second_derivative(i,l,k) += current_terms;
1287  }
1288  }
1289 
1290  // Don't leave the parameter perturbed
1291  *parameters[k] = old_parameterk;
1292 
1293  // Our last remaining terms are -R_uu(u,z)*u_k*u_l and
1294  // Q_uu(u)*u_k*u_l
1295  //
1296  // We take directional central finite differences of R_u and Q_u
1297  // to approximate these terms, e.g.:
1298  //
1299  // Q_uu(u)*u_k ~= (Q_u(u+dp*u_k) - Q_u(u-dp*u_k))/(2*dp)
1300 
1301  *this->solution = this->get_sensitivity_solution(k);
1302  *this->solution *= delta_p;
1303  *this->solution += *oldsolution;
1304 
1305  // We've modified solution, so we need to update before calling
1306  // assembly since assembly may only use current_local_solution
1307  this->update();
1308  this->assembly(false, true);
1309  this->matrix->close();
1310  this->assemble_qoi_derivative(qoi_indices,
1311  /* include_liftfunc = */ true,
1312  /* apply_constraints = */ false);
1313 
1314  // The Hessian is symmetric, so we just calculate the lower
1315  // triangle and the diagonal, and we get the upper triangle from
1316  // the transpose of the lower
1317  //
1318  // Note that, because we took the directional finite difference
1319  // with respect to k and not l, we've added an O(delta_p^2)
1320  // error to any permutational symmetry in the Hessian...
1321  for (unsigned int l=0; l != k+1; ++l)
1322  {
1323  this->matrix->vector_mult(*tempvec, this->get_sensitivity_solution(l));
1324  for (unsigned int i=0; i != Nq; ++i)
1325  if (qoi_indices.has_index(i))
1326  {
1327  this->get_adjoint_rhs(i).close();
1328  Number current_terms =
1329  (this->get_adjoint_rhs(i).dot(this->get_sensitivity_solution(l)) -
1330  tempvec->dot(this->get_adjoint_solution(i))) / (2.*delta_p);
1331  sensitivities.second_derivative(i,k,l) += current_terms;
1332  if (k != l)
1333  sensitivities.second_derivative(i,l,k) += current_terms;
1334  }
1335  }
1336 
1337  *this->solution = this->get_sensitivity_solution(k);
1338  *this->solution *= -delta_p;
1339  *this->solution += *oldsolution;
1340 
1341  // We've modified solution, so we need to update before calling
1342  // assembly since assembly may only use current_local_solution
1343  this->update();
1344  this->assembly(false, true);
1345  this->matrix->close();
1346  this->assemble_qoi_derivative(qoi_indices,
1347  /* include_liftfunc = */ true,
1348  /* apply_constraints = */ false);
1349 
1350  for (unsigned int l=0; l != k+1; ++l)
1351  {
1352  this->matrix->vector_mult(*tempvec, this->get_sensitivity_solution(l));
1353  for (unsigned int i=0; i != Nq; ++i)
1354  if (qoi_indices.has_index(i))
1355  {
1356  this->get_adjoint_rhs(i).close();
1357  Number current_terms =
1358  (-this->get_adjoint_rhs(i).dot(this->get_sensitivity_solution(l)) +
1359  tempvec->dot(this->get_adjoint_solution(i))) / (2.*delta_p);
1360  sensitivities.second_derivative(i,k,l) += current_terms;
1361  if (k != l)
1362  sensitivities.second_derivative(i,l,k) += current_terms;
1363  }
1364  }
1365 
1366  // Don't leave the solution perturbed
1367  *this->solution = *oldsolution;
1368  }
1369 
1370  // All parameters have been reset.
1371  // Don't leave the qoi or system changed - principle of least
1372  // surprise.
1373  // We've modified solution, so we need to update before calling
1374  // assembly since assembly may only use current_local_solution
1375  this->update();
1376  this->assembly(true, true);
1377  this->rhs->close();
1378  this->matrix->close();
1379  this->assemble_qoi(qoi_indices);
1380 }

References libMesh::ImplicitSystem::adjoint_solve(), libMesh::SensitivityData::allocate_hessian_data(), libMesh::ExplicitSystem::assemble_qoi(), libMesh::ExplicitSystem::assemble_qoi_derivative(), libMesh::ImplicitSystem::assembly(), libMesh::SparseMatrix< T >::close(), libMesh::NumericVector< T >::close(), libMesh::NumericVector< T >::dot(), libMesh::System::get_adjoint_rhs(), libMesh::System::get_adjoint_solution(), libMesh::System::get_sensitivity_solution(), libMesh::QoISet::has_index(), libMesh::System::is_adjoint_already_solved(), libMesh::ImplicitSystem::matrix, libMesh::System::n_qois(), libMesh::System::qoi, 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().

◆ 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 886 of file implicit_system.C.

890 {
891  // We currently get partial derivatives via finite differencing
892  const Real delta_p = TOLERANCE;
893 
894  ParameterVector & parameters =
895  const_cast<ParameterVector &>(parameters_in);
896 
897  // We'll use a single temporary vector for matrix-vector-vector products
898  std::unique_ptr<NumericVector<Number>> tempvec = this->solution->zero_clone();
899 
900  const unsigned int Np = cast_int<unsigned int>
901  (parameters.size());
902  const unsigned int Nq = this->n_qois();
903 
904  // For each quantity of interest q, the parameter sensitivity
905  // Hessian is defined as q''_{kl} = {d^2 q}/{d p_k d p_l}.
906  // Given a vector of parameter perturbation weights w_l, this
907  // function evaluates the hessian-vector product sum_l(q''_{kl}*w_l)
908  //
909  // We calculate it from values and partial derivatives of the
910  // quantity of interest function Q, solution u, adjoint solution z,
911  // parameter sensitivity adjoint solutions z^l, and residual R, as:
912  //
913  // sum_l(q''_{kl}*w_l) =
914  // sum_l(w_l * Q''_{kl}) + Q''_{uk}(u)*(sum_l(w_l u'_l)) -
915  // R'_k(u, sum_l(w_l*z^l)) - R'_{uk}(u,z)*(sum_l(w_l u'_l) -
916  // sum_l(w_l*R''_{kl}(u,z))
917  //
918  // See the adjoints model document for more details.
919 
920  // We first do an adjoint solve to get z for each quantity of
921  // interest
922  // if we havent already or dont have an initial condition for the adjoint
923  if (!this->is_adjoint_already_solved())
924  {
925  this->adjoint_solve(qoi_indices);
926  }
927 
928  // Get ready to fill in sensitivities:
929  sensitivities.allocate_data(qoi_indices, *this, parameters);
930 
931  // We can't solve for all the solution sensitivities u'_l or for all
932  // of the parameter sensitivity adjoint solutions z^l without
933  // requiring O(Nq*Np) linear solves. So we'll solve directly for their
934  // weighted sum - this is just O(Nq) solves.
935 
936  // First solve for sum_l(w_l u'_l).
937  this->weighted_sensitivity_solve(parameters, vector);
938 
939  // Then solve for sum_l(w_l z^l).
940  this->weighted_sensitivity_adjoint_solve(parameters, vector, qoi_indices);
941 
942  for (unsigned int k=0; k != Np; ++k)
943  {
944  // We approximate sum_l(w_l * Q''_{kl}) with a central
945  // differencing perturbation:
946  // sum_l(w_l * Q''_{kl}) ~=
947  // (Q(p + dp*w_l*e_l + dp*e_k) - Q(p - dp*w_l*e_l + dp*e_k) -
948  // Q(p + dp*w_l*e_l - dp*e_k) + Q(p - dp*w_l*e_l - dp*e_k))/(4*dp^2)
949 
950  // The sum(w_l*R''_kl) term requires the same sort of perturbation,
951  // and so we subtract it in at the same time:
952  // sum_l(w_l * R''_{kl}) ~=
953  // (R(p + dp*w_l*e_l + dp*e_k) - R(p - dp*w_l*e_l + dp*e_k) -
954  // R(p + dp*w_l*e_l - dp*e_k) + R(p - dp*w_l*e_l - dp*e_k))/(4*dp^2)
955 
956  ParameterVector oldparameters, parameterperturbation;
957  parameters.deep_copy(oldparameters);
958  vector.deep_copy(parameterperturbation);
959  parameterperturbation *= delta_p;
960  parameters += parameterperturbation;
961 
962  Number old_parameter = *parameters[k];
963 
964  *parameters[k] = old_parameter + delta_p;
965  this->assemble_qoi(qoi_indices);
966  this->assembly(true, false, true);
967  this->rhs->close();
968  std::vector<Number> partial2q_term = this->qoi;
969  std::vector<Number> partial2R_term(this->n_qois());
970  for (unsigned int i=0; i != Nq; ++i)
971  if (qoi_indices.has_index(i))
972  partial2R_term[i] = this->rhs->dot(this->get_adjoint_solution(i));
973 
974  *parameters[k] = old_parameter - delta_p;
975  this->assemble_qoi(qoi_indices);
976  this->assembly(true, false, true);
977  this->rhs->close();
978  for (unsigned int i=0; i != Nq; ++i)
979  if (qoi_indices.has_index(i))
980  {
981  partial2q_term[i] -= this->qoi[i];
982  partial2R_term[i] -= this->rhs->dot(this->get_adjoint_solution(i));
983  }
984 
985  oldparameters.value_copy(parameters);
986  parameterperturbation *= -1.0;
987  parameters += parameterperturbation;
988 
989  // Re-center old_parameter, which may be affected by vector
990  old_parameter = *parameters[k];
991 
992  *parameters[k] = old_parameter + delta_p;
993  this->assemble_qoi(qoi_indices);
994  this->assembly(true, false, true);
995  this->rhs->close();
996  for (unsigned int i=0; i != Nq; ++i)
997  if (qoi_indices.has_index(i))
998  {
999  partial2q_term[i] -= this->qoi[i];
1000  partial2R_term[i] -= this->rhs->dot(this->get_adjoint_solution(i));
1001  }
1002 
1003  *parameters[k] = old_parameter - 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->qoi[i];
1011  partial2R_term[i] += this->rhs->dot(this->get_adjoint_solution(i));
1012  }
1013 
1014  for (unsigned int i=0; i != Nq; ++i)
1015  if (qoi_indices.has_index(i))
1016  {
1017  partial2q_term[i] /= (4. * delta_p * delta_p);
1018  partial2R_term[i] /= (4. * delta_p * delta_p);
1019  }
1020 
1021  for (unsigned int i=0; i != Nq; ++i)
1022  if (qoi_indices.has_index(i))
1023  sensitivities[i][k] = partial2q_term[i] - partial2R_term[i];
1024 
1025  // We get (partial q / partial u), R, and
1026  // (partial R / partial u) from the user, but centrally
1027  // difference to get q_uk, R_k, and R_uk terms:
1028  // (partial R / partial k)
1029  // 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)
1030  // (partial^2 q / partial u partial k)
1031  // q_uk = (q_u(p+dp*e_k) - q_u(p-dp*e_k))/(2*dp)
1032  // (partial^2 R / partial u partial k)
1033  // 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)
1034 
1035  // To avoid creating Nq temporary vectors for q_uk or R_uk, we add
1036  // subterms to the sensitivities output one by one.
1037  //
1038  // FIXME: this is probably a bad order of operations for
1039  // controlling floating point error.
1040 
1041  *parameters[k] = old_parameter + delta_p;
1042  this->assembly(true, true);
1043  this->rhs->close();
1044  this->matrix->close();
1045  this->assemble_qoi_derivative(qoi_indices,
1046  /* include_liftfunc = */ true,
1047  /* apply_constraints = */ false);
1048 
1049  this->matrix->vector_mult(*tempvec, this->get_weighted_sensitivity_solution());
1050 
1051  for (unsigned int i=0; i != Nq; ++i)
1052  if (qoi_indices.has_index(i))
1053  {
1054  this->get_adjoint_rhs(i).close();
1055  sensitivities[i][k] += (this->get_adjoint_rhs(i).dot(this->get_weighted_sensitivity_solution()) -
1057  this->get_adjoint_solution(i).dot(*tempvec)) / (2.*delta_p);
1058  }
1059 
1060  *parameters[k] = old_parameter - delta_p;
1061  this->assembly(true, true);
1062  this->rhs->close();
1063  this->matrix->close();
1064  this->assemble_qoi_derivative(qoi_indices,
1065  /* include_liftfunc = */ true,
1066  /* apply_constraints = */ false);
1067 
1068  this->matrix->vector_mult(*tempvec, this->get_weighted_sensitivity_solution());
1069 
1070  for (unsigned int i=0; i != Nq; ++i)
1071  if (qoi_indices.has_index(i))
1072  {
1073  this->get_adjoint_rhs(i).close();
1074  sensitivities[i][k] += (-this->get_adjoint_rhs(i).dot(this->get_weighted_sensitivity_solution()) +
1076  this->get_adjoint_solution(i).dot(*tempvec)) / (2.*delta_p);
1077  }
1078  }
1079 
1080  // All parameters have been reset.
1081  // Don't leave the qoi or system changed - principle of least
1082  // surprise.
1083  this->assembly(true, true);
1084  this->rhs->close();
1085  this->matrix->close();
1086  this->assemble_qoi(qoi_indices);
1087 }

References libMesh::ImplicitSystem::adjoint_solve(), libMesh::SensitivityData::allocate_data(), libMesh::ExplicitSystem::assemble_qoi(), libMesh::ExplicitSystem::assemble_qoi_derivative(), libMesh::ImplicitSystem::assembly(), libMesh::SparseMatrix< T >::close(), libMesh::NumericVector< T >::close(), libMesh::ParameterVector::deep_copy(), libMesh::NumericVector< T >::dot(), libMesh::System::get_adjoint_rhs(), libMesh::System::get_adjoint_solution(), 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::System::qoi, 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().

◆ 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 498 of file system.C.

501 {
502  // Forward sensitivities are more efficient for Nq > Np
503  if (qoi_indices.size(*this) > parameters.size())
504  forward_qoi_parameter_sensitivity(qoi_indices, parameters, sensitivities);
505  // Adjoint sensitivities are more efficient for Np > Nq,
506  // and an adjoint may be more reusable than a forward
507  // solution sensitivity in the Np == Nq case.
508  else
509  adjoint_qoi_parameter_sensitivity(qoi_indices, parameters, sensitivities);
510 }

References libMesh::System::adjoint_qoi_parameter_sensitivity(), libMesh::System::forward_qoi_parameter_sensitivity(), libMesh::ParameterVector::size(), and libMesh::QoISet::size().

◆ re_update()

void libMesh::System::re_update ( )
virtualinherited

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 in libMesh::TransientSystem< RBConstruction >.

Definition at line 429 of file system.C.

430 {
431  parallel_object_only();
432 
433  // If this system is empty... don't do anything!
434  if (!this->n_vars())
435  return;
436 
437  const std::vector<dof_id_type> & send_list = this->get_dof_map().get_send_list ();
438 
439  // Check sizes
440  libmesh_assert_equal_to (current_local_solution->size(), solution->size());
441  // Not true with ghosted vectors
442  // libmesh_assert_equal_to (current_local_solution->local_size(), solution->size());
443  // libmesh_assert (!send_list.empty());
444  libmesh_assert_less_equal (send_list.size(), solution->size());
445 
446  // Create current_local_solution from solution. This will
447  // put a local copy of solution into current_local_solution.
448  solution->localize (*current_local_solution, send_list);
449 }

References libMesh::System::current_local_solution, libMesh::System::get_dof_map(), libMesh::DofMap::get_send_list(), libMesh::System::n_vars(), and libMesh::System::solution.

◆ read_discrete_parameter_values_from_file()

void libMesh::RBParametrized::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 
)
privateinherited

Read in the discrete parameter values from file, if we have any.

Definition at line 340 of file rb_parametrized.C.

343 {
344  // read in the discrete parameters, if we have any
345  std::ifstream check_if_file_exists(file_name.c_str());
346  if (check_if_file_exists.good())
347  {
348  // The reading mode: DECODE for binary, READ for ASCII
349  XdrMODE mode = read_binary_data ? DECODE : READ;
350 
351  // Read in the parameter ranges
352  Xdr discrete_parameter_values_in(file_name, mode);
353  unsigned int n_discrete_params;
354  discrete_parameter_values_in >> n_discrete_params;
355 
356  for (unsigned int i=0; i<n_discrete_params; i++)
357  {
358  std::string param_name;
359  discrete_parameter_values_in >> param_name;
360 
361  unsigned int n_discrete_values;
362  discrete_parameter_values_in >> n_discrete_values;
363 
364  std::vector<Real> discrete_values(n_discrete_values);
365  for (auto & val : discrete_values)
366  discrete_parameter_values_in >> val;
367 
368  discrete_parameter_values[param_name] = discrete_values;
369  }
370  }
371 }

References libMesh::DECODE, and libMesh::READ.

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

◆ read_header()

void libMesh::System::read_header ( Xdr io,
const std::string &  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 114 of file system_io.C.

119 {
120  // This method implements the input of a
121  // System object, embedded in the output of
122  // an EquationSystems<T_sys>. This warrants some
123  // documentation. The output file essentially
124  // consists of 5 sections:
125  //
126  // for this system
127  //
128  // 5.) The number of variables in the system (unsigned int)
129  //
130  // for each variable in the system
131  //
132  // 6.) The name of the variable (string)
133  //
134  // 6.1.) Variable subdomains
135  //
136  // 7.) Combined in an FEType:
137  // - The approximation order(s) of the variable
138  // (Order Enum, cast to int/s)
139  // - The finite element family/ies of the variable
140  // (FEFamily Enum, cast to int/s)
141  //
142  // end variable loop
143  //
144  // 8.) The number of additional vectors (unsigned int),
145  //
146  // for each additional vector in the system object
147  //
148  // 9.) the name of the additional vector (string)
149  //
150  // end system
151  libmesh_assert (io.reading());
152 
153  // Possibly clear data structures and start from scratch.
154  if (read_header_in)
155  this->clear ();
156 
157  // Figure out if we need to read infinite element information.
158  // This will be true if the version string contains " with infinite elements"
159  const bool read_ifem_info =
160  (version.rfind(" with infinite elements") < version.size()) ||
161  libMesh::on_command_line ("--read-ifem-systems");
162 
163 
164  {
165  // 5.)
166  // Read the number of variables in the system
167  unsigned int nv=0;
168  if (this->processor_id() == 0)
169  io.data (nv);
170  this->comm().broadcast(nv);
171 
172  _written_var_indices.clear();
173  _written_var_indices.resize(nv, 0);
174 
175  for (unsigned int var=0; var<nv; var++)
176  {
177  // 6.)
178  // Read the name of the var-th variable
179  std::string var_name;
180  if (this->processor_id() == 0)
181  io.data (var_name);
182  this->comm().broadcast(var_name);
183 
184  // 6.1.)
185  std::set<subdomain_id_type> domains;
186  if (io.version() >= LIBMESH_VERSION_ID(0,7,2))
187  {
188  std::vector<subdomain_id_type> domain_array;
189  if (this->processor_id() == 0)
190  io.data (domain_array);
191  for (const auto & id : domain_array)
192  domains.insert(id);
193  }
194  this->comm().broadcast(domains);
195 
196  // 7.)
197  // Read the approximation order(s) of the var-th variable
198  int order=0;
199  if (this->processor_id() == 0)
200  io.data (order);
201  this->comm().broadcast(order);
202 
203 
204  // do the same for infinite element radial_order
205  int rad_order=0;
206  if (read_ifem_info)
207  {
208  if (this->processor_id() == 0)
209  io.data(rad_order);
210  this->comm().broadcast(rad_order);
211  }
212 
213  // Read the finite element type of the var-th variable
214  int fam=0;
215  if (this->processor_id() == 0)
216  io.data (fam);
217  this->comm().broadcast(fam);
218  FEType type;
219  type.order = static_cast<Order>(order);
220  type.family = static_cast<FEFamily>(fam);
221 
222  // Check for incompatibilities. The shape function indexing was
223  // changed for the monomial and xyz finite element families to
224  // simplify extension to arbitrary p. The consequence is that
225  // old restart files will not be read correctly. This is expected
226  // to be an unlikely occurence, but catch it anyway.
227  if (read_legacy_format)
228  if ((type.family == MONOMIAL || type.family == XYZ) &&
229  ((type.order.get_order() > 2 && this->get_mesh().mesh_dimension() == 2) ||
230  (type.order.get_order() > 1 && this->get_mesh().mesh_dimension() == 3)))
231  {
232  libmesh_here();
233  libMesh::out << "*****************************************************************\n"
234  << "* WARNING: reading a potentially incompatible restart file!!! *\n"
235  << "* contact [email protected] for more details *\n"
236  << "*****************************************************************"
237  << std::endl;
238  }
239 
240  // Read additional information for infinite elements
241  int radial_fam=0;
242  int i_map=0;
243  if (read_ifem_info)
244  {
245  if (this->processor_id() == 0)
246  io.data (radial_fam);
247  this->comm().broadcast(radial_fam);
248  if (this->processor_id() == 0)
249  io.data (i_map);
250  this->comm().broadcast(i_map);
251  }
252 
253 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
254 
255  type.radial_order = static_cast<Order>(rad_order);
256  type.radial_family = static_cast<FEFamily>(radial_fam);
257  type.inf_map = static_cast<InfMapType>(i_map);
258 
259 #endif
260 
261  if (read_header_in)
262  {
263  if (domains.empty())
264  _written_var_indices[var] = this->add_variable (var_name, type);
265  else
266  _written_var_indices[var] = this->add_variable (var_name, type, &domains);
267  }
268  else
269  _written_var_indices[var] = this->variable_number(var_name);
270  }
271  }
272 
273  // 8.)
274  // Read the number of additional vectors.
275  unsigned int nvecs=0;
276  if (this->processor_id() == 0)
277  io.data (nvecs);
278  this->comm().broadcast(nvecs);
279 
280  // If nvecs > 0, this means that write_additional_data
281  // was true when this file was written. We will need to
282  // make use of this fact later.
283  this->_additional_data_written = nvecs;
284 
285  for (unsigned int vec=0; vec<nvecs; vec++)
286  {
287  // 9.)
288  // Read the name of the vec-th additional vector
289  std::string vec_name;
290  if (this->processor_id() == 0)
291  io.data (vec_name);
292  this->comm().broadcast(vec_name);
293 
294  if (read_additional_data)
295  {
296  // Systems now can handle adding post-initialization vectors
297  // libmesh_assert(this->_can_add_vectors);
298  // Some systems may have added their own vectors already
299  // libmesh_assert_equal_to (this->_vectors.count(vec_name), 0);
300 
301  this->add_vector(vec_name);
302  }
303  }
304 }

References libMesh::System::_additional_data_written, libMesh::System::_written_var_indices, libMesh::System::add_variable(), libMesh::System::add_vector(), 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_impl(), and libMesh::RBEvaluation::read_in_vectors_from_multiple_files().

◆ 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.

Definition at line 309 of file system_io.C.

311 {
312  libmesh_deprecated();
313 
314  // This method implements the output of the vectors
315  // contained in this System object, embedded in the
316  // output of an EquationSystems<T_sys>.
317  //
318  // 10.) The global solution vector, re-ordered to be node-major
319  // (More on this later.)
320  //
321  // for each additional vector in the object
322  //
323  // 11.) The global additional vector, re-ordered to be
324  // node-major (More on this later.)
325  libmesh_assert (io.reading());
326 
327  // read and reordering buffers
328  std::vector<Number> global_vector;
329  std::vector<Number> reordered_vector;
330 
331  // 10.)
332  // Read and set the solution vector
333  {
334  if (this->processor_id() == 0)
335  io.data (global_vector);
336  this->comm().broadcast(global_vector);
337 
338  // Remember that the stored vector is node-major.
339  // We need to put it into whatever application-specific
340  // ordering we may have using the dof_map.
341  reordered_vector.resize(global_vector.size());
342 
343  //libMesh::out << "global_vector.size()=" << global_vector.size() << std::endl;
344  //libMesh::out << "this->n_dofs()=" << this->n_dofs() << std::endl;
345 
346  libmesh_assert_equal_to (global_vector.size(), this->n_dofs());
347 
348  dof_id_type cnt=0;
349 
350  const unsigned int sys = this->number();
351  const unsigned int nv = cast_int<unsigned int>
352  (this->_written_var_indices.size());
353  libmesh_assert_less_equal (nv, this->n_vars());
354 
355  for (unsigned int data_var=0; data_var<nv; data_var++)
356  {
357  const unsigned int var = _written_var_indices[data_var];
358 
359  // First reorder the nodal DOF values
360  for (auto & node : this->get_mesh().node_ptr_range())
361  for (auto index : IntRange<unsigned int>(0, node->n_comp(sys,var)))
362  {
363  libmesh_assert_not_equal_to (node->dof_number(sys, var, index),
365 
366  libmesh_assert_less (cnt, global_vector.size());
367 
368  reordered_vector[node->dof_number(sys, var, index)] =
369  global_vector[cnt++];
370  }
371 
372  // Then reorder the element DOF values
373  for (auto & elem : this->get_mesh().active_element_ptr_range())
374  for (auto index : IntRange<unsigned int>(0, elem->n_comp(sys,var)))
375  {
376  libmesh_assert_not_equal_to (elem->dof_number(sys, var, index),
378 
379  libmesh_assert_less (cnt, global_vector.size());
380 
381  reordered_vector[elem->dof_number(sys, var, index)] =
382  global_vector[cnt++];
383  }
384  }
385 
386  *(this->solution) = reordered_vector;
387  }
388 
389  // For each additional vector, simply go through the list.
390  // ONLY attempt to do this IF additional data was actually
391  // written to the file for this system (controlled by the
392  // _additional_data_written flag).
393  if (this->_additional_data_written)
394  {
395  const std::size_t nvecs = this->_vectors.size();
396 
397  // If the number of additional vectors written is non-zero, and
398  // the number of additional vectors we have is non-zero, and
399  // they don't match, then something is wrong and we can't be
400  // sure we're reading data into the correct places.
401  if (read_additional_data && nvecs &&
402  nvecs != this->_additional_data_written)
403  libmesh_error_msg
404  ("Additional vectors in file do not match system");
405 
406  std::map<std::string, NumericVector<Number> *>::iterator
407  pos = this->_vectors.begin();
408 
409  for (std::size_t i = 0; i != this->_additional_data_written; ++i)
410  {
411  // 11.)
412  // Read the values of the vec-th additional vector.
413  // Prior do _not_ clear, but fill with zero, since the
414  // additional vectors _have_ to have the same size
415  // as the solution vector
416  std::fill (global_vector.begin(), global_vector.end(), libMesh::zero);
417 
418  if (this->processor_id() == 0)
419  io.data (global_vector);
420 
421  // If read_additional_data==true and we have additional vectors,
422  // then we will keep this vector data; otherwise we are going to
423  // throw it away.
424  if (read_additional_data && nvecs)
425  {
426  this->comm().broadcast(global_vector);
427 
428  // Remember that the stored vector is node-major.
429  // We need to put it into whatever application-specific
430  // ordering we may have using the dof_map.
431  std::fill (reordered_vector.begin(),
432  reordered_vector.end(),
433  libMesh::zero);
434 
435  reordered_vector.resize(global_vector.size());
436 
437  libmesh_assert_equal_to (global_vector.size(), this->n_dofs());
438 
439  dof_id_type cnt=0;
440 
441  const unsigned int sys = this->number();
442  const unsigned int nv = cast_int<unsigned int>
443  (this->_written_var_indices.size());
444  libmesh_assert_less_equal (nv, this->n_vars());
445 
446  for (unsigned int data_var=0; data_var<nv; data_var++)
447  {
448  const unsigned int var = _written_var_indices[data_var];
449  // First reorder the nodal DOF values
450  for (auto & node : this->get_mesh().node_ptr_range())
451  for (auto index : IntRange<unsigned int>(0, node->n_comp(sys,var)))
452  {
453  libmesh_assert_not_equal_to (node->dof_number(sys, var, index),
455 
456  libmesh_assert_less (cnt, global_vector.size());
457 
458  reordered_vector[node->dof_number(sys, var, index)] =
459  global_vector[cnt++];
460  }
461 
462  // Then reorder the element DOF values
463  for (auto & elem : this->get_mesh().active_element_ptr_range())
464  for (auto index : IntRange<unsigned int>(0, elem->n_comp(sys,var)))
465  {
466  libmesh_assert_not_equal_to (elem->dof_number(sys, var, index),
468 
469  libmesh_assert_less (cnt, global_vector.size());
470 
471  reordered_vector[elem->dof_number(sys, var, index)] =
472  global_vector[cnt++];
473  }
474  }
475 
476  // use the overloaded operator=(std::vector) to assign the values
477  *(pos->second) = reordered_vector;
478  }
479 
480  // If we've got vectors then we need to be iterating through
481  // those too
482  if (pos != this->_vectors.end())
483  ++pos;
484  }
485  } // end if (_additional_data_written)
486 }

References libMesh::System::_additional_data_written, libMesh::System::_vectors, libMesh::System::_written_var_indices, libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::System::get_mesh(), libMesh::DofObject::invalid_id, libMesh::libmesh_assert(), libMesh::System::n_dofs(), libMesh::System::n_vars(), libMesh::System::number(), libMesh::ParallelObject::processor_id(), libMesh::Xdr::reading(), libMesh::System::solution, and libMesh::zero.

◆ 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 492 of file system_io.C.

494 {
514  // PerfLog pl("IO Performance",false);
515  // pl.push("read_parallel_data");
516  dof_id_type total_read_size = 0;
517 
518  libmesh_assert (io.reading());
519  libmesh_assert (io.is_open());
520 
521  // build the ordered nodes and element maps.
522  // when writing/reading parallel files we need to iterate
523  // over our nodes/elements in order of increasing global id().
524  // however, this is not guaranteed to be ordering we obtain
525  // by using the node_iterators/element_iterators directly.
526  // so build a set, sorted by id(), that provides the ordering.
527  // further, for memory economy build the set but then transfer
528  // its contents to vectors, which will be sorted.
529  std::vector<const DofObject *> ordered_nodes, ordered_elements;
530  {
531  std::set<const DofObject *, CompareDofObjectsByID>
532  ordered_nodes_set (this->get_mesh().local_nodes_begin(),
533  this->get_mesh().local_nodes_end());
534 
535  ordered_nodes.insert(ordered_nodes.end(),
536  ordered_nodes_set.begin(),
537  ordered_nodes_set.end());
538  }
539  {
540  std::set<const DofObject *, CompareDofObjectsByID>
541  ordered_elements_set (this->get_mesh().local_elements_begin(),
542  this->get_mesh().local_elements_end());
543 
544  ordered_elements.insert(ordered_elements.end(),
545  ordered_elements_set.begin(),
546  ordered_elements_set.end());
547  }
548 
549  // std::vector<Number> io_buffer;
550  std::vector<InValType> io_buffer;
551 
552  // 9.)
553  //
554  // Actually read the solution components
555  // for the ith system to disk
556  io.data(io_buffer);
557 
558  total_read_size += cast_int<dof_id_type>(io_buffer.size());
559 
560  const unsigned int sys_num = this->number();
561  const unsigned int nv = cast_int<unsigned int>
562  (this->_written_var_indices.size());
563  libmesh_assert_less_equal (nv, this->n_vars());
564 
565  dof_id_type cnt=0;
566 
567  // Loop over each non-SCALAR variable and each node, and read out the value.
568  for (unsigned int data_var=0; data_var<nv; data_var++)
569  {
570  const unsigned int var = _written_var_indices[data_var];
571  if (this->variable(var).type().family != SCALAR)
572  {
573  // First read the node DOF values
574  for (const auto & node : ordered_nodes)
575  for (auto comp : IntRange<unsigned int>(0, node->n_comp(sys_num,var)))
576  {
577  libmesh_assert_not_equal_to (node->dof_number(sys_num, var, comp),
579  libmesh_assert_less (cnt, io_buffer.size());
580  this->solution->set(node->dof_number(sys_num, var, comp), io_buffer[cnt++]);
581  }
582 
583  // Then read the element DOF values
584  for (const auto & elem : ordered_elements)
585  for (auto comp : IntRange<unsigned int>(0, elem->n_comp(sys_num,var)))
586  {
587  libmesh_assert_not_equal_to (elem->dof_number(sys_num, var, comp),
589  libmesh_assert_less (cnt, io_buffer.size());
590  this->solution->set(elem->dof_number(sys_num, var, comp), io_buffer[cnt++]);
591  }
592  }
593  }
594 
595  // Finally, read the SCALAR variables on the last processor
596  for (unsigned int data_var=0; data_var<nv; data_var++)
597  {
598  const unsigned int var = _written_var_indices[data_var];
599  if (this->variable(var).type().family == SCALAR)
600  {
601  if (this->processor_id() == (this->n_processors()-1))
602  {
603  const DofMap & dof_map = this->get_dof_map();
604  std::vector<dof_id_type> SCALAR_dofs;
605  dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
606 
607  for (auto dof : SCALAR_dofs)
608  this->solution->set(dof, io_buffer[cnt++]);
609  }
610  }
611  }
612 
613  // And we're done setting solution entries
614  this->solution->close();
615 
616  // For each additional vector, simply go through the list.
617  // ONLY attempt to do this IF additional data was actually
618  // written to the file for this system (controlled by the
619  // _additional_data_written flag).
620  if (this->_additional_data_written)
621  {
622  const std::size_t nvecs = this->_vectors.size();
623 
624  // If the number of additional vectors written is non-zero, and
625  // the number of additional vectors we have is non-zero, and
626  // they don't match, then something is wrong and we can't be
627  // sure we're reading data into the correct places.
628  if (read_additional_data && nvecs &&
629  nvecs != this->_additional_data_written)
630  libmesh_error_msg
631  ("Additional vectors in file do not match system");
632 
633  std::map<std::string, NumericVector<Number> *>::const_iterator
634  pos = _vectors.begin();
635 
636  for (std::size_t i = 0; i != this->_additional_data_written; ++i)
637  {
638  cnt=0;
639  io_buffer.clear();
640 
641  // 10.)
642  //
643  // Actually read the additional vector components
644  // for the ith system from disk
645  io.data(io_buffer);
646 
647  total_read_size += cast_int<dof_id_type>(io_buffer.size());
648 
649  // If read_additional_data==true and we have additional vectors,
650  // then we will keep this vector data; otherwise we are going to
651  // throw it away.
652  if (read_additional_data && nvecs)
653  {
654  // Loop over each non-SCALAR variable and each node, and read out the value.
655  for (unsigned int data_var=0; data_var<nv; data_var++)
656  {
657  const unsigned int var = _written_var_indices[data_var];
658  if (this->variable(var).type().family != SCALAR)
659  {
660  // First read the node DOF values
661  for (const auto & node : ordered_nodes)
662  for (auto comp : IntRange<unsigned int>(0, node->n_comp(sys_num,var)))
663  {
664  libmesh_assert_not_equal_to (node->dof_number(sys_num, var, comp),
666  libmesh_assert_less (cnt, io_buffer.size());
667  pos->second->set(node->dof_number(sys_num, var, comp), io_buffer[cnt++]);
668  }
669 
670  // Then read the element DOF values
671  for (const auto & elem : ordered_elements)
672  for (auto comp : IntRange<unsigned int>(0, elem->n_comp(sys_num,var)))
673  {
674  libmesh_assert_not_equal_to (elem->dof_number(sys_num, var, comp),
676  libmesh_assert_less (cnt, io_buffer.size());
677  pos->second->set(elem->dof_number(sys_num, var, comp), io_buffer[cnt++]);
678  }
679  }
680  }
681 
682  // Finally, read the SCALAR variables on the last processor
683  for (unsigned int data_var=0; data_var<nv; data_var++)
684  {
685  const unsigned int var = _written_var_indices[data_var];
686  if (this->variable(var).type().family == SCALAR)
687  {
688  if (this->processor_id() == (this->n_processors()-1))
689  {
690  const DofMap & dof_map = this->get_dof_map();
691  std::vector<dof_id_type> SCALAR_dofs;
692  dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
693 
694  for (auto dof : SCALAR_dofs)
695  pos->second->set(dof, io_buffer[cnt++]);
696  }
697  }
698  }
699 
700  // And we're done setting entries for this variable
701  pos->second->close();
702  }
703 
704  // If we've got vectors then we need to be iterating through
705  // those too
706  if (pos != this->_vectors.end())
707  ++pos;
708  }
709  }
710 
711  // const Real
712  // dt = pl.get_elapsed_time(),
713  // rate = total_read_size*sizeof(Number)/dt;
714 
715  // libMesh::err << "Read " << total_read_size << " \"Number\" values\n"
716  // << " Elapsed time = " << dt << '\n'
717  // << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";
718 
719  // pl.pop("read_parallel_data");
720 }

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::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().

◆ read_parallel_data() [2/2]

template 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 1315 of file system.h.

1317  { 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 284 of file rb_parametrized.C.

287 {
288  RBParameters param_min;
289  RBParameters param_max;
290  read_parameter_ranges_from_file(continuous_param_file_name,
291  read_binary_data,
292  param_min,
293  param_max);
294 
295  std::map<std::string, std::vector<Real>> discrete_parameter_values_in;
296  read_discrete_parameter_values_from_file(discrete_param_file_name,
297  read_binary_data,
298  discrete_parameter_values_in);
299 
300  initialize_parameters(param_min, param_max, discrete_parameter_values_in);
301 }

References libMesh::RBParametrized::initialize_parameters(), libMesh::RBParametrized::read_discrete_parameter_values_from_file(), and libMesh::RBParametrized::read_parameter_ranges_from_file().

Referenced by libMesh::RBEvaluation::legacy_read_offline_data_from_files(), and libMesh::RBSCMEvaluation::legacy_read_offline_data_from_files().

◆ read_parameter_ranges_from_file()

void libMesh::RBParametrized::read_parameter_ranges_from_file ( const std::string &  file_name,
const bool  read_binary,
RBParameters param_min,
RBParameters param_max 
)
privateinherited

Read in the parameter ranges from file.

Initialize parameters to the "minimum" parameter values.

Definition at line 303 of file rb_parametrized.C.

307 {
308  // The reading mode: DECODE for binary, READ for ASCII
309  XdrMODE mode = read_binary_data ? DECODE : READ;
310 
311  // Read in the parameter ranges
312  Xdr parameter_ranges_in(file_name, mode);
313  unsigned int n_continuous_params;
314  parameter_ranges_in >> n_continuous_params;
315 
316  for (unsigned int i=0; i<n_continuous_params; i++)
317  {
318  std::string param_name;
319  Real param_value;
320 
321  parameter_ranges_in >> param_name;
322  parameter_ranges_in >> param_value;
323 
324  param_min.set_value(param_name, param_value);
325  }
326  for (unsigned int i=0; i<n_continuous_params; i++)
327  {
328  std::string param_name;
329  Real param_value;
330 
331  parameter_ranges_in >> param_name;
332  parameter_ranges_in >> param_value;
333 
334  param_max.set_value(param_name, param_value);
335  }
336 
337  parameter_ranges_in.close();
338 }

References libMesh::Xdr::close(), libMesh::DECODE, libMesh::READ, libMesh::Real, and libMesh::RBParameters::set_value().

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

◆ read_riesz_representors_from_files()

void libMesh::RBConstruction::read_riesz_representors_from_files ( const std::string &  riesz_representors_dir,
const bool  write_binary_residual_representors 
)
virtualinherited

Read in all the Riesz representor data from files.

directory_name specifies which directory to read from. io_flag specifies whether we read in all data, or only a basis (in)dependent subset.

Reimplemented in libMesh::TransientRBConstruction.

Definition at line 2140 of file rb_construction.C.

2142 {
2143  LOG_SCOPE("read_riesz_representors_from_files()", "RBConstruction");
2144 
2145  libMesh::out << "Reading in the Fq_representors..." << std::endl;
2146 
2147  const std::string riesz_representor_suffix = (read_binary_residual_representors ? ".xdr" : ".dat");
2148  std::ostringstream file_name;
2149  struct stat stat_info;
2150 
2151  // Read in the Fq_representors. There should be Q_f of these. FIXME:
2152  // should we be worried about leaks here?
2153  for (const auto & rep : Fq_representor)
2154  if (rep)
2155  libmesh_error_msg("Error, must delete existing Fq_representor before reading in from file.");
2156 
2157  for (auto i : index_range(Fq_representor))
2158  {
2159  file_name.str(""); // reset filename
2160  file_name << riesz_representors_dir
2161  << "/Fq_representor" << i << riesz_representor_suffix;
2162 
2163  // On processor zero check to be sure the file exists
2164  if (this->processor_id() == 0)
2165  {
2166  int stat_result = stat(file_name.str().c_str(), &stat_info);
2167 
2168  if (stat_result != 0)
2169  libmesh_error_msg("File does not exist: " << file_name.str());
2170  }
2171 
2172  Xdr fqr_data(file_name.str(),
2173  read_binary_residual_representors ? DECODE : READ);
2174 
2175  read_serialized_data(fqr_data, false);
2176 
2178  Fq_representor[i]->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
2179 
2180  // No need to copy, just swap
2181  // *Fq_representor[i] = *solution;
2182  Fq_representor[i]->swap(*solution);
2183  }
2184 
2185  // Alert the update_residual_terms() function that we don't need to recompute
2186  // the Fq_representors as we have already read them in from file!
2188 
2189 
2190  libMesh::out << "Reading in the Aq_representors..." << std::endl;
2191 
2192  // Read in the Aq representors. The class makes room for [Q_a][Nmax] of these. We are going to
2193  // read in [Q_a][get_rb_evaluation().get_n_basis_functions()]. FIXME:
2194  // should we be worried about leaks in the locations where we're about to fill entries?
2195  RBEvaluation & rbe = get_rb_evaluation();
2196  for (const auto & row : rbe.Aq_representor)
2197  for (const auto & rep : row)
2198  if (rep)
2199  libmesh_error_msg("Error, must delete existing Aq_representor before reading in from file.");
2200 
2201  // Now ready to read them in from file!
2202  for (auto i : index_range(rbe.Aq_representor))
2203  for (unsigned int j=0; j<rbe.get_n_basis_functions(); ++j)
2204  {
2205  file_name.str(""); // reset filename
2206  file_name << riesz_representors_dir
2207  << "/Aq_representor" << i << "_" << j << riesz_representor_suffix;
2208 
2209  // On processor zero check to be sure the file exists
2210  if (this->processor_id() == 0)
2211  {
2212  int stat_result = stat(file_name.str().c_str(), &stat_info);
2213 
2214  if (stat_result != 0)
2215  libmesh_error_msg("File does not exist: " << file_name.str());
2216  }
2217 
2218  Xdr aqr_data(file_name.str(), read_binary_residual_representors ? DECODE : READ);
2219 
2220  read_serialized_data(aqr_data, false);
2221 
2222  rbe.Aq_representor[i][j] = NumericVector<Number>::build(this->comm());
2223  rbe.Aq_representor[i][j]->init (n_dofs(), n_local_dofs(),
2224  false, PARALLEL);
2225 
2226  // No need to copy, just swap
2227  rbe.Aq_representor[i][j]->swap(*solution);
2228  }
2229 }

References libMesh::RBEvaluation::Aq_representor, libMesh::NumericVector< T >::build(), libMesh::ParallelObject::comm(), libMesh::DECODE, libMesh::RBConstruction::Fq_representor, libMesh::RBConstruction::Fq_representor_innerprods_computed, libMesh::RBEvaluation::get_n_basis_functions(), libMesh::RBConstruction::get_rb_evaluation(), libMesh::index_range(), 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.

◆ read_SCALAR_dofs()

unsigned int libMesh::System::read_SCALAR_dofs ( const unsigned int  var,
Xdr io,
NumericVector< Number > *  vec 
) const
privateinherited

Reads the SCALAR dofs from the stream io and assigns the values to the appropriate entries of vec.

Returns
The number of dofs read.

Reads data and discards it if vec is a null pointer.

Definition at line 1120 of file system_io.C.

1123 {
1124  unsigned int n_assigned_vals = 0; // the number of values assigned, this will be returned.
1125 
1126  // Processor 0 will read the block from the buffer stream and send it to the last processor
1127  const unsigned int n_SCALAR_dofs = this->variable(var).type().order.get_order();
1128  std::vector<Number> input_buffer(n_SCALAR_dofs);
1129  if (this->processor_id() == 0)
1130  io.data_stream(input_buffer.data(), n_SCALAR_dofs);
1131 
1132 #ifdef LIBMESH_HAVE_MPI
1133  if (this->n_processors() > 1)
1134  {
1135  const Parallel::MessageTag val_tag = this->comm().get_unique_tag();
1136 
1137  // Post the receive on the last processor
1138  if (this->processor_id() == (this->n_processors()-1))
1139  this->comm().receive(0, input_buffer, val_tag);
1140 
1141  // Send the data to processor 0
1142  if (this->processor_id() == 0)
1143  this->comm().send(this->n_processors()-1, input_buffer, val_tag);
1144  }
1145 #endif
1146 
1147  // Finally, set the SCALAR values
1148  if (this->processor_id() == (this->n_processors()-1))
1149  {
1150  const DofMap & dof_map = this->get_dof_map();
1151  std::vector<dof_id_type> SCALAR_dofs;
1152  dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
1153 
1154  for (auto i : index_range(SCALAR_dofs))
1155  {
1156  if (vec)
1157  vec->set (SCALAR_dofs[i], input_buffer[i]);
1158  ++n_assigned_vals;
1159  }
1160  }
1161 
1162  return n_assigned_vals;
1163 }

References libMesh::ParallelObject::comm(), libMesh::Xdr::data_stream(), libMesh::System::get_dof_map(), libMesh::OrderWrapper::get_order(), libMesh::index_range(), libMesh::ParallelObject::n_processors(), libMesh::FEType::order, libMesh::ParallelObject::processor_id(), libMesh::DofMap::SCALAR_dof_indices(), libMesh::NumericVector< T >::set(), libMesh::Variable::type(), and libMesh::System::variable().

Referenced by libMesh::System::read_serialized_vector(), and libMesh::System::read_serialized_vectors().

◆ read_serialized_blocked_dof_objects()

template<typename iterator_type , typename InValType >
std::size_t libMesh::System::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
privateinherited

Reads an input vector from the stream io and assigns the values to a set of DofObjects.

This method uses blocked input and is safe to call on a distributed memory-mesh. Unless otherwise specified, all variables are read.

If an entry in vecs is a null pointer, the corresponding data is read (incrementing the file read location) but discarded.

Definition at line 810 of file system_io.C.

817 {
818  //-------------------------------------------------------
819  // General order: (IO format 0.7.4 & greater)
820  //
821  // for (objects ...)
822  // for (vecs ....)
823  // for (vars ....)
824  // for (comps ...)
825  //
826  // where objects are nodes or elements, sorted to be
827  // partition independent,
828  // vecs are one or more *identically distributed* solution
829  // coefficient vectors, vars are one or more variables
830  // to write, and comps are all the components for said
831  // vars on the object.
832 
833  // variables to read. Unless specified otherwise, defaults to _written_var_indices.
834  std::vector<unsigned int> vars_to_read (_written_var_indices);
835 
836  if (var_to_read != libMesh::invalid_uint)
837  {
838  vars_to_read.clear();
839  vars_to_read.push_back(var_to_read);
840  }
841 
842  const unsigned int
843  sys_num = this->number(),
844  num_vecs = cast_int<unsigned int>(vecs.size());
845  const dof_id_type
846  io_blksize = cast_int<dof_id_type>(std::min(max_io_blksize, static_cast<std::size_t>(n_objs))),
847  num_blks = cast_int<unsigned int>(std::ceil(static_cast<double>(n_objs)/
848  static_cast<double>(io_blksize)));
849 
850  libmesh_assert_less_equal (_written_var_indices.size(), this->n_vars());
851 
852  std::size_t n_read_values=0;
853 
854  std::vector<std::vector<dof_id_type>> xfer_ids(num_blks); // The global IDs and # of components for the local objects in all blocks
855  std::vector<std::vector<Number>> recv_vals(num_blks); // The raw values for the local objects in all blocks
856  std::vector<Parallel::Request>
857  id_requests(num_blks), val_requests(num_blks);
858  std::vector<Parallel::MessageTag>
859  id_tags(num_blks), val_tags(num_blks);
860 
861  // ------------------------------------------------------
862  // First pass - count the number of objects in each block
863  // traverse all the objects and figure out which block they
864  // will ultimately live in.
865  std::vector<std::size_t>
866  xfer_ids_size (num_blks,0),
867  recv_vals_size (num_blks,0);
868 
869 
870  for (iterator_type it=begin; it!=end; ++it)
871  {
872  const dof_id_type
873  id = (*it)->id(),
874  block = id/io_blksize;
875 
876  libmesh_assert_less (block, num_blks);
877 
878  xfer_ids_size[block] += 2; // for each object, we send its id, as well as the total number of components for all variables
879 
880  dof_id_type n_comp_tot=0;
881  for (const auto & var : vars_to_read)
882  n_comp_tot += (*it)->n_comp(sys_num, var); // for each variable, we will receive the nonzero components
883 
884  recv_vals_size[block] += n_comp_tot*num_vecs;
885  }
886 
887  // knowing the recv_vals_size[block] for each processor allows
888  // us to sum them and find the global size for each block.
889  std::vector<std::size_t> tot_vals_size(recv_vals_size);
890  this->comm().sum (tot_vals_size);
891 
892 
893  //------------------------------------------
894  // Collect the ids & number of values needed
895  // for all local objects, binning them into
896  // 'blocks' that will be sent to processor 0
897  for (dof_id_type blk=0; blk<num_blks; blk++)
898  {
899  // Each processor should build up its transfer buffers for its
900  // local objects in [first_object,last_object).
901  const dof_id_type
902  first_object = blk*io_blksize,
903  last_object = std::min(cast_int<dof_id_type>((blk+1)*io_blksize), n_objs);
904 
905  // convenience
906  std::vector<dof_id_type> & ids (xfer_ids[blk]);
907  std::vector<Number> & vals (recv_vals[blk]);
908 
909  // we now know the number of values we will store for each block,
910  // so we can do efficient preallocation
911  ids.clear(); ids.reserve (xfer_ids_size[blk]);
912  vals.resize(recv_vals_size[blk]);
913 
914  if (recv_vals_size[blk] != 0) // only if there are nonzero values to receive
915  for (iterator_type it=begin; it!=end; ++it)
916  if (((*it)->id() >= first_object) && // object in [first_object,last_object)
917  ((*it)->id() < last_object))
918  {
919  ids.push_back((*it)->id());
920 
921  unsigned int n_comp_tot=0;
922 
923  for (const auto & var : vars_to_read)
924  n_comp_tot += (*it)->n_comp(sys_num, var);
925 
926  ids.push_back (n_comp_tot*num_vecs);
927  }
928 
929 #ifdef LIBMESH_HAVE_MPI
930  id_tags[blk] = this->comm().get_unique_tag(100*num_blks + blk);
931  val_tags[blk] = this->comm().get_unique_tag(200*num_blks + blk);
932 
933  // nonblocking send the data for this block
934  this->comm().send (0, ids, id_requests[blk], id_tags[blk]);
935 
936  // Go ahead and post the receive too
937  this->comm().receive (0, vals, val_requests[blk], val_tags[blk]);
938 #endif
939  }
940 
941  //---------------------------------------------------
942  // Here processor 0 will read and distribute the data.
943  // We have to do this block-wise to ensure that we
944  // do not exhaust memory on processor 0.
945 
946  // give these variables scope outside the block to avoid reallocation
947  std::vector<std::vector<dof_id_type>> recv_ids (this->n_processors());
948  std::vector<std::vector<Number>> send_vals (this->n_processors());
949  std::vector<Parallel::Request> reply_requests (this->n_processors());
950  std::vector<unsigned int> obj_val_offsets; // map to traverse entry-wise rather than processor-wise
951  std::vector<Number> input_vals; // The input buffer for the current block
952  std::vector<InValType> input_vals_tmp; // The input buffer for the current block
953 
954  for (dof_id_type blk=0; blk<num_blks; blk++)
955  {
956  // Each processor should build up its transfer buffers for its
957  // local objects in [first_object,last_object).
958  const dof_id_type
959  first_object = blk*io_blksize,
960  last_object = std::min(cast_int<dof_id_type>((blk+1)*io_blksize), n_objs),
961  n_objects_blk = last_object - first_object;
962 
963  // Processor 0 has a special job. It needs to gather the requested indices
964  // in [first_object,last_object) from all processors, read the data from
965  // disk, and reply
966  if (this->processor_id() == 0)
967  {
968  // we know the input buffer size for this block and can begin reading it now
969  input_vals.resize(tot_vals_size[blk]);
970  input_vals_tmp.resize(tot_vals_size[blk]);
971 
972  // a ThreadedIO object to perform asynchronous file IO
973  ThreadedIO<InValType> threaded_io(io, input_vals_tmp);
974  Threads::Thread async_io(threaded_io);
975 
976  // offset array. this will define where each object's values
977  // map into the actual input_vals buffer. this must get
978  // 0-initialized because 0-component objects are not actually sent
979  obj_val_offsets.resize (n_objects_blk); std::fill (obj_val_offsets.begin(), obj_val_offsets.end(), 0);
980  recv_vals_size.resize(this->n_processors()); // reuse this to count how many values are going to each processor
981 
982 #ifndef NDEBUG
983  std::size_t n_vals_blk = 0;
984 #endif
985 
986  // loop over all processors and process their index request
987  for (processor_id_type comm_step=0, tnp=this->n_processors(); comm_step != tnp; ++comm_step)
988  {
989 #ifdef LIBMESH_HAVE_MPI
990  // blocking receive indices for this block, imposing no particular order on processor
991  Parallel::Status id_status (this->comm().probe (Parallel::any_source, id_tags[blk]));
992  std::vector<dof_id_type> & ids (recv_ids[id_status.source()]);
993  std::size_t & n_vals_proc (recv_vals_size[id_status.source()]);
994  this->comm().receive (id_status.source(), ids, id_tags[blk]);
995 #else
996  // straight copy without MPI
997  std::vector<dof_id_type> & ids (recv_ids[0]);
998  std::size_t & n_vals_proc (recv_vals_size[0]);
999  ids = xfer_ids[blk];
1000 #endif
1001 
1002  n_vals_proc = 0;
1003 
1004  // note its possible we didn't receive values for objects in
1005  // this block if they have no components allocated.
1006  for (std::size_t idx=0, sz=ids.size(); idx<sz; idx+=2)
1007  {
1008  const dof_id_type
1009  local_idx = ids[idx+0]-first_object,
1010  n_vals_tot_allvecs = ids[idx+1];
1011 
1012  libmesh_assert_less (local_idx, n_objects_blk);
1013 
1014  obj_val_offsets[local_idx] = n_vals_tot_allvecs;
1015  n_vals_proc += n_vals_tot_allvecs;
1016  }
1017 
1018 #ifndef NDEBUG
1019  n_vals_blk += n_vals_proc;
1020 #endif
1021  }
1022 
1023  // We need the offsets into the input_vals vector for each object.
1024  // fortunately, this is simply the partial sum of the total number
1025  // of components for each object
1026  std::partial_sum(obj_val_offsets.begin(), obj_val_offsets.end(),
1027  obj_val_offsets.begin());
1028 
1029  libmesh_assert_equal_to (n_vals_blk, obj_val_offsets.back());
1030  libmesh_assert_equal_to (n_vals_blk, tot_vals_size[blk]);
1031 
1032  // Wait for read completion
1033  async_io.join();
1034  // now copy the values back to the main vector for transfer
1035  for (auto i_val : index_range(input_vals))
1036  input_vals[i_val] = input_vals_tmp[i_val];
1037 
1038  n_read_values += input_vals.size();
1039 
1040  // pack data replies for each processor
1041  for (auto proc : IntRange<processor_id_type>(0, this->n_processors()))
1042  {
1043  const std::vector<dof_id_type> & ids (recv_ids[proc]);
1044  std::vector<Number> & vals (send_vals[proc]);
1045  const std::size_t & n_vals_proc (recv_vals_size[proc]);
1046 
1047  vals.clear(); vals.reserve(n_vals_proc);
1048 
1049  for (std::size_t idx=0, sz=ids.size(); idx<sz; idx+=2)
1050  {
1051  const dof_id_type
1052  local_idx = ids[idx+0]-first_object,
1053  n_vals_tot_allvecs = ids[idx+1];
1054 
1055  std::vector<Number>::const_iterator in_vals(input_vals.begin());
1056  if (local_idx != 0)
1057  std::advance (in_vals, obj_val_offsets[local_idx-1]);
1058 
1059  for (unsigned int val=0; val<n_vals_tot_allvecs; val++, ++in_vals)
1060  {
1061  libmesh_assert (in_vals != input_vals.end());
1062  //libMesh::out << "*in_vals=" << *in_vals << '\n';
1063  vals.push_back(*in_vals);
1064  }
1065  }
1066 
1067 #ifdef LIBMESH_HAVE_MPI
1068  // send the relevant values to this processor
1069  this->comm().send (proc, vals, reply_requests[proc], val_tags[blk]);
1070 #else
1071  recv_vals[blk] = vals;
1072 #endif
1073  }
1074  } // end processor 0 read/reply
1075 
1076  // all processors complete the (already posted) read for this block
1077  {
1078  Parallel::wait (val_requests[blk]);
1079 
1080  const std::vector<Number> & vals (recv_vals[blk]);
1081  std::vector<Number>::const_iterator val_it(vals.begin());
1082 
1083  if (!recv_vals[blk].empty()) // nonzero values to receive
1084  for (iterator_type it=begin; it!=end; ++it)
1085  if (((*it)->id() >= first_object) && // object in [first_object,last_object)
1086  ((*it)->id() < last_object))
1087  // unpack & set the values
1088  for (auto & vec : vecs)
1089  for (const auto & var : vars_to_read)
1090  {
1091  const unsigned int n_comp = (*it)->n_comp(sys_num, var);
1092 
1093  for (unsigned int comp=0; comp<n_comp; comp++, ++val_it)
1094  {
1095  const dof_id_type dof_index = (*it)->dof_number (sys_num, var, comp);
1096  libmesh_assert (val_it != vals.end());
1097  if (vec)
1098  {
1099  libmesh_assert_greater_equal (dof_index, vec->first_local_index());
1100  libmesh_assert_less (dof_index, vec->last_local_index());
1101  //libMesh::out << "dof_index, *val_it = \t" << dof_index << ", " << *val_it << '\n';
1102  vec->set (dof_index, *val_it);
1103  }
1104  }
1105  }
1106  }
1107 
1108  // processor 0 needs to make sure all replies have been handed off
1109  if (this->processor_id () == 0)
1110  Parallel::wait(reply_requests);
1111  }
1112 
1113  Parallel::wait(id_requests);
1114 
1115  return n_read_values;
1116 }

References libMesh::System::_written_var_indices, libMesh::ParallelObject::comm(), end, libMesh::MeshTools::Generation::Private::idx(), libMesh::index_range(), libMesh::invalid_uint, libMesh::Threads::NonConcurrentThread::join(), libMesh::libmesh_assert(), libMesh::ParallelObject::n_processors(), libMesh::System::n_vars(), libMesh::System::number(), and libMesh::ParallelObject::processor_id().

Referenced by libMesh::System::read_serialized_vector(), and libMesh::System::read_serialized_vectors().

◆ 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 724 of file system_io.C.

726 {
727  // This method implements the input of the vectors
728  // contained in this System object, embedded in the
729  // output of an EquationSystems<T_sys>.
730  //
731  // 10.) The global solution vector, re-ordered to be node-major
732  // (More on this later.)
733  //
734  // for each additional vector in the object
735  //
736  // 11.) The global additional vector, re-ordered to be
737  // node-major (More on this later.)
738  parallel_object_only();
739  std::string comment;
740 
741  // PerfLog pl("IO Performance",false);
742  // pl.push("read_serialized_data");
743  // std::size_t total_read_size = 0;
744 
745  // 10.)
746  // Read the global solution vector
747  {
748  // total_read_size +=
749  this->read_serialized_vector<InValType>(io, this->solution.get());
750 
751  // get the comment
752  if (this->processor_id() == 0)
753  io.comment (comment);
754  }
755 
756  // 11.)
757  // Only read additional vectors if data is available, and only use
758  // that data to fill our vectors if the user requested it.
759  if (this->_additional_data_written)
760  {
761  const std::size_t nvecs = this->_vectors.size();
762 
763  // If the number of additional vectors written is non-zero, and
764  // the number of additional vectors we have is non-zero, and
765  // they don't match, then we can't read additional vectors
766  // and be sure we're reading data into the correct places.
767  if (read_additional_data && nvecs &&
768  nvecs != this->_additional_data_written)
769  libmesh_error_msg
770  ("Additional vectors in file do not match system");
771 
772  std::map<std::string, NumericVector<Number> *>::const_iterator
773  pos = _vectors.begin();
774 
775  for (std::size_t i = 0; i != this->_additional_data_written; ++i)
776  {
777  // Read data, but only put it into a vector if we've been
778  // asked to and if we have a corresponding vector to read.
779 
780  // total_read_size +=
781  this->read_serialized_vector<InValType>
782  (io, (read_additional_data && nvecs) ? pos->second : nullptr);
783 
784  // get the comment
785  if (this->processor_id() == 0)
786  io.comment (comment);
787 
788 
789  // If we've got vectors then we need to be iterating through
790  // those too
791  if (pos != this->_vectors.end())
792  ++pos;
793  }
794  }
795 
796  // const Real
797  // dt = pl.get_elapsed_time(),
798  // rate = total_read_size*sizeof(Number)/dt;
799 
800  // libMesh::out << "Read " << total_read_size << " \"Number\" values\n"
801  // << " Elapsed time = " << dt << '\n'
802  // << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";
803 
804  // pl.pop("read_serialized_data");
805 }

References libMesh::System::_additional_data_written, libMesh::System::_vectors, libMesh::Xdr::comment(), libMesh::ParallelObject::processor_id(), and libMesh::System::solution.

Referenced by libMesh::TransientRBConstruction::initialize_truth(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), and libMesh::RBConstruction::read_riesz_representors_from_files().

◆ read_serialized_data() [2/2]

template 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 1273 of file system.h.

1275  { read_serialized_data<Number>(io, read_additional_data); }

◆ read_serialized_vector() [1/2]

numeric_index_type libMesh::System::read_serialized_vector ( Xdr io,
NumericVector< Number > &  vec 
)
inlineprivateinherited

Non-templated version for backward compatibility.

Reads a vector for this System. This method may safely be called on a distributed-memory mesh.

Returns
The length of the vector read.

Definition at line 1835 of file system.h.

1837  { return read_serialized_vector<Number>(io, &vec); }

◆ read_serialized_vector() [2/2]

template<typename InValType >
numeric_index_type libMesh::System::read_serialized_vector ( Xdr io,
NumericVector< Number > *  vec 
)
privateinherited

Reads a vector for this System.

This method may safely be called on a distributed-memory mesh.

Returns
The length of the vector read.

Reads data and discards it if vec is a null pointer.

Definition at line 1167 of file system_io.C.

1169 {
1170  parallel_object_only();
1171 
1172 #ifndef NDEBUG
1173  // In parallel we better be reading a parallel vector -- if not
1174  // we will not set all of its components below!!
1175  if (this->n_processors() > 1 && vec)
1176  {
1177  libmesh_assert (vec->type() == PARALLEL ||
1178  vec->type() == GHOSTED);
1179  }
1180 #endif
1181 
1182  libmesh_assert (io.reading());
1183 
1184  // vector length
1185  unsigned int vector_length=0; // FIXME? size_t would break binary compatibility...
1186 #ifndef NDEBUG
1187  std::size_t n_assigned_vals=0;
1188 #endif
1189 
1190  // Get the buffer size
1191  if (this->processor_id() == 0)
1192  io.data(vector_length, "# vector length");
1193  this->comm().broadcast(vector_length);
1194 
1195  const unsigned int nv = cast_int<unsigned int>
1196  (this->_written_var_indices.size());
1197  const dof_id_type
1198  n_nodes = this->get_mesh().n_nodes(),
1199  n_elem = this->get_mesh().n_elem();
1200 
1201  libmesh_assert_less_equal (nv, this->n_vars());
1202 
1203  // for newer versions, read variables node/elem major
1204  if (io.version() >= LIBMESH_VERSION_ID(0,7,4))
1205  {
1206  //---------------------------------
1207  // Collect the values for all nodes
1208 #ifndef NDEBUG
1209  n_assigned_vals +=
1210 #endif
1211  this->read_serialized_blocked_dof_objects (n_nodes,
1212  this->get_mesh().local_nodes_begin(),
1213  this->get_mesh().local_nodes_end(),
1214  InValType(),
1215  io,
1216  std::vector<NumericVector<Number> *> (1,vec));
1217 
1218 
1219  //------------------------------------
1220  // Collect the values for all elements
1221 #ifndef NDEBUG
1222  n_assigned_vals +=
1223 #endif
1225  this->get_mesh().local_elements_begin(),
1226  this->get_mesh().local_elements_end(),
1227  InValType(),
1228  io,
1229  std::vector<NumericVector<Number> *> (1,vec));
1230  }
1231 
1232  // for older versions, read variables var-major
1233  else
1234  {
1235  // Loop over each variable in the system, and then each node/element in the mesh.
1236  for (unsigned int data_var=0; data_var<nv; data_var++)
1237  {
1238  const unsigned int var = _written_var_indices[data_var];
1239  if (this->variable(var).type().family != SCALAR)
1240  {
1241  //---------------------------------
1242  // Collect the values for all nodes
1243 #ifndef NDEBUG
1244  n_assigned_vals +=
1245 #endif
1246  this->read_serialized_blocked_dof_objects (n_nodes,
1247  this->get_mesh().local_nodes_begin(),
1248  this->get_mesh().local_nodes_end(),
1249  InValType(),
1250  io,
1251  std::vector<NumericVector<Number> *> (1,vec),
1252  var);
1253 
1254 
1255  //------------------------------------
1256  // Collect the values for all elements
1257 #ifndef NDEBUG
1258  n_assigned_vals +=
1259 #endif
1261  this->get_mesh().local_elements_begin(),
1262  this->get_mesh().local_elements_end(),
1263  InValType(),
1264  io,
1265  std::vector<NumericVector<Number> *> (1,vec),
1266  var);
1267  } // end variable loop
1268  }
1269  }
1270 
1271  //-------------------------------------------
1272  // Finally loop over all the SCALAR variables
1273  for (unsigned int data_var=0; data_var<nv; data_var++)
1274  {
1275  const unsigned int var = _written_var_indices[data_var];
1276  if (this->variable(var).type().family == SCALAR)
1277  {
1278 #ifndef NDEBUG
1279  n_assigned_vals +=
1280 #endif
1281  this->read_SCALAR_dofs (var, io, vec);
1282  }
1283  }
1284 
1285  if (vec)
1286  vec->close();
1287 
1288 #ifndef NDEBUG
1289  this->comm().sum (n_assigned_vals);
1290  libmesh_assert_equal_to (n_assigned_vals, vector_length);
1291 #endif
1292 
1293  return vector_length;
1294 }

References libMesh::System::_written_var_indices, libMesh::NumericVector< T >::close(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::System::get_mesh(), libMesh::GHOSTED, libMesh::libmesh_assert(), libMesh::MeshBase::n_elem(), libMesh::MeshTools::n_elem(), n_nodes, libMesh::MeshBase::n_nodes(), libMesh::ParallelObject::n_processors(), libMesh::System::n_vars(), libMesh::PARALLEL, libMesh::ParallelObject::processor_id(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::Xdr::reading(), libMesh::SCALAR, libMesh::NumericVector< T >::type(), libMesh::System::variable(), and libMesh::Xdr::version().

◆ 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 2199 of file system_io.C.

2201 {
2202  parallel_object_only();
2203 
2204  // Error checking
2205  // #ifndef NDEBUG
2206  // // In parallel we better be reading a parallel vector -- if not
2207  // // we will not set all of its components below!!
2208  // if (this->n_processors() > 1)
2209  // {
2210  // libmesh_assert (vec.type() == PARALLEL ||
2211  // vec.type() == GHOSTED);
2212  // }
2213  // #endif
2214 
2215  libmesh_assert (io.reading());
2216 
2217  if (this->processor_id() == 0)
2218  {
2219  // sizes
2220  unsigned int num_vecs=0;
2221  dof_id_type vector_length=0;
2222 
2223  // Get the number of vectors
2224  io.data(num_vecs);
2225  // Get the buffer size
2226  io.data(vector_length);
2227 
2228  libmesh_assert_equal_to (num_vecs, vectors.size());
2229 
2230  if (num_vecs != 0)
2231  {
2232  libmesh_assert_not_equal_to (vectors[0], 0);
2233  libmesh_assert_equal_to (vectors[0]->size(), vector_length);
2234  }
2235  }
2236 
2237  // no need to actually communicate these.
2238  // this->comm().broadcast(num_vecs);
2239  // this->comm().broadcast(vector_length);
2240 
2241  // Cache these - they are not free!
2242  const dof_id_type
2243  n_nodes = this->get_mesh().n_nodes(),
2244  n_elem = this->get_mesh().n_elem();
2245 
2246  std::size_t read_length = 0;
2247 
2248  //---------------------------------
2249  // Collect the values for all nodes
2250  read_length +=
2251  this->read_serialized_blocked_dof_objects (n_nodes,
2252  this->get_mesh().local_nodes_begin(),
2253  this->get_mesh().local_nodes_end(),
2254  InValType(),
2255  io,
2256  vectors);
2257 
2258  //------------------------------------
2259  // Collect the values for all elements
2260  read_length +=
2262  this->get_mesh().local_elements_begin(),
2263  this->get_mesh().local_elements_end(),
2264  InValType(),
2265  io,
2266  vectors);
2267 
2268  //-------------------------------------------
2269  // Finally loop over all the SCALAR variables
2270  for (NumericVector<Number> * vec : vectors)
2271  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
2272  if (this->variable(var).type().family == SCALAR)
2273  {
2274  libmesh_assert_not_equal_to (vec, 0);
2275 
2276  read_length +=
2277  this->read_SCALAR_dofs (var, io, vec);
2278  }
2279 
2280  //---------------------------------------
2281  // last step - must close all the vectors
2282  for (NumericVector<Number> * vec : vectors)
2283  {
2284  libmesh_assert_not_equal_to (vec, 0);
2285  vec->close();
2286  }
2287 
2288  return read_length;
2289 }

References libMesh::Xdr::data(), libMesh::System::get_mesh(), libMesh::libmesh_assert(), libMesh::MeshBase::n_elem(), libMesh::MeshTools::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().

◆ read_serialized_vectors() [2/2]

template 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 1293 of file system.h.

1295  { 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 1380 of file rb_construction.C.

1381 {
1382  // Compute the basis independent terms
1384  compute_Fq_representor_innerprods(compute_inner_products);
1385 
1386  // and all the basis dependent terms
1387  unsigned int saved_delta_N = delta_N;
1389 
1390  update_residual_terms(compute_inner_products);
1391 
1392  delta_N = saved_delta_N;
1393 }

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().

◆ 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::ImplicitSystem.

Reimplemented in libMesh::NewmarkSystem.

Definition at line 85 of file linear_implicit_system.C.

86 {
87  // re-initialize the linear solver interface
88  linear_solver->clear();
89 
90  // initialize parent data
92 }

References libMesh::LinearImplicitSystem::linear_solver, and libMesh::ImplicitSystem::reinit().

◆ reinit_constraints()

void libMesh::System::reinit_constraints ( )
virtualinherited

◆ release_linear_solver()

void libMesh::LinearImplicitSystem::release_linear_solver ( LinearSolver< Number > *  ) const
overridevirtualinherited

Releases a pointer to a linear solver acquired by this->get_linear_solver()

Reimplemented from libMesh::ImplicitSystem.

Definition at line 360 of file linear_implicit_system.C.

361 {
362 }

◆ remove_matrix()

void libMesh::ImplicitSystem::remove_matrix ( const std::string &  mat_name)
inherited

Removes the additional matrix mat_name from this system.

Definition at line 221 of file implicit_system.C.

222 {
223  matrices_iterator pos = _matrices.find (mat_name);
224 
225  //Return if the matrix does not exist
226  if (pos == _matrices.end())
227  return;
228 
229  delete pos->second;
230 
231  _matrices.erase(pos);
232 }

References libMesh::ImplicitSystem::_matrices.

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

◆ remove_vector()

void libMesh::System::remove_vector ( const std::string &  vec_name)
inherited

Removes the additional vector vec_name from this system.

Definition at line 699 of file system.C.

700 {
701  vectors_iterator pos = _vectors.find(vec_name);
702 
703  //Return if the vector does not exist
704  if (pos == _vectors.end())
705  return;
706 
707  delete pos->second;
708 
709  _vectors.erase(pos);
710 
711  _vector_projections.erase(vec_name);
712  _vector_is_adjoint.erase(vec_name);
713  _vector_types.erase(vec_name);
714 }

References libMesh::System::_vector_is_adjoint, libMesh::System::_vector_projections, libMesh::System::_vector_types, and libMesh::System::_vectors.

◆ request_matrix() [1/2]

SparseMatrix< Number > * libMesh::ImplicitSystem::request_matrix ( const std::string &  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 249 of file implicit_system.C.

250 {
251  // Make sure the matrix exists
252  matrices_iterator pos = _matrices.find (mat_name);
253 
254  if (pos == _matrices.end())
255  return nullptr;
256 
257  return pos->second;
258 }

References libMesh::ImplicitSystem::_matrices.

◆ request_matrix() [2/2]

const SparseMatrix< Number > * libMesh::ImplicitSystem::request_matrix ( const std::string &  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 236 of file implicit_system.C.

237 {
238  // Make sure the matrix exists
239  const_matrices_iterator pos = _matrices.find (mat_name);
240 
241  if (pos == _matrices.end())
242  return nullptr;
243 
244  return pos->second;
245 }

References libMesh::ImplicitSystem::_matrices.

Referenced by libMesh::ImplicitSystem::sensitivity_solve(), libMesh::NewtonSolver::solve(), and libMesh::LinearImplicitSystem::solve().

◆ request_vector() [1/4]

NumericVector< Number > * libMesh::System::request_vector ( const std::string &  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 728 of file system.C.

729 {
730  vectors_iterator pos = _vectors.find(vec_name);
731 
732  if (pos == _vectors.end())
733  return nullptr;
734 
735  return pos->second;
736 }

References libMesh::System::_vectors.

◆ request_vector() [2/4]

const NumericVector< Number > * libMesh::System::request_vector ( const std::string &  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 716 of file system.C.

717 {
718  const_vectors_iterator pos = _vectors.find(vec_name);
719 
720  if (pos == _vectors.end())
721  return nullptr;
722 
723  return pos->second;
724 }

References libMesh::System::_vectors.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error().

◆ request_vector() [3/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 757 of file system.C.

758 {
760  vectors_iterator v_end = vectors_end();
761  unsigned int num = 0;
762  while ((num<vec_num) && (v!=v_end))
763  {
764  num++;
765  ++v;
766  }
767  if (v==v_end)
768  return nullptr;
769  return v->second;
770 }

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

◆ request_vector() [4/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 740 of file system.C.

741 {
744  unsigned int num = 0;
745  while ((num<vec_num) && (v!=v_end))
746  {
747  num++;
748  ++v;
749  }
750  if (v==v_end)
751  return nullptr;
752  return v->second;
753 }

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

◆ 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 96 of file linear_implicit_system.C.

98 {
99  _subset = subset;
100  _subset_solve_mode = subset_solve_mode;
101 
102  if (subset != nullptr)
103  libmesh_assert_equal_to (&subset->get_system(), this);
104 }

References libMesh::LinearImplicitSystem::_subset, libMesh::LinearImplicitSystem::_subset_solve_mode, and libMesh::SystemSubset::get_system().

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

◆ restrict_vectors()

void libMesh::System::restrict_vectors ( )
virtualinherited

Restrict vectors after the mesh has coarsened.

Definition at line 324 of file system.C.

325 {
326 #ifdef LIBMESH_ENABLE_AMR
327  // Restrict the _vectors on the coarsened cells
328  for (auto & pr : _vectors)
329  {
330  NumericVector<Number> * v = pr.second;
331 
332  if (_vector_projections[pr.first])
333  {
334  this->project_vector (*v, this->vector_is_adjoint(pr.first));
335  }
336  else
337  {
338  ParallelType type = _vector_types[pr.first];
339 
340  if (type == GHOSTED)
341  {
342 #ifdef LIBMESH_ENABLE_GHOSTED
343  pr.second->init (this->n_dofs(), this->n_local_dofs(),
344  _dof_map->get_send_list(), false,
345  GHOSTED);
346 #else
347  libmesh_error_msg("Cannot initialize ghosted vectors when they are not enabled.");
348 #endif
349  }
350  else
351  pr.second->init (this->n_dofs(), this->n_local_dofs(), false, type);
352  }
353  }
354 
355  const std::vector<dof_id_type> & send_list = _dof_map->get_send_list ();
356 
357  // Restrict the solution on the coarsened cells
359  this->project_vector (*solution);
360  // Or at least make sure the solution vector is the correct size
361  else
362  solution->init (this->n_dofs(), this->n_local_dofs(), true, PARALLEL);
363 
364 #ifdef LIBMESH_ENABLE_GHOSTED
365  current_local_solution->init(this->n_dofs(),
366  this->n_local_dofs(), send_list,
367  false, GHOSTED);
368 #else
369  current_local_solution->init(this->n_dofs());
370 #endif
371 
373  solution->localize (*current_local_solution, send_list);
374 
375 #endif // LIBMESH_ENABLE_AMR
376 }

References libMesh::System::_dof_map, libMesh::System::_solution_projection, libMesh::System::_vector_projections, libMesh::System::_vector_types, libMesh::System::_vectors, libMesh::System::current_local_solution, 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().

◆ 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 301 of file implicit_system.C.

302 {
303  // Log how long the linear solve takes.
304  LOG_SCOPE("sensitivity_solve()", "ImplicitSystem");
305 
306  // The forward system should now already be solved.
307  // Now assemble the corresponding sensitivity system.
308 
309  if (this->assemble_before_solve)
310  {
311  // Build the Jacobian
312  this->assembly(false, true);
313  this->matrix->close();
314 
315  // Reset and build the RHS from the residual derivatives
316  this->assemble_residual_derivatives(parameters);
317  }
318 
319  // The sensitivity problem is linear
320  LinearSolver<Number> * linear_solver = this->get_linear_solver();
321 
322  // Our iteration counts and residuals will be sums of the individual
323  // results
324  std::pair<unsigned int, Real> solver_params =
326  std::pair<unsigned int, Real> totalrval = std::make_pair(0,0.0);
327 
328  // Solve the linear system.
329  SparseMatrix<Number> * pc = this->request_matrix("Preconditioner");
330  for (auto p : IntRange<unsigned int>(0, parameters.size()))
331  {
332  std::pair<unsigned int, Real> rval =
333  linear_solver->solve (*matrix, pc,
334  this->add_sensitivity_solution(p),
335  this->get_sensitivity_rhs(p),
336  double(solver_params.second),
337  solver_params.first);
338 
339  totalrval.first += rval.first;
340  totalrval.second += rval.second;
341  }
342 
343  // The linear solver may not have fit our constraints exactly
344 #ifdef LIBMESH_ENABLE_CONSTRAINTS
345  for (auto p : IntRange<unsigned int>(0, parameters.size()))
347  (*this, &this->get_sensitivity_solution(p),
348  /* homogeneous = */ true);
349 #endif
350 
351  this->release_linear_solver(linear_solver);
352 
353  return totalrval;
354 }

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::ImplicitSystem::matrix, libMesh::ImplicitSystem::release_linear_solver(), libMesh::ImplicitSystem::request_matrix(), libMesh::ParameterVector::size(), and libMesh::LinearSolver< T >::solve().

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

◆ 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 191 of file rb_construction.h.

192  {this->abs_training_tolerance = new_training_tolerance; }

References libMesh::RBConstruction::abs_training_tolerance.

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

◆ set_adjoint_already_solved()

void libMesh::System::set_adjoint_already_solved ( bool  setting)
inlineinherited

Setter for the adjoint_already_solved boolean.

Definition at line 402 of file system.h.

403  { adjoint_already_solved = setting;}

References libMesh::System::adjoint_already_solved.

Referenced by main().

◆ 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 2147 of file system.h.

2148 {
2149  _basic_system_only = true;
2150 }

References libMesh::System::_basic_system_only.

Referenced by libMesh::EquationSystems::_read_impl().

◆ 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 797 of file rb_construction.C.

798 {
799  // Set current_local_solution = vec so that we can access
800  // vec from DGFEMContext during assembly
801  vec.localize
802  (*current_local_solution, this->get_dof_map().get_send_list());
803 }

References libMesh::System::current_local_solution, libMesh::System::get_dof_map(), and libMesh::NumericVector< T >::localize().

◆ 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 2250 of file rb_construction.C.

2251 {
2252  assert_convergence = flag;
2253 }

References libMesh::RBConstruction::assert_convergence.

◆ 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_deterministic_training_parameter_repeats()

void libMesh::RBConstructionBase< LinearImplicitSystem >::set_deterministic_training_parameter_repeats ( unsigned int  repeats)
inherited

Set the number of times each sample of the deterministic training parameter is repeated.

◆ 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 396 of file rb_construction.C.

397 {
399  energy_inner_product_coeffs = energy_inner_product_coeffs_in;
400 }

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

◆ 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 379 of file rb_construction.C.

380 {
381  use_energy_inner_product = false;
382  inner_product_assembly = &inner_product_assembly_in;
383 }

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

Referenced by SimpleRBConstruction::init_data().

◆ set_Nmax()

void libMesh::RBConstruction::set_Nmax ( unsigned int  Nmax)
virtualinherited

Definition at line 1300 of file rb_construction.C.

1301 {
1302  this->Nmax = Nmax_in;
1303 }

References libMesh::RBConstruction::Nmax.

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

◆ 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 198 of file rb_construction.h.

199  {this->normalize_rb_bound_in_greedy = normalize_rb_bound_in_greedy_in; }

References libMesh::RBConstruction::normalize_rb_bound_in_greedy.

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

◆ set_parameters()

void libMesh::RBParametrized::set_parameters ( const RBParameters params)
inherited

Set the current parameters to params.

Definition at line 155 of file rb_parametrized.C.

156 {
158  libmesh_error_msg("Error: parameters not initialized in RBParametrized::set_current_parameters");
159 
160  valid_params(params); // Terminates if params has the wrong number of parameters
161 
162  // Make a copy of params (default assignment operator just does memberwise copy, which is sufficient here)
163  this->parameters = params;
164 }

References libMesh::RBParametrized::parameters, libMesh::RBParametrized::parameters_initialized, and libMesh::RBParametrized::valid_params().

Referenced by libMesh::RBEIMConstruction::compute_best_fit_error(), libMesh::RBSCMConstruction::compute_SCM_bounds_on_training_set(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::RBEIMTheta::evaluate(), 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 libMesh::RBEIMConstruction::truth_solve().

◆ set_params_from_training_set()

void libMesh::RBConstructionBase< LinearImplicitSystem >::set_params_from_training_set ( unsigned int  index)
protectedinherited

Set parameters to the RBParameters stored in index index of the training set.

Definition at line 130 of file rb_construction_base.C.

131 {
133 }

◆ set_params_from_training_set_and_broadcast()

void libMesh::RBConstructionBase< LinearImplicitSystem >::set_params_from_training_set_and_broadcast ( unsigned int  index)
protectedvirtualinherited

Load the specified training parameter and then broadcast to all processors.

Definition at line 160 of file rb_construction_base.C.

161 {
163 
164  processor_id_type root_id = 0;
165  if ((this->get_first_local_training_index() <= index) &&
166  (index < this->get_last_local_training_index()))
167  {
168  // Set parameters on only one processor
170 
171  // set root_id, only non-zero on one processor
172  root_id = this->processor_id();
173  }
174 
175  // broadcast
176  this->comm().max(root_id);
177  broadcast_parameters(root_id);
178 }

◆ 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 92 of file rb_construction_base.h.

93  { this->quiet_mode = quiet_mode_in; }

◆ 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 366 of file rb_construction.C.

367 {
368  rb_assembly_expansion = &rb_assembly_expansion_in;
369 }

References libMesh::RBConstruction::rb_assembly_expansion.

Referenced by SimpleRBConstruction::init_data(), and libMesh::RBEIMConstruction::RBEIMConstruction().

◆ set_rb_construction_parameters()

void libMesh::RBConstruction::set_rb_construction_parameters ( unsigned int  n_training_samples_in,
bool  deterministic_training_in,
unsigned 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,
RBParameters  mu_min_in,
RBParameters  mu_max_in,
std::map< std::string, std::vector< Real >>  discrete_parameter_values_in,
std::map< std::string, bool >  log_scaling 
)
inherited

Set the state of this RBConstruction object based on the arguments to this function.

Definition at line 272 of file rb_construction.C.

285 {
286  // Read in training_parameters_random_seed value. This is used to
287  // seed the RNG when picking the training parameters. By default the
288  // value is -1, which means use std::time to seed the RNG.
289  set_training_random_seed(training_parameters_random_seed_in);
290 
291  // Set quiet mode
292  set_quiet_mode(quiet_mode_in);
293 
294  // Initialize RB parameters
295  set_Nmax(Nmax_in);
296 
297  set_rel_training_tolerance(rel_training_tolerance_in);
298  set_abs_training_tolerance(abs_training_tolerance_in);
299 
300  set_normalize_rb_bound_in_greedy(normalize_rb_bound_in_greedy_in);
301 
302  // Initialize the parameter ranges and the parameters themselves
303  initialize_parameters(mu_min_in, mu_max_in, discrete_parameter_values_in);
304 
306  this->get_parameters_max(),
307  n_training_samples_in,
308  log_scaling_in,
309  deterministic_training_in); // use deterministic parameters
310 }

References libMesh::RBParametrized::get_parameters_max(), libMesh::RBParametrized::get_parameters_min(), libMesh::RBParametrized::initialize_parameters(), libMesh::RBConstructionBase< LinearImplicitSystem >::initialize_training_parameters(), 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_rel_training_tolerance(), and libMesh::RBConstructionBase< LinearImplicitSystem >::set_training_random_seed().

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

◆ 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.

171 {
172  rb_eval = &rb_eval_in;
173 }

References libMesh::RBConstruction::rb_eval.

Referenced by main().

◆ 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 184 of file rb_construction.h.

185  {this->rel_training_tolerance = new_training_tolerance; }

References libMesh::RBConstruction::rel_training_tolerance.

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

◆ set_training_random_seed()

void libMesh::RBConstructionBase< LinearImplicitSystem >::set_training_random_seed ( unsigned int  seed)
inherited

Set the seed that is used to randomly generate training parameters.

Definition at line 630 of file rb_construction_base.C.

631 {
632  this->training_parameters_random_seed = seed;
633 }

◆ 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 873 of file system.C.

875 {
876  // We reserve -1 for vectors which get primal constraints, -2 for
877  // vectors which get no constraints
878  libmesh_assert_greater_equal(qoi_num, -2);
879  _vector_is_adjoint[vec_name] = qoi_num;
880 }

References libMesh::System::_vector_is_adjoint.

Referenced by libMesh::System::add_adjoint_solution(), and libMesh::System::add_weighted_sensitivity_adjoint_solution().

◆ 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 855 of file system.C.

857 {
858  _vector_projections[vec_name] = preserve;
859 }

References libMesh::System::_vector_projections.

Referenced by main().

◆ 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 108 of file linear_implicit_system.C.

109 {
110  if (this->assemble_before_solve)
111  // Assemble the linear system
112  this->assemble ();
113 
114  // Get a reference to the EquationSystems
115  const EquationSystems & es =
116  this->get_equation_systems();
117 
118  // If the linear solver hasn't been initialized, we do so here.
119  if (libMesh::on_command_line("--solver-system-names"))
120  linear_solver->init((this->name()+"_").c_str());
121  else
122  linear_solver->init();
123 
124  // Get the user-specified linear solver tolerance
125  const double tol =
126  double(es.parameters.get<Real>("linear solver tolerance"));
127 
128  // Get the user-specified maximum # of linear solver iterations
129  const unsigned int maxits =
130  es.parameters.get<unsigned int>("linear solver maximum iterations");
131 
132  if (_subset != nullptr)
133  linear_solver->restrict_solve_to(&_subset->dof_ids(),_subset_solve_mode);
134 
135  // Solve the linear system. Several cases:
136  std::pair<unsigned int, Real> rval = std::make_pair(0,0.0);
137  if (_shell_matrix)
138  // 1.) Shell matrix with or without user-supplied preconditioner.
139  rval = linear_solver->solve(*_shell_matrix, this->request_matrix("Preconditioner"), *solution, *rhs, tol, maxits);
140  else
141  // 2.) No shell matrix, with or without user-supplied preconditioner
142  rval = linear_solver->solve (*matrix, this->request_matrix("Preconditioner"), *solution, *rhs, tol, maxits);
143 
144  if (_subset != nullptr)
145  linear_solver->restrict_solve_to(nullptr);
146 
147  // Store the number of linear iterations required to
148  // solve and the final residual.
149  _n_linear_iterations = rval.first;
150  _final_linear_residual = rval.second;
151 
152  // Update the system after the solve
153  this->update();
154 }

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::Parameters::get(), libMesh::System::get_equation_systems(), libMesh::LinearImplicitSystem::linear_solver, libMesh::ImplicitSystem::matrix, libMesh::System::name(), libMesh::on_command_line(), libMesh::EquationSystems::parameters, libMesh::Real, libMesh::ImplicitSystem::request_matrix(), libMesh::ExplicitSystem::rhs, libMesh::System::solution, and libMesh::System::update().

Referenced by assemble_and_solve(), main(), and SystemsTest::testDofCouplingWithVarGroups().

◆ 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 130 of file rb_construction.C.

133 {
134  // This is similar to LinearImplicitSysmte::solve()
135 
136  // Get a reference to the EquationSystems
137  const EquationSystems & es =
138  this->get_equation_systems();
139 
140  // If the linear solver hasn't been initialized, we do so here.
141  input_solver.init();
142 
143  // Get the user-specifiied linear solver tolerance
144  const double tol =
145  double(es.parameters.get<Real>("linear solver tolerance"));
146 
147  // Get the user-specified maximum # of linear solver iterations
148  const unsigned int maxits =
149  es.parameters.get<unsigned int>("linear solver maximum iterations");
150 
151  // Solve the linear system. Several cases:
152  std::pair<unsigned int, Real> rval = std::make_pair(0,0.0);
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  rval = input_solver.solve (input_matrix, *solution, input_rhs, tol, maxits);
158 
159  // Store the number of linear iterations required to
160  // solve and the final residual.
161  _n_linear_iterations = rval.first;
162  _final_linear_residual = rval.second;
163 
165 
166  // Update the system after the solve
167  this->update();
168 }

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(), libMesh::TransientRBConstruction::truth_solve(), libMesh::RBEIMConstruction::truth_solve(), libMesh::RBConstruction::truth_solve(), libMesh::TransientRBConstruction::update_residual_terms(), and libMesh::RBConstruction::update_residual_terms().

◆ system()

sys_type& libMesh::RBConstruction::system ( )
inlineinherited
Returns
A reference to *this.

Definition at line 117 of file rb_construction.h.

117 { return *this; }

◆ system_type()

std::string libMesh::RBConstruction::system_type ( ) const
overridevirtualinherited
Returns
A string indicating the type of the system.

Reimplemented from libMesh::LinearImplicitSystem.

Reimplemented in libMesh::TransientSystem< RBConstruction >.

Definition at line 125 of file rb_construction.C.

126 {
127  return "RBConstruction";
128 }

◆ train_reduced_basis()

Real libMesh::RBConstruction::train_reduced_basis ( const bool  resize_rb_eval_data = true)
virtualinherited

Train the reduced basis.

This is the crucial function in the Offline stage: it generates 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.

Reimplemented in libMesh::RBEIMConstruction, and libMesh::TransientRBConstruction.

Definition at line 1024 of file rb_construction.C.

1025 {
1026  LOG_SCOPE("train_reduced_basis()", "RBConstruction");
1027 
1028  int count = 0;
1029 
1030  RBEvaluation & rbe = get_rb_evaluation();
1031 
1032  // initialize rbe's parameters
1033  rbe.initialize_parameters(*this);
1034 
1035  // possibly resize data structures according to Nmax
1036  if (resize_rb_eval_data)
1037  rbe.resize_data_structures(get_Nmax());
1038 
1039  // Clear the Greedy param list
1040  for (auto & plist : rbe.greedy_param_list)
1041  plist.clear();
1042 
1043  rbe.greedy_param_list.clear();
1044 
1045  Real training_greedy_error = 0.;
1046 
1047 
1048  // If we are continuing from a previous training run,
1049  // we might already be at the max number of basis functions.
1050  // If so, we can just return.
1051  if (rbe.get_n_basis_functions() >= get_Nmax())
1052  {
1053  libMesh::out << "Maximum number of basis functions reached: Nmax = "
1054  << get_Nmax() << std::endl;
1055  return 0.;
1056  }
1057 
1058 
1060  {
1061  // Compute the dual norms of the outputs if we haven't already done so.
1063 
1064  // Compute the Fq Riesz representor dual norms if we haven't already done so.
1066  }
1067 
1068  libMesh::out << std::endl << "---- Performing Greedy basis enrichment ----" << std::endl;
1069  Real initial_greedy_error = 0.;
1070  bool initial_greedy_error_initialized = false;
1071  while (true)
1072  {
1073  libMesh::out << std::endl << "---- Basis dimension: "
1074  << rbe.get_n_basis_functions() << " ----" << std::endl;
1075 
1076  if (count > 0 || (count==0 && use_empty_rb_solve_in_greedy))
1077  {
1078  libMesh::out << "Performing RB solves on training set" << std::endl;
1079  training_greedy_error = compute_max_error_bound();
1080 
1081  libMesh::out << "Maximum error bound is " << training_greedy_error << std::endl << std::endl;
1082 
1083  // record the initial error
1084  if (!initial_greedy_error_initialized)
1085  {
1086  initial_greedy_error = training_greedy_error;
1087  initial_greedy_error_initialized = true;
1088  }
1089 
1090  // Break out of training phase if we have reached Nmax
1091  // or if the training_tolerance is satisfied.
1092  if (greedy_termination_test(training_greedy_error, initial_greedy_error, count))
1093  break;
1094  }
1095 
1096  libMesh::out << "Performing truth solve at parameter:" << std::endl;
1097  print_parameters();
1098 
1099  // Update the list of Greedily selected parameters
1100  this->update_greedy_param_list();
1101 
1102  // Perform an Offline truth solve for the current parameter
1103  truth_solve(-1);
1104 
1105  // Add orthogonal part of the snapshot to the RB space
1106  libMesh::out << "Enriching the RB space" << std::endl;
1107  enrich_RB_space();
1108 
1109  update_system();
1110 
1111  // Check if we've reached Nmax now. We do this before calling
1112  // update_residual_terms() since we can skip that step if we've
1113  // already reached Nmax.
1114  if (rbe.get_n_basis_functions() >= this->get_Nmax())
1115  {
1116  libMesh::out << "Maximum number of basis functions reached: Nmax = "
1117  << get_Nmax() << std::endl;
1118  break;
1119  }
1120 
1122  {
1124  }
1125 
1126  // Increment counter
1127  count++;
1128  }
1129  this->update_greedy_param_list();
1130 
1131  return training_greedy_error;
1132 }

References 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_rb_evaluation(), libMesh::RBEvaluation::greedy_param_list, libMesh::RBConstruction::greedy_termination_test(), libMesh::RBParametrized::initialize_parameters(), libMesh::out, 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 main(), libMesh::TransientRBConstruction::train_reduced_basis(), and libMesh::RBEIMConstruction::train_reduced_basis().

◆ truth_assembly()

void libMesh::RBConstruction::truth_assembly ( )
protectedvirtualinherited

Assemble the truth matrix and right-hand side for current_parameters.

Reimplemented in libMesh::TransientRBConstruction.

Definition at line 805 of file rb_construction.C.

806 {
807  LOG_SCOPE("truth_assembly()", "RBConstruction");
808 
809  const RBParameters & mu = get_parameters();
810 
811  this->matrix->zero();
812  this->rhs->zero();
813 
814  this->matrix->close();
815  this->rhs->close();
816 
817  {
818  // We should have already assembled the matrices
819  // and vectors in the affine expansion, so
820  // just use them
821 
822  for (unsigned int q_a=0; q_a<get_rb_theta_expansion().get_n_A_terms(); q_a++)
823  {
824  matrix->add(get_rb_theta_expansion().eval_A_theta(q_a, mu), *get_Aq(q_a));
825  }
826 
827  std::unique_ptr<NumericVector<Number>> temp_vec = NumericVector<Number>::build(this->comm());
828  temp_vec->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
829  for (unsigned int q_f=0; q_f<get_rb_theta_expansion().get_n_F_terms(); q_f++)
830  {
831  *temp_vec = *get_Fq(q_f);
832  temp_vec->scale( get_rb_theta_expansion().eval_F_theta(q_f, mu) );
833  rhs->add(*temp_vec);
834  }
835  }
836 
837  this->matrix->close();
838  this->rhs->close();
839 }

References libMesh::SparseMatrix< T >::add(), libMesh::NumericVector< T >::add(), libMesh::NumericVector< T >::build(), libMesh::SparseMatrix< T >::close(), libMesh::NumericVector< T >::close(), libMesh::ParallelObject::comm(), libMesh::RBConstruction::get_Aq(), 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::ImplicitSystem::matrix, libMesh::System::n_dofs(), libMesh::System::n_local_dofs(), libMesh::PARALLEL, libMesh::ExplicitSystem::rhs, libMesh::SparseMatrix< T >::zero(), and libMesh::NumericVector< T >::zero().

Referenced by libMesh::RBConstruction::compute_residual_dual_norm_slow(), libMesh::RBConstruction::enrich_basis_from_rhs_terms(), and libMesh::RBConstruction::truth_solve().

◆ truth_solve()

Real libMesh::RBConstruction::truth_solve ( int  plot_solution)
virtualinherited

Perform a "truth" solve, i.e.

solve the finite element system at at the parameters currently set in the system. This is used extensively in training the reduced basis, since "truth snapshots" are employed as basis functions.

Reimplemented in libMesh::TransientRBConstruction, and libMesh::RBEIMConstruction.

Definition at line 1242 of file rb_construction.C.

1243 {
1244  LOG_SCOPE("truth_solve()", "RBConstruction");
1245 
1246  truth_assembly();
1247 
1248  // truth_assembly assembles into matrix and rhs, so use those for the solve
1249  if (extra_linear_solver)
1250  {
1251  // If extra_linear_solver has been initialized, then we use it for the
1252  // truth solves.
1254 
1255  if (assert_convergence)
1257  }
1258  else
1259  {
1261 
1262  if (assert_convergence)
1264  }
1265 
1266  // Call user-defined post-processing routines on the truth solution.
1268 
1269  const RBParameters & mu = get_parameters();
1270 
1271  for (unsigned int n=0; n<get_rb_theta_expansion().get_n_outputs(); n++)
1272  {
1273  truth_outputs[n] = 0.;
1274  for (unsigned int q_l=0; q_l<get_rb_theta_expansion().get_n_output_terms(n); q_l++)
1276  get_output_vector(n,q_l)->dot(*solution);
1277  }
1278 
1279  if (plot_solution > 0)
1280  {
1281 #if defined(LIBMESH_USE_COMPLEX_NUMBERS)
1282  GMVIO(get_mesh()).write_equation_systems ("truth.gmv",
1283  this->get_equation_systems());
1284 #else
1285 #ifdef LIBMESH_HAVE_EXODUS_API
1286  ExodusII_IO(get_mesh()).write_equation_systems ("truth.e",
1287  this->get_equation_systems());
1288 #endif
1289 #endif
1290  }
1291 
1292  // Get the X norm of the truth solution
1293  // Useful for normalizing our true error data
1295  Number truth_X_norm = std::sqrt(inner_product_storage_vector->dot(*solution));
1296 
1297  return libmesh_real(truth_X_norm);
1298 }

References libMesh::RBConstruction::assert_convergence, libMesh::RBConstruction::check_convergence(), libMesh::NumericVector< T >::dot(), libMesh::RBThetaExpansion::eval_output_theta(), libMesh::RBConstruction::extra_linear_solver, 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::RBConstruction::get_non_dirichlet_inner_product_matrix_if_avail(), libMesh::RBConstruction::get_output_vector(), libMesh::RBParametrized::get_parameters(), libMesh::RBConstruction::get_rb_theta_expansion(), libMesh::RBConstructionBase< LinearImplicitSystem >::inner_product_storage_vector, libMesh::libmesh_real(), libMesh::ImplicitSystem::matrix, libMesh::RBConstruction::post_process_truth_solution(), libMesh::ExplicitSystem::rhs, libMesh::System::solution, libMesh::RBConstruction::solve_for_matrix_and_rhs(), std::sqrt(), libMesh::RBConstruction::truth_assembly(), libMesh::RBConstruction::truth_outputs, libMesh::SparseMatrix< T >::vector_mult(), and libMesh::MeshOutput< MT >::write_equation_systems().

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

◆ update()

void libMesh::System::update ( )
virtualinherited

Update the local values to reflect the solution on neighboring processors.

Reimplemented in SolidSystem.

Definition at line 408 of file system.C.

409 {
410  libmesh_assert(solution->closed());
411 
412  const std::vector<dof_id_type> & send_list = _dof_map->get_send_list ();
413 
414  // Check sizes
415  libmesh_assert_equal_to (current_local_solution->size(), solution->size());
416  // More processors than elements => empty send_list
417  // libmesh_assert (!send_list.empty());
418  libmesh_assert_less_equal (send_list.size(), solution->size());
419 
420  // Create current_local_solution from solution. This will
421  // put a local copy of solution into current_local_solution.
422  // Only the necessary values (specified by the send_list)
423  // are copied to minimize communication
424  solution->localize (*current_local_solution, send_list);
425 }

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(), LinearElasticityWithContact::compute_stresses(), LinearElasticity::compute_stresses(), compute_stresses(), LargeDeformationElasticity::compute_stresses(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::GMVIO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), DMlibMeshFunction(), DMlibMeshJacobian(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::TransientRBConstruction::initialize_truth(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_residual_helper(), libMesh::NewtonSolver::line_search(), libMesh::RBEIMConstruction::load_basis_function(), libMesh::RBConstruction::load_basis_function(), libMesh::RBEIMConstruction::load_rb_solution(), libMesh::RBConstruction::load_rb_solution(), libMesh::TransientRBConstruction::load_rb_solution(), libMesh::FEMSystem::mesh_position_get(), HeatSystem::perturb_accumulate_residuals(), libMesh::FEMSystem::postprocess(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::NewtonSolver::solve(), libMesh::ExplicitSystem::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::NonlinearImplicitSystem::solve(), libMesh::OptimizationSystem::solve(), libMesh::RBConstruction::solve_for_matrix_and_rhs(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::DirectSolutionTransfer::transfer(), and libMesh::RBEIMConstruction::truth_solve().

◆ 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 642 of file system.C.

643 {
644  global_soln.resize (solution->size());
645 
646  solution->localize (global_soln);
647 }

References libMesh::System::solution.

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::ExactErrorEstimator::estimate_error(), and main().

◆ 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 651 of file system.C.

653 {
654  global_soln.resize (solution->size());
655 
656  solution->localize_to_one (global_soln, dest_proc);
657 }

References libMesh::System::solution.

◆ 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 1229 of file rb_construction.C.

1230 {
1232 }

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

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

◆ update_RB_system_matrices()

void libMesh::RBConstruction::update_RB_system_matrices ( )
protectedvirtualinherited

Compute the reduced basis matrices for the current basis.

Reimplemented in libMesh::TransientRBConstruction, and libMesh::RBEIMConstruction.

Definition at line 1466 of file rb_construction.C.

1467 {
1468  LOG_SCOPE("update_RB_system_matrices()", "RBConstruction");
1469 
1470  unsigned int RB_size = get_rb_evaluation().get_n_basis_functions();
1471 
1472  std::unique_ptr<NumericVector<Number>> temp = NumericVector<Number>::build(this->comm());
1473  temp->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
1474 
1475  for (unsigned int q_f=0; q_f<get_rb_theta_expansion().get_n_F_terms(); q_f++)
1476  {
1477  for (unsigned int i=(RB_size-delta_N); i<RB_size; i++)
1478  {
1479  get_rb_evaluation().RB_Fq_vector[q_f](i) = get_non_dirichlet_Fq_if_avail(q_f)->dot(get_rb_evaluation().get_basis_function(i));
1480  }
1481  }
1482 
1483  for (unsigned int i=(RB_size-delta_N); i<RB_size; i++)
1484  {
1485  for (unsigned int n=0; n<get_rb_theta_expansion().get_n_outputs(); n++)
1486  for (unsigned int q_l=0; q_l<get_rb_theta_expansion().get_n_output_terms(n); q_l++)
1487  {
1488  get_rb_evaluation().RB_output_vectors[n][q_l](i) =
1489  get_output_vector(n,q_l)->dot(get_rb_evaluation().get_basis_function(i));
1490  }
1491 
1492  for (unsigned int j=0; j<RB_size; j++)
1493  {
1494  Number value = 0.;
1495 
1497  {
1498  // Compute reduced inner_product_matrix
1499  temp->zero();
1501 
1502  value = temp->dot( get_rb_evaluation().get_basis_function(i) );
1504  if (i!=j)
1505  {
1506  // The inner product matrix is assumed
1507  // to be hermitian
1509  }
1510  }
1511 
1512  for (unsigned int q_a=0; q_a<get_rb_theta_expansion().get_n_A_terms(); q_a++)
1513  {
1514  // Compute reduced Aq matrix
1515  temp->zero();
1516  get_non_dirichlet_Aq_if_avail(q_a)->vector_mult(*temp, get_rb_evaluation().get_basis_function(j));
1517 
1518  value = (*temp).dot(get_rb_evaluation().get_basis_function(i));
1519  get_rb_evaluation().RB_Aq_vector[q_a](i,j) = value;
1520 
1521  if (i!=j)
1522  {
1523  temp->zero();
1524  get_non_dirichlet_Aq_if_avail(q_a)->vector_mult(*temp, get_rb_evaluation().get_basis_function(i));
1525 
1526  value = (*temp).dot(get_rb_evaluation().get_basis_function(j));
1527  get_rb_evaluation().RB_Aq_vector[q_a](j,i) = value;
1528  }
1529  }
1530  }
1531  }
1532 }

References libMesh::NumericVector< T >::build(), libMesh::ParallelObject::comm(), libMesh::RBConstruction::compute_RB_inner_product, libMesh::RBConstruction::delta_N, libMesh::NumericVector< T >::dot(), libMesh::RBThetaExpansion::get_n_A_terms(), libMesh::RBEvaluation::get_n_basis_functions(), libMesh::RBThetaExpansion::get_n_F_terms(), libMesh::RBThetaExpansion::get_n_output_terms(), libMesh::RBThetaExpansion::get_n_outputs(), libMesh::RBConstruction::get_non_dirichlet_Aq_if_avail(), libMesh::RBConstruction::get_non_dirichlet_Fq_if_avail(), libMesh::RBConstruction::get_non_dirichlet_inner_product_matrix_if_avail(), libMesh::RBConstruction::get_output_vector(), libMesh::RBConstruction::get_rb_evaluation(), libMesh::RBConstruction::get_rb_theta_expansion(), libMesh::libmesh_conj(), libMesh::System::n_dofs(), libMesh::System::n_local_dofs(), libMesh::PARALLEL, libMesh::RBEvaluation::RB_Aq_vector, libMesh::RBEvaluation::RB_Fq_vector, libMesh::RBEvaluation::RB_inner_product_matrix, libMesh::RBEvaluation::RB_output_vectors, value, and libMesh::SparseMatrix< T >::vector_mult().

Referenced by libMesh::TransientRBConstruction::update_RB_system_matrices(), and libMesh::RBConstruction::update_system().

◆ update_residual_terms()

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

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

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.

Reimplemented in libMesh::TransientRBConstruction.

Definition at line 1535 of file rb_construction.C.

1536 {
1537  LOG_SCOPE("update_residual_terms()", "RBConstruction");
1538 
1539  libMesh::out << "Updating RB residual terms" << std::endl;
1540 
1541  unsigned int RB_size = get_rb_evaluation().get_n_basis_functions();
1542 
1543  for (unsigned int q_a=0; q_a<get_rb_theta_expansion().get_n_A_terms(); q_a++)
1544  {
1545  for (unsigned int i=(RB_size-delta_N); i<RB_size; i++)
1546  {
1547  // Initialize the vector in which we'll store the representor
1548  if (!get_rb_evaluation().Aq_representor[q_a][i])
1549  {
1551  get_rb_evaluation().Aq_representor[q_a][i]->init(this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
1552  }
1553 
1554  libmesh_assert(get_rb_evaluation().Aq_representor[q_a][i]->size() == this->n_dofs() &&
1555  get_rb_evaluation().Aq_representor[q_a][i]->local_size() == this->n_local_dofs() );
1556 
1557  rhs->zero();
1558  get_Aq(q_a)->vector_mult(*rhs, get_rb_evaluation().get_basis_function(i));
1559  rhs->scale(-1.);
1560 
1561  if (!is_quiet())
1562  {
1563  libMesh::out << "Starting solve [q_a][i]=[" << q_a <<"]["<< i << "] in RBConstruction::update_residual_terms() at "
1564  << Utility::get_timestamp() << std::endl;
1565  }
1566 
1568 
1569  if (assert_convergence)
1571 
1572  if (!is_quiet())
1573  {
1574  libMesh::out << "Finished solve [q_a][i]=[" << q_a <<"]["<< i << "] in RBConstruction::update_residual_terms() at "
1575  << Utility::get_timestamp() << std::endl;
1576  libMesh::out << this->n_linear_iterations() << " iterations, final residual "
1577  << this->final_linear_residual() << std::endl;
1578  }
1579 
1580  // Store the representor
1582  }
1583  }
1584 
1585  // Now compute and store the inner products (if requested)
1586  if (compute_inner_products)
1587  {
1588 
1589  for (unsigned int q_f=0; q_f<get_rb_theta_expansion().get_n_F_terms(); q_f++)
1590  {
1592 
1593  for (unsigned int q_a=0; q_a<get_rb_theta_expansion().get_n_A_terms(); q_a++)
1594  {
1595  for (unsigned int i=(RB_size-delta_N); i<RB_size; i++)
1596  {
1598  inner_product_storage_vector->dot(*get_rb_evaluation().Aq_representor[q_a][i]);
1599  }
1600  }
1601  }
1602 
1603  unsigned int q=0;
1604  for (unsigned int q_a1=0; q_a1<get_rb_theta_expansion().get_n_A_terms(); q_a1++)
1605  {
1606  for (unsigned int q_a2=q_a1; q_a2<get_rb_theta_expansion().get_n_A_terms(); q_a2++)
1607  {
1608  for (unsigned int i=(RB_size-delta_N); i<RB_size; i++)
1609  {
1610  for (unsigned int j=0; j<RB_size; j++)
1611  {
1614  inner_product_storage_vector->dot(*get_rb_evaluation().Aq_representor[q_a1][i]);
1615 
1616  if (i != j)
1617  {
1620  inner_product_storage_vector->dot(*get_rb_evaluation().Aq_representor[q_a1][j]);
1621  }
1622  }
1623  }
1624  q++;
1625  }
1626  }
1627  } // end if (compute_inner_products)
1628 }

References libMesh::RBEvaluation::Aq_Aq_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::RBEvaluation::Fq_Aq_representor_innerprods, libMesh::RBConstruction::Fq_representor, libMesh::RBConstruction::get_Aq(), libMesh::RBThetaExpansion::get_n_A_terms(), libMesh::RBEvaluation::get_n_basis_functions(), 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::NumericVector< T >::scale(), 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(), libMesh::RBConstruction::train_reduced_basis(), and libMesh::TransientRBConstruction::update_residual_terms().

◆ update_system()

void libMesh::RBConstruction::update_system ( )
protectedvirtualinherited

Update the system after enriching the RB space; this calls a series of functions to update the system properly.

Reimplemented in libMesh::TransientRBConstruction, and libMesh::RBEIMConstruction.

Definition at line 1350 of file rb_construction.C.

1351 {
1352  libMesh::out << "Updating RB matrices" << std::endl;
1354 }

References libMesh::out, and libMesh::RBConstruction::update_RB_system_matrices().

Referenced by libMesh::RBConstruction::enrich_basis_from_rhs_terms(), libMesh::RBConstruction::train_reduced_basis(), and libMesh::TransientRBConstruction::update_system().

◆ 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 1910 of file system.C.

1911 {
1912  // Call the user-provided assembly function,
1913  // if it was provided
1914  if (_assemble_system_function != nullptr)
1916 
1917  // ...or the user-provided assembly object.
1918  else if (_assemble_system_object != nullptr)
1920 }

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().

◆ 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 1924 of file system.C.

1925 {
1926  // Call the user-provided constraint function,
1927  // if it was provided
1928  if (_constrain_system_function!= nullptr)
1930 
1931  // ...or the user-provided constraint object.
1932  else if (_constrain_system_object != nullptr)
1934 }

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().

◆ 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 1896 of file system.C.

1897 {
1898  // Call the user-provided initialization function,
1899  // if it was provided
1900  if (_init_system_function != nullptr)
1901  this->_init_system_function (_equation_systems, this->name());
1902 
1903  // ...or the user-provided initialization object.
1904  else if (_init_system_object != nullptr)
1906 }

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::System::init(), and libMesh::NewmarkSystem::initial_conditions().

◆ 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 1938 of file system.C.

1939 {
1940  // Call the user-provided quantity of interest function,
1941  // if it was provided
1942  if (_qoi_evaluate_function != nullptr)
1943  this->_qoi_evaluate_function(_equation_systems, this->name(), qoi_indices);
1944 
1945  // ...or the user-provided QOI function object.
1946  else if (_qoi_evaluate_object != nullptr)
1947  this->_qoi_evaluate_object->qoi(qoi_indices);
1948 }

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().

◆ 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 1952 of file system.C.

1955 {
1956  // Call the user-provided quantity of interest derivative,
1957  // if it was provided
1958  if (_qoi_evaluate_derivative_function != nullptr)
1960  (_equation_systems, this->name(), qoi_indices, include_liftfunc,
1961  apply_constraints);
1962 
1963  // ...or the user-provided QOI derivative function object.
1964  else if (_qoi_evaluate_derivative_object != nullptr)
1966  (qoi_indices, include_liftfunc, apply_constraints);
1967 }

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().

◆ valid_params()

bool libMesh::RBParametrized::valid_params ( const RBParameters params)
privateinherited

Helper function to check that params is valid.

Definition at line 402 of file rb_parametrized.C.

403 {
404  if (params.n_parameters() != get_n_params())
405  libmesh_error_msg("Error: Number of parameters don't match");
406 
407  else
408  {
409  bool valid = true;
410  for (const auto & pr : params)
411  {
412  const std::string & param_name = pr.first;
413  valid = valid && ( (get_parameter_min(param_name) <= params.get_value(param_name)) &&
414  (params.get_value(param_name) <= get_parameter_max(param_name)) );
415 
416  if (is_discrete_parameter(param_name))
417  {
418  // make sure params.get_value(param_name) is sufficiently close
419  // to one of the discrete parameter values
420  valid = valid && is_value_in_list(params.get_value(param_name),
421  get_discrete_parameter_values().find(param_name)->second,
422  TOLERANCE);
423  }
424  }
425 
426  if (!valid && verbose_mode)
427  libMesh::out << "Warning: parameter is outside parameter range" << std::endl;
428 
429  return valid;
430  }
431 }

References libMesh::RBParametrized::get_discrete_parameter_values(), libMesh::RBParametrized::get_n_params(), libMesh::RBParametrized::get_parameter_max(), libMesh::RBParametrized::get_parameter_min(), libMesh::RBParametrized::is_discrete_parameter(), libMesh::RBParametrized::is_value_in_list(), libMesh::RBParameters::n_parameters(), libMesh::out, libMesh::TOLERANCE, libMesh::Quality::valid(), and libMesh::RBParametrized::verbose_mode.

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

◆ variable()

const Variable & libMesh::System::variable ( unsigned int  var) const
inlineinherited

◆ variable_group()

const VariableGroup & libMesh::System::variable_group ( unsigned int  vg) const
inlineinherited

Return a constant reference to VariableGroup vg.

Definition at line 2193 of file system.h.

2194 {
2195  libmesh_assert_less (vg, _variable_groups.size());
2196 
2197  return _variable_groups[vg];
2198 }

References libMesh::System::_variable_groups.

Referenced by libMesh::FEMSystem::assembly(), libMesh::System::get_info(), and libMesh::System::init_data().

◆ variable_name()

const std::string & libMesh::System::variable_name ( const unsigned int  i) const
inlineinherited

◆ variable_number()

unsigned short int libMesh::System::variable_number ( const std::string &  var) const
inherited
Returns
The variable number associated with the user-specified variable named var.

Definition at line 1232 of file system.C.

1233 {
1234  auto var_num = libmesh_map_find(_variable_numbers, var);
1235  libmesh_assert_equal_to (_variables[var_num].name(), var);
1236  return var_num;
1237 }

References libMesh::System::_variable_numbers, libMesh::System::_variables, and libMesh::System::name().

Referenced by libMesh::ExactSolution::_compute_error(), LinearElasticity::assemble(), AssembleOptimization::assemble_A_and_F(), assemble_elasticity(), assemble_matrix_and_rhs(), assemble_shell(), assemble_stokes(), LinearElasticityWithContact::compute_stresses(), LinearElasticity::compute_stresses(), compute_stresses(), LargeDeformationElasticity::compute_stresses(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::GMVIO::copy_nodal_solution(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::find_squared_element_error(), LargeDeformationElasticity::jacobian(), line_print(), main(), LinearElasticityWithContact::move_mesh(), libMesh::System::read_header(), 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().

◆ variable_scalar_number() [1/2]

unsigned int libMesh::System::variable_scalar_number ( const std::string &  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 2214 of file system.h.

2216 {
2217  return variable_scalar_number(this->variable_number(var), component);
2218 }

References libMesh::System::variable_number().

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::ExodusII_IO::copy_scalar_solution(), and libMesh::ExactErrorEstimator::find_squared_element_error().

◆ 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 2224 of file system.h.

2226 {
2227  return _variables[var_num].first_scalar_number() + component;
2228 }

References libMesh::System::_variables.

◆ variable_type() [1/2]

const FEType & libMesh::System::variable_type ( const std::string &  var) const
inlineinherited
Returns
The finite element type for variable var.

Definition at line 2243 of file system.h.

2244 {
2245  return _variables[this->variable_number(var)].type();
2246 }

References libMesh::System::_variables, and libMesh::System::variable_number().

◆ variable_type() [2/2]

const FEType & libMesh::System::variable_type ( const unsigned int  i) const
inlineinherited

◆ vector_is_adjoint()

int libMesh::System::vector_is_adjoint ( const std::string &  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 884 of file system.C.

885 {
886  libmesh_assert(_vector_is_adjoint.find(vec_name) !=
887  _vector_is_adjoint.end());
888 
889  return _vector_is_adjoint.find(vec_name)->second;
890 }

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

Referenced by libMesh::System::restrict_vectors().

◆ vector_name() [1/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 834 of file system.C.

835 {
838 
839  for (; v != v_end; ++v)
840  {
841  // Check if the current vector is the one whose name we want
842  if (&vec_reference == v->second)
843  break; // exit loop if it is
844  }
845 
846  // Before returning, make sure we didnt loop till the end and not find any match
847  libmesh_assert (v != v_end);
848 
849  // Return the string associated with the current vector
850  return v->first;
851 }

References libMesh::libmesh_assert(), libMesh::System::vectors_begin(), and libMesh::System::vectors_end().

◆ vector_name() [2/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 820 of file system.C.

821 {
824  unsigned int num = 0;
825  while ((num<vec_num) && (v!=v_end))
826  {
827  num++;
828  ++v;
829  }
830  libmesh_assert (v != v_end);
831  return v->first;
832 }

References libMesh::libmesh_assert(), libMesh::System::vectors_begin(), and libMesh::System::vectors_end().

Referenced by main().

◆ vector_preservation()

bool libMesh::System::vector_preservation ( const std::string &  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 863 of file system.C.

864 {
865  if (_vector_projections.find(vec_name) == _vector_projections.end())
866  return false;
867 
868  return _vector_projections.find(vec_name)->second;
869 }

References libMesh::System::_vector_projections.

Referenced by libMesh::MemorySolutionHistory::store().

◆ vectors_begin() [1/2]

System::vectors_iterator libMesh::System::vectors_begin ( )
inlineinherited

◆ vectors_begin() [2/2]

System::const_vectors_iterator libMesh::System::vectors_begin ( ) const
inlineinherited

Beginning of vectors container.

Definition at line 2301 of file system.h.

2302 {
2303  return _vectors.begin();
2304 }

References libMesh::System::_vectors.

◆ vectors_end() [1/2]

System::vectors_iterator libMesh::System::vectors_end ( )
inlineinherited

◆ vectors_end() [2/2]

System::const_vectors_iterator libMesh::System::vectors_end ( ) const
inlineinherited

End of vectors container.

Definition at line 2313 of file system.h.

2314 {
2315  return _vectors.end();
2316 }

References libMesh::System::_vectors.

◆ 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 412 of file implicit_system.C.

415 {
416  // Log how long the linear solve takes.
417  LOG_SCOPE("weighted_sensitivity_adjoint_solve()", "ImplicitSystem");
418 
419  // We currently get partial derivatives via central differencing
420  const Real delta_p = TOLERANCE;
421 
422  ParameterVector & parameters =
423  const_cast<ParameterVector &>(parameters_in);
424 
425  // The forward system should now already be solved.
426  // The adjoint system should now already be solved.
427  // Now we're assembling a weighted sum of adjoint-adjoint systems:
428  //
429  // dR/du (u, sum_l(w_l*z^l)) = sum_l(w_l*(Q''_ul - R''_ul (u, z)))
430 
431  // FIXME: The derivation here does not yet take adjoint boundary
432  // conditions into account.
433 #ifdef LIBMESH_ENABLE_DIRICHLET
434  for (auto i : IntRange<unsigned int>(0, this->n_qois()))
435  if (qoi_indices.has_index(i))
437 #endif
438 
439  // We'll assemble the rhs first, because the R'' term will require
440  // perturbing the jacobian
441 
442  // We'll use temporary rhs vectors, because we haven't (yet) found
443  // any good reasons why users might want to save these:
444 
445  std::vector<std::unique_ptr<NumericVector<Number>>> temprhs(this->n_qois());
446  for (auto i : IntRange<unsigned int>(0, this->n_qois()))
447  if (qoi_indices.has_index(i))
448  temprhs[i] = this->rhs->zero_clone();
449 
450  // We approximate the _l partial derivatives via a central
451  // differencing perturbation in the w_l direction:
452  //
453  // sum_l(w_l*v_l) ~= (v(p + dp*w_l*e_l) - v(p - dp*w_l*e_l))/(2*dp)
454 
455  // PETSc doesn't implement SGEMX, so neither does NumericVector,
456  // so we want to avoid calculating f -= R'*z. We'll thus evaluate
457  // the above equation by first adding -v(p+dp...), then multiplying
458  // the intermediate result vectors by -1, then adding -v(p-dp...),
459  // then finally dividing by 2*dp.
460 
461  ParameterVector oldparameters, parameterperturbation;
462  parameters.deep_copy(oldparameters);
463  weights.deep_copy(parameterperturbation);
464  parameterperturbation *= delta_p;
465  parameters += parameterperturbation;
466 
467  this->assembly(false, true);
468  this->matrix->close();
469 
470  // Take the discrete adjoint, so that we can calculate R_u(u,z) with
471  // a matrix-vector product of R_u and z.
473 
474  this->assemble_qoi_derivative(qoi_indices,
475  /* include_liftfunc = */ false,
476  /* apply_constraints = */ true);
477  for (auto i : IntRange<unsigned int>(0, this->n_qois()))
478  if (qoi_indices.has_index(i))
479  {
480  this->get_adjoint_rhs(i).close();
481  *(temprhs[i]) -= this->get_adjoint_rhs(i);
482  this->matrix->vector_mult_add(*(temprhs[i]), this->get_adjoint_solution(i));
483  *(temprhs[i]) *= -1.0;
484  }
485 
486  oldparameters.value_copy(parameters);
487  parameterperturbation *= -1.0;
488  parameters += parameterperturbation;
489 
490  this->assembly(false, true);
491  this->matrix->close();
493 
494  this->assemble_qoi_derivative(qoi_indices,
495  /* include_liftfunc = */ false,
496  /* apply_constraints = */ true);
497  for (auto i : IntRange<unsigned int>(0, this->n_qois()))
498  if (qoi_indices.has_index(i))
499  {
500  this->get_adjoint_rhs(i).close();
501  *(temprhs[i]) -= this->get_adjoint_rhs(i);
502  this->matrix->vector_mult_add(*(temprhs[i]), this->get_adjoint_solution(i));
503  *(temprhs[i]) /= (2.0*delta_p);
504  }
505 
506  // Finally, assemble the jacobian at the non-perturbed parameter
507  // values. Ignore assemble_before_solve; if we had a good
508  // non-perturbed matrix before we've already overwritten it.
509  oldparameters.value_copy(parameters);
510 
511  // if (this->assemble_before_solve)
512  {
513  // Build the Jacobian
514  this->assembly(false, true);
515  this->matrix->close();
516 
517  // Take the discrete adjoint
519  }
520 
521  // The weighted adjoint-adjoint problem is linear
522  LinearSolver<Number> * linear_solver = this->get_linear_solver();
523 
524  // Our iteration counts and residuals will be sums of the individual
525  // results
526  std::pair<unsigned int, Real> solver_params =
528  std::pair<unsigned int, Real> totalrval = std::make_pair(0,0.0);
529 
530  for (auto i : IntRange<unsigned int>(0, this->n_qois()))
531  if (qoi_indices.has_index(i))
532  {
533  const std::pair<unsigned int, Real> rval =
534  linear_solver->solve (*matrix, this->add_weighted_sensitivity_adjoint_solution(i),
535  *(temprhs[i]),
536  double(solver_params.second),
537  solver_params.first);
538 
539  totalrval.first += rval.first;
540  totalrval.second += rval.second;
541  }
542 
543  this->release_linear_solver(linear_solver);
544 
545  // The linear solver may not have fit our constraints exactly
546 #ifdef LIBMESH_ENABLE_CONSTRAINTS
547  for (auto i : IntRange<unsigned int>(0, this->n_qois()))
548  if (qoi_indices.has_index(i))
551  /* homogeneous = */ true);
552 #endif
553 
554  return totalrval;
555 }

References libMesh::System::add_weighted_sensitivity_adjoint_solution(), libMesh::ExplicitSystem::assemble_qoi_derivative(), libMesh::ImplicitSystem::assembly(), libMesh::SparseMatrix< T >::close(), libMesh::NumericVector< 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::ImplicitSystem::matrix, libMesh::System::n_qois(), libMesh::Real, libMesh::ImplicitSystem::release_linear_solver(), 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().

◆ 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 560 of file implicit_system.C.

562 {
563  // Log how long the linear solve takes.
564  LOG_SCOPE("weighted_sensitivity_solve()", "ImplicitSystem");
565 
566  // We currently get partial derivatives via central differencing
567  const Real delta_p = TOLERANCE;
568 
569  ParameterVector & parameters =
570  const_cast<ParameterVector &>(parameters_in);
571 
572  // The forward system should now already be solved.
573 
574  // Now we're assembling a weighted sum of sensitivity systems:
575  //
576  // dR/du (u, v)(sum(w_l*u'_l)) = -sum_l(w_l*R'_l (u, v)) forall v
577 
578  // We'll assemble the rhs first, because the R' term will require
579  // perturbing the system, and some applications may not be able to
580  // assemble a perturbed residual without simultaneously constructing
581  // a perturbed jacobian.
582 
583  // We approximate the _l partial derivatives via a central
584  // differencing perturbation in the w_l direction:
585  //
586  // sum_l(w_l*v_l) ~= (v(p + dp*w_l*e_l) - v(p - dp*w_l*e_l))/(2*dp)
587 
588  ParameterVector oldparameters, parameterperturbation;
589  parameters.deep_copy(oldparameters);
590  weights.deep_copy(parameterperturbation);
591  parameterperturbation *= delta_p;
592  parameters += parameterperturbation;
593 
594  this->assembly(true, false, true);
595  this->rhs->close();
596 
597  std::unique_ptr<NumericVector<Number>> temprhs = this->rhs->clone();
598 
599  oldparameters.value_copy(parameters);
600  parameterperturbation *= -1.0;
601  parameters += parameterperturbation;
602 
603  this->assembly(true, false, true);
604  this->rhs->close();
605 
606  *temprhs -= *(this->rhs);
607  *temprhs /= (2.0*delta_p);
608 
609  // Finally, assemble the jacobian at the non-perturbed parameter
610  // values
611  oldparameters.value_copy(parameters);
612 
613  // Build the Jacobian
614  this->assembly(false, true);
615  this->matrix->close();
616 
617  // The weighted sensitivity problem is linear
618  LinearSolver<Number> * linear_solver = this->get_linear_solver();
619 
620  std::pair<unsigned int, Real> solver_params =
622 
623  const std::pair<unsigned int, Real> rval =
624  linear_solver->solve (*matrix, this->add_weighted_sensitivity_solution(),
625  *temprhs,
626  double(solver_params.second),
627  solver_params.first);
628 
629  this->release_linear_solver(linear_solver);
630 
631  // The linear solver may not have fit our constraints exactly
632 #ifdef LIBMESH_ENABLE_CONSTRAINTS
634  (*this, &this->get_weighted_sensitivity_solution(),
635  /* homogeneous = */ true);
636 #endif
637 
638  return rval;
639 }

References libMesh::System::add_weighted_sensitivity_solution(), libMesh::ImplicitSystem::assembly(), libMesh::NumericVector< T >::clone(), libMesh::SparseMatrix< T >::close(), libMesh::NumericVector< 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::ImplicitSystem::release_linear_solver(), libMesh::ExplicitSystem::rhs, libMesh::LinearSolver< T >::solve(), libMesh::TOLERANCE, and libMesh::ParameterVector::value_copy().

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

◆ write_discrete_parameter_values_to_file()

void libMesh::RBParametrized::write_discrete_parameter_values_to_file ( const std::string &  file_name,
const bool  write_binary_data 
)
privateinherited

Write out the discrete parameter values to file.

Definition at line 255 of file rb_parametrized.C.

257 {
258  // write out the discrete parameters, if we have any
259  if (get_n_discrete_params() > 0)
260  {
261  // The writing mode: ENCODE for binary, WRITE for ASCII
262  XdrMODE mode = write_binary_data ? ENCODE : WRITE;
263 
264  Xdr discrete_parameters_out(file_name, mode);
265  unsigned int n_discrete_params = get_n_discrete_params();
266  discrete_parameters_out << n_discrete_params;
267 
268  for (const auto & pr : get_discrete_parameter_values())
269  {
270  std::string param_name = pr.first;
271  unsigned int n_discrete_values = cast_int<unsigned int>
272  (pr.second.size());
273  discrete_parameters_out << param_name << n_discrete_values;
274 
275  for (unsigned int i=0; i<n_discrete_values; i++)
276  {
277  Real discrete_value = pr.second[i];
278  discrete_parameters_out << discrete_value;
279  }
280  }
281  }
282 }

References libMesh::ENCODE, libMesh::RBParametrized::get_discrete_parameter_values(), libMesh::RBParametrized::get_n_discrete_params(), libMesh::Real, and libMesh::WRITE.

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

◆ write_header()

void libMesh::System::write_header ( Xdr io,
const std::string &  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 1298 of file system_io.C.

1301 {
1335  libmesh_assert (io.writing());
1336 
1337 
1338  // Only write the header information
1339  // if we are processor 0.
1340  if (this->get_mesh().processor_id() != 0)
1341  return;
1342 
1343  std::string comment;
1344  char buf[80];
1345 
1346  // 5.)
1347  // Write the number of variables in the system
1348 
1349  {
1350  // set up the comment
1351  comment = "# No. of Variables in System \"";
1352  comment += this->name();
1353  comment += "\"";
1354 
1355  unsigned int nv = this->n_vars();
1356  io.data (nv, comment.c_str());
1357  }
1358 
1359 
1360  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
1361  {
1362  // 6.)
1363  // Write the name of the var-th variable
1364  {
1365  // set up the comment
1366  comment = "# Name, Variable No. ";
1367  std::sprintf(buf, "%u", var);
1368  comment += buf;
1369  comment += ", System \"";
1370  comment += this->name();
1371  comment += "\"";
1372 
1373  std::string var_name = this->variable_name(var);
1374  io.data (var_name, comment.c_str());
1375  }
1376 
1377  // 6.1.) Variable subdomains
1378  {
1379  // set up the comment
1380  comment = "# Subdomains, Variable \"";
1381  std::sprintf(buf, "%s", this->variable_name(var).c_str());
1382  comment += buf;
1383  comment += "\", System \"";
1384  comment += this->name();
1385  comment += "\"";
1386 
1387  const std::set<subdomain_id_type> & domains = this->variable(var).active_subdomains();
1388  std::vector<subdomain_id_type> domain_array;
1389  domain_array.assign(domains.begin(), domains.end());
1390  io.data (domain_array, comment.c_str());
1391  }
1392 
1393  // 7.)
1394  // Write the approximation order of the var-th variable
1395  // in this system
1396  {
1397  // set up the comment
1398  comment = "# Approximation Order, Variable \"";
1399  std::sprintf(buf, "%s", this->variable_name(var).c_str());
1400  comment += buf;
1401  comment += "\", System \"";
1402  comment += this->name();
1403  comment += "\"";
1404 
1405  int order = static_cast<int>(this->variable_type(var).order);
1406  io.data (order, comment.c_str());
1407  }
1408 
1409 
1410 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1411 
1412  // do the same for radial_order
1413  {
1414  comment = "# Radial Approximation Order, Variable \"";
1415  std::sprintf(buf, "%s", this->variable_name(var).c_str());
1416  comment += buf;
1417  comment += "\", System \"";
1418  comment += this->name();
1419  comment += "\"";
1420 
1421  int rad_order = static_cast<int>(this->variable_type(var).radial_order);
1422  io.data (rad_order, comment.c_str());
1423  }
1424 
1425 #endif
1426 
1427  // Write the Finite Element type of the var-th variable
1428  // in this System
1429  {
1430  // set up the comment
1431  comment = "# FE Family, Variable \"";
1432  std::sprintf(buf, "%s", this->variable_name(var).c_str());
1433  comment += buf;
1434  comment += "\", System \"";
1435  comment += this->name();
1436  comment += "\"";
1437 
1438  const FEType & type = this->variable_type(var);
1439  int fam = static_cast<int>(type.family);
1440  io.data (fam, comment.c_str());
1441 
1442 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1443 
1444  comment = "# Radial FE Family, Variable \"";
1445  std::sprintf(buf, "%s", this->variable_name(var).c_str());
1446  comment += buf;
1447  comment += "\", System \"";
1448  comment += this->name();
1449  comment += "\"";
1450 
1451  int radial_fam = static_cast<int>(type.radial_family);
1452  io.data (radial_fam, comment.c_str());
1453 
1454  comment = "# Infinite Mapping Type, Variable \"";
1455  std::sprintf(buf, "%s", this->variable_name(var).c_str());
1456  comment += buf;
1457  comment += "\", System \"";
1458  comment += this->name();
1459  comment += "\"";
1460 
1461  int i_map = static_cast<int>(type.inf_map);
1462  io.data (i_map, comment.c_str());
1463 #endif
1464  }
1465  } // end of the variable loop
1466 
1467  // 8.)
1468  // Write the number of additional vectors in the System.
1469  // If write_additional_data==false, then write zero for
1470  // the number of additional vectors.
1471  {
1472  {
1473  // set up the comment
1474  comment = "# No. of Additional Vectors, System \"";
1475  comment += this->name();
1476  comment += "\"";
1477 
1478  unsigned int nvecs = write_additional_data ? this->n_vectors () : 0;
1479  io.data (nvecs, comment.c_str());
1480  }
1481 
1482  if (write_additional_data)
1483  {
1484  unsigned int cnt=0;
1485  for (const auto & pr : _vectors)
1486  {
1487  // 9.)
1488  // write the name of the cnt-th additional vector
1489  comment = "# Name of ";
1490  std::sprintf(buf, "%d", cnt++);
1491  comment += buf;
1492  comment += "th vector";
1493  std::string vec_name = pr.first;
1494 
1495  io.data (vec_name, comment.c_str());
1496  }
1497  }
1498  }
1499 }

References 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::System::n_vars(), libMesh::System::n_vectors(), libMesh::System::name(), libMesh::ParallelObject::processor_id(), libMesh::FEType::radial_family, libMesh::System::variable(), libMesh::System::variable_name(), libMesh::System::variable_type(), and libMesh::Xdr::writing().

Referenced by libMesh::RBEvaluation::write_out_vectors().

◆ 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 1503 of file system_io.C.

1505 {
1525  // PerfLog pl("IO Performance",false);
1526  // pl.push("write_parallel_data");
1527  // std::size_t total_written_size = 0;
1528 
1529  std::string comment;
1530 
1531  libmesh_assert (io.writing());
1532 
1533  std::vector<Number> io_buffer; io_buffer.reserve(this->solution->local_size());
1534 
1535  // build the ordered nodes and element maps.
1536  // when writing/reading parallel files we need to iterate
1537  // over our nodes/elements in order of increasing global id().
1538  // however, this is not guaranteed to be ordering we obtain
1539  // by using the node_iterators/element_iterators directly.
1540  // so build a set, sorted by id(), that provides the ordering.
1541  // further, for memory economy build the set but then transfer
1542  // its contents to vectors, which will be sorted.
1543  std::vector<const DofObject *> ordered_nodes, ordered_elements;
1544  {
1545  std::set<const DofObject *, CompareDofObjectsByID>
1546  ordered_nodes_set (this->get_mesh().local_nodes_begin(),
1547  this->get_mesh().local_nodes_end());
1548 
1549  ordered_nodes.insert(ordered_nodes.end(),
1550  ordered_nodes_set.begin(),
1551  ordered_nodes_set.end());
1552  }
1553  {
1554  std::set<const DofObject *, CompareDofObjectsByID>
1555  ordered_elements_set (this->get_mesh().local_elements_begin(),
1556  this->get_mesh().local_elements_end());
1557 
1558  ordered_elements.insert(ordered_elements.end(),
1559  ordered_elements_set.begin(),
1560  ordered_elements_set.end());
1561  }
1562 
1563  const unsigned int sys_num = this->number();
1564  const unsigned int nv = this->n_vars();
1565 
1566  // Loop over each non-SCALAR variable and each node, and write out the value.
1567  for (unsigned int var=0; var<nv; var++)
1568  if (this->variable(var).type().family != SCALAR)
1569  {
1570  // First write the node DOF values
1571  for (const auto & node : ordered_nodes)
1572  for (auto comp : IntRange<unsigned int>(0, node->n_comp(sys_num,var)))
1573  {
1574  libmesh_assert_not_equal_to (node->dof_number(sys_num, var, comp),
1576 
1577  io_buffer.push_back((*this->solution)(node->dof_number(sys_num, var, comp)));
1578  }
1579 
1580  // Then write the element DOF values
1581  for (const auto & elem : ordered_elements)
1582  for (auto comp : IntRange<unsigned int>(0, elem->n_comp(sys_num,var)))
1583  {
1584  libmesh_assert_not_equal_to (elem->dof_number(sys_num, var, comp),
1586 
1587  io_buffer.push_back((*this->solution)(elem->dof_number(sys_num, var, comp)));
1588  }
1589  }
1590 
1591  // Finally, write the SCALAR data on the last processor
1592  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
1593  if (this->variable(var).type().family == SCALAR)
1594  {
1595  if (this->processor_id() == (this->n_processors()-1))
1596  {
1597  const DofMap & dof_map = this->get_dof_map();
1598  std::vector<dof_id_type> SCALAR_dofs;
1599  dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
1600 
1601  for (auto dof : SCALAR_dofs)
1602  io_buffer.push_back((*this->solution)(dof));
1603  }
1604  }
1605 
1606  // 9.)
1607  //
1608  // Actually write the reordered solution vector
1609  // for the ith system to disk
1610 
1611  // set up the comment
1612  {
1613  comment = "# System \"";
1614  comment += this->name();
1615  comment += "\" Solution Vector";
1616  }
1617 
1618  io.data (io_buffer, comment.c_str());
1619 
1620  // total_written_size += io_buffer.size();
1621 
1622  // Only write additional vectors if wanted
1623  if (write_additional_data)
1624  {
1625  for (auto & pr : _vectors)
1626  {
1627  io_buffer.clear();
1628  io_buffer.reserve(pr.second->local_size());
1629 
1630  // Loop over each non-SCALAR variable and each node, and write out the value.
1631  for (unsigned int var=0; var<nv; var++)
1632  if (this->variable(var).type().family != SCALAR)
1633  {
1634  // First write the node DOF values
1635  for (const auto & node : ordered_nodes)
1636  for (auto comp : IntRange<unsigned int>(0, node->n_comp(sys_num,var)))
1637  {
1638  libmesh_assert_not_equal_to (node->dof_number(sys_num, var, comp),
1640 
1641  io_buffer.push_back((*pr.second)(node->dof_number(sys_num, var, comp)));
1642  }
1643 
1644  // Then write the element DOF values
1645  for (const auto & elem : ordered_elements)
1646  for (auto comp : IntRange<unsigned int>(0, elem->n_comp(sys_num,var)))
1647  {
1648  libmesh_assert_not_equal_to (elem->dof_number(sys_num, var, comp),
1650 
1651  io_buffer.push_back((*pr.second)(elem->dof_number(sys_num, var, comp)));
1652  }
1653  }
1654 
1655  // Finally, write the SCALAR data on the last processor
1656  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
1657  if (this->variable(var).type().family == SCALAR)
1658  {
1659  if (this->processor_id() == (this->n_processors()-1))
1660  {
1661  const DofMap & dof_map = this->get_dof_map();
1662  std::vector<dof_id_type> SCALAR_dofs;
1663  dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
1664 
1665  for (auto dof : SCALAR_dofs)
1666  io_buffer.push_back((*pr.second)(dof));
1667  }
1668  }
1669 
1670  // 10.)
1671  //
1672  // Actually write the reordered additional vector
1673  // for this system to disk
1674 
1675  // set up the comment
1676  {
1677  comment = "# System \"";
1678  comment += this->name();
1679  comment += "\" Additional Vector \"";
1680  comment += pr.first;
1681  comment += "\"";
1682  }
1683 
1684  io.data (io_buffer, comment.c_str());
1685 
1686  // total_written_size += io_buffer.size();
1687  }
1688  }
1689 
1690  // const Real
1691  // dt = pl.get_elapsed_time(),
1692  // rate = total_written_size*sizeof(Number)/dt;
1693 
1694  // libMesh::err << "Write " << total_written_size << " \"Number\" values\n"
1695  // << " Elapsed time = " << dt << '\n'
1696  // << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";
1697 
1698  // pl.pop("write_parallel_data");
1699 }

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::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().

◆ 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 214 of file rb_parametrized.C.

217 {
218  write_parameter_ranges_to_file(continuous_param_file_name, write_binary_data);
219  write_discrete_parameter_values_to_file(discrete_param_file_name, write_binary_data);
220 }

References libMesh::RBParametrized::write_discrete_parameter_values_to_file(), and libMesh::RBParametrized::write_parameter_ranges_to_file().

Referenced by libMesh::RBEvaluation::legacy_write_offline_data_to_files(), and libMesh::RBSCMEvaluation::legacy_write_offline_data_to_files().

◆ write_parameter_ranges_to_file()

void libMesh::RBParametrized::write_parameter_ranges_to_file ( const std::string &  file_name,
const bool  write_binary 
)
privateinherited

Write out the parameter ranges to file.

Definition at line 222 of file rb_parametrized.C.

224 {
225  // The writing mode: ENCODE for binary, WRITE for ASCII
226  XdrMODE mode = write_binary_data ? ENCODE : WRITE;
227 
228  // Write out the parameter ranges
229  Xdr parameter_ranges_out(file_name, mode);
230  unsigned int n_continuous_params = get_n_continuous_params();
231  parameter_ranges_out << n_continuous_params;
232 
233  for (const auto & pr : get_parameters_min())
234  {
235  std::string param_name = pr.first;
236  if (!is_discrete_parameter(param_name))
237  {
238  Real param_value = pr.second;
239  parameter_ranges_out << param_name << param_value;
240  }
241  }
242 
243  for (const auto & pr : get_parameters_max())
244  {
245  std::string param_name = pr.first;
246  if (!is_discrete_parameter(param_name))
247  {
248  Real param_value = pr.second;
249  parameter_ranges_out << param_name << param_value;
250  }
251  }
252  parameter_ranges_out.close();
253 }

References libMesh::Xdr::close(), libMesh::ENCODE, libMesh::RBParametrized::get_n_continuous_params(), libMesh::RBParametrized::get_parameters_max(), libMesh::RBParametrized::get_parameters_min(), libMesh::RBParametrized::is_discrete_parameter(), libMesh::Real, and libMesh::WRITE.

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

◆ write_riesz_representors_to_files()

void libMesh::RBConstruction::write_riesz_representors_to_files ( const std::string &  riesz_representors_dir,
const bool  write_binary_residual_representors 
)
virtualinherited

Write out all the Riesz representor data to files.

residual_representors_dir specifies which directory to write to. write_binary_residual_representors specifies whether we write binary or ASCII data.

Reimplemented in libMesh::TransientRBConstruction.

Definition at line 2031 of file rb_construction.C.

2033 {
2034  LOG_SCOPE("write_riesz_representors_to_files()", "RBConstruction");
2035 
2036  // Write out Riesz representors. These are useful to have when restarting,
2037  // so you don't have to recompute them all over again.
2038 
2039  // First we write out the Fq representors, these are independent of an RBEvaluation object.
2040  libMesh::out << "Writing out the Fq_representors..." << std::endl;
2041 
2042  std::ostringstream file_name;
2043  const std::string riesz_representor_suffix = (write_binary_residual_representors ? ".xdr" : ".dat");
2044  struct stat stat_info;
2045 
2046  // Residual representors written out to their own separate directory
2047  if ( this->processor_id() == 0)
2048  if ( Utility::mkdir(riesz_representors_dir.c_str()) != 0)
2049  libMesh::out << "Skipping creating residual_representors directory: " << strerror(errno) << std::endl;
2050 
2051  for (auto i : index_range(Fq_representor))
2052  {
2053  if (Fq_representor[i])
2054  {
2055  file_name.str(""); // reset filename
2056  file_name << riesz_representors_dir << "/Fq_representor" << i << riesz_representor_suffix;
2057 
2058  // Check to see if file exists, if so, don't overwrite it, we assume it was
2059  // there from a previous call to this function. Note: if stat returns zero
2060  // it means it successfully got the file attributes (and therefore the file
2061  // exists). Because of the following factors:
2062  // 1.) write_serialized_data takes longer for proc 0 than it does for others,
2063  // so processors can get out of sync.
2064  // 2.) The constructor for Xdr opens a (0 length) file on *all* processors,
2065  // there are typically hundreds of 0-length files created during this loop,
2066  // and that screws up checking for the existence of files. One way to stay
2067  // in sync is to but a barrier at each iteration of the loop -- not sure how
2068  // bad this will affect performance, but it can't be much worse than serialized
2069  // I/O already is :)
2070  int stat_result = stat(file_name.str().c_str(), &stat_info);
2071 
2072  if ( (stat_result != 0) || // file definitely doesn't already exist
2073  (stat_info.st_size == 0)) // file exists, but has zero length (can happen if another proc already opened it!)
2074  {
2075  // No need to copy!
2076  // *solution = *(Fq_representor[i]);
2077  // std::swap doesn't work on pointers
2078  //std::swap(solution.get(), Fq_representor[i]);
2079  Fq_representor[i]->swap(*solution);
2080 
2081  Xdr fqr_data(file_name.str(),
2082  write_binary_residual_representors ? ENCODE : WRITE);
2083 
2084  write_serialized_data(fqr_data, false);
2085 
2086  // Synchronize before moving on
2087  this->comm().barrier();
2088 
2089  // Swap back.
2090  Fq_representor[i]->swap(*solution);
2091 
2092  // TODO: bzip the resulting file? See $LIBMESH_DIR/src/mesh/unstructured_mesh.C
2093  // for the system call, be sure to do it only on one processor, etc.
2094  }
2095  }
2096  }
2097 
2098 
2099  // Next, write out the Aq representors associated with rb_eval.
2100  libMesh::out << "Writing out the Aq_representors..." << std::endl;
2101 
2102  const unsigned int jstop = get_rb_evaluation().get_n_basis_functions();
2103  const unsigned int jstart = jstop-get_delta_N();
2104 
2105  RBEvaluation & rbe = get_rb_evaluation();
2106  for (auto i : index_range(rbe.Aq_representor))
2107  for (unsigned int j=jstart; j<jstop; ++j)
2108  {
2109  libMesh::out << "Writing out Aq_representor[" << i << "][" << j << "]..." << std::endl;
2110  libmesh_assert(get_rb_evaluation().Aq_representor[i][j]);
2111 
2112  file_name.str(""); // reset filename
2113  file_name << riesz_representors_dir
2114  << "/Aq_representor" << i << "_" << j << riesz_representor_suffix;
2115 
2116  {
2117  // No need to copy! Use swap instead.
2118  // *solution = *(Aq_representor[i][j]);
2119  rbe.Aq_representor[i][j]->swap(*solution);
2120 
2121  Xdr aqr_data(file_name.str(),
2122  write_binary_residual_representors ? ENCODE : WRITE);
2123 
2124  write_serialized_data(aqr_data, false);
2125 
2126  // Synchronize before moving on
2127  this->comm().barrier();
2128 
2129  // Swap back.
2130  rbe.Aq_representor[i][j]->swap(*solution);
2131 
2132  // TODO: bzip the resulting file? See $LIBMESH_DIR/src/mesh/unstructured_mesh.C
2133  // for the system call, be sure to do it only on one processor, etc.
2134  }
2135  }
2136 }

References libMesh::RBEvaluation::Aq_representor, libMesh::ParallelObject::comm(), libMesh::ENCODE, libMesh::RBConstruction::Fq_representor, libMesh::RBConstruction::get_delta_N(), libMesh::RBEvaluation::get_n_basis_functions(), libMesh::RBConstruction::get_rb_evaluation(), libMesh::index_range(), libMesh::libmesh_assert(), libMesh::Utility::mkdir(), libMesh::out, libMesh::ParallelObject::processor_id(), libMesh::System::solution, libMesh::WRITE, and libMesh::System::write_serialized_data().

◆ write_SCALAR_dofs()

unsigned int libMesh::System::write_SCALAR_dofs ( const NumericVector< Number > &  vec,
const unsigned int  var,
Xdr io 
) const
privateinherited

Writes the SCALAR dofs associated with var to the stream io.

Returns
The number of values written.

Definition at line 2097 of file system_io.C.

2100 {
2101  unsigned int written_length=0;
2102  std::vector<Number> vals; // The raw values for the local objects in the current block
2103  // Collect the SCALARs for the current variable
2104  if (this->processor_id() == (this->n_processors()-1))
2105  {
2106  const DofMap & dof_map = this->get_dof_map();
2107  std::vector<dof_id_type> SCALAR_dofs;
2108  dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
2109  const unsigned int n_scalar_dofs = cast_int<unsigned int>
2110  (SCALAR_dofs.size());
2111 
2112  for (unsigned int i=0; i<n_scalar_dofs; i++)
2113  {
2114  vals.push_back( vec(SCALAR_dofs[i]) );
2115  }
2116  }
2117 
2118 #ifdef LIBMESH_HAVE_MPI
2119  if (this->n_processors() > 1)
2120  {
2121  const Parallel::MessageTag val_tag(1);
2122 
2123  // Post the receive on processor 0
2124  if (this->processor_id() == 0)
2125  {
2126  this->comm().receive(this->n_processors()-1, vals, val_tag);
2127  }
2128 
2129  // Send the data to processor 0
2130  if (this->processor_id() == (this->n_processors()-1))
2131  {
2132  this->comm().send(0, vals, val_tag);
2133  }
2134  }
2135 #endif
2136 
2137  // -------------------------------------------------------
2138  // Write the output on processor 0.
2139  if (this->processor_id() == 0)
2140  {
2141  const unsigned int vals_size =
2142  cast_int<unsigned int>(vals.size());
2143  io.data_stream (vals.data(), vals_size);
2144  written_length += vals_size;
2145  }
2146 
2147  return written_length;
2148 }

References libMesh::ParallelObject::comm(), libMesh::Xdr::data_stream(), libMesh::System::get_dof_map(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), and libMesh::DofMap::SCALAR_dof_indices().

Referenced by libMesh::System::write_serialized_vector(), and libMesh::System::write_serialized_vectors().

◆ write_serialized_blocked_dof_objects()

template<typename iterator_type >
std::size_t libMesh::System::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
privateinherited

Writes an output vector to the stream io for a set of DofObjects.

This method uses blocked output and is safe to call on a distributed memory-mesh.

Returns
The number of values written

Definition at line 1811 of file system_io.C.

1817 {
1818  parallel_object_only();
1819 
1820  //-------------------------------------------------------
1821  // General order: (IO format 0.7.4 & greater)
1822  //
1823  // for (objects ...)
1824  // for (vecs ....)
1825  // for (vars ....)
1826  // for (comps ...)
1827  //
1828  // where objects are nodes or elements, sorted to be
1829  // partition independent,
1830  // vecs are one or more *identically distributed* solution
1831  // coefficient vectors, vars are one or more variables
1832  // to write, and comps are all the components for said
1833  // vars on the object.
1834 
1835  // We will write all variables unless requested otherwise.
1836  std::vector<unsigned int> vars_to_write(1, var_to_write);
1837 
1838  if (var_to_write == libMesh::invalid_uint)
1839  {
1840  vars_to_write.clear(); vars_to_write.reserve(this->n_vars());
1841  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
1842  vars_to_write.push_back(var);
1843  }
1844 
1845  const dof_id_type io_blksize = cast_int<dof_id_type>
1846  (std::min(max_io_blksize, static_cast<std::size_t>(n_objs)));
1847 
1848  const unsigned int
1849  sys_num = this->number(),
1850  num_vecs = cast_int<unsigned int>(vecs.size()),
1851  num_blks = cast_int<unsigned int>(std::ceil(static_cast<double>(n_objs)/
1852  static_cast<double>(io_blksize)));
1853 
1854  // libMesh::out << "io_blksize = " << io_blksize
1855  // << ", num_objects = " << n_objs
1856  // << ", num_blks = " << num_blks
1857  // << std::endl;
1858 
1859  std::size_t written_length=0; // The numer of values written. This will be returned
1860  std::vector<std::vector<dof_id_type>> xfer_ids(num_blks); // The global IDs and # of components for the local objects in all blocks
1861  std::vector<std::vector<Number>> send_vals(num_blks); // The raw values for the local objects in all blocks
1862  std::vector<Parallel::Request>
1863  id_requests(num_blks), val_requests(num_blks); // send request handle for each block
1864  std::vector<Parallel::MessageTag>
1865  id_tags(num_blks), val_tags(num_blks); // tag number for each block
1866 
1867  // ------------------------------------------------------
1868  // First pass - count the number of objects in each block
1869  // traverse all the objects and figure out which block they
1870  // will ultimately live in.
1871  std::vector<unsigned int>
1872  xfer_ids_size (num_blks,0),
1873  send_vals_size (num_blks,0);
1874 
1875  for (iterator_type it=begin; it!=end; ++it)
1876  {
1877  const dof_id_type
1878  id = (*it)->id(),
1879  block = id/io_blksize;
1880 
1881  libmesh_assert_less (block, num_blks);
1882 
1883  xfer_ids_size[block] += 2; // for each object, we store its id, as well as the total number of components for all variables
1884 
1885  unsigned int n_comp_tot=0;
1886 
1887  for (const auto & var : vars_to_write)
1888  n_comp_tot += (*it)->n_comp(sys_num, var); // for each variable, we will store the nonzero components
1889 
1890  send_vals_size[block] += n_comp_tot*num_vecs;
1891  }
1892 
1893  //-----------------------------------------
1894  // Collect the values for all local objects,
1895  // binning them into 'blocks' that will be
1896  // sent to processor 0
1897  for (unsigned int blk=0; blk<num_blks; blk++)
1898  {
1899  // libMesh::out << "Writing object block " << blk << std::endl;
1900 
1901  // Each processor should build up its transfer buffers for its
1902  // local objects in [first_object,last_object).
1903  const dof_id_type
1904  first_object = blk*io_blksize,
1905  last_object = std::min(cast_int<dof_id_type>((blk+1)*io_blksize), n_objs);
1906 
1907  // convenience
1908  std::vector<dof_id_type> & ids (xfer_ids[blk]);
1909  std::vector<Number> & vals (send_vals[blk]);
1910 
1911  // we now know the number of values we will store for each block,
1912  // so we can do efficient preallocation
1913  ids.clear(); ids.reserve (xfer_ids_size[blk]);
1914  vals.clear(); vals.reserve (send_vals_size[blk]);
1915 
1916  if (send_vals_size[blk] != 0) // only send if we have nonzero components to write
1917  for (iterator_type it=begin; it!=end; ++it)
1918  if (((*it)->id() >= first_object) && // object in [first_object,last_object)
1919  ((*it)->id() < last_object))
1920  {
1921  ids.push_back((*it)->id());
1922 
1923  // count the total number of nonzeros transferred for this object
1924  {
1925  unsigned int n_comp_tot=0;
1926 
1927  for (const auto & var : vars_to_write)
1928  n_comp_tot += (*it)->n_comp(sys_num, var);
1929 
1930  ids.push_back (n_comp_tot*num_vecs); // even if 0 - processor 0 has no way of knowing otherwise...
1931  }
1932 
1933  // pack the values to send
1934  for (const auto & vec : vecs)
1935  for (const auto & var : vars_to_write)
1936  {
1937  const unsigned int n_comp = (*it)->n_comp(sys_num, var);
1938 
1939  for (unsigned int comp=0; comp<n_comp; comp++)
1940  {
1941  libmesh_assert_greater_equal ((*it)->dof_number(sys_num, var, comp), vec->first_local_index());
1942  libmesh_assert_less ((*it)->dof_number(sys_num, var, comp), vec->last_local_index());
1943  vals.push_back((*vec)((*it)->dof_number(sys_num, var, comp)));
1944  }
1945  }
1946  }
1947 
1948 #ifdef LIBMESH_HAVE_MPI
1949  id_tags[blk] = this->comm().get_unique_tag(100*num_blks + blk);
1950  val_tags[blk] = this->comm().get_unique_tag(200*num_blks + blk);
1951 
1952  // nonblocking send the data for this block
1953  this->comm().send (0, ids, id_requests[blk], id_tags[blk]);
1954  this->comm().send (0, vals, val_requests[blk], val_tags[blk]);
1955 #endif
1956  }
1957 
1958 
1959  if (this->processor_id() == 0)
1960  {
1961  std::vector<std::vector<dof_id_type>> recv_ids (this->n_processors());
1962  std::vector<std::vector<Number>> recv_vals (this->n_processors());
1963  std::vector<unsigned int> obj_val_offsets; // map to traverse entry-wise rather than processor-wise
1964  std::vector<Number> output_vals; // The output buffer for the current block
1965 
1966  // a ThreadedIO object to perform asynchronous file IO
1967  ThreadedIO<Number> threaded_io(io, output_vals);
1968  std::unique_ptr<Threads::Thread> async_io;
1969 
1970  for (unsigned int blk=0; blk<num_blks; blk++)
1971  {
1972  // Each processor should build up its transfer buffers for its
1973  // local objects in [first_object,last_object).
1974  const dof_id_type
1975  first_object = cast_int<dof_id_type>(blk*io_blksize),
1976  last_object = std::min(cast_int<dof_id_type>((blk+1)*io_blksize), n_objs),
1977  n_objects_blk = last_object - first_object;
1978 
1979  // offset array. this will define where each object's values
1980  // map into the actual output_vals buffer. this must get
1981  // 0-initialized because 0-component objects are not actually sent
1982  obj_val_offsets.resize (n_objects_blk); std::fill (obj_val_offsets.begin(), obj_val_offsets.end(), 0);
1983 
1984  std::size_t n_val_recvd_blk=0;
1985 
1986  // receive this block of data from all processors.
1987  for (processor_id_type comm_step=0, tnp=this->n_processors(); comm_step != tnp; ++comm_step)
1988  {
1989 #ifdef LIBMESH_HAVE_MPI
1990  // blocking receive indices for this block, imposing no particular order on processor
1991  Parallel::Status id_status (this->comm().probe (Parallel::any_source, id_tags[blk]));
1992  std::vector<dof_id_type> & ids (recv_ids[id_status.source()]);
1993  this->comm().receive (id_status.source(), ids, id_tags[blk]);
1994 #else
1995  std::vector<dof_id_type> & ids (recv_ids[0]);
1996  ids = xfer_ids[blk];
1997 #endif
1998 
1999  // note its possible we didn't receive values for objects in
2000  // this block if they have no components allocated.
2001  for (std::size_t idx=0, sz=ids.size(); idx<sz; idx+=2)
2002  {
2003  const dof_id_type
2004  local_idx = ids[idx+0]-first_object,
2005  n_vals_tot_allvecs = ids[idx+1];
2006 
2007  libmesh_assert_less (local_idx, n_objects_blk);
2008  libmesh_assert_less (local_idx, obj_val_offsets.size());
2009 
2010  obj_val_offsets[local_idx] = n_vals_tot_allvecs;
2011  }
2012 
2013 #ifdef LIBMESH_HAVE_MPI
2014  // blocking receive values for this block, imposing no particular order on processor
2015  Parallel::Status val_status (this->comm().probe (Parallel::any_source, val_tags[blk]));
2016  std::vector<Number> & vals (recv_vals[val_status.source()]);
2017  this->comm().receive (val_status.source(), vals, val_tags[blk]);
2018 #else
2019  // straight copy without MPI
2020  std::vector<Number> & vals (recv_vals[0]);
2021  vals = send_vals[blk];
2022 #endif
2023 
2024  n_val_recvd_blk += vals.size();
2025  }
2026 
2027  // We need the offsets into the output_vals vector for each object.
2028  // fortunately, this is simply the partial sum of the total number
2029  // of components for each object
2030  std::partial_sum(obj_val_offsets.begin(), obj_val_offsets.end(),
2031  obj_val_offsets.begin());
2032 
2033  // wait on any previous asynchronous IO - this *must* complete before
2034  // we start messing with the output_vals buffer!
2035  if (async_io.get()) async_io->join();
2036 
2037  // this is the actual output buffer that will be written to disk.
2038  // at ths point we finally know wha size it will be.
2039  output_vals.resize(n_val_recvd_blk);
2040 
2041  // pack data from all processors into output values
2042  for (auto proc : IntRange<unsigned int>(0, this->n_processors()))
2043  {
2044  const std::vector<dof_id_type> & ids (recv_ids [proc]);
2045  const std::vector<Number> & vals(recv_vals[proc]);
2046  std::vector<Number>::const_iterator proc_vals(vals.begin());
2047 
2048  for (std::size_t idx=0, sz=ids.size(); idx<sz; idx+=2)
2049  {
2050  const dof_id_type
2051  local_idx = ids[idx+0]-first_object,
2052  n_vals_tot_allvecs = ids[idx+1];
2053 
2054  // put this object's data into the proper location
2055  // in the output buffer
2056  std::vector<Number>::iterator out_vals(output_vals.begin());
2057  if (local_idx != 0)
2058  std::advance (out_vals, obj_val_offsets[local_idx-1]);
2059 
2060  for (unsigned int val=0; val<n_vals_tot_allvecs; val++, ++out_vals, ++proc_vals)
2061  {
2062  libmesh_assert (out_vals != output_vals.end());
2063  libmesh_assert (proc_vals != vals.end());
2064  *out_vals = *proc_vals;
2065  }
2066  }
2067  }
2068 
2069  // output_vals buffer is now filled for this block.
2070  // write it to disk
2071  async_io = libmesh_make_unique<Threads::Thread>(threaded_io);
2072  written_length += output_vals.size();
2073  }
2074 
2075  // wait on any previous asynchronous IO - this *must* complete before
2076  // our stuff goes out of scope
2077  async_io->join();
2078  }
2079 
2080  Parallel::wait(id_requests);
2081  Parallel::wait(val_requests);
2082 
2083  // we need some synchronization here. Because this method
2084  // can be called for a range of nodes, then a range of elements,
2085  // we need some mechanism to prevent processors from racing past
2086  // to the next range and overtaking ongoing communication. one
2087  // approach would be to figure out unique tags for each range,
2088  // but for now we just impose a barrier here. And might as
2089  // well have it do some useful work.
2090  this->comm().broadcast(written_length);
2091 
2092  return written_length;
2093 }

References libMesh::ParallelObject::comm(), end, libMesh::MeshTools::Generation::Private::idx(), libMesh::invalid_uint, libMesh::libmesh_assert(), libMesh::ParallelObject::n_processors(), libMesh::System::n_vars(), libMesh::System::number(), and libMesh::ParallelObject::processor_id().

Referenced by libMesh::System::write_serialized_vector(), and libMesh::System::write_serialized_vectors().

◆ 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 1703 of file system_io.C.

1705 {
1719  parallel_object_only();
1720  std::string comment;
1721 
1722  // PerfLog pl("IO Performance",false);
1723  // pl.push("write_serialized_data");
1724  // std::size_t total_written_size = 0;
1725 
1726  // total_written_size +=
1727  this->write_serialized_vector(io, *this->solution);
1728 
1729  // set up the comment
1730  if (this->processor_id() == 0)
1731  {
1732  comment = "# System \"";
1733  comment += this->name();
1734  comment += "\" Solution Vector";
1735 
1736  io.comment (comment);
1737  }
1738 
1739  // Only write additional vectors if wanted
1740  if (write_additional_data)
1741  {
1742  for (auto & pair : this->_vectors)
1743  {
1744  // total_written_size +=
1745  this->write_serialized_vector(io, *pair.second);
1746 
1747  // set up the comment
1748  if (this->processor_id() == 0)
1749  {
1750  comment = "# System \"";
1751  comment += this->name();
1752  comment += "\" Additional Vector \"";
1753  comment += pair.first;
1754  comment += "\"";
1755  io.comment (comment);
1756  }
1757  }
1758  }
1759 
1760  // const Real
1761  // dt = pl.get_elapsed_time(),
1762  // rate = total_written_size*sizeof(Number)/dt;
1763 
1764  // libMesh::out << "Write " << total_written_size << " \"Number\" values\n"
1765  // << " Elapsed time = " << dt << '\n'
1766  // << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";
1767 
1768  // pl.pop("write_serialized_data");
1769 
1770 
1771 
1772 
1773  // // test the new method
1774  // {
1775  // std::vector<std::string> names;
1776  // std::vector<NumericVector<Number> *> vectors_to_write;
1777 
1778  // names.push_back("Solution Vector");
1779  // vectors_to_write.push_back(this->solution.get());
1780 
1781  // // Only write additional vectors if wanted
1782  // if (write_additional_data)
1783  // {
1784  // std::map<std::string, NumericVector<Number> *>::const_iterator
1785  // pos = _vectors.begin();
1786 
1787  // for (; pos != this->_vectors.end(); ++pos)
1788  // {
1789  // names.push_back("Additional Vector " + pos->first);
1790  // vectors_to_write.push_back(pos->second);
1791  // }
1792  // }
1793 
1794  // total_written_size =
1795  // this->write_serialized_vectors (io, names, vectors_to_write);
1796 
1797  // const Real
1798  // dt2 = pl.get_elapsed_time(),
1799  // rate2 = total_written_size*sizeof(Number)/(dt2-dt);
1800 
1801  // libMesh::out << "Write (new) " << total_written_size << " \"Number\" values\n"
1802  // << " Elapsed time = " << (dt2-dt) << '\n'
1803  // << " Rate = " << rate2/1.e6 << "(MB/sec)\n\n";
1804 
1805  // }
1806 }

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 libMesh::TransientRBConstruction::write_riesz_representors_to_files(), and libMesh::RBConstruction::write_riesz_representors_to_files().

◆ write_serialized_vector()

dof_id_type libMesh::System::write_serialized_vector ( Xdr io,
const NumericVector< Number > &  vec 
) const
privateinherited

Writes a vector for this System.

This method may safely be called on a distributed-memory mesh.

Returns
The number of values written.

Definition at line 2152 of file system_io.C.

2154 {
2155  parallel_object_only();
2156 
2157  libmesh_assert (io.writing());
2158 
2159  dof_id_type vec_length = vec.size();
2160  if (this->processor_id() == 0) io.data (vec_length, "# vector length");
2161 
2162  dof_id_type written_length = 0;
2163 
2164  //---------------------------------
2165  // Collect the values for all nodes
2166  written_length += cast_int<dof_id_type>
2167  (this->write_serialized_blocked_dof_objects (std::vector<const NumericVector<Number> *>(1,&vec),
2168  this->get_mesh().n_nodes(),
2169  this->get_mesh().local_nodes_begin(),
2170  this->get_mesh().local_nodes_end(),
2171  io));
2172 
2173  //------------------------------------
2174  // Collect the values for all elements
2175  written_length += cast_int<dof_id_type>
2176  (this->write_serialized_blocked_dof_objects (std::vector<const NumericVector<Number> *>(1,&vec),
2177  this->get_mesh().n_elem(),
2178  this->get_mesh().local_elements_begin(),
2179  this->get_mesh().local_elements_end(),
2180  io));
2181 
2182  //-------------------------------------------
2183  // Finally loop over all the SCALAR variables
2184  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
2185  if (this->variable(var).type().family == SCALAR)
2186  {
2187  written_length +=
2188  this->write_SCALAR_dofs (vec, var, io);
2189  }
2190 
2191  if (this->processor_id() == 0)
2192  libmesh_assert_equal_to (written_length, vec_length);
2193 
2194  return written_length;
2195 }

References libMesh::Xdr::data(), libMesh::System::get_mesh(), libMesh::libmesh_assert(), libMesh::MeshTools::n_elem(), n_nodes, libMesh::System::n_vars(), libMesh::ParallelObject::processor_id(), libMesh::SCALAR, libMesh::NumericVector< T >::size(), libMesh::System::variable(), libMesh::System::write_SCALAR_dofs(), libMesh::System::write_serialized_blocked_dof_objects(), and libMesh::Xdr::writing().

Referenced by libMesh::System::write_serialized_data().

◆ 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 2293 of file system_io.C.

2295 {
2296  parallel_object_only();
2297 
2298  libmesh_assert (io.writing());
2299 
2300  // Cache these - they are not free!
2301  const dof_id_type
2302  n_nodes = this->get_mesh().n_nodes(),
2303  n_elem = this->get_mesh().n_elem();
2304 
2305  std::size_t written_length = 0;
2306 
2307  if (this->processor_id() == 0)
2308  {
2309  unsigned int
2310  n_vec = cast_int<unsigned int>(vectors.size());
2311  dof_id_type
2312  vec_size = vectors.empty() ? 0 : vectors[0]->size();
2313  // Set the number of vectors
2314  io.data(n_vec, "# number of vectors");
2315  // Set the buffer size
2316  io.data(vec_size, "# vector length");
2317  }
2318 
2319  //---------------------------------
2320  // Collect the values for all nodes
2321  written_length +=
2322  this->write_serialized_blocked_dof_objects (vectors,
2323  n_nodes,
2324  this->get_mesh().local_nodes_begin(),
2325  this->get_mesh().local_nodes_end(),
2326  io);
2327 
2328  //------------------------------------
2329  // Collect the values for all elements
2330  written_length +=
2331  this->write_serialized_blocked_dof_objects (vectors,
2332  n_elem,
2333  this->get_mesh().local_elements_begin(),
2334  this->get_mesh().local_elements_end(),
2335  io);
2336 
2337  //-------------------------------------------
2338  // Finally loop over all the SCALAR variables
2339  for (const NumericVector<Number> * vec : vectors)
2340  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
2341  if (this->variable(var).type().family == SCALAR)
2342  {
2343  libmesh_assert_not_equal_to (vec, 0);
2344 
2345  written_length +=
2346  this->write_SCALAR_dofs (*vec, var, io);
2347  }
2348 
2349  return written_length;
2350 }

References libMesh::Xdr::data(), libMesh::System::get_mesh(), libMesh::libmesh_assert(), libMesh::MeshBase::n_elem(), libMesh::MeshTools::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().

◆ zero_constrained_dofs_on_vector()

void libMesh::RBConstruction::zero_constrained_dofs_on_vector ( NumericVector< Number > &  vector)
inherited

It is sometimes useful to be able to zero vector entries that correspond to constrained dofs.

Definition at line 402 of file rb_construction.C.

403 {
404 #ifdef LIBMESH_ENABLE_CONSTRAINTS
405  const DofMap & dof_map = get_dof_map();
406 
407  for (dof_id_type i=dof_map.first_dof(); i<dof_map.end_dof(); i++)
408  {
410  {
411  vector.set(i, 0.);
412  }
413  }
414 #endif
415 
416  vector.close();
417 }

References libMesh::NumericVector< T >::close(), libMesh::DofMap::end_dof(), libMesh::DofMap::first_dof(), libMesh::System::get_dof_map(), libMesh::DofMap::is_constrained_dof(), and libMesh::NumericVector< T >::set().

◆ 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 1300 of file system.C.

1302 {
1303  /* Make sure the call makes sense. */
1304  libmesh_assert_less (var_num, this->n_vars());
1305 
1306  /* Get a reference to the mesh. */
1307  const MeshBase & mesh = this->get_mesh();
1308 
1309  /* Check which system we are. */
1310  const unsigned int sys_num = this->number();
1311 
1312  // Loop over nodes.
1313  for (const auto & node : mesh.local_node_ptr_range())
1314  {
1315  unsigned int n_comp = node->n_comp(sys_num,var_num);
1316  for (unsigned int i=0; i<n_comp; i++)
1317  {
1318  const dof_id_type index = node->dof_number(sys_num,var_num,i);
1319  v.set(index,0.0);
1320  }
1321  }
1322 
1323  // Loop over elements.
1324  for (const auto & elem : mesh.active_local_element_ptr_range())
1325  {
1326  unsigned int n_comp = elem->n_comp(sys_num,var_num);
1327  for (unsigned int i=0; i<n_comp; i++)
1328  {
1329  const dof_id_type index = elem->dof_number(sys_num,var_num,i);
1330  v.set(index,0.0);
1331  }
1332  }
1333 }

References libMesh::System::get_mesh(), mesh, libMesh::System::n_vars(), libMesh::System::number(), and libMesh::NumericVector< T >::set().

Member Data Documentation

◆ _active

bool libMesh::System::_active
privateinherited

Flag stating if the system is active or not.

Definition at line 1977 of file system.h.

Referenced by libMesh::System::activate(), libMesh::System::active(), and libMesh::System::deactivate().

◆ _additional_data_written

unsigned int libMesh::System::_additional_data_written
privateinherited

This flag is used only when reading in a system from file.

Based on the system header, it keeps track of how many additional vectors were actually written for this file.

Definition at line 2034 of file system.h.

Referenced by libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::System::read_parallel_data(), and libMesh::System::read_serialized_data().

◆ _assemble_system_function

void(* libMesh::System::_assemble_system_function) (EquationSystems &es, const std::string &name)
privateinherited

◆ _assemble_system_object

Assembly* libMesh::System::_assemble_system_object
privateinherited

◆ _basic_system_only

bool libMesh::System::_basic_system_only
privateinherited

Holds true if the components of more advanced system types (e.g.

system matrices) should not be initialized.

Definition at line 2015 of file system.h.

Referenced by libMesh::System::init(), and libMesh::System::set_basic_system_only().

◆ _can_add_matrices

bool libMesh::ImplicitSystem::_can_add_matrices
privateinherited

true when additional matrices may still be added, false otherwise.

Definition at line 431 of file implicit_system.h.

Referenced by libMesh::ImplicitSystem::add_matrix(), libMesh::ImplicitSystem::clear(), and libMesh::ImplicitSystem::init_matrices().

◆ _communicator

const Parallel::Communicator& libMesh::ParallelObject::_communicator
protectedinherited

◆ _constrain_system_function

void(* libMesh::System::_constrain_system_function) (EquationSystems &es, const std::string &name)
privateinherited

◆ _constrain_system_object

Constraint* libMesh::System::_constrain_system_object
privateinherited

◆ _counts [1/2]

ReferenceCounter::Counts libMesh::ReferenceCounter::_counts
staticprotectedinherited

◆ _counts [2/2]

ReferenceCounter::Counts libMesh::ReferenceCounter::_counts
staticprotectedinherited

◆ _discrete_parameter_values

std::map<std::string, std::vector<Real> > libMesh::RBParametrized::_discrete_parameter_values
privateinherited

Map that defines the allowable values of any discrete parameters.

Definition at line 235 of file rb_parametrized.h.

Referenced by libMesh::RBParametrized::get_discrete_parameter_values(), libMesh::RBParametrized::initialize_parameters(), and libMesh::RBParametrized::is_discrete_parameter().

◆ _dof_map

std::unique_ptr<DofMap> libMesh::System::_dof_map
privateinherited

◆ _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 141 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 141 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::disable_print_counter_info(), libMesh::ReferenceCounter::enable_print_counter_info(), and libMesh::ReferenceCounter::print_info().

◆ _equation_systems

EquationSystems& libMesh::System::_equation_systems
privateinherited

◆ _final_linear_residual

Real libMesh::LinearImplicitSystem::_final_linear_residual
protectedinherited

◆ _hide_output

bool libMesh::System::_hide_output
privateinherited

Are we allowed to write this system to file? If _hide_output is true, then EquationSystems::write will ignore this system.

Definition at line 2059 of file system.h.

Referenced by libMesh::System::hide_output().

◆ _identify_variable_groups

bool libMesh::System::_identify_variable_groups
privateinherited

true when VariableGroup structures should be automatically identified, false otherwise.

Defaults to true.

Definition at line 2027 of file system.h.

Referenced by libMesh::System::identify_variable_groups().

◆ _init_system_function

void(* libMesh::System::_init_system_function) (EquationSystems &es, const std::string &name)
privateinherited

◆ _init_system_object

Initialization* libMesh::System::_init_system_object
privateinherited

◆ _is_initialized

bool libMesh::System::_is_initialized
privateinherited

true when additional vectors and variables do not require immediate initialization, false otherwise.

Definition at line 2021 of file system.h.

Referenced by libMesh::System::add_vector(), libMesh::System::clear(), libMesh::System::compare(), libMesh::System::init_data(), and libMesh::System::is_initialized().

◆ _matrices

std::map<std::string, SparseMatrix<Number> *> libMesh::ImplicitSystem::_matrices
privateinherited

◆ _mesh

MeshBase& libMesh::System::_mesh
privateinherited

Constant reference to the mesh data structure used for the simulation.

Definition at line 1946 of file system.h.

Referenced by libMesh::System::calculate_norm(), libMesh::System::get_mesh(), and libMesh::System::reinit_constraints().

◆ _mutex [1/2]

Threads::spin_mutex libMesh::ReferenceCounter::_mutex
staticprotectedinherited

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 135 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 135 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 130 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 130 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::n_objects(), libMesh::ReferenceCounter::ReferenceCounter(), and libMesh::ReferenceCounter::~ReferenceCounter().

◆ _qoi_evaluate_derivative_function

void(* libMesh::System::_qoi_evaluate_derivative_function) (EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
privateinherited

Function to evaluate quantity of interest derivative.

Definition at line 1919 of file system.h.

Referenced by libMesh::System::attach_QOI_derivative(), libMesh::System::attach_QOI_derivative_object(), libMesh::System::user_QOI_derivative(), and libMesh::System::~System().

◆ _qoi_evaluate_derivative_object

QOIDerivative* libMesh::System::_qoi_evaluate_derivative_object
privateinherited

Object to compute derivatives of quantities of interest.

Definition at line 1928 of file system.h.

Referenced by libMesh::System::attach_QOI_derivative(), libMesh::System::attach_QOI_derivative_object(), libMesh::System::user_QOI_derivative(), and libMesh::System::~System().

◆ _qoi_evaluate_function

void(* libMesh::System::_qoi_evaluate_function) (EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
privateinherited

Function to evaluate quantity of interest.

Definition at line 1907 of file system.h.

Referenced by libMesh::System::attach_QOI_function(), libMesh::System::attach_QOI_object(), libMesh::System::user_QOI(), and libMesh::System::~System().

◆ _qoi_evaluate_object

QOI* libMesh::System::_qoi_evaluate_object
privateinherited

Object to compute quantities of interest.

Definition at line 1914 of file system.h.

Referenced by libMesh::System::attach_QOI_function(), libMesh::System::attach_QOI_object(), libMesh::System::user_QOI(), and libMesh::System::~System().

◆ _shell_matrix

ShellMatrix<Number>* libMesh::LinearImplicitSystem::_shell_matrix
protectedinherited

User supplies shell matrix or nullptr if no shell matrix is used.

Definition at line 209 of file linear_implicit_system.h.

Referenced by libMesh::LinearImplicitSystem::attach_shell_matrix(), libMesh::LinearImplicitSystem::get_shell_matrix(), and libMesh::LinearImplicitSystem::solve().

◆ _solution_projection

bool libMesh::System::_solution_projection
privateinherited

Holds true if the solution vector should be projected onto a changed grid, false if it should be zeroed.

This is true by default.

Definition at line 2009 of file system.h.

Referenced by libMesh::System::project_solution_on_reinit(), and libMesh::System::restrict_vectors().

◆ _subset

const SystemSubset* libMesh::LinearImplicitSystem::_subset
protectedinherited

The current subset on which to solve (or nullptr if none).

Definition at line 214 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 220 of file linear_implicit_system.h.

Referenced by libMesh::LinearImplicitSystem::restrict_solve_to(), and libMesh::LinearImplicitSystem::solve().

◆ _sys_name

const std::string libMesh::System::_sys_name
privateinherited

A name associated with this system.

Definition at line 1951 of file system.h.

Referenced by libMesh::System::compare(), and libMesh::System::name().

◆ _sys_number

const unsigned int libMesh::System::_sys_number
privateinherited

The number associated with this system.

Definition at line 1956 of file system.h.

Referenced by libMesh::System::number().

◆ _variable_groups

std::vector<VariableGroup> libMesh::System::_variable_groups
privateinherited

◆ _variable_numbers

std::map<std::string, unsigned short int> libMesh::System::_variable_numbers
privateinherited

The variable numbers corresponding to user-specified names, useful for name-based lookups.

Definition at line 1972 of file system.h.

Referenced by libMesh::System::add_variable(), libMesh::System::add_variables(), libMesh::System::clear(), libMesh::System::get_all_variable_numbers(), libMesh::System::has_variable(), and libMesh::System::variable_number().

◆ _variables

std::vector<Variable> libMesh::System::_variables
privateinherited

◆ _vector_is_adjoint

std::map<std::string, int> libMesh::System::_vector_is_adjoint
privateinherited

Holds non-negative if a vector by that name should be projected using adjoint constraints/BCs, -1 if primal.

Definition at line 1997 of file system.h.

Referenced by libMesh::System::add_vector(), libMesh::System::clear(), libMesh::System::remove_vector(), libMesh::System::set_vector_as_adjoint(), and libMesh::System::vector_is_adjoint().

◆ _vector_projections

std::map<std::string, bool> libMesh::System::_vector_projections
privateinherited

Holds true if a vector by that name should be projected onto a changed grid, false if it should be zeroed.

Definition at line 1991 of file system.h.

Referenced by libMesh::System::add_vector(), libMesh::System::clear(), libMesh::System::remove_vector(), libMesh::System::restrict_vectors(), libMesh::System::set_vector_preservation(), and libMesh::System::vector_preservation().

◆ _vector_types

std::map<std::string, ParallelType> libMesh::System::_vector_types
privateinherited

◆ _vectors

std::map<std::string, NumericVector<Number> * > libMesh::System::_vectors
privateinherited

◆ _written_var_indices

std::vector<unsigned int> libMesh::System::_written_var_indices
privateinherited

This vector is used only when reading in a system from file.

Based on the system header, it keeps track of any index remapping between variable names in the data file and variable names in the already-constructed system. I.e. if we have a system with variables "A1", "A2", "B1", and "B2", but we read in a data file with only "A1" and "B1" defined, then we don't want to try and read in A2 or B2, and we don't want to assign A1 and B1 values to different dof indices.

Definition at line 2046 of file system.h.

Referenced by libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::System::read_parallel_data(), libMesh::System::read_serialized_blocked_dof_objects(), and libMesh::System::read_serialized_vector().

◆ abs_training_tolerance

Real libMesh::RBConstruction::abs_training_tolerance
privateinherited

◆ adjoint_already_solved

bool libMesh::System::adjoint_already_solved
privateinherited

Has the adjoint problem already been solved? If the user sets adjoint_already_solved to true, we won't waste time solving it again.

Definition at line 2053 of file system.h.

Referenced by libMesh::System::is_adjoint_already_solved(), and libMesh::System::set_adjoint_already_solved().

◆ Aq_vector

std::vector<std::unique_ptr<SparseMatrix<Number> > > libMesh::RBConstruction::Aq_vector
privateinherited

Vector storing the Q_a matrices from the affine expansion.

Definition at line 826 of file rb_construction.h.

Referenced by libMesh::RBConstruction::allocate_data_structures(), libMesh::RBConstruction::clear(), and libMesh::RBConstruction::get_Aq().

◆ 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 1493 of file system.h.

Referenced by libMesh::ImplicitSystem::adjoint_solve(), libMesh::ImplicitSystem::disable_cache(), libMesh::System::disable_cache(), main(), libMesh::RBConstruction::RBConstruction(), libMesh::RBSCMConstruction::RBSCMConstruction(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::CondensedEigenSystem::solve(), libMesh::EigenSystem::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 553 of file rb_construction.h.

Referenced by libMesh::RBEIMConstruction::RBEIMConstruction(), libMesh::TransientRBConstruction::TransientRBConstruction(), and libMesh::RBConstruction::update_RB_system_matrices().

◆ 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 1551 of file system.h.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::UniformRefinementEstimator::_estimate_error(), 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(), 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(), FETest< order, family, elem_type >::testGradU(), FETest< order, family, elem_type >::testGradUComp(), FETest< order, family, elem_type >::testU(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::TransientRBConstruction::truth_solve(), libMesh::System::update(), and libMesh::Nemesis_IO_Helper::write_nodal_solution().

◆ delta_N

unsigned int libMesh::RBConstruction::delta_N
protectedinherited

◆ dirichlet_bc

std::unique_ptr<DirichletBoundary> ElasticityRBConstruction::dirichlet_bc

The object that defines which degrees of freedom are on a Dirichlet boundary.

Definition at line 139 of file rb_classes.h.

◆ elasticity_assembly_expansion

ElasticityAssemblyExpansion ElasticityRBConstruction::elasticity_assembly_expansion

The object that stores the "assembly" expansion of the parameter dependent PDE.

Definition at line 129 of file rb_classes.h.

◆ energy_inner_product_coeffs

std::vector<Number> libMesh::RBConstruction::energy_inner_product_coeffs
privateinherited

We may optionally want to use the "energy inner-product" rather than the inner-product assembly specified in inner_product_assembly.

In this case the inner-product will be defined by sum_q^Q k_q * A_q. Here we provide the k_q values that will be used. (Note that a true "energy-inner product" would obtain the k_q from the theta_q's, but this is different for each parameter choice so we just provide a fixed set of k_q's here to ensure that the inner-product is parameter independent)

Definition at line 821 of file rb_construction.h.

Referenced by libMesh::RBConstruction::assemble_inner_product_matrix(), and libMesh::RBConstruction::set_energy_inner_product().

◆ 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 530 of file rb_construction.h.

Referenced by libMesh::RBConstruction::greedy_termination_test(), and libMesh::TransientRBConstruction::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 479 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 1524 of file system.h.

Referenced by libMesh::JumpErrorEstimator::estimate_error(), 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 513 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 574 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().

◆ Fq_vector

std::vector<std::unique_ptr<NumericVector<Number> > > libMesh::RBConstruction::Fq_vector
privateinherited

Vector storing the Q_f vectors in the affine decomposition of the right-hand side.

Definition at line 832 of file rb_construction.h.

Referenced by libMesh::RBConstruction::allocate_data_structures(), libMesh::RBConstruction::clear(), and libMesh::RBConstruction::get_Fq().

◆ 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 537 of file rb_construction.h.

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

◆ inner_product_assembly

ElemAssembly* libMesh::RBConstruction::inner_product_assembly
privateinherited

◆ 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

◆ inner_product_storage_vector

std::unique_ptr<NumericVector<Number> > libMesh::RBConstructionBase< LinearImplicitSystem >::inner_product_storage_vector
protectedinherited

We keep an extra temporary vector that is useful for performing inner products (avoids unnecessary memory allocation/deallocation).

Definition at line 254 of file rb_construction_base.h.

◆ ip_assembly

InnerProductAssembly ElasticityRBConstruction::ip_assembly

Object to assemble the inner product matrix.

Definition at line 134 of file rb_classes.h.

◆ linear_solver

std::unique_ptr<LinearSolver<Number> > libMesh::LinearImplicitSystem::linear_solver
inherited

The LinearSolver defines the interface used to solve the linear_implicit system.

This class handles all the details of interfacing with various linear algebra packages like PETSc or LASPACK.

Definition at line 158 of file linear_implicit_system.h.

Referenced by libMesh::LinearImplicitSystem::clear(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::LinearImplicitSystem::get_linear_solver(), libMesh::LinearImplicitSystem::init_data(), libMesh::LinearImplicitSystem::reinit(), libMesh::FrequencySystem::solve(), libMesh::LinearImplicitSystem::solve(), and libMesh::TransientRBConstruction::truth_solve().

◆ 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.

Definition at line 393 of file implicit_system.h.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), add_M_C_K_helmholtz(), libMesh::ImplicitSystem::add_system_matrix(), libMesh::ImplicitSystem::adjoint_solve(), assemble(), libMesh::ImplicitSystem::assemble(), LinearElasticity::assemble(), assemble_1D(), assemble_biharmonic(), assemble_elasticity(), assemble_ellipticdg(), assemble_helmholtz(), assemble_laplace(), assemble_matrix_and_rhs(), assemble_poisson(), assemble_shell(), assemble_stokes(), assemble_wave(), libMesh::FEMSystem::assembly(), libMesh::LinearImplicitSystem::assembly(), libMesh::NonlinearImplicitSystem::assembly(), assembly_with_dg_fem_context(), libMesh::NewmarkSystem::compute_matrix(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), libMesh::ContinuationSystem::continuation_solve(), DMlibMeshJacobian(), libMesh::RBConstruction::enrich_basis_from_rhs_terms(), fill_dirichlet_bc(), libMesh::ImplicitSystem::forward_qoi_parameter_sensitivity(), libMesh::ImplicitSystem::init_matrices(), main(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), 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::ContinuationSystem::solve_tangent(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::TransientRBConstruction::truth_solve(), libMesh::RBConstruction::truth_solve(), libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve(), and libMesh::ImplicitSystem::weighted_sensitivity_solve().

◆ Nmax

unsigned int libMesh::RBConstruction::Nmax
protectedinherited

◆ non_dirichlet_Aq_vector

std::vector<std::unique_ptr<SparseMatrix<Number> > > libMesh::RBConstruction::non_dirichlet_Aq_vector
privateinherited

We may also need a second set of matrices/vectors that do not have the Dirichlet boundary conditions enforced.

Definition at line 845 of file rb_construction.h.

Referenced by libMesh::RBConstruction::allocate_data_structures(), libMesh::RBConstruction::clear(), and libMesh::RBConstruction::get_non_dirichlet_Aq().

◆ non_dirichlet_Fq_vector

std::vector<std::unique_ptr<NumericVector<Number> > > libMesh::RBConstruction::non_dirichlet_Fq_vector
privateinherited

◆ non_dirichlet_inner_product_matrix

std::unique_ptr<SparseMatrix<Number> > libMesh::RBConstruction::non_dirichlet_inner_product_matrix
privateinherited

◆ non_dirichlet_outputs_vector

std::vector<std::vector<std::unique_ptr<NumericVector<Number> > > > libMesh::RBConstruction::non_dirichlet_outputs_vector
privateinherited

◆ normalize_rb_bound_in_greedy

bool libMesh::RBConstruction::normalize_rb_bound_in_greedy
privateinherited

This boolean indicates if we normalize the RB error in the greedy using RBEvaluation::get_error_bound_normalization().

Definition at line 861 of file rb_construction.h.

Referenced by libMesh::RBConstruction::get_normalize_rb_bound_in_greedy(), libMesh::RBConstruction::get_RB_error_bound(), and libMesh::RBConstruction::set_normalize_rb_bound_in_greedy().

◆ 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 496 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 775 of file rb_construction.h.

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

◆ outputs_vector

std::vector<std::vector<std::unique_ptr<NumericVector<Number> > > > libMesh::RBConstruction::outputs_vector
privateinherited

The libMesh vectors that define the output functionals.

Each row corresponds to the affine expansion of an output.

Definition at line 838 of file rb_construction.h.

Referenced by libMesh::RBConstruction::allocate_data_structures(), libMesh::RBConstruction::clear(), and libMesh::RBConstruction::get_output_vector().

◆ parameters

RBParameters libMesh::RBParametrized::parameters
privateinherited

◆ parameters_initialized

bool libMesh::RBParametrized::parameters_initialized
privateinherited

◆ parameters_max

RBParameters libMesh::RBParametrized::parameters_max
privateinherited

◆ parameters_min

RBParameters libMesh::RBParametrized::parameters_min
privateinherited

◆ qoi

std::vector<Number> libMesh::System::qoi
inherited

◆ 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 239 of file rb_construction_base.h.

◆ rb_assembly_expansion

RBAssemblyExpansion* libMesh::RBConstruction::rb_assembly_expansion
privateinherited

◆ rb_eval

RBEvaluation* libMesh::RBConstruction::rb_eval
privateinherited

The current RBEvaluation object we are using to perform the Evaluation stage of the reduced basis method.

Definition at line 792 of file rb_construction.h.

Referenced by libMesh::RBConstruction::get_rb_evaluation(), libMesh::RBConstruction::is_rb_eval_initialized(), and libMesh::RBConstruction::set_rb_evaluation().

◆ rel_training_tolerance

Real libMesh::RBConstruction::rel_training_tolerance
privateinherited

◆ 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 114 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(), assemble_elasticity(), assemble_ellipticdg(), 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(), 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(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::TransientRBConstruction::truth_solve(), libMesh::RBEIMConstruction::truth_solve(), libMesh::RBConstruction::truth_solve(), libMesh::TransientRBConstruction::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 247 of file rb_construction_base.h.

◆ 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 545 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 522 of file rb_construction.h.

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

◆ solution

std::unique_ptr<NumericVector<Number> > libMesh::System::solution
inherited

Data structure to hold solution values.

Definition at line 1539 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(), libMesh::TransientRBConstruction::add_IC_to_RB_space(), libMesh::NewmarkSolver::advance_timestep(), libMesh::AdaptiveTimeSolver::advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), libMesh::ContinuationSystem::apply_predictor(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::FEMSystem::assembly(), libMesh::LinearImplicitSystem::assembly(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::System::clear(), libMesh::System::compare(), libMesh::RBEIMConstruction::compute_best_fit_error(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::NewmarkSolver::compute_initial_accel(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), LinearElasticityWithContact::compute_stresses(), LinearElasticity::compute_stresses(), 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::ExodusII_IO::copy_nodal_solution(), libMesh::GMVIO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), DMCreateGlobalVector_libMesh(), DMlibMeshFunction(), DMlibMeshJacobian(), libMesh::UnsteadySolver::du(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::RBConstruction::enrich_RB_space(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::RBSCMConstruction::evaluate_stability_constant(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::EigenSystem::get_eigenpair(), LinearElasticityWithContact::get_least_and_max_gap_function(), libMesh::System::init_data(), libMesh::RBEIMConstruction::initialize_parametrized_functions_in_training_set(), libMesh::ContinuationSystem::initialize_tangent(), libMesh::TransientRBConstruction::initialize_truth(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_residual_helper(), libMesh::RBEIMConstruction::load_basis_function(), libMesh::RBConstruction::load_basis_function(), libMesh::RBEIMConstruction::load_rb_solution(), libMesh::RBConstruction::load_rb_solution(), libMesh::TransientRBConstruction::load_rb_solution(), main(), libMesh::DofMap::max_constraint_error(), libMesh::FEMSystem::mesh_position_get(), libMesh::ErrorVector::plot_error(), libMesh::RBEIMConstruction::plot_parametrized_functions_in_training_set(), libMesh::RBConstruction::print_basis_function_orthogonality(), 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(), libMesh::TransientRBConstruction::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::MemorySolutionHistory::retrieve(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), libMesh::ContinuationSystem::save_current_solution(), libMesh::TransientRBConstruction::set_error_temporal_data(), setup(), libMesh::TwostepTimeSolver::solve(), libMesh::NewtonSolver::solve(), libMesh::PetscDiffSolver::solve(), libMesh::FrequencySystem::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::NonlinearImplicitSystem::solve(), libMesh::RBConstruction::solve_for_matrix_and_rhs(), libMesh::ContinuationSystem::solve_tangent(), libMesh::MemorySolutionHistory::store(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), SystemsTest::testBoundaryProjectCube(), SystemsTest::testDofCouplingWithVarGroups(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), SystemsTest::testProjectCubeWithMeshFunction(), WriteVecAndScalar::testWrite(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::DirectSolutionTransfer::transfer(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), libMesh::BoundaryVolumeSolutionTransfer::transfer_volume_boundary(), libMesh::TransientRBConstruction::truth_solve(), libMesh::RBEIMConstruction::truth_solve(), libMesh::RBConstruction::truth_solve(), libMesh::System::update(), libMesh::System::update_global_solution(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::RBEIMConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::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(), libMesh::TransientRBConstruction::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

◆ time

Real libMesh::System::time
inherited

◆ 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 464 of file rb_construction.h.

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

◆ training_parameters

std::map<std::string, std::unique_ptr<NumericVector<Number> > > libMesh::RBConstructionBase< LinearImplicitSystem >::training_parameters
privateinherited

The training samples.

Definition at line 268 of file rb_construction_base.h.

◆ training_parameters_initialized

bool libMesh::RBConstructionBase< LinearImplicitSystem >::training_parameters_initialized
privateinherited

Boolean flag to indicate whether or not the parameter ranges have been initialized.

Definition at line 263 of file rb_construction_base.h.

◆ training_parameters_random_seed

int libMesh::RBConstructionBase< LinearImplicitSystem >::training_parameters_random_seed
privateinherited

If < 0, use std::time() * processor_id() to seed the random number generator for the training parameters (default).

If >= 0, use the provided value * processor_id() as the random number generator seed.

Definition at line 276 of file rb_construction_base.h.

◆ 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 490 of file rb_construction.h.

Referenced by libMesh::RBConstruction::allocate_data_structures(), and libMesh::RBConstruction::truth_solve().

◆ u_var

unsigned int ElasticityRBConstruction::u_var

◆ 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 567 of file rb_construction.h.

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

◆ use_energy_inner_product

bool libMesh::RBConstruction::use_energy_inner_product
privateinherited

Boolean to indicate whether we're using the energy inner-product.

If this is false then we use inner_product_assembly instead.

Definition at line 809 of file rb_construction.h.

Referenced by libMesh::RBConstruction::assemble_inner_product_matrix(), libMesh::RBConstruction::get_inner_product_assembly(), libMesh::RBConstruction::set_energy_inner_product(), and libMesh::RBConstruction::set_inner_product_assembly().

◆ 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 1509 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().

◆ v_var

unsigned int ElasticityRBConstruction::v_var

◆ verbose_mode

bool libMesh::RBParametrized::verbose_mode
inherited

Public boolean to toggle verbose mode.

Definition at line 170 of file rb_parametrized.h.

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

◆ w_var

unsigned int ElasticityRBConstruction::w_var

◆ 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 400 of file implicit_system.h.

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


The documentation for this class was generated from the following file:
libMesh::LinearSolver::reuse_preconditioner
virtual void reuse_preconditioner(bool)
Set the same_preconditioner flag, which indicates if we reuse the same preconditioner for subsequent ...
Definition: linear_solver.C:129
libMesh::LinearImplicitSystem::_final_linear_residual
Real _final_linear_residual
The final residual for the linear system Ax=b.
Definition: linear_implicit_system.h:204
libMesh::RBConstruction::inner_product_matrix
std::unique_ptr< SparseMatrix< Number > > inner_product_matrix
The inner product matrix.
Definition: rb_construction.h:484
libMesh::DISCRETE_L_INF
Definition: enum_norm_type.h:54
libMesh::ImplicitSystem::assemble_residual_derivatives
virtual void assemble_residual_derivatives(const ParameterVector &parameters) override
Residual parameter derivative function.
Definition: implicit_system.C:643
libMesh::SparseMatrix::close
virtual void close()=0
Calls the SparseMatrix's internal assembly routines, ensuring that the values are consistent across p...
libMesh::RBConstruction::enrich_RB_space
virtual void enrich_RB_space()
Add a new basis function to the RB space.
Definition: rb_construction.C:1316
libMesh::RBConstruction::post_process_truth_solution
virtual void post_process_truth_solution()
Similarly, provide an opportunity to post-process the truth solution after the solve is complete.
Definition: rb_construction.h:651
libMesh::RBEvaluation::get_n_basis_functions
virtual unsigned int get_n_basis_functions() const
Get the current number of basis functions.
Definition: rb_evaluation.h:145
libMesh::System::write_serialized_vector
dof_id_type write_serialized_vector(Xdr &io, const NumericVector< Number > &vec) const
Writes a vector for this System.
Definition: system_io.C:2152
libMesh::ImplicitSystem::request_matrix
const SparseMatrix< Number > * request_matrix(const std::string &mat_name) const
Definition: implicit_system.C:236
libMesh::System::_vector_projections
std::map< std::string, bool > _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:1991
libMesh::RBParametrized::print_discrete_parameter_values
void print_discrete_parameter_values() const
Print out all the discrete parameter values.
Definition: rb_parametrized.C:389
libMesh::NumericVector::zero
virtual void zero()=0
Set all entries to zero.
libMesh::RBParametrized::get_parameters_min
const RBParameters & get_parameters_min() const
Get an RBParameters object that specifies the minimum allowable value for each parameter.
Definition: rb_parametrized.C:174
libMesh::RBConstructionBase< LinearImplicitSystem >::generate_training_parameters_random
static void generate_training_parameters_random(const Parallel::Communicator &communicator, std::map< std::string, bool > log_param_scale, std::map< std::string, std::unique_ptr< NumericVector< Number >>> &training_parameters_in, unsigned int n_training_samples_in, const RBParameters &min_parameters, const RBParameters &max_parameters, int training_parameters_random_seed=-1, bool serial_training_set=false)
Static helper function for generating a randomized set of parameters.
Definition: rb_construction_base.C:300
libMesh::RBConstructionBase< LinearImplicitSystem >::clear
virtual void clear()
Clear all the data structures associated with the system.
Definition: rb_construction_base.C:65
libMesh::dof_id_type
uint8_t dof_id_type
Definition: id_types.h:67
libMesh::Number
Real Number
Definition: libmesh_common.h:195
libMesh::System::boundary_project_solution
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...
Definition: system_projection.C:1126
libMesh::System::n_vars
unsigned int n_vars() const
Definition: system.h:2155
libMesh::RBParametrized::_discrete_parameter_values
std::map< std::string, std::vector< Real > > _discrete_parameter_values
Map that defines the allowable values of any discrete parameters.
Definition: rb_parametrized.h:235
libMesh::RBEvaluation::RB_Aq_vector
std::vector< DenseMatrix< Number > > RB_Aq_vector
Dense matrices for the RB computations.
Definition: rb_evaluation.h:260
libMesh::LinearSolver::get_converged_reason
virtual LinearConvergenceReason get_converged_reason() const =0
libMesh::RBThetaExpansion::get_n_output_terms
unsigned int get_n_output_terms(unsigned int output_index) const
Get the number of affine terms associated with the specified output.
Definition: rb_theta_expansion.C:53
libMesh::RBThetaExpansion::get_n_F_terms
unsigned int get_n_F_terms() const
Get Q_f, the number of terms in the affine expansion for the right-hand side.
Definition: rb_theta_expansion.C:41
libMesh::System::have_vector
bool have_vector(const std::string &vec_name) const
Definition: system.h:2275
libMesh::RBParameters::print
void print() const
Print the parameters.
Definition: rb_parameters.C:134
libMesh::System::get_equation_systems
const EquationSystems & get_equation_systems() const
Definition: system.h:720
libMesh::OrderWrapper::get_order
int get_order() const
Explicitly request the order as an int.
Definition: fe_type.h:77
libMesh::invalid_uint
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value.
Definition: libmesh.h:249
libMesh::NumericVector::add
virtual void add(const numeric_index_type i, const T value)=0
Adds value to each entry of the vector.
libMesh::System::project_vector
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.
Definition: system_projection.C:991
libMesh::RBConstruction::get_RB_error_bound
virtual Real get_RB_error_bound()
Definition: rb_construction.C:1356
libMesh::System::get_sensitivity_rhs
NumericVector< Number > & get_sensitivity_rhs(unsigned int i=0)
Definition: system.C:1049
libMesh::System::is_initialized
bool is_initialized()
Definition: system.h:2139
libMesh::System::_is_initialized
bool _is_initialized
true when additional vectors and variables do not require immediate initialization,...
Definition: system.h:2021
libMesh::RBConstruction::get_non_dirichlet_Fq
NumericVector< Number > * get_non_dirichlet_Fq(unsigned int q)
Get a pointer to non-Dirichlet Fq.
Definition: rb_construction.C:1913
ElasticityRBConstruction::v_var
unsigned int v_var
Definition: rb_classes.h:123
libMesh::MeshTools::n_elem
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:705
libMesh::DofMap::prepare_send_list
void prepare_send_list()
Takes the _send_list vector (which may have duplicate entries) and sorts it.
Definition: dof_map.C:1651
libMesh::System::_variable_groups
std::vector< VariableGroup > _variable_groups
The VariableGroup in this System.
Definition: system.h:1966
libMesh::System::vectors_iterator
std::map< std::string, NumericVector< Number > * >::iterator vectors_iterator
Vector iterator typedefs.
Definition: system.h:756
libMesh::System::_constrain_system_function
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Function to impose constraints.
Definition: system.h:1896
ElasticityRBConstruction::ip_assembly
InnerProductAssembly ip_assembly
Object to assemble the inner product matrix.
Definition: rb_classes.h:134
libMesh::RBConstruction::get_Aq
SparseMatrix< Number > * get_Aq(unsigned int q)
Get a pointer to Aq.
Definition: rb_construction.C:1876
libMesh::FEType::family
FEFamily family
The type of finite element.
Definition: fe_type.h:203
libMesh::ExplicitSystem::rhs
NumericVector< Number > * rhs
The system matrix.
Definition: explicit_system.h:114
libMesh::System::boundary_project_vector
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...
Definition: system_projection.C:1162
libMesh::RBConstructionBase< LinearImplicitSystem >::get_first_local_training_index
numeric_index_type get_first_local_training_index() const
Get the first local index of the training parameters.
Definition: rb_construction_base.C:116
libMesh::RBConstruction::Nmax
unsigned int Nmax
Maximum number of reduced basis functions we are willing to use.
Definition: rb_construction.h:762
libMesh::RBConstructionBase< LinearImplicitSystem >::inner_product_storage_vector
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...
Definition: rb_construction_base.h:254
libMesh::DofMap::dof_indices
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Fills the vector di with the global degree of freedom indices for the element.
Definition: dof_map.C:1967
libMesh::ImplicitSystem::get_linear_solve_parameters
virtual std::pair< unsigned int, Real > get_linear_solve_parameters() const
Definition: implicit_system.C:1410
libMesh::System::add_adjoint_solution
NumericVector< Number > & add_adjoint_solution(unsigned int i=0)
Definition: system.C:945
libMesh::L_INF
Definition: enum_norm_type.h:42
libMesh::PARALLEL
Definition: enum_parallel_type.h:36
libMesh::DofMap::add_dirichlet_boundary
void add_dirichlet_boundary(const DirichletBoundary &dirichlet_boundary)
Adds a copy of the specified Dirichlet boundary to the system.
Definition: dof_map_constraints.C:4390
libMesh::System::_dof_map
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:1934
libMesh::System::add_variables
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:1160
libMesh::RBConstructionBase< LinearImplicitSystem >::training_parameters
std::map< std::string, std::unique_ptr< NumericVector< Number > > > training_parameters
The training samples.
Definition: rb_construction_base.h:268
libMesh::ImplicitSystem::adjoint_solve
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...
Definition: implicit_system.C:359
libMesh::RBParametrized::get_closest_value
static Real get_closest_value(Real value, const std::vector< Real > &list_of_values)
Definition: rb_parametrized.C:433
libMesh::LinearSolver::solve
virtual std::pair< unsigned int, Real > solve(SparseMatrix< T > &, NumericVector< T > &, NumericVector< T > &, const double, const unsigned int)=0
This function calls the solver _solver_type preconditioned with the _preconditioner_type precondition...
libMesh::RBParametrized::read_discrete_parameter_values_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.
Definition: rb_parametrized.C:340
libMesh::RBAssemblyExpansion::get_output_assembly
ElemAssembly & get_output_assembly(unsigned int output_index, unsigned int q_l)
Return a reference to the specified output assembly object.
Definition: rb_assembly_expansion.C:190
libMesh::NumericVector::subset_linfty_norm
virtual Real subset_linfty_norm(const std::set< numeric_index_type > &indices) const
Definition: numeric_vector.C:342
libMesh::libmesh_real
T libmesh_real(T a)
Definition: libmesh_common.h:166
libMesh::RBConstruction::get_non_dirichlet_Fq_if_avail
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.
Definition: rb_construction.C:1924
libMesh::System::_assemble_system_function
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Function that assembles the system.
Definition: system.h:1885
libMesh::LinearImplicitSystem::_subset
const SystemSubset * _subset
The current subset on which to solve (or nullptr if none).
Definition: linear_implicit_system.h:214
libMesh::DofMap::has_adjoint_dirichlet_boundaries
bool has_adjoint_dirichlet_boundaries(unsigned int q) const
Definition: dof_map_constraints.C:4409
libMesh::DofMap::get_info
std::string get_info() const
Gets summary info about the sparsity bandwidth and constraints.
Definition: dof_map.C:2843
libMesh::System::_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:2059
libMesh::DISCRETE_L2
Definition: enum_norm_type.h:53
libMesh::MeshBase::n_elem
virtual dof_id_type n_elem() const =0
libMesh::System::get_adjoint_solution
NumericVector< Number > & get_adjoint_solution(unsigned int i=0)
Definition: system.C:957
libMesh::System::system_type
virtual std::string system_type() const
Definition: system.h:495
libMesh::RBConstruction::abs_training_tolerance
Real abs_training_tolerance
Definition: rb_construction.h:855
libMesh::System::_vectors
std::map< std::string, NumericVector< Number > * > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:1985
libMesh::System::get_weighted_sensitivity_adjoint_solution
NumericVector< Number > & get_weighted_sensitivity_adjoint_solution(unsigned int i=0)
Definition: system.C:989
libMesh::System::_vector_types
std::map< std::string, ParallelType > _vector_types
Holds the type of a vector.
Definition: system.h:2002
libMesh::RBEvaluation::rb_solve
virtual Real rb_solve(unsigned int N)
Perform online solve with the N RB basis functions, for the set of parameters in current_params,...
Definition: rb_evaluation.C:209
ElasticityRBConstruction::dirichlet_bc
std::unique_ptr< DirichletBoundary > dirichlet_bc
The object that defines which degrees of freedom are on a Dirichlet boundary.
Definition: rb_classes.h:139
libMesh::RBConstructionBase< LinearImplicitSystem >::set_training_random_seed
void set_training_random_seed(unsigned int seed)
Set the seed that is used to randomly generate training parameters.
Definition: rb_construction_base.C:630
libMesh::RBConstruction::get_non_dirichlet_inner_product_matrix
SparseMatrix< Number > * get_non_dirichlet_inner_product_matrix()
Get the non-Dirichlet (or more generally no-constraints) version of the inner-product matrix.
Definition: rb_construction.C:1858
libMesh::SparseMatrix::vector_mult
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.
Definition: sparse_matrix.C:170
libMesh::System::variable_name
const std::string & variable_name(const unsigned int i) const
Definition: system.h:2203
libMesh::RBConstructionBase< LinearImplicitSystem >::training_parameters_initialized
bool training_parameters_initialized
Boolean flag to indicate whether or not the parameter ranges have been initialized.
Definition: rb_construction_base.h:263
libMesh::RBConstruction::rel_training_tolerance
Real rel_training_tolerance
Relative and absolute tolerances for training reduced basis using the Greedy scheme.
Definition: rb_construction.h:854
libMesh::System::read_serialized_blocked_dof_objects
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:810
libMesh::SERIAL
Definition: enum_parallel_type.h:35
libMesh::index_range
IntRange< std::size_t > index_range(const std::vector< T > &vec)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:106
libMesh::ImplicitSystem::reinit
virtual void reinit() override
Reinitializes the member data fields associated with the system, so that, e.g., assemble() may be use...
Definition: implicit_system.C:149
libMesh::RBParametrized::get_n_params
unsigned int get_n_params() const
Get the number of parameters.
Definition: rb_parametrized.C:115
libMesh::RBParametrized::verbose_mode
bool verbose_mode
Public boolean to toggle verbose mode.
Definition: rb_parametrized.h:170
libMesh::L1
Definition: enum_norm_type.h:41
libMesh::RBConstruction::Fq_representor_innerprods
std::vector< Number > Fq_representor_innerprods
Vectors storing the residual representor inner products to be used in computing the residuals online.
Definition: rb_construction.h:513
libMesh::System::n_vectors
unsigned int n_vectors() const
Definition: system.h:2283
libMesh::XYZ
Definition: enum_fe_family.h:46
libMesh::System::add_sensitivity_solution
NumericVector< Number > & add_sensitivity_solution(unsigned int i=0)
Definition: system.C:894
libMesh::System::restrict_vectors
virtual void restrict_vectors()
Restrict vectors after the mesh has coarsened.
Definition: system.C:324
libMesh::RBConstruction::compute_output_dual_innerprods
virtual void compute_output_dual_innerprods()
Compute and store the dual norm of each output functional.
Definition: rb_construction.C:1635
libMesh::RBAssemblyExpansion::get_F_assembly
ElemAssembly & get_F_assembly(unsigned int q)
Return a reference to the specified F_assembly object.
Definition: rb_assembly_expansion.C:182
libMesh::NumericVector::close
virtual void close()=0
Calls the NumericVector's internal assembly routines, ensuring that the values are consistent across ...
libMesh::RBEvaluation::output_dual_innerprods
std::vector< std::vector< Number > > output_dual_innerprods
The vector storing the dual norm inner product terms for each output.
Definition: rb_evaluation.h:308
libMesh::FEGenericBase
This class forms the foundation from which generic finite elements may be derived.
Definition: exact_error_estimator.h:39
libMesh::SparseMatrix::initialized
virtual bool initialized() const
Definition: sparse_matrix.h:103
libMesh::H1_SEMINORM
Definition: enum_norm_type.h:43
libMesh::ImplicitSystem::add_matrix
SparseMatrix< Number > & add_matrix(const std::string &mat_name)
Adds the additional matrix mat_name to this system.
Definition: implicit_system.C:202
libMesh::ImplicitSystem::assemble
virtual void assemble() override
Prepares matrix and rhs for system assembly, then calls user assembly function.
Definition: implicit_system.C:183
libMesh::System::identify_variable_groups
bool identify_variable_groups() const
Definition: system.h:2251
libMesh::System::_identify_variable_groups
bool _identify_variable_groups
true when VariableGroup structures should be automatically identified, false otherwise.
Definition: system.h:2027
libMesh::NumericVector::init
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.
libMesh::RBConstruction::post_process_elem_matrix_and_vector
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...
Definition: rb_construction.h:641
libMesh::FEAbstract::get_JxW
const std::vector< Real > & get_JxW() const
Definition: fe_abstract.h:244
end
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end.
Definition: variant_filter_iterator.h:343
libMesh::ReferenceCounter::_counts
static Counts _counts
Actually holds the data.
Definition: reference_counter.h:122
std::sqrt
MetaPhysicL::DualNumber< T, D > sqrt(const MetaPhysicL::DualNumber< T, D > &in)
libMesh::TOLERANCE
static const Real TOLERANCE
Definition: libmesh_common.h:128
libMesh::ImplicitSystem::_matrices
std::map< std::string, SparseMatrix< Number > * > _matrices
Some systems need an arbitrary number of matrices.
Definition: implicit_system.h:426
libMesh::RBConstruction::Fq_representor
std::vector< std::unique_ptr< NumericVector< Number > > > Fq_representor
Vector storing the residual representors associated with the right-hand side.
Definition: rb_construction.h:504
libMesh::System::_active
bool _active
Flag stating if the system is active or not.
Definition: system.h:1977
libMesh::ParallelObject::comm
const Parallel::Communicator & comm() const
Definition: parallel_object.h:94
libMesh::System::get_adjoint_rhs
NumericVector< Number > & get_adjoint_rhs(unsigned int i=0)
Definition: system.C:1019
libMesh::RBConstruction::assert_convergence
bool assert_convergence
A boolean flag to indicate whether to check for proper convergence after each solve.
Definition: rb_construction.h:781
libMesh::GHOSTED
Definition: enum_parallel_type.h:37
libMesh::RBConstructionBase< LinearImplicitSystem >::init_data
virtual void init_data()
Initializes the member data fields associated with the system, so that, e.g., assemble() may be used.
Definition: rb_construction_base.C:74
libMesh::RBConstruction::get_matrix_for_output_dual_solves
virtual SparseMatrix< Number > & get_matrix_for_output_dual_solves()
Return the matrix for the output residual dual norm solves.
Definition: rb_construction.C:1630
libMesh::RBConstruction::build_zero_dirichlet_boundary_object
static std::unique_ptr< DirichletBoundary > build_zero_dirichlet_boundary_object()
It's helpful to be able to generate a DirichletBoundary that stores a ZeroFunction in order to impose...
Definition: rb_construction.C:2018
libMesh::NumericVector::clone
virtual std::unique_ptr< NumericVector< T > > clone() const =0
libMesh::DofMap::process_constraints
void process_constraints(MeshBase &)
Postprocesses any constrained degrees of freedom to be constrained only in terms of unconstrained dof...
Definition: dof_map_constraints.C:3334
libMesh::libmesh_conj
T libmesh_conj(T a)
Definition: libmesh_common.h:167
libMesh::System::number
unsigned int number() const
Definition: system.h:2075
libMesh::ReferenceCounter::_n_objects
static Threads::atomic< unsigned int > _n_objects
The number of objects.
Definition: reference_counter.h:130
libMesh::RBConstruction::Aq_vector
std::vector< std::unique_ptr< SparseMatrix< Number > > > Aq_vector
Vector storing the Q_a matrices from the affine expansion.
Definition: rb_construction.h:826
libMesh::Variable::type
const FEType & type() const
Definition: variable.h:119
libMesh::W2_INF_SEMINORM
Definition: enum_norm_type.h:50
libMesh::H2
Definition: enum_norm_type.h:38
libMesh::WRITE
Definition: enum_xdr_mode.h:40
libMesh::FEMFunctionBase::component
virtual Output component(const FEMContext &, unsigned int i, const Point &p, Real time=0.)
Definition: fem_function_base.h:132
mesh
MeshBase & mesh
Definition: mesh_communication.C:1257
libMesh::RBConstruction::non_dirichlet_Fq_vector
std::vector< std::unique_ptr< NumericVector< Number > > > non_dirichlet_Fq_vector
Definition: rb_construction.h:846
libMesh::MeshBase::mesh_dimension
unsigned int mesh_dimension() const
Definition: mesh_base.C:135
libMesh::ImplicitSystem::get_linear_solver
virtual LinearSolver< Number > * get_linear_solver() const
Definition: implicit_system.C:1384
libMesh::RBConstruction::init_context
virtual void init_context(FEMContext &)
Initialize the FEMContext prior to performing an element loop.
Definition: rb_construction.h:742
libMesh::W1_INF_SEMINORM
Definition: enum_norm_type.h:49
libMesh::DofMap::first_dof
dof_id_type first_dof(const processor_id_type proc) const
Definition: dof_map.h:650
libMesh::FEGenericBase::get_dphi
const std::vector< std::vector< OutputGradient > > & get_dphi() const
Definition: fe_base.h:214
libMesh::RBThetaExpansion::eval_output_theta
virtual Number eval_output_theta(unsigned int output_index, unsigned int q_l, const RBParameters &mu)
Evaluate theta_q_l at the current parameter.
Definition: rb_theta_expansion.C:141
libMesh::RBConstruction::outputs_vector
std::vector< std::vector< std::unique_ptr< NumericVector< Number > > > > outputs_vector
The libMesh vectors that define the output functionals.
Definition: rb_construction.h:838
libMesh::RBConstruction::rb_eval
RBEvaluation * rb_eval
The current RBEvaluation object we are using to perform the Evaluation stage of the reduced basis met...
Definition: rb_construction.h:792
libMesh::System::read_SCALAR_dofs
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:1120
libMesh::RBConstruction::set_inner_product_assembly
void set_inner_product_assembly(ElemAssembly &inner_product_assembly_in)
Set the rb_assembly_expansion object.
Definition: rb_construction.C:379
libMesh::System::variable
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2183
libMesh::RBConstruction::use_empty_rb_solve_in_greedy
bool use_empty_rb_solve_in_greedy
A boolean flag to indicate whether or not we initialize the Greedy algorithm by performing rb_solves ...
Definition: rb_construction.h:567
libMesh::DofMap::is_constrained_dof
bool is_constrained_dof(const dof_id_type dof) const
Definition: dof_map.h:1962
libMesh::Variable::active_subdomains
const std::set< subdomain_id_type > & active_subdomains() const
Definition: variable.h:150
libMesh::RBParametrized::set_parameters
void set_parameters(const RBParameters &params)
Set the current parameters to params.
Definition: rb_parametrized.C:155
libMesh::RBParametrized::get_n_discrete_params
unsigned int get_n_discrete_params() const
Get the number of discrete parameters.
Definition: rb_parametrized.C:135
libMesh::ReferenceCounter::get_info
static std::string get_info()
Gets a string containing the reference information.
Definition: reference_counter.C:47
libMesh::System::local_dof_indices
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 ...
Definition: system.C:1259
libMesh::System::n_matrices
virtual unsigned int n_matrices() const
Definition: system.h:2289
libMesh::LinearImplicitSystem::_shell_matrix
ShellMatrix< Number > * _shell_matrix
User supplies shell matrix or nullptr if no shell matrix is used.
Definition: linear_implicit_system.h:209
libMesh::RBParametrized::parameters_max
RBParameters parameters_max
Definition: rb_parametrized.h:230
libMesh::System::is_adjoint_already_solved
bool is_adjoint_already_solved() const
Accessor for the adjoint_already_solved boolean.
Definition: system.h:396
libMesh::RBParameters::n_parameters
unsigned int n_parameters() const
Get the number of parameters that have been added.
Definition: rb_parameters.C:63
libMesh::LinearSolver::init
virtual void init(const char *name=nullptr)=0
Initialize data structures if not done so already.
libMesh::RBParametrized::get_n_continuous_params
unsigned int get_n_continuous_params() const
Get the number of continuous parameters.
Definition: rb_parametrized.C:125
libMesh::RBConstructionBase< LinearImplicitSystem >::get_global_max_error_pair
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...
Definition: rb_construction_base.C:85
libMesh::System::QOI::qoi
virtual void qoi(const QoISet &qoi_indices)=0
Quantity of interest function.
dim
unsigned int dim
Definition: adaptivity_ex3.C:113
libMesh::RBParametrized::get_parameters_max
const RBParameters & get_parameters_max() const
Get an RBParameters object that specifies the maximum allowable value for each parameter.
Definition: rb_parametrized.C:182
libMesh::NumericVector::build
static std::unique_ptr< NumericVector< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
Builds a NumericVector on the processors in communicator comm using the linear solver package specifi...
Definition: numeric_vector.C:49
libMesh::RBParametrized::get_parameters
const RBParameters & get_parameters() const
Get the current parameters.
Definition: rb_parametrized.C:166
libMesh::ImplicitSystem::const_matrices_iterator
std::map< std::string, SparseMatrix< Number > * >::const_iterator const_matrices_iterator
Definition: implicit_system.h:307
libMesh::System::_init_system_function
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Function that initializes the system.
Definition: system.h:1874
libMesh::System::_qoi_evaluate_function
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Function to evaluate quantity of interest.
Definition: system.h:1907
libMesh::System::get_weighted_sensitivity_solution
NumericVector< Number > & get_weighted_sensitivity_solution()
Definition: system.C:931
libMesh::NumericVector::size
virtual numeric_index_type size() const =0
libMesh::RBConstruction::greedy_termination_test
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.
Definition: rb_construction.C:1192
libMesh::RBConstruction::assemble_misc_matrices
virtual void assemble_misc_matrices()
Assemble and store all the inner-product matrix, the constraint matrix (for constrained problems) and...
Definition: rb_construction.C:918
libMesh::System::vector_is_adjoint
int vector_is_adjoint(const std::string &vec_name) const
Definition: system.C:884
libMesh::System::QOIDerivative::qoi_derivative
virtual void qoi_derivative(const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)=0
Quantity of interest derivative function.
libMesh::RBConstruction::update_greedy_param_list
void update_greedy_param_list()
Update the list of Greedily chosen parameters with current_parameters.
Definition: rb_construction.C:1229
libMesh::zero
const Number zero
.
Definition: libmesh.h:243
libMesh::System::n_qois
unsigned int n_qois() const
Number of currently active quantities of interest.
Definition: system.h:2328
libMesh::DofMap::enforce_adjoint_constraints_exactly
void enforce_adjoint_constraints_exactly(NumericVector< Number > &v, unsigned int q) const
Heterogenously constrains the numeric vector v, which represents an adjoint solution defined on the m...
Definition: dof_map.h:2058
libMesh::System::n_components
unsigned int n_components() const
Definition: system.h:2171
libMesh::System::_basic_system_only
bool _basic_system_only
Holds true if the components of more advanced system types (e.g.
Definition: system.h:2015
libMesh::System::assemble_before_solve
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:1493
libMesh::ImplicitSystem::weighted_sensitivity_solve
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...
Definition: implicit_system.C:560
libMesh::System::add_adjoint_rhs
NumericVector< Number > & add_adjoint_rhs(unsigned int i=0)
Definition: system.C:1009
libMesh::System::_init_system_object
Initialization * _init_system_object
Object that initializes the system.
Definition: system.h:1880
libMesh::libmesh_assert
libmesh_assert(ctx)
libMesh::RBConstruction::get_inner_product_matrix
SparseMatrix< Number > * get_inner_product_matrix()
Get a pointer to inner_product_matrix.
Definition: rb_construction.C:1853
libMesh::RBConstruction::inner_product_assembly
ElemAssembly * inner_product_assembly
Pointer to inner product assembly.
Definition: rb_construction.h:803
ElasticityRBConstruction::elasticity_assembly_expansion
ElasticityAssemblyExpansion elasticity_assembly_expansion
The object that stores the "assembly" expansion of the parameter dependent PDE.
Definition: rb_classes.h:129
libMesh::FEMNormType
FEMNormType
Definition: enum_norm_type.h:34
libMesh::RBConstruction::skip_degenerate_sides
bool skip_degenerate_sides
In some cases meshes are intentionally created with degenerate sides as a way to represent,...
Definition: rb_construction.h:545
libMesh::RBConstruction::update_residual_terms
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.
Definition: rb_construction.C:1535
libMesh::NumericVector::add_vector
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].
Definition: numeric_vector.C:363
libMesh::LinearConvergenceReason
LinearConvergenceReason
Linear solver convergence flags (taken from the PETSc flags).
Definition: enum_convergence_flags.h:33
libMesh::System::n_variable_groups
unsigned int n_variable_groups() const
Definition: system.h:2163
libMesh::RBParametrized::get_parameter_max
Real get_parameter_max(const std::string &param_name) const
Get maximum allowable value of parameter param_name.
Definition: rb_parametrized.C:198
libMesh::Threads::Thread
NonConcurrentThread Thread
Use the non-concurrent placeholder.
Definition: threads_none.h:43
std::abs
MetaPhysicL::DualNumber< T, D > abs(const MetaPhysicL::DualNumber< T, D > &in)
libMesh::Threads::parallel_for
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
libMesh::System::vectors_end
vectors_iterator vectors_end()
End of vectors container.
Definition: system.h:2307
libMesh::RBConstruction::inner_product_solver
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...
Definition: rb_construction.h:471
libMesh::NumericVector::localize
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.
libMesh::RBConstruction::allocate_data_structures
virtual void allocate_data_structures()
Helper function that actually allocates all the data structures required by this class.
Definition: rb_construction.C:467
libMesh::NumericVector::subset_l2_norm
virtual Real subset_l2_norm(const std::set< numeric_index_type > &indices) const
Definition: numeric_vector.C:327
libMesh::RBConstructionBase< LinearImplicitSystem >::broadcast_parameters
void broadcast_parameters(unsigned int proc_id)
Broadcasts parameters on processor proc_id to all processors.
Definition: rb_construction_base.C:600
libMesh::System::qoi
std::vector< Number > qoi
Values of the quantities of interest.
Definition: system.h:1574
libMesh::System::vectors_begin
vectors_iterator vectors_begin()
Beginning of vectors container.
Definition: system.h:2295
libMesh::FEMap::inverse_map
static Point inverse_map(const unsigned int dim, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true)
Definition: fe_map.C:1622
libMesh::System::_mesh
MeshBase & _mesh
Constant reference to the mesh data structure used for the simulation.
Definition: system.h:1946
libMesh::XdrMODE
XdrMODE
Defines an enum for read/write mode in Xdr format.
Definition: enum_xdr_mode.h:35
libMesh::RBConstructionBase< LinearImplicitSystem >::get_n_training_samples
numeric_index_type get_n_training_samples() const
Get the total number of training samples.
Definition: rb_construction_base.C:98
libMesh::System::_variables
std::vector< Variable > _variables
The Variable in this System.
Definition: system.h:1961
libMesh::ParallelObject::n_processors
processor_id_type n_processors() const
Definition: parallel_object.h:100
libMesh::LinearImplicitSystem::get_linear_solver
virtual LinearSolver< Number > * get_linear_solver() const override
Definition: linear_implicit_system.C:353
libMesh::System::n_local_dofs
dof_id_type n_local_dofs() const
Definition: system.C:187
libMesh::RBConstruction::assemble_Fq_vector
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.
Definition: rb_construction.C:971
libMesh::System::variable_scalar_number
unsigned int variable_scalar_number(const std::string &var, unsigned int component) const
Definition: system.h:2214
libMesh::System::_qoi_evaluate_derivative_function
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:1919
libMesh::System::variable_group
const VariableGroup & variable_group(unsigned int vg) const
Return a constant reference to VariableGroup vg.
Definition: system.h:2193
libMesh::DECODE
Definition: enum_xdr_mode.h:39
libMesh::RBConstruction::update_system
virtual void update_system()
Update the system after enriching the RB space; this calls a series of functions to update the system...
Definition: rb_construction.C:1350
libMesh::RBConstructionBase< LinearImplicitSystem >::get_params_from_training_set
RBParameters get_params_from_training_set(unsigned int index)
Return the RBParameters in index index of training set.
Definition: rb_construction_base.C:136
libMesh::FEBase
FEGenericBase< Real > FEBase
Definition: exact_error_estimator.h:39
libMesh::RBConstruction::set_rel_training_tolerance
void set_rel_training_tolerance(Real new_training_tolerance)
Get/set the relative tolerance for the basis training.
Definition: rb_construction.h:184
libMesh::RBConstruction::get_non_dirichlet_Aq_if_avail
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.
Definition: rb_construction.C:1895
libMesh::RBConstruction::is_rb_eval_initialized
bool is_rb_eval_initialized() const
Definition: rb_construction.C:183
libMesh::RBEvaluation::RB_solution
DenseVector< Number > RB_solution
The RB solution vector.
Definition: rb_evaluation.h:270
libMesh::RBConstruction::get_output_vectors
virtual void get_output_vectors(std::map< std::string, NumericVector< Number > * > &all_vectors)
Get a map that stores pointers to all of the vectors.
Definition: rb_construction.C:1997
libMesh::RBConstruction::energy_inner_product_coeffs
std::vector< Number > energy_inner_product_coeffs
We may optionally want to use the "energy inner-product" rather than the inner-product assembly speci...
Definition: rb_construction.h:821
libMesh::RBEvaluation::Fq_representor_innerprods
std::vector< Number > Fq_representor_innerprods
Vectors storing the residual representor inner products to be used in computing the residuals online.
Definition: rb_evaluation.h:290
libMesh::ImplicitSystem::_can_add_matrices
bool _can_add_matrices
true when additional matrices may still be added, false otherwise.
Definition: implicit_system.h:431
libMesh::RBConstructionBase< LinearImplicitSystem >::set_params_from_training_set
void set_params_from_training_set(unsigned int index)
Set parameters to the RBParameters stored in index index of the training set.
Definition: rb_construction_base.C:130
libMesh::Utility::iota
void iota(ForwardIter first, ForwardIter last, T value)
Utility::iota is a duplication of the SGI STL extension std::iota.
Definition: utility.h:105
libMesh::Threads::spin_mtx
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.
Definition: threads.C:29
libMesh::System::set_vector_as_adjoint
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:873
libMesh::ImplicitSystem::assembly
virtual void assembly(bool, bool, bool=false, bool=false)
Assembles a residual in rhs and/or a jacobian in matrix, as requested.
Definition: implicit_system.h:161
libMesh::System::get_mesh
const MeshBase & get_mesh() const
Definition: system.h:2083
libMesh::ParallelObject::processor_id
processor_id_type processor_id() const
Definition: parallel_object.h:106
libMesh::System::n_local_constrained_dofs
dof_id_type n_local_constrained_dofs() const
Definition: system.C:172
libMesh::libmesh_ignore
void libmesh_ignore(const Args &...)
Definition: libmesh_common.h:526
libMesh::DofMap::enforce_constraints_exactly
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:2054
libMesh::RBConstruction::non_dirichlet_outputs_vector
std::vector< std::vector< std::unique_ptr< NumericVector< Number > > > > non_dirichlet_outputs_vector
Definition: rb_construction.h:847
libMesh::RBConstruction::get_output_vector
NumericVector< Number > * get_output_vector(unsigned int n, unsigned int q_l)
Get a pointer to the n^th output.
Definition: rb_construction.C:1934
libMesh::FEGenericBase::build
static std::unique_ptr< FEGenericBase > build(const unsigned int dim, const FEType &type)
Builds a specific finite element type.
libMesh::DofObject::invalid_id
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:421
libMesh::RBConstruction::compute_max_error_bound
virtual Real compute_max_error_bound()
(i) Compute the a posteriori error bound for each set of parameters in the training set,...
Definition: rb_construction.C:1395
libMesh::System::add_variable
unsigned int add_variable(const std::string &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:1069
libMesh::RBEvaluation::Fq_Aq_representor_innerprods
std::vector< std::vector< std::vector< Number > > > Fq_Aq_representor_innerprods
Vectors storing the residual representor inner products to be used in computing the residuals online.
Definition: rb_evaluation.h:299
libMesh::System::current_local_solution
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:1551
libMesh::System::Constraint::constrain
virtual void constrain()=0
Constraint function.
libMesh::System::get_sensitivity_solution
NumericVector< Number > & get_sensitivity_solution(unsigned int i=0)
Definition: system.C:904
libMesh::ParallelObject::_communicator
const Parallel::Communicator & _communicator
Definition: parallel_object.h:112
libMesh::RBConstruction::extra_linear_solver
LinearSolver< Number > * extra_linear_solver
Also, we store a pointer to an extra linear solver.
Definition: rb_construction.h:479
libMesh::RBConstruction::assemble_Aq_matrix
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.
Definition: rb_construction.C:876
libMesh::ConstElemRange
StoredRange< MeshBase::const_element_iterator, const Elem * > ConstElemRange
Definition: elem_range.h:34
libMesh::processor_id_type
uint8_t processor_id_type
Definition: id_types.h:104
libMesh::System::read_serialized_data
void read_serialized_data(Xdr &io, const bool read_additional_data=true)
Reads additional data, namely vectors, for this System.
Definition: system_io.C:724
libMesh::ImplicitSystem::matrix
SparseMatrix< Number > * matrix
The system matrix.
Definition: implicit_system.h:393
libMesh::TypeVector::add_scaled
void add_scaled(const TypeVector< T2 > &, const T &)
Add a scaled value to this vector without creating a temporary.
Definition: type_vector.h:665
libMesh::MeshBase::elem_dimensions
const std::set< unsigned char > & elem_dimensions() const
Definition: mesh_base.h:225
libMesh::RBParametrized::print_parameters
void print_parameters() const
Print the current parameters.
Definition: rb_parametrized.C:206
libMesh::System::write_SCALAR_dofs
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:2097
libMesh::RBConstruction::solve_for_matrix_and_rhs
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 ...
Definition: rb_construction.C:130
libMesh::RBConstruction::get_rb_evaluation
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.
Definition: rb_construction.C:175
libMesh::RBParameters::set_value
void set_value(const std::string &param_name, Real value)
Set the value of the specified parameter.
Definition: rb_parameters.C:47
libMesh::SparseMatrix::vector_mult_add
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.
Definition: sparse_matrix.C:180
libMesh::LinearImplicitSystem::assemble
virtual void assemble() override
Prepares matrix and _dof_map for matrix assembly.
Definition: linear_implicit_system.h:110
libMesh::RBConstruction::get_rb_theta_expansion
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the RBThetaExpansion object that that belongs to rb_eval.
Definition: rb_construction.C:188
libMesh::System::_sys_number
const unsigned int _sys_number
The number associated with this system.
Definition: system.h:1956
libMesh::MeshTools::Generation::Private::idx
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.
Definition: mesh_generation.C:72
libMesh::TypeTensor::add_scaled
void add_scaled(const TypeTensor< T2 > &, const T &)
Add a scaled tensor to this tensor without creating a temporary.
Definition: type_tensor.h:869
libMesh::Threads::parallel_reduce
void parallel_reduce(const Range &range, Body &body)
Execute the provided reduction operation in parallel on the specified range.
Definition: threads_none.h:101
libMesh::ImplicitSystem::sensitivity_solve
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...
Definition: implicit_system.C:301
libMesh::ImplicitSystem::have_matrix
bool have_matrix(const std::string &mat_name) const
Definition: implicit_system.h:439
std::pow
double pow(double a, int b)
Definition: libmesh_augment_std_namespace.h:58
ElasticityRBConstruction::w_var
unsigned int w_var
Definition: rb_classes.h:124
libMesh::RBAssemblyExpansion::get_A_assembly
ElemAssembly & get_A_assembly(unsigned int q)
Return a reference to the specified A_assembly object.
Definition: rb_assembly_expansion.C:174
libMesh::NumericVector::local_size
virtual numeric_index_type local_size() const =0
libMesh::RBParametrized::parameters_min
RBParameters parameters_min
Vectors that define the ranges (min and max) for the parameters.
Definition: rb_parametrized.h:229
libMesh::System::_written_var_indices
std::vector< unsigned int > _written_var_indices
This vector is used only when reading in a system from file.
Definition: system.h:2046
libMesh::DofMap::variable_type
const FEType & variable_type(const unsigned int c) const
Definition: dof_map.h:1924
libMesh::as_range
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
libMesh::RBConstructionBase< LinearImplicitSystem >::is_quiet
bool is_quiet() const
Is the system in quiet mode?
Definition: rb_construction_base.h:98
libMesh::ExplicitSystem::assemble_qoi
virtual void assemble_qoi(const QoISet &qoi_indices=QoISet()) override
Prepares qoi for quantity of interest assembly, then calls user qoi function.
Definition: explicit_system.C:56
libMesh::System::assemble_qoi
virtual void assemble_qoi(const QoISet &qoi_indices=QoISet())
Calls user qoi function.
Definition: system.C:473
libMesh::RBConstructionBase< LinearImplicitSystem >::generate_training_parameters_deterministic
static void generate_training_parameters_deterministic(const Parallel::Communicator &communicator, std::map< std::string, bool > log_param_scale, std::map< std::string, std::unique_ptr< NumericVector< Number >>> &training_parameters_in, unsigned int n_training_samples_in, const RBParameters &min_parameters, const RBParameters &max_parameters, bool serial_training_set=false)
Static helper function for generating a deterministic set of parameters.
Definition: rb_construction_base.C:412
n_nodes
const dof_id_type n_nodes
Definition: tecplot_io.C:68
gptr
Gradient gptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:95
libMesh::RBConstruction::get_Nmax
unsigned int get_Nmax() const
Get/set Nmax, the maximum number of RB functions we are willing to compute.
Definition: rb_construction.h:206
libMesh::RBConstruction::set_rb_assembly_expansion
void set_rb_assembly_expansion(RBAssemblyExpansion &rb_assembly_expansion_in)
Set the rb_assembly_expansion object.
Definition: rb_construction.C:366
libMesh::LinearImplicitSystem::_subset_solve_mode
SubsetSolveMode _subset_solve_mode
If restrict-solve-to-subset mode is active, this member decides what happens with the dofs outside th...
Definition: linear_implicit_system.h:220
libMesh::DenseVector::size
virtual unsigned int size() const override
Definition: dense_vector.h:92
libMesh::NumericVector::l1_norm
virtual Real l1_norm() const =0
libMesh::DofMap::get_send_list
const std::vector< dof_id_type > & get_send_list() const
Definition: dof_map.h:496
libMesh::H2_SEMINORM
Definition: enum_norm_type.h:44
libMesh::READ
Definition: enum_xdr_mode.h:41
libMesh::ImplicitSystem::matrices_iterator
std::map< std::string, SparseMatrix< Number > * >::iterator matrices_iterator
Matrix iterator typedefs.
Definition: implicit_system.h:306
libMesh::NumericVector::clear
virtual void clear()
Restores the NumericVector<T> to a pristine state.
Definition: numeric_vector.h:811
libMesh::System::_additional_data_written
unsigned int _additional_data_written
This flag is used only when reading in a system from file.
Definition: system.h:2034
libMesh::RBParametrized::write_discrete_parameter_values_to_file
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.
Definition: rb_parametrized.C:255
libMesh::RBConstruction::check_convergence
void check_convergence(LinearSolver< Number > &input_solver)
Check if the linear solver reports convergence.
Definition: rb_construction.C:2231
libMesh::ImplicitSystem::release_linear_solver
virtual void release_linear_solver(LinearSolver< Number > *) const
Releases a pointer to a linear solver acquired by this->get_linear_solver()
Definition: implicit_system.C:1418
libMesh::SparseMatrix::add
virtual void add(const numeric_index_type i, const numeric_index_type j, const T value)=0
Add value to the element (i,j).
libMesh::Utility::get_timestamp
std::string get_timestamp()
Definition: timestamp.C:37
libMesh::System::Assembly::assemble
virtual void assemble()=0
Assembly function.
libMesh::numeric_index_type
dof_id_type numeric_index_type
Definition: id_types.h:99
libMesh::MONOMIAL
Definition: enum_fe_family.h:39
libMesh::System::_assemble_system_object
Assembly * _assemble_system_object
Object that assembles the system.
Definition: system.h:1891
libMesh::DofMap::create_dof_constraints
void create_dof_constraints(const MeshBase &, Real time=0)
Rebuilds the raw degree of freedom and DofObject constraints.
Definition: dof_map_constraints.C:1206
libMesh::System::time
Real time
For time-dependent problems, this is the time t at the beginning of the current timestep.
Definition: system.h:1561
libMesh::DofMap::constrain_element_matrix_and_vector
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:2034
libMesh::LinearImplicitSystem::n_linear_iterations
unsigned int n_linear_iterations() const
Definition: linear_implicit_system.h:164
libMesh::Utility::mkdir
int mkdir(const char *pathname)
Create a directory.
Definition: utility.C:140
libMesh::RBEvaluation::Aq_Aq_representor_innerprods
std::vector< std::vector< std::vector< Number > > > Aq_Aq_representor_innerprods
Definition: rb_evaluation.h:300
libMesh::RBConstruction::get_non_dirichlet_inner_product_matrix_if_avail
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 ...
Definition: rb_construction.C:1866
libMesh::RBThetaExpansion::get_n_outputs
unsigned int get_n_outputs() const
Get n_outputs, the number output functionals.
Definition: rb_theta_expansion.C:47
libMesh::RBConstruction::assemble_affine_expansion
virtual void assemble_affine_expansion(bool skip_matrix_assembly, bool skip_vector_assembly)
Assemble the matrices and vectors for this system.
Definition: rb_construction.C:449
libMesh::RBConstruction::get_normalize_rb_bound_in_greedy
bool get_normalize_rb_bound_in_greedy()
Definition: rb_construction.h:200
libMesh::NumericVector::linfty_norm
virtual Real linfty_norm() const =0
libMesh::System::variable_type
const FEType & variable_type(const unsigned int i) const
Definition: system.h:2233
libMesh::RBConstruction::set_normalize_rb_bound_in_greedy
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.
Definition: rb_construction.h:198
libMesh::MeshBase::n_nodes
virtual dof_id_type n_nodes() const =0
libMesh::System::write_serialized_data
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:1703
libMesh::RBConstruction::update_RB_system_matrices
virtual void update_RB_system_matrices()
Compute the reduced basis matrices for the current basis.
Definition: rb_construction.C:1466
libMesh::System::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:2053
libMesh::RBConstruction::Fq_vector
std::vector< std::unique_ptr< NumericVector< Number > > > Fq_vector
Vector storing the Q_f vectors in the affine decomposition of the right-hand side.
Definition: rb_construction.h:832
libMesh::RBParameters::get_parameter_names
void get_parameter_names(std::set< std::string > &param_names) const
Fill param_names with the names of the parameters.
Definition: rb_parameters.C:69
libMesh::Quality::valid
std::vector< ElemQuality > valid(const ElemType t)
Returns all valid quality metrics for element type t.
Definition: elem_quality.C:324
libMesh::System::discrete_var_norm
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:1337
libMesh::RBEvaluation::RB_output_vectors
std::vector< std::vector< DenseVector< Number > > > RB_output_vectors
The vectors storing the RB output vectors.
Definition: rb_evaluation.h:275
libMesh::ENCODE
Definition: enum_xdr_mode.h:38
distance
Real distance(const Point &p)
Definition: subdomains_ex3.C:50
libMesh::RBConstruction::truth_outputs
std::vector< Number > truth_outputs
Vector storing the truth output values from the most recent truth solve.
Definition: rb_construction.h:490
libMesh::RBParametrized::initialize_parameters
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.
Definition: rb_parametrized.C:60
libMesh::RBConstructionBase< LinearImplicitSystem >::get_last_local_training_index
numeric_index_type get_last_local_training_index() const
Get the last local index of the training parameters.
Definition: rb_construction_base.C:123
libMesh::RBParametrized::read_parameter_ranges_from_file
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.
Definition: rb_parametrized.C:303
libMesh::RBConstruction::skip_residual_in_train_reduced_basis
bool skip_residual_in_train_reduced_basis
Boolean flag to indicate if we skip residual calculations in train_reduced_basis.
Definition: rb_construction.h:522
libMesh::System::_constrain_system_object
Constraint * _constrain_system_object
Object that constrains the system.
Definition: system.h:1902
libMesh::RBConstruction::compute_RB_inner_product
bool compute_RB_inner_product
Boolean flag to indicate whether we compute the RB_inner_product_matrix.
Definition: rb_construction.h:553
libMesh::RBConstruction::get_non_dirichlet_Aq
SparseMatrix< Number > * get_non_dirichlet_Aq(unsigned int q)
Get a pointer to non_dirichlet_Aq.
Definition: rb_construction.C:1884
libMesh::Gradient
NumberVectorValue Gradient
Definition: exact_solution.h:58
libMesh::RBConstruction::delta_N
unsigned int delta_N
The number of basis functions that we add at each greedy step.
Definition: rb_construction.h:768
libMesh::FEMContext::get_element_fe
void get_element_fe(unsigned int var, FEGenericBase< OutputShape > *&fe) const
Accessor for interior finite element object for variable var for the largest dimension in the mesh.
Definition: fem_context.h:275
libMesh::System::solution
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1539
libMesh::SparseMatrix::add_matrix
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.
libMesh::RBConstruction::get_delta_N
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...
Definition: rb_construction.h:417
libMesh::ReferenceElem::get
const Elem & get(const ElemType type_in)
Definition: reference_elem.C:237
libMesh::TensorTools::norm_sq
T norm_sq(std::complex< T > a)
Definition: tensor_tools.h:85
libMesh::RBParametrized::parameters
RBParameters parameters
Vector storing the current parameters.
Definition: rb_parametrized.h:224
libMesh::RBConstruction::non_dirichlet_Aq_vector
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 ...
Definition: rb_construction.h:845
libMesh::RBConstruction::normalize_rb_bound_in_greedy
bool normalize_rb_bound_in_greedy
This boolean indicates if we normalize the RB error in the greedy using RBEvaluation::get_error_bound...
Definition: rb_construction.h:861
libMesh::RBEvaluation::RB_inner_product_matrix
DenseMatrix< Number > RB_inner_product_matrix
The inner product matrix.
Definition: rb_evaluation.h:255
libMesh::SparseMatrix::build
static std::unique_ptr< SparseMatrix< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
Builds a SparseMatrix<T> using the linear solver package specified by solver_package.
Definition: sparse_matrix.C:130
libMesh::System::point_value
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:1971
libMesh::FEType::order
OrderWrapper order
The approximation order of the element.
Definition: fe_type.h:197
libMesh::DISCRETE_L1
Definition: enum_norm_type.h:52
libMesh::RBConstruction::add_scaled_matrix_and_vector
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...
Definition: rb_construction.C:588
libMesh::RBConstruction::rb_assembly_expansion
RBAssemblyExpansion * rb_assembly_expansion
This member holds the (parameter independent) assembly functors that define the "affine expansion" of...
Definition: rb_construction.h:798
libMesh::RBConstructionBase< LinearImplicitSystem >::set_quiet_mode
void set_quiet_mode(bool quiet_mode_in)
Set the quiet_mode flag.
Definition: rb_construction_base.h:92
libMesh::RBParametrized::valid_params
bool valid_params(const RBParameters &params)
Helper function to check that params is valid.
Definition: rb_parametrized.C:402
libMesh::NumericVector::set
virtual void set(const numeric_index_type i, const T value)=0
Sets v(i) = value.
libMesh::System::_qoi_evaluate_derivative_object
QOIDerivative * _qoi_evaluate_derivative_object
Object to compute derivatives of quantities of interest.
Definition: system.h:1928
value
static const bool value
Definition: xdr_io.C:56
libMesh::RBConstruction::output_dual_innerprods
std::vector< std::vector< Number > > output_dual_innerprods
The vector storing the dual norm inner product terms for each output.
Definition: rb_construction.h:496
libMesh::System::name
const std::string & name() const
Definition: system.h:2067
libMesh::RBConstruction::impose_internal_fluxes
bool impose_internal_fluxes
Boolean flag to indicate whether we impose "fluxes" (i.e.
Definition: rb_construction.h:537
libMesh::RBEvaluation::get_error_bound_normalization
virtual Real get_error_bound_normalization()
Definition: rb_evaluation.C:291
libMesh::RBConstruction::get_abs_training_tolerance
Real get_abs_training_tolerance()
Definition: rb_construction.h:193
libMesh::RBConstructionBase< LinearImplicitSystem >::serial_training_set
bool serial_training_set
This boolean flag indicates whether or not the training set should be the same on all processors.
Definition: rb_construction_base.h:247
libMesh::System::init_data
virtual void init_data()
Initializes the data for the system.
Definition: system.C:262
libMesh::RBParametrized::get_discrete_parameter_values
const std::map< std::string, std::vector< Real > > & get_discrete_parameter_values() const
Get a const reference to the discrete parameter values.
Definition: rb_parametrized.C:381
ElasticityRBConstruction::Parent
RBConstruction Parent
The type of the parent.
Definition: rb_classes.h:71
libMesh::System::n_constrained_dofs
dof_id_type n_constrained_dofs() const
Definition: system.C:157
libMesh::SystemSubset::dof_ids
virtual const std::vector< unsigned int > & dof_ids() const =0
libMesh::RBEvaluation::Aq_representor
std::vector< std::vector< std::unique_ptr< NumericVector< Number > > > > Aq_representor
Vector storing the residual representors associated with the left-hand side.
Definition: rb_evaluation.h:316
libMesh::RBConstruction::get_rel_training_tolerance
Real get_rel_training_tolerance()
Definition: rb_construction.h:186
libMesh::RBConstruction::use_energy_inner_product
bool use_energy_inner_product
Boolean to indicate whether we're using the energy inner-product.
Definition: rb_construction.h:809
libMesh::RBConstruction::exit_on_repeated_greedy_parameters
bool exit_on_repeated_greedy_parameters
Boolean flag to indicate whether we exit the greedy if we select the same parameters twice in a row.
Definition: rb_construction.h:530
libMesh::RBConstruction::training_error_bounds
std::vector< Real > training_error_bounds
Vector storing the values of the error bound for each parameter in the training set — the parameter g...
Definition: rb_construction.h:464
libMesh::RBConstruction::truth_assembly
virtual void truth_assembly()
Assemble the truth matrix and right-hand side for current_parameters.
Definition: rb_construction.C:805
libMesh::RBConstruction::set_abs_training_tolerance
void set_abs_training_tolerance(Real new_training_tolerance)
Get/set the absolute tolerance for the basis training.
Definition: rb_construction.h:191
libMesh::L2
Definition: enum_norm_type.h:36
libMesh::System::variable_number
unsigned short int variable_number(const std::string &var) const
Definition: system.C:1232
libMesh::System::write_serialized_blocked_dof_objects
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:1811
libMesh::RBConstruction::get_Fq
NumericVector< Number > * get_Fq(unsigned int q)
Get a pointer to Fq.
Definition: rb_construction.C:1905
libMesh::NumericVector::l2_norm
virtual Real l2_norm() const =0
libMesh::RBConstruction::output_dual_innerprods_computed
bool output_dual_innerprods_computed
A boolean flag to indicate whether or not the output dual norms have already been computed — used to ...
Definition: rb_construction.h:775
libMesh::RBConstructionBase< LinearImplicitSystem >::training_parameters_random_seed
int training_parameters_random_seed
If < 0, use std::time() * processor_id() to seed the random number generator for the training paramet...
Definition: rb_construction_base.h:276
libMesh::RBConstruction::non_dirichlet_inner_product_matrix
std::unique_ptr< SparseMatrix< Number > > non_dirichlet_inner_product_matrix
Definition: rb_construction.h:848
libMesh::on_command_line
bool on_command_line(std::string arg)
Definition: libmesh.C:898
libMesh::NumericVector::scale
virtual void scale(const T factor)=0
Scale each element of the vector by the given factor.
std::norm
MetaPhysicL::DualNumber< T, D > norm(const MetaPhysicL::DualNumber< T, D > &in)
libMesh::System::assemble_qoi_derivative
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:484
libMesh::RBThetaExpansion::get_n_A_terms
unsigned int get_n_A_terms() const
Get Q_a, the number of terms in the affine expansion for the bilinear form.
Definition: rb_theta_expansion.C:35
libMesh::System::_equation_systems
EquationSystems & _equation_systems
Constant reference to the EquationSystems object used for the simulation.
Definition: system.h:1940
libMesh::RBConstruction::assemble_all_affine_vectors
virtual void assemble_all_affine_vectors()
Assemble and store the affine RHS vectors.
Definition: rb_construction.C:950
libMesh::System::calculate_norm
Real calculate_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=nullptr) const
Definition: system.C:1356
libMesh::RBConstructionBase< LinearImplicitSystem >::quiet_mode
bool quiet_mode
Flag to indicate whether we print out extra information during the Offline stage.
Definition: rb_construction_base.h:239
libMesh::RBConstruction::store_non_dirichlet_operators
bool store_non_dirichlet_operators
Boolean flag to indicate whether we store a second copy of each affine operator and vector which does...
Definition: rb_construction.h:560
libMesh::System::clear
virtual void clear()
Clear all the data structures associated with the system.
Definition: system.C:205
libMesh::RBConstruction::truth_solve
virtual Real truth_solve(int plot_solution)
Perform a "truth" solve, i.e.
Definition: rb_construction.C:1242
libMesh::RBParametrized::parameters_initialized
bool parameters_initialized
Flag indicating whether the parameters have been initialized.
Definition: rb_parametrized.h:219
libMesh::System::forward_qoi_parameter_sensitivity
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:2375
libMesh::System::add_vector
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Adds the additional vector vec_name to this system.
Definition: system.C:661
libMesh::ParallelType
ParallelType
Defines an enum for parallel data structure types.
Definition: enum_parallel_type.h:33
libMesh::LinearImplicitSystem::final_linear_residual
Real final_linear_residual() const
Definition: linear_implicit_system.h:169
libMesh::RBConstruction::get_non_dirichlet_output_vector
NumericVector< Number > * get_non_dirichlet_output_vector(unsigned int n, unsigned int q_l)
Get a pointer to non-Dirichlet output vector.
Definition: rb_construction.C:1943
libMesh::NumericVector::get
virtual void get(const std::vector< numeric_index_type > &index, T *values) const
Access multiple components at once.
Definition: numeric_vector.h:821
libMesh::System::get_dof_map
const DofMap & get_dof_map() const
Definition: system.h:2099
libMesh::System::n_dofs
dof_id_type n_dofs() const
Definition: system.C:150
libMesh::System::user_initialization
virtual void user_initialization()
Calls user's attached initialization function, or is overridden by the user in derived classes.
Definition: system.C:1896
libMesh::SparseMatrix::set
virtual void set(const numeric_index_type i, const numeric_index_type j, const T value)=0
Set the element (i,j) to value.
libMesh::DofMap::_dof_coupling
CouplingMatrix * _dof_coupling
Degree of freedom coupling.
Definition: dof_map.h:1434
libMesh::LinearImplicitSystem::_n_linear_iterations
unsigned int _n_linear_iterations
The number of linear iterations required to solve the linear system Ax=b.
Definition: linear_implicit_system.h:199
libMesh::System::_qoi_evaluate_object
QOI * _qoi_evaluate_object
Object to compute quantities of interest.
Definition: system.h:1914
libMesh::RBEvaluation::resize_data_structures
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.
Definition: rb_evaluation.C:108
libMesh::SCALAR
Definition: enum_fe_family.h:58
libMesh::FEGenericBase::get_phi
const std::vector< std::vector< OutputShape > > & get_phi() const
Definition: fe_base.h:206
libMesh::RBConstructionBase< LinearImplicitSystem >::get_local_n_training_samples
numeric_index_type get_local_n_training_samples() const
Get the total number of training samples local to this processor.
Definition: rb_construction_base.C:109
libMesh::TRI3SUBDIVISION
Definition: enum_elem_type.h:69
libMesh::RBEvaluation::get_rb_theta_expansion
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the rb_theta_expansion.
Definition: rb_evaluation.C:88
libMesh::H1
Definition: enum_norm_type.h:37
libMesh::RBEvaluation::basis_functions
std::vector< std::unique_ptr< NumericVector< Number > > > basis_functions
The libMesh vectors storing the finite element coefficients of the RB basis functions.
Definition: rb_evaluation.h:241
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121
libMesh::SparseMatrix::get_transpose
virtual void get_transpose(SparseMatrix< T > &dest) const =0
Copies the transpose of the matrix into dest, which may be *this.
libMesh::RBConstruction::assemble_inner_product_matrix
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.
Definition: rb_construction.C:841
libMesh::RBParametrized::is_value_in_list
static bool is_value_in_list(Real value, const std::vector< Real > &list_of_values, Real tol)
Helper function to check if the specified value is in the list of values (within a tolerance given by...
Definition: rb_parametrized.C:453
libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve
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)),...
Definition: implicit_system.C:412
libMesh::RBConstruction::compute_Fq_representor_innerprods
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.
Definition: rb_construction.C:1730
libMesh::System::user_constrain
virtual void user_constrain()
Calls user's attached constraint function, or is overridden by the user in derived classes.
Definition: system.C:1924
libMesh::ReferenceCounter::_enable_print_counter
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called.
Definition: reference_counter.h:141
libMesh::System::add_weighted_sensitivity_solution
NumericVector< Number > & add_weighted_sensitivity_solution()
Definition: system.C:924
libMesh::RBConstruction::assemble_all_output_vectors
virtual void assemble_all_output_vectors()
Assemble and store the output vectors.
Definition: rb_construction.C:988
libMesh::System::project_solution
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr) const
Projects arbitrary functions onto the current solution.
Definition: system_projection.C:950
libMesh::Tensor
NumberTensorValue Tensor
Definition: exact_solution.h:56
libMesh::RBConstruction::assemble_all_affine_operators
virtual void assemble_all_affine_operators()
Assemble and store all Q_a affine operators as well as the inner-product matrix.
Definition: rb_construction.C:930
libMesh::RBEvaluation::RB_Fq_vector
std::vector< DenseVector< Number > > RB_Fq_vector
Dense vector for the RHS.
Definition: rb_evaluation.h:265
fptr
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::System::Initialization::initialize
virtual void initialize()=0
Initialization function.
libMesh::System::add_weighted_sensitivity_adjoint_solution
NumericVector< Number > & add_weighted_sensitivity_adjoint_solution(unsigned int i=0)
Definition: system.C:977
libMesh::Parameters::get
const T & get(const std::string &) const
Definition: parameters.h:421
libMesh::RBConstruction::Fq_representor_innerprods_computed
bool Fq_representor_innerprods_computed
A boolean flag to indicate whether or not the Fq representor norms have already been computed — used ...
Definition: rb_construction.h:574
libMesh::RBConstruction::set_Nmax
virtual void set_Nmax(unsigned int Nmax)
Definition: rb_construction.C:1300
libMesh::out
OStreamProxy out
libMesh::NumericVector::subset_l1_norm
virtual Real subset_l1_norm(const std::set< numeric_index_type > &indices) const
Definition: numeric_vector.C:312
libMesh::LinearImplicitSystem::attach_shell_matrix
void attach_shell_matrix(ShellMatrix< Number > *shell_matrix)
This function enables the user to provide a shell matrix, i.e.
Definition: linear_implicit_system.C:158
libMesh::System::get_vector
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:774
libMesh::System::_variable_numbers
std::map< std::string, unsigned short int > _variable_numbers
The variable numbers corresponding to user-specified names, useful for name-based lookups.
Definition: system.h:1972
libMesh::RBParametrized::write_parameter_ranges_to_file
void write_parameter_ranges_to_file(const std::string &file_name, const bool write_binary)
Write out the parameter ranges to file.
Definition: rb_parametrized.C:222
libMesh::System::update
virtual void update()
Update the local values to reflect the solution on neighboring processors.
Definition: system.C:408
libMesh::SparseMatrix::zero
virtual void zero()=0
Set all entries to 0.
libMesh::System::add_sensitivity_rhs
NumericVector< Number > & add_sensitivity_rhs(unsigned int i=0)
Definition: system.C:1039
libMesh::FIRST
Definition: enum_order.h:42
libMesh::NumericVector::zero_clone
virtual std::unique_ptr< NumericVector< T > > zero_clone() const =0
libMesh::LinearImplicitSystem::linear_solver
std::unique_ptr< LinearSolver< Number > > linear_solver
The LinearSolver defines the interface used to solve the linear_implicit system.
Definition: linear_implicit_system.h:158
libMesh::NumericVector::type
ParallelType type() const
Definition: numeric_vector.h:160
libMesh::System::_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:2009
libMesh::RBConstructionBase< LinearImplicitSystem >::initialize_training_parameters
virtual void initialize_training_parameters(const RBParameters &mu_min, const RBParameters &mu_max, unsigned int n_training_parameters, std::map< std::string, bool > log_param_scale, bool deterministic=true)
Initialize the parameter ranges and indicate whether deterministic or random training parameters shou...
Definition: rb_construction_base.C:181
ElasticityRBConstruction::u_var
unsigned int u_var
Variable numbers.
Definition: rb_classes.h:122
libMesh::RBEvaluation::get_basis_function
NumericVector< Number > & get_basis_function(unsigned int i)
Get a reference to the i^th basis function.
Definition: rb_evaluation.C:202
libMesh::System::point_gradient
Gradient point_gradient(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:2100
libMesh::RBParametrized::is_discrete_parameter
bool is_discrete_parameter(const std::string &mu_name) const
Is parameter mu_name discrete?
Definition: rb_parametrized.C:373
libMesh::NumericVector::dot
virtual T dot(const NumericVector< T > &v) const =0
libMesh::Quality::name
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
libMesh::System::point_hessian
Tensor point_hessian(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:2244
libMesh::System::_sys_name
const std::string _sys_name
A name associated with this system.
Definition: system.h:1951
libMesh::System::const_vectors_iterator
std::map< std::string, NumericVector< Number > * >::const_iterator const_vectors_iterator
Definition: system.h:757
libMesh::System::adjoint_qoi_parameter_sensitivity
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:2366
libMesh::DofMap::variable_group
const VariableGroup & variable_group(const unsigned int c) const
Definition: dof_map.h:1884
libMesh::ExplicitSystem::assemble_qoi_derivative
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...
Definition: explicit_system.C:69
libMesh::DofMap::end_dof
dof_id_type end_dof(const processor_id_type proc) const
Definition: dof_map.h:692
libMesh::FEInterface::compute_data
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,...
Definition: fe_interface.C:1028
libMesh::RBParameters::get_value
Real get_value(const std::string &param_name) const
Get the value of the specific parameter.
Definition: rb_parameters.C:41
libMesh::RBConstruction::get_rb_assembly_expansion
RBAssemblyExpansion & get_rb_assembly_expansion()
Definition: rb_construction.C:371
libMesh::RBEvaluation::greedy_param_list
std::vector< RBParameters > greedy_param_list
The list of parameters selected by the Greedy algorithm in generating the Reduced Basis associated wi...
Definition: rb_evaluation.h:247
libMesh::System::_vector_is_adjoint
std::map< std::string, int > _vector_is_adjoint
Holds non-negative if a vector by that name should be projected using adjoint constraints/BCs,...
Definition: system.h:1997
libMesh::RBParametrized::get_parameter_min
Real get_parameter_min(const std::string &param_name) const
Get minimum allowable value of parameter param_name.
Definition: rb_parametrized.C:190
libMesh::RBConstruction::set_rb_construction_parameters
void set_rb_construction_parameters(unsigned int n_training_samples_in, bool deterministic_training_in, unsigned 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, RBParameters mu_min_in, RBParameters mu_max_in, std::map< std::string, std::vector< Real >> discrete_parameter_values_in, std::map< std::string, bool > log_scaling)
Set the state of this RBConstruction object based on the arguments to this function.
Definition: rb_construction.C:272
libMesh::EquationSystems::parameters
Parameters parameters
Data structure holding arbitrary parameters.
Definition: equation_systems.h:557
libMesh::RBConstruction::build_context
virtual std::unique_ptr< DGFEMContext > build_context()
Builds a DGFEMContext object with enough information to do evaluations on each element.
Definition: rb_construction.C:583