libMesh::RBEIMConstruction Class Referenceabstract

#include <rb_eim_construction.h>

Inheritance diagram for libMesh::RBEIMConstruction:

Public Types

enum  BEST_FIT_TYPE { PROJECTION_BEST_FIT, EIM_BEST_FIT }
 
typedef RBEIMConstruction sys_type
 
typedef RBConstruction Parent
 
typedef std::map< std::string,
SparseMatrix< Number >
* >::iterator 
matrices_iterator
 
typedef std::map< std::string,
SparseMatrix< Number >
* >::const_iterator 
const_matrices_iterator
 
typedef std::map< std::string,
NumericVector< Number >
* >::iterator 
vectors_iterator
 
typedef std::map< std::string,
NumericVector< Number >
* >::const_iterator 
const_vectors_iterator
 

Public Member Functions

 RBEIMConstruction (EquationSystems &es, const std::string &name, const unsigned int number)
 
virtual ~RBEIMConstruction ()
 
virtual void clear ()
 
virtual void process_parameters_file (const std::string &parameters_filename)
 
void set_best_fit_type_flag (const std::string &best_fit_type_string)
 
virtual void print_info ()
 
virtual void initialize_rb_construction ()
 
virtual Real train_reduced_basis (const std::string &directory_name="offline_data", const bool resize_rb_eval_data=true)
 
virtual Real truth_solve (int plot_solution)
 
virtual Real compute_best_fit_error ()
 
virtual void init_context (FEMContext &c)
 
Number evaluate_mesh_function (unsigned int var_number, Point p)
 
virtual void initialize_eim_assembly_objects ()
 
std::vector< ElemAssembly * > get_eim_assembly_objects ()
 
virtual AutoPtr< ElemAssemblybuild_eim_assembly (unsigned int bf_index)=0
 
void set_rb_evaluation (RBEvaluation &rb_eval_in)
 
RBEvaluationget_rb_evaluation ()
 
bool is_rb_eval_initialized () const
 
RBThetaExpansionget_rb_theta_expansion ()
 
void set_rb_assembly_expansion (RBAssemblyExpansion &rb_assembly_expansion_in)
 
RBAssemblyExpansionget_rb_assembly_expansion ()
 
sys_typesystem ()
 
virtual std::string system_type () const
 
virtual Real compute_max_error_bound ()
 
const RBParametersget_greedy_parameter (unsigned int i)
 
void set_training_tolerance (Real new_training_tolerance)
 
Real get_training_tolerance ()
 
unsigned int get_Nmax () const
 
virtual void set_Nmax (unsigned int Nmax)
 
void set_quiet_mode (bool quiet_mode_in)
 
bool is_quiet () const
 
virtual void load_basis_function (unsigned int i)
 
virtual void load_rb_solution ()
 
SparseMatrix< Number > * get_inner_product_matrix ()
 
SparseMatrix< Number > * get_non_dirichlet_inner_product_matrix ()
 
SparseMatrix< Number > * get_Aq (unsigned int q)
 
SparseMatrix< Number > * get_non_dirichlet_Aq (unsigned int q)
 
NumericVector< Number > * get_Fq (unsigned int q)
 
NumericVector< Number > * get_non_dirichlet_Fq (unsigned int q)
 
NumericVector< Number > * get_output_vector (unsigned int n, unsigned int q_l)
 
NumericVector< Number > * get_non_dirichlet_output_vector (unsigned int n, unsigned int q_l)
 
void assemble_inner_product_matrix (SparseMatrix< Number > *input_matrix, bool apply_dof_constraints=true)
 
void assemble_constraint_matrix (SparseMatrix< Number > *input_matrix)
 
void assemble_and_add_constraint_matrix (SparseMatrix< Number > *input_matrix)
 
void assemble_Aq_matrix (unsigned int q, SparseMatrix< Number > *input_matrix, bool apply_dof_constraints=true)
 
void assemble_Fq_vector (unsigned int q, NumericVector< Number > *input_vector, bool apply_dof_constraints=true)
 
void add_scaled_Aq (Number scalar, unsigned int q_a, SparseMatrix< Number > *input_matrix, bool symmetrize)
 
virtual void write_riesz_representors_to_files (const std::string &riesz_representors_dir, const bool write_binary_residual_representors)
 
virtual void read_riesz_representors_from_files (const std::string &riesz_representors_dir, const bool write_binary_residual_representors)
 
virtual void recompute_all_residual_terms (const bool compute_inner_products=true)
 
void set_rb_construction_parameters (unsigned int n_training_samples_in, bool deterministic_training_in, std::string deterministic_training_parameter_name_in, unsigned int deterministic_training_parameter_repeats_in, std::string alternative_solver_in, bool reuse_preconditioner_in, bool use_relative_bound_in_greedy_in, bool write_data_during_training_in, unsigned int training_parameters_random_seed_in, bool quiet_mode_in, unsigned int Nmax_in, Real training_tolerance_in, RBParameters mu_min_in, RBParameters mu_max_in, RBParameters initial_mu_in, std::map< std::string, bool > log_scaling)
 
void print_basis_function_orthogonality ()
 
unsigned int get_delta_N () const
 
void set_inner_product_assembly (ElemAssembly &inner_product_assembly_in)
 
ElemAssemblyget_inner_product_assembly ()
 
void set_constraint_assembly (ElemAssembly &constraint_assembly_in)
 
ElemAssemblyget_constraint_assembly ()
 
void zero_constrained_dofs_on_vector (NumericVector< Number > &vector)
 
numeric_index_type get_n_training_samples () const
 
numeric_index_type get_local_n_training_samples () const
 
numeric_index_type get_first_local_training_index () const
 
numeric_index_type get_last_local_training_index () const
 
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)
 
virtual void load_training_set (std::map< std::string, std::vector< Number > > &new_training_set)
 
std::pair< std::string,
std::string > 
set_alternative_solver (AutoPtr< LinearSolver< Number > > &ls)
 
void reset_alternative_solver (AutoPtr< LinearSolver< Number > > &ls, const std::pair< std::string, std::string > &orig)
 
void broadcast_parameters (unsigned int proc_id)
 
void set_training_random_seed (unsigned int seed)
 
void set_deterministic_training_parameter_name (const std::string name)
 
const std::string & get_deterministic_training_parameter_name () const
 
void set_deterministic_training_parameter_repeats (unsigned int repeats)
 
unsigned int get_deterministic_training_parameter_repeats () const
 
virtual void reinit ()
 
virtual void assemble ()
 
virtual void restrict_solve_to (const SystemSubset *subset, const SubsetSolveMode subset_solve_mode=SUBSET_ZERO)
 
virtual void solve ()
 
virtual LinearSolver< Number > * get_linear_solver () const
 
virtual void release_linear_solver (LinearSolver< Number > *) const
 
virtual void assembly (bool get_residual, bool get_jacobian)
 
unsigned int n_linear_iterations () const
 
Real final_linear_residual () const
 
void attach_shell_matrix (ShellMatrix< Number > *shell_matrix)
 
void detach_shell_matrix (void)
 
ShellMatrix< Number > * get_shell_matrix (void)
 
virtual void disable_cache ()
 
virtual std::pair< unsigned
int, Real
get_linear_solve_parameters () const
 
virtual void assemble_residual_derivatives (const ParameterVector &parameters)
 
virtual std::pair< unsigned
int, Real
sensitivity_solve (const ParameterVector &parameters)
 
virtual std::pair< unsigned
int, Real
weighted_sensitivity_solve (const ParameterVector &parameters, const ParameterVector &weights)
 
virtual std::pair< unsigned
int, Real
adjoint_solve (const QoISet &qoi_indices=QoISet())
 
virtual std::pair< unsigned
int, Real
weighted_sensitivity_adjoint_solve (const ParameterVector &parameters, const ParameterVector &weights, const QoISet &qoi_indices=QoISet())
 
virtual void adjoint_qoi_parameter_sensitivity (const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
 
virtual void forward_qoi_parameter_sensitivity (const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
 
virtual void qoi_parameter_hessian (const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &hessian)
 
virtual void qoi_parameter_hessian_vector_product (const QoISet &qoi_indices, const ParameterVector &parameters, const ParameterVector &vector, SensitivityData &product)
 
SparseMatrix< Number > & add_matrix (const std::string &mat_name)
 
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
 
virtual void assemble_qoi (const QoISet &qoi_indices=QoISet())
 
virtual void assemble_qoi_derivative (const QoISet &qoi_indices=QoISet())
 
void init ()
 
virtual void update ()
 
bool is_adjoint_already_solved () const
 
void set_adjoint_already_solved (bool setting)
 
virtual void qoi_parameter_sensitivity (const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
 
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=NULL) const
 
void project_solution (FEMFunctionBase< Number > *f, FEMFunctionBase< Gradient > *g=NULL) const
 
void project_solution (Number fptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), Gradient gptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), const Parameters &parameters) const
 
void project_vector (NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=NULL) const
 
void project_vector (NumericVector< Number > &new_vector, FEMFunctionBase< Number > *f, FEMFunctionBase< Gradient > *g=NULL) const
 
void project_vector (Number fptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), Gradient gptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), const Parameters &parameters, NumericVector< Number > &new_vector) const
 
void boundary_project_solution (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, FunctionBase< Number > *f, FunctionBase< Gradient > *g=NULL)
 
void boundary_project_solution (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, Number fptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), Gradient gptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), const Parameters &parameters)
 
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=NULL) const
 
void boundary_project_vector (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, Number fptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), Gradient gptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), const Parameters &parameters, NumericVector< Number > &new_vector) const
 
unsigned int number () const
 
void update_global_solution (std::vector< Number > &global_soln) const
 
void update_global_solution (std::vector< Number > &global_soln, const unsigned int dest_proc) const
 
const MeshBaseget_mesh () const
 
MeshBaseget_mesh ()
 
const DofMapget_dof_map () const
 
DofMapget_dof_map ()
 
const EquationSystemsget_equation_systems () const
 
EquationSystemsget_equation_systems ()
 
bool active () const
 
void activate ()
 
void deactivate ()
 
void set_basic_system_only ()
 
vectors_iterator vectors_begin ()
 
const_vectors_iterator vectors_begin () const
 
vectors_iterator vectors_end ()
 
const_vectors_iterator vectors_end () const
 
NumericVector< Number > & add_vector (const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
 
void remove_vector (const std::string &vec_name)
 
bool & project_solution_on_reinit (void)
 
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_preservation (const std::string &vec_name, bool preserve)
 
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=NULL)
 
unsigned int add_variable (const std::string &var, const Order order=FIRST, const FEFamily=LAGRANGE, const std::set< subdomain_id_type > *const active_subdomains=NULL)
 
unsigned int add_variables (const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=NULL)
 
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=NULL)
 
const Variablevariable (unsigned int var) const
 
const VariableGroupvariable_group (unsigned int vg) const
 
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
 
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 FETypevariable_type (const unsigned int i) const
 
const FETypevariable_type (const std::string &var) const
 
bool identify_variable_groups () const
 
void identify_variable_groups (const bool)
 
Real calculate_norm (const NumericVector< Number > &v, unsigned int var=0, FEMNormType norm_type=L2) const
 
Real calculate_norm (const NumericVector< Number > &v, const SystemNorm &norm) 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)
 
void read_legacy_data (Xdr &io, const bool read_additional_data=true)
 
template<typename ValType >
void read_serialized_data (Xdr &io, const bool read_additional_data=true)
 
void read_serialized_data (Xdr &io, const bool read_additional_data=true)
 
template<typename InValType >
std::size_t read_serialized_vectors (Xdr &io, const std::vector< NumericVector< Number > * > &vectors) const
 
std::size_t read_serialized_vectors (Xdr &io, const std::vector< NumericVector< Number > * > &vectors) const
 
template<typename InValType >
void read_parallel_data (Xdr &io, const bool read_additional_data)
 
void read_parallel_data (Xdr &io, const bool read_additional_data)
 
void write_header (Xdr &io, const std::string &version, const bool write_additional_data) const
 
void write_serialized_data (Xdr &io, const bool write_additional_data=true) const
 
dof_id_type write_serialized_vectors (Xdr &io, const std::vector< const NumericVector< Number > * > &vectors) const
 
void write_parallel_data (Xdr &io, const bool write_additional_data) const
 
std::string get_info () const
 
void attach_init_function (void fptr(EquationSystems &es, const std::string &name))
 
void attach_init_object (Initialization &init)
 
void attach_assemble_function (void fptr(EquationSystems &es, const std::string &name))
 
void attach_assemble_object (Assembly &assemble)
 
void attach_constraint_function (void fptr(EquationSystems &es, const std::string &name))
 
void attach_constraint_object (Constraint &constrain)
 
void attach_QOI_function (void fptr(EquationSystems &es, const std::string &name, const QoISet &qoi_indices))
 
void attach_QOI_object (QOI &qoi)
 
void attach_QOI_derivative (void fptr(EquationSystems &es, const std::string &name, const QoISet &qoi_indices))
 
void attach_QOI_derivative_object (QOIDerivative &qoi_derivative)
 
virtual void user_initialization ()
 
virtual void user_assembly ()
 
virtual void user_constrain ()
 
virtual void user_QOI (const QoISet &qoi_indices)
 
virtual void user_QOI_derivative (const QoISet &qoi_indices)
 
virtual void re_update ()
 
virtual void restrict_vectors ()
 
virtual void prolong_vectors ()
 
Number current_solution (const dof_id_type global_dof_number) const
 
Number point_value (unsigned int var, const Point &p, const bool insist_on_success=true) const
 
Number point_value (unsigned int var, const Point &p, const Elem &e) const
 
Gradient point_gradient (unsigned int var, const Point &p, const bool insist_on_success=true) const
 
Gradient point_gradient (unsigned int var, const Point &p, const Elem &e) const
 
Tensor point_hessian (unsigned int var, const Point &p, const bool insist_on_success=true) const
 
Tensor point_hessian (unsigned int var, const Point &p, const Elem &e) const
 
void local_dof_indices (const unsigned int var, std::set< dof_id_type > &var_indices) const
 
void zero_variable (NumericVector< Number > &v, unsigned int var_num) const
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 
void initialize_parameters (const RBParameters &mu_min_in, const RBParameters &mu_max_in, const RBParameters &mu_in)
 
void initialize_parameters (const RBParametrized &rb_parametrized)
 
unsigned int get_n_params () const
 
const RBParametersget_parameters () const
 
void set_parameters (const RBParameters &params)
 
const RBParametersget_parameters_min () const
 
const RBParametersget_parameters_max () const
 
Real get_parameter_min (const std::string &param_name) const
 
Real get_parameter_max (const std::string &param_name) const
 
void print_parameters () const
 
void write_parameter_ranges_to_file (const std::string &file_name, const bool write_binary)
 
void read_parameter_ranges_from_file (const std::string &file_name, const bool read_binary)
 

Static Public Member Functions

static void print_info (std::ostream &out=libMesh::out)
 
static void print_info (std::ostream &out=libMesh::out)
 
static AutoPtr< DirichletBoundarybuild_zero_dirichlet_boundary_object ()
 
static std::string get_info ()
 
static std::string get_info ()
 
static unsigned int n_objects ()
 
static unsigned int n_objects ()
 
static void enable_print_counter_info ()
 
static void enable_print_counter_info ()
 
static void disable_print_counter_info ()
 
static void disable_print_counter_info ()
 

Public Attributes

BEST_FIT_TYPE best_fit_type_flag
 
CouplingMatrix _coupling_matrix
 
std::vector< Realtraining_error_bounds
 
AutoPtr< SparseMatrix< Number > > inner_product_matrix
 
AutoPtr< SparseMatrix< Number > > non_dirichlet_inner_product_matrix
 
AutoPtr< SparseMatrix< Number > > constraint_matrix
 
std::vector< Numbertruth_outputs
 
std::vector< std::vector
< Number > > 
output_dual_innerprods
 
std::vector< NumericVector
< Number > * > 
Fq_representor
 
std::vector< NumberFq_representor_innerprods
 
bool constrained_problem
 
bool reuse_preconditioner
 
bool use_relative_bound_in_greedy
 
bool exit_on_repeated_greedy_parameters
 
bool write_data_during_training
 
bool impose_internal_dirichlet_BCs
 
bool impose_internal_fluxes
 
bool compute_RB_inner_product
 
bool store_non_dirichlet_operators
 
bool enforce_constraints_exactly
 
bool use_empty_rb_solve_in_greedy
 
AutoPtr< LinearSolver< Number > > linear_solver
 
SparseMatrix< Number > * matrix
 
NumericVector< Number > * rhs
 
bool assemble_before_solve
 
bool use_fixed_solution
 
int extra_quadrature_order
 
AutoPtr< NumericVector< Number > > solution
 
AutoPtr< NumericVector< Number > > current_local_solution
 
Real time
 
std::vector< Numberqoi
 
bool verbose_mode
 

Protected Types

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

Protected Member Functions

virtual void init_data ()
 
virtual void enrich_RB_space ()
 
virtual void update_system ()
 
virtual void update_RB_system_matrices ()
 
virtual Real get_RB_error_bound ()
 
virtual bool greedy_termination_test (Real training_greedy_error, int count)
 
void initialize_parametrized_functions_in_training_set ()
 
virtual void allocate_data_structures ()
 
virtual void assemble_affine_expansion ()
 
virtual void truth_assembly ()
 
virtual AutoPtr< DGFEMContextbuild_context ()
 
virtual void assemble_matrix_for_output_dual_solves ()
 
void update_greedy_param_list ()
 
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)
 
virtual void set_context_solution_vec (NumericVector< Number > &vec)
 
void assemble_scaled_matvec (Number scalar, ElemAssembly *elem_assembly, NumericVector< Number > &dest, NumericVector< Number > &arg)
 
virtual void assemble_misc_matrices ()
 
virtual void assemble_all_affine_operators ()
 
virtual void assemble_all_affine_vectors ()
 
virtual void assemble_all_output_vectors ()
 
virtual void compute_output_dual_innerprods ()
 
virtual void compute_Fq_representor_innerprods (bool compute_inner_products=true)
 
virtual void update_residual_terms (bool compute_inner_products=true)
 
RBParameters get_params_from_training_set (unsigned int index)
 
void set_params_from_training_set (unsigned int index)
 
virtual void set_params_from_training_set_and_broadcast (unsigned int index)
 
virtual void init_matrices ()
 
void project_vector (NumericVector< Number > &) const
 
void project_vector (const NumericVector< Number > &, NumericVector< Number > &) const
 
void increment_constructor_count (const std::string &name)
 
void increment_constructor_count (const std::string &name)
 
void increment_destructor_count (const std::string &name)
 
void increment_destructor_count (const std::string &name)
 

Static Protected Member Functions

static void get_global_max_error_pair (const Parallel::Communicator &communicator, std::pair< unsigned int, Real > &error_pair)
 
static void generate_training_parameters_random (const Parallel::Communicator &communicator, std::map< std::string, bool > log_param_scale, std::map< std::string, 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 void generate_training_parameters_partially_random (const Parallel::Communicator &communicator, const std::string &deterministic_parameter_name, const unsigned int deterministic_parameter_repeats, std::map< std::string, bool > log_param_scale, std::map< std::string, NumericVector< Number > * > &training_parameters_in, unsigned int n_deterministic_training_samples_in, const RBParameters &min_parameters, const RBParameters &max_parameters, int training_parameters_random_seed=-1, bool serial_training_set=false)
 
static void generate_training_parameters_deterministic (const Parallel::Communicator &communicator, std::map< std::string, bool > log_param_scale, std::map< std::string, NumericVector< Number > * > &training_parameters_in, unsigned int n_training_samples_in, const RBParameters &min_parameters, const RBParameters &max_parameters, bool serial_training_set=false)
 

Protected Attributes

bool _parametrized_functions_in_training_set_initialized
 
std::vector< NumericVector
< Number > * > 
_parametrized_functions_in_training_set
 
unsigned int Nmax
 
unsigned int delta_N
 
bool quiet_mode
 
bool output_dual_innerprods_computed
 
bool Fq_representor_innerprods_computed
 
bool serial_training_set
 
AutoPtr< NumericVector< Number > > inner_product_storage_vector
 
std::string alternative_solver
 
unsigned int _n_linear_iterations
 
Real _final_linear_residual
 
ShellMatrix< Number > * _shell_matrix
 
const SystemSubset_subset
 
SubsetSolveMode _subset_solve_mode
 
const Parallel::Communicator_communicator
 

Static Protected Attributes

static Counts _counts
 
static Counts _counts
 
static Threads::atomic
< unsigned int > 
_n_objects
 
static Threads::atomic
< unsigned int > 
_n_objects
 
static Threads::spin_mutex _mutex
 
static Threads::spin_mutex _mutex
 
static bool _enable_print_counter = true
 
static bool _enable_print_counter = true
 

Private Attributes

MeshFunction_mesh_function
 
bool _performing_extra_greedy_step
 
AutoPtr< NumericVector< Number > > _ghosted_meshfunction_vector
 
RBAssemblyExpansion _empty_rb_assembly_expansion
 
std::vector< ElemAssembly * > _rb_eim_assembly_objects
 

Detailed Description

This class is part of the rbOOmit framework.

RBEIMConstruction implements the Construction stage of the Empirical Interpolation Method (EIM). This can be used to generate an affine approximation to non-affine operators.

Author
David J. Knezevic, 2010

Definition at line 51 of file rb_eim_construction.h.

Member Typedef Documentation

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

Definition at line 277 of file implicit_system.h.

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

Definition at line 718 of file system.h.

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

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

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

Matrix iterator typedefs.

Definition at line 276 of file implicit_system.h.

The type of the parent.

Definition at line 78 of file rb_eim_construction.h.

The type of system.

Definition at line 73 of file rb_eim_construction.h.

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

Vector iterator typedefs.

Definition at line 717 of file system.h.

Member Enumeration Documentation

Enumerator
PROJECTION_BEST_FIT 
EIM_BEST_FIT 

Definition at line 55 of file rb_eim_construction.h.

Constructor & Destructor Documentation

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

Constructor. Optionally initializes required data structures.

virtual libMesh::RBEIMConstruction::~RBEIMConstruction ( )
virtual

Destructor.

Member Function Documentation

void libMesh::System::activate ( )
inlineinherited

Activates the system. Only active systems are solved.

Definition at line 1927 of file system.h.

References libMesh::System::_active.

1928 {
1929  _active = true;
1930 }
bool libMesh::System::active ( ) const
inlineinherited
Returns
true if the system is active, false otherwise. An active system will be solved.

Definition at line 1919 of file system.h.

References libMesh::System::_active.

1920 {
1921  return _active;
1922 }
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 1017 of file system.C.

References libMesh::System::add_vector().

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

1018 {
1019  std::ostringstream adjoint_rhs_name;
1020  adjoint_rhs_name << "adjoint_rhs" << i;
1021 
1022  return this->add_vector(adjoint_rhs_name.str(), false);
1023 }
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 957 of file system.C.

References libMesh::System::add_vector().

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

958 {
959  std::ostringstream adjoint_name;
960  adjoint_name << "adjoint_solution" << i;
961 
962  return this->add_vector(adjoint_name.str());
963 }
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.

Definition at line 207 of file implicit_system.C.

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

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

208 {
209  // only add matrices before initializing...
210  if (!_can_add_matrices)
211  {
212  libMesh::err << "ERROR: Too late. Cannot add matrices to the system after initialization"
213  << std::endl
214  << " any more. You should have done this earlier."
215  << std::endl;
216  libmesh_error();
217  }
218 
219  // Return the matrix if it is already there.
220  if (this->have_matrix(mat_name))
221  return *(_matrices[mat_name]);
222 
223  // Otherwise build the matrix and return it.
224  SparseMatrix<Number>* buf = SparseMatrix<Number>::build(this->comm()).release();
225  _matrices.insert (std::make_pair (mat_name, buf));
226 
227  return *buf;
228 }
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.

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)

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

References libMesh::System::add_vector().

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

1048 {
1049  std::ostringstream sensitivity_rhs_name;
1050  sensitivity_rhs_name << "sensitivity_rhs" << i;
1051 
1052  return this->add_vector(sensitivity_rhs_name.str(), false);
1053 }
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 906 of file system.C.

References libMesh::System::add_vector().

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

907 {
908  std::ostringstream sensitivity_name;
909  sensitivity_name << "sensitivity_solution" << i;
910 
911  return this->add_vector(sensitivity_name.str());
912 }
unsigned int libMesh::System::add_variable ( const std::string &  var,
const FEType type,
const std::set< subdomain_id_type > *const  active_subdomains = NULL 
)
inherited

Adds the variable var to the list of variables for this system. Returns the index number for the new variable.

Definition at line 1077 of file system.C.

References libMesh::System::_variable_groups, libMesh::System::_variable_numbers, libMesh::System::_variables, libMesh::System::add_variables(), libMesh::err, libMesh::System::identify_variable_groups(), libMesh::System::n_variable_groups(), libMesh::System::n_vars(), libMesh::System::number(), libMesh::System::variable_name(), and libMesh::System::variable_type().

Referenced by libMesh::System::add_variable(), libMesh::ErrorVector::plot_error(), and libMesh::System::read_header().

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

Definition at line 1156 of file system.C.

References libMesh::System::add_variable().

1160 {
1161  return this->add_variable(var,
1162  FEType(order, family),
1163  active_subdomains);
1164 }
unsigned int libMesh::System::add_variables ( const std::vector< std::string > &  vars,
const FEType type,
const std::set< subdomain_id_type > *const  active_subdomains = NULL 
)
inherited

Adds the variable var to the list of variables for this system. Returns the index number for the new variable.

Definition at line 1168 of file system.C.

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

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

1171 {
1172  // Make sure the variable isn't there already
1173  // or if it is, that it's the type we want
1174  for (unsigned int ov=0; ov<vars.size(); ov++)
1175  for (unsigned int v=0; v<this->n_vars(); v++)
1176  if (this->variable_name(v) == vars[ov])
1177  {
1178  if (this->variable_type(v) == type)
1179  return _variables[v].number();
1180 
1181  libMesh::err << "ERROR: incompatible variable "
1182  << vars[ov]
1183  << " has already been added for this system!"
1184  << std::endl;
1185  libmesh_error();
1186  }
1187 
1188  const unsigned int curr_n_vars = this->n_vars();
1189 
1190  const unsigned int next_first_component = this->n_components();
1191 
1192  // Add the variable group to the list
1193  _variable_groups.push_back((active_subdomains == NULL) ?
1194  VariableGroup(this, vars, curr_n_vars,
1195  next_first_component, type) :
1196  VariableGroup(this, vars, curr_n_vars,
1197  next_first_component, type, *active_subdomains));
1198 
1199  const VariableGroup &vg (_variable_groups.back());
1200 
1201  // Add each component of the group individually
1202  for (unsigned int v=0; v<vars.size(); v++)
1203  {
1204  _variables.push_back (vg(v));
1205  _variable_numbers[vars[v]] = curr_n_vars+v;
1206  }
1207 
1208  libmesh_assert_equal_to ((curr_n_vars+vars.size()), this->n_vars());
1209 
1210  // BSK - Defer this now to System::init_data() so we can detect
1211  // VariableGroups 12/28/2012
1212  // // Add the variable group to the _dof_map
1213  // _dof_map->add_variable_group (vg);
1214 
1215  // Return the number of the new variable
1216  return curr_n_vars+vars.size()-1;
1217 }
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 = NULL 
)
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.

Definition at line 1221 of file system.C.

References libMesh::System::add_variables().

1225 {
1226  return this->add_variables(vars,
1227  FEType(order, family),
1228  active_subdomains);
1229 }
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 inititialized 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 676 of file system.C.

References libMesh::System::_can_add_vectors, libMesh::System::_dof_map, libMesh::System::_vector_projections, libMesh::System::_vector_types, libMesh::System::_vectors, libMesh::NumericVector< T >::build(), libMesh::ParallelObject::comm(), libMesh::err, libMeshEnums::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::UnsteadySolver::init(), libMesh::ContinuationSystem::init_data(), libMesh::NewmarkSystem::NewmarkSystem(), libMesh::System::read_header(), libMesh::FrequencySystem::set_frequencies(), libMesh::FrequencySystem::set_frequencies_by_range(), and libMesh::FrequencySystem::set_frequencies_by_steps().

679 {
680  // Return the vector if it is already there.
681  if (this->have_vector(vec_name))
682  return *(_vectors[vec_name]);
683 
684  // Otherwise build the vector
685  NumericVector<Number>* buf = NumericVector<Number>::build(this->comm()).release();
686  _vectors.insert (std::make_pair (vec_name, buf));
687  _vector_projections.insert (std::make_pair (vec_name, projections));
688 
689  _vector_types.insert (std::make_pair (vec_name, type));
690 
691  // Initialize it if necessary
692  if (!_can_add_vectors)
693  {
694  if(type == GHOSTED)
695  {
696 #ifdef LIBMESH_ENABLE_GHOSTED
697  buf->init (this->n_dofs(), this->n_local_dofs(),
698  _dof_map->get_send_list(), false,
699  GHOSTED);
700 #else
701  libMesh::err << "Cannot initialize ghosted vectors when they are not enabled." << std::endl;
702  libmesh_error();
703 #endif
704  }
705  else
706  buf->init (this->n_dofs(), this->n_local_dofs(), false, type);
707  }
708 
709  return *buf;
710 }
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 987 of file system.C.

References libMesh::System::add_vector().

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

988 {
989  std::ostringstream adjoint_name;
990  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
991 
992  return this->add_vector(adjoint_name.str());
993 }
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 936 of file system.C.

References libMesh::System::add_vector().

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

937 {
938  return this->add_vector("weighted_sensitivity_solution");
939 }
void libMesh::ImplicitSystem::adjoint_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].

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

References libMesh::SensitivityData::allocate_data(), libMesh::AutoPtr< Tp >::get(), libMesh::QoISet::has_index(), libMesh::Real, libMesh::ParameterVector::size(), and libMesh::TOLERANCE.

704 {
705  const unsigned int Np = libmesh_cast_int<unsigned int>
706  (parameters.size());
707  const unsigned int Nq = libmesh_cast_int<unsigned int>
708  (qoi.size());
709 
710  // We currently get partial derivatives via central differencing
711  const Real delta_p = TOLERANCE;
712 
713  // An introduction to the problem:
714  //
715  // Residual R(u(p),p) = 0
716  // partial R / partial u = J = system matrix
717  //
718  // This implies that:
719  // d/dp(R) = 0
720  // (partial R / partial p) +
721  // (partial R / partial u) * (partial u / partial p) = 0
722 
723  // We first do an adjoint solve:
724  // J^T * z = (partial q / partial u)
725  // if we havent already or dont have an initial condition for the adjoint
726  if (!this->is_adjoint_already_solved())
727  {
728  this->adjoint_solve(qoi_indices);
729  }
730 
731  // Get ready to fill in senstivities:
732  sensitivities.allocate_data(qoi_indices, *this, parameters);
733 
734  // We use the identities:
735  // dq/dp = (partial q / partial p) + (partial q / partial u) *
736  // (partial u / partial p)
737  // dq/dp = (partial q / partial p) + (J^T * z) *
738  // (partial u / partial p)
739  // dq/dp = (partial q / partial p) + z * J *
740  // (partial u / partial p)
741 
742  // Leading to our final formula:
743  // dq/dp = (partial q / partial p) - z * (partial R / partial p)
744 
745  // In the case of adjoints with heterogenous Dirichlet boundary
746  // function phi, where
747  // q := R(u,phi) + S(u)
748  // the final formula works out to:
749  // dq/dp = (partial S / partial p) - z * (partial R / partial p)
750  // Because we currently have no direct access to
751  // (partial S / partial p), we use the identity
752  // (partial S / partial p) = (partial q / partial p) -
753  // phi * (partial R / partial p)
754  // to derive an equivalent equation:
755  // dq/dp = (partial q / partial p) - (z+phi) * (partial R / partial p)
756 
757  for (unsigned int j=0; j != Np; ++j)
758  {
759  // (partial q / partial p) ~= (q(p+dp)-q(p-dp))/(2*dp)
760  // (partial R / partial p) ~= (rhs(p+dp) - rhs(p-dp))/(2*dp)
761 
762  Number old_parameter = *parameters[j];
763  // Number old_qoi = this->qoi;
764 
765  *parameters[j] = old_parameter - delta_p;
766  this->assemble_qoi(qoi_indices);
767  std::vector<Number> qoi_minus = this->qoi;
768 
769  this->assembly(true, false);
770  this->rhs->close();
771 
772  // FIXME - this can and should be optimized to avoid the clone()
773  AutoPtr<NumericVector<Number> > partialR_partialp = this->rhs->clone();
774  *partialR_partialp *= -1;
775 
776  *parameters[j] = old_parameter + delta_p;
777  this->assemble_qoi(qoi_indices);
778  std::vector<Number>& qoi_plus = this->qoi;
779 
780  std::vector<Number> partialq_partialp(Nq, 0);
781  for (unsigned int i=0; i != Nq; ++i)
782  if (qoi_indices.has_index(i))
783  partialq_partialp[i] = (qoi_plus[i] - qoi_minus[i]) / (2.*delta_p);
784 
785  this->assembly(true, false);
786  this->rhs->close();
787  *partialR_partialp += *this->rhs;
788  *partialR_partialp /= (2.*delta_p);
789 
790  // Don't leave the parameter changed
791  *parameters[j] = old_parameter;
792 
793  for (unsigned int i=0; i != Nq; ++i)
794  if (qoi_indices.has_index(i))
795  {
796 
798  {
799  AutoPtr<NumericVector<Number> > lift_func =
800  this->get_adjoint_solution(i).zero_clone();
802  (*this, lift_func.get(),
803  /* homogeneous = */ false);
804  sensitivities[i][j] = partialq_partialp[i] -
805  partialR_partialp->dot(*lift_func) -
806  partialR_partialp->dot(this->get_adjoint_solution(i));
807  }
808  else
809  sensitivities[i][j] = partialq_partialp[i] -
810  partialR_partialp->dot(this->get_adjoint_solution(i));
811  }
812  }
813 
814  // All parameters have been reset.
815  // We didn't cache the original rhs or matrix for memory reasons,
816  // but we can restore them to a state consistent solution -
817  // principle of least surprise.
818  this->assembly(true, true);
819  this->rhs->close();
820  this->matrix->close();
821  this->assemble_qoi(qoi_indices);
822 }
std::pair< unsigned int, Real > libMesh::ImplicitSystem::adjoint_solve ( const QoISet qoi_indices = QoISet())
virtualinherited

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

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

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

383 {
384  // Log how long the linear solve takes.
385  START_LOG("adjoint_solve()", "ImplicitSystem");
386 
387  if (this->assemble_before_solve)
388  // Assemble the linear system
389  this->assembly (/* get_residual = */ false,
390  /* get_jacobian = */ true);
391 
392  // The adjoint problem is linear
393  LinearSolver<Number> *linear_solver = this->get_linear_solver();
394 
395  // Reset and build the RHS from the QOI derivative
396  this->assemble_qoi_derivative(qoi_indices);
397 
398  // Our iteration counts and residuals will be sums of the individual
399  // results
400  std::pair<unsigned int, Real> solver_params =
402  std::pair<unsigned int, Real> totalrval = std::make_pair(0,0.0);
403 
404  for (unsigned int i=0; i != this->qoi.size(); ++i)
405  if (qoi_indices.has_index(i))
406  {
407  const std::pair<unsigned int, Real> rval =
408  linear_solver->adjoint_solve (*matrix, this->add_adjoint_solution(i),
409  this->get_adjoint_rhs(i),
410  solver_params.second,
411  solver_params.first);
412 
413  totalrval.first += rval.first;
414  totalrval.second += rval.second;
415  }
416 
417  this->release_linear_solver(linear_solver);
418 
419  // The linear solver may not have fit our constraints exactly
420 #ifdef LIBMESH_ENABLE_CONSTRAINTS
421  for (unsigned int i=0; i != this->qoi.size(); ++i)
422  if (qoi_indices.has_index(i))
424  (this->get_adjoint_solution(i), i);
425 #endif
426 
427  // Stop logging the nonlinear solve
428  STOP_LOG("adjoint_solve()", "ImplicitSystem");
429 
430  return totalrval;
431 }
virtual void libMesh::RBConstruction::allocate_data_structures ( )
protectedvirtualinherited

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

Reimplemented in libMesh::TransientRBConstruction.

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

Prepares matrix and _dof_map for matrix assembly. Does not actually assemble anything. For matrix assembly, use the assemble() in derived classes. Should be overloaded in derived classes.

Reimplemented from libMesh::ImplicitSystem.

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

Definition at line 104 of file linear_implicit_system.h.

References libMesh::ImplicitSystem::assemble().

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

virtual void libMesh::RBConstruction::assemble_affine_expansion ( )
protectedvirtualinherited

Assemble and store the Dirichlet dof lists, the affine and output vectors. Optionally assemble and store all the affine matrices if we are not in low-memory mode.

Reimplemented in libMesh::TransientRBConstruction.

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

virtual void libMesh::RBConstruction::assemble_all_affine_vectors ( )
protectedvirtualinherited

Assemble and store the affine RHS vectors.

virtual void libMesh::RBConstruction::assemble_all_output_vectors ( )
protectedvirtualinherited

Assemble and store the output vectors.

void libMesh::RBConstruction::assemble_and_add_constraint_matrix ( SparseMatrix< Number > *  input_matrix)
inherited

Assemble the constraint matrix and add it to input_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.

void libMesh::RBConstruction::assemble_constraint_matrix ( SparseMatrix< Number > *  input_matrix)
inherited

Assemble the constraint matrix and store it in input_matrix.

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.

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.

virtual void libMesh::RBConstruction::assemble_matrix_for_output_dual_solves ( )
protectedvirtualinherited

Define the matrix assembly for the output residual dual norm solves. By default we use the inner product matrix for steady state problems.

Reimplemented in libMesh::TransientRBConstruction.

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

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

Prepares qoi for quantity of interest assembly, then calls user qoi function. Can be overloaded in derived classes.

Reimplemented from libMesh::System.

Reimplemented in libMesh::FEMSystem.

Definition at line 89 of file explicit_system.C.

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

90 {
91  // The user quantity of interest assembly gets to expect to
92  // accumulate on initially zero values
93  for (unsigned int i=0; i != qoi.size(); ++i)
94  if (qoi_indices.has_index(i))
95  qoi[i] = 0;
96 
97  Parent::assemble_qoi (qoi_indices);
98 }
void libMesh::ExplicitSystem::assemble_qoi_derivative ( const QoISet qoi_indices = QoISet())
virtualinherited

Prepares adjoint_rhs for quantity of interest derivative assembly, then calls user qoi derivative function. Can be overloaded in derived classes.

Reimplemented from libMesh::System.

Reimplemented in libMesh::FEMSystem.

Definition at line 102 of file explicit_system.C.

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

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

103 {
104  // The user quantity of interest derivative assembly gets to expect
105  // to accumulate on initially zero vectors
106  for (unsigned int i=0; i != qoi.size(); ++i)
107  if (qoi_indices.has_index(i))
108  this->add_adjoint_rhs(i).zero();
109 
110  Parent::assemble_qoi_derivative (qoi_indices);
111 }
void libMesh::ImplicitSystem::assemble_residual_derivatives ( const ParameterVector parameters)
virtualinherited

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 overloaded in derived classes.

Reimplemented from libMesh::System.

Definition at line 665 of file implicit_system.C.

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

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

666 {
667  const unsigned int Np = libmesh_cast_int<unsigned int>
668  (parameters.size());
669  Real deltap = TOLERANCE;
670 
671  for (unsigned int p=0; p != Np; ++p)
672  {
673  NumericVector<Number> &sensitivity_rhs = this->add_sensitivity_rhs(p);
674 
675  // Approximate -(partial R / partial p) by
676  // (R(p-dp) - R(p+dp)) / (2*dp)
677 
678  Number old_parameter = *parameters[p];
679  *parameters[p] -= deltap;
680 
681  this->assembly(true, false);
682  this->rhs->close();
683  sensitivity_rhs = *this->rhs;
684 
685  *parameters[p] = old_parameter + deltap;
686 
687  this->assembly(true, false);
688  this->rhs->close();
689 
690  sensitivity_rhs -= *this->rhs;
691  sensitivity_rhs /= (2*deltap);
692  sensitivity_rhs.close();
693 
694  *parameters[p] = old_parameter;
695  }
696 }
void libMesh::RBConstruction::assemble_scaled_matvec ( Number  scalar,
ElemAssembly elem_assembly,
NumericVector< Number > &  dest,
NumericVector< Number > &  arg 
)
protectedinherited

This function loops over the mesh and assembles the matrix-vector product and stores the scaled result in dest.

void libMesh::LinearImplicitSystem::assembly ( bool  get_residual,
bool  get_jacobian 
)
virtualinherited

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

Reimplemented from libMesh::ImplicitSystem.

Definition at line 373 of file linear_implicit_system.C.

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

375 {
376  // Residual R(u(p),p) := A(p)*u(p) - b(p)
377  // partial R / partial u = A
378 
379  this->assemble();
380  this->rhs->close();
381  this->matrix->close();
382 
383  *(this->rhs) *= -1.0;
384  this->rhs->add_vector(*this->solution, *this->matrix);
385 }
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 1754 of file system.C.

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

1756 {
1757  libmesh_assert(fptr);
1758 
1759  if (_assemble_system_object != NULL)
1760  {
1761  libmesh_here();
1762  libMesh::out << "WARNING: Cannot specify both assembly function and object!"
1763  << std::endl;
1764 
1765  _assemble_system_object = NULL;
1766  }
1767 
1769 }
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 1773 of file system.C.

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

1774 {
1775  if (_assemble_system_function != NULL)
1776  {
1777  libmesh_here();
1778  libMesh::out << "WARNING: Cannot specify both assembly object and function!"
1779  << std::endl;
1780 
1782  }
1783 
1784  _assemble_system_object = &assemble_in;
1785 }
void libMesh::System::attach_constraint_function ( void   fptrEquationSystems &es,const std::string &name)
inherited

Register a user function for imposing constraints.

Definition at line 1789 of file system.C.

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

1791 {
1792  libmesh_assert(fptr);
1793 
1794  if (_constrain_system_object != NULL)
1795  {
1796  libmesh_here();
1797  libMesh::out << "WARNING: Cannot specify both constraint function and object!"
1798  << std::endl;
1799 
1800  _constrain_system_object = NULL;
1801  }
1802 
1804 }
void libMesh::System::attach_constraint_object ( System::Constraint constrain)
inherited

Register a user object for imposing constraints.

Definition at line 1808 of file system.C.

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

1809 {
1810  if (_constrain_system_function != NULL)
1811  {
1812  libmesh_here();
1813  libMesh::out << "WARNING: Cannot specify both constraint object and function!"
1814  << std::endl;
1815 
1817  }
1818 
1819  _constrain_system_object = &constrain;
1820 }
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 1719 of file system.C.

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

1721 {
1722  libmesh_assert(fptr);
1723 
1724  if (_init_system_object != NULL)
1725  {
1726  libmesh_here();
1727  libMesh::out << "WARNING: Cannot specify both initialization function and object!"
1728  << std::endl;
1729 
1730  _init_system_object = NULL;
1731  }
1732 
1733  _init_system_function = fptr;
1734 }
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 1738 of file system.C.

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

1739 {
1740  if (_init_system_function != NULL)
1741  {
1742  libmesh_here();
1743  libMesh::out << "WARNING: Cannot specify both initialization object and function!"
1744  << std::endl;
1745 
1746  _init_system_function = NULL;
1747  }
1748 
1749  _init_system_object = &init_in;
1750 }
void libMesh::System::attach_QOI_derivative ( void   fptrEquationSystems &es,const std::string &name,const QoISet &qoi_indices)
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 1860 of file system.C.

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

1863 {
1864  libmesh_assert(fptr);
1865 
1866  if (_qoi_evaluate_derivative_object != NULL)
1867  {
1868  libmesh_here();
1869  libMesh::out << "WARNING: Cannot specify both QOI derivative function and object!"
1870  << std::endl;
1871 
1873  }
1874 
1876 }
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.

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

1881 {
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 }
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 1824 of file system.C.

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

1827 {
1828  libmesh_assert(fptr);
1829 
1830  if (_qoi_evaluate_object != NULL)
1831  {
1832  libmesh_here();
1833  libMesh::out << "WARNING: Cannot specify both QOI function and object!"
1834  << std::endl;
1835 
1836  _qoi_evaluate_object = NULL;
1837  }
1838 
1839  _qoi_evaluate_function = fptr;
1840 }
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 1844 of file system.C.

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

1845 {
1846  if (_qoi_evaluate_function != NULL)
1847  {
1848  libmesh_here();
1849  libMesh::out << "WARNING: Cannot specify both QOI object and function!"
1850  << std::endl;
1851 
1852  _qoi_evaluate_function = NULL;
1853  }
1854 
1855  _qoi_evaluate_object = &qoi_in;
1856 }
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 NULL pointer to this function.

Definition at line 165 of file linear_implicit_system.C.

References libMesh::LinearImplicitSystem::_shell_matrix.

Referenced by libMesh::LinearImplicitSystem::detach_shell_matrix().

166 {
167  _shell_matrix = shell_matrix;
168 }
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 = NULL 
)
inherited

Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system. 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.

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

Definition at line 665 of file system_projection.C.

669 {
670  this->boundary_project_vector(b, variables, *solution, f, g);
671 
672  solution->localize(*current_local_solution);
673 }
void libMesh::System::boundary_project_solution ( const std::set< boundary_id_type > &  b,
const std::vector< unsigned int > &  variables,
Number   fptrconst Point &p,const Parameters &parameters,const std::string &sys_name,const std::string &unknown_name,
Gradient   gptrconst Point &p,const Parameters &parameters,const std::string &sys_name,const std::string &unknown_name,
const Parameters parameters 
)
inherited

Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system. 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.

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

Definition at line 641 of file system_projection.C.

652 {
653  WrappedFunction<Number> f(*this, fptr, &parameters);
654  WrappedFunction<Gradient> g(*this, gptr, &parameters);
655  this->boundary_project_solution(b, variables, &f, &g);
656 }
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 = NULL 
) const
inherited

Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system. 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.

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

Definition at line 707 of file system_projection.C.

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

712 {
713  START_LOG ("boundary_project_vector()", "System");
714 
716  (ConstElemRange (this->get_mesh().active_local_elements_begin(),
717  this->get_mesh().active_local_elements_end() ),
718  BoundaryProjectSolution(b, variables, *this, f, g,
719  this->get_equation_systems().parameters,
720  new_vector)
721  );
722 
723  // We don't do SCALAR dofs when just projecting the boundary, so
724  // we're done here.
725 
726  new_vector.close();
727 
728 #ifdef LIBMESH_ENABLE_CONSTRAINTS
729  this->get_dof_map().enforce_constraints_exactly(*this, &new_vector);
730 #endif
731 
732  STOP_LOG("boundary_project_vector()", "System");
733 }
void libMesh::System::boundary_project_vector ( const std::set< boundary_id_type > &  b,
const std::vector< unsigned int > &  variables,
Number   fptrconst Point &p,const Parameters &parameters,const std::string &sys_name,const std::string &unknown_name,
Gradient   gptrconst Point &p,const Parameters &parameters,const std::string &sys_name,const std::string &unknown_name,
const Parameters parameters,
NumericVector< Number > &  new_vector 
) const
inherited

Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system. 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.

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

Definition at line 684 of file system_projection.C.

696 {
697  WrappedFunction<Number> f(*this, fptr, &parameters);
698  WrappedFunction<Gradient> g(*this, gptr, &parameters);
699  this->boundary_project_vector(b, variables, new_vector, &f, &g);
700 }
void libMesh::RBConstructionBase< LinearImplicitSystem >::broadcast_parameters ( unsigned int  proc_id)
inherited

Broadcasts parameters on processor proc_id to all processors.

virtual AutoPtr<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.

virtual AutoPtr<ElemAssembly> libMesh::RBEIMConstruction::build_eim_assembly ( unsigned int  bf_index)
pure virtual

Build an element assembly object that will access basis function bf_index. This is pure virtual, override in subclasses to specify the appropriate ElemAssembly object.

static AutoPtr<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.

Real libMesh::System::calculate_norm ( const NumericVector< Number > &  v,
unsigned int  var = 0,
FEMNormType  norm_type = L2 
) 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 1380 of file system.C.

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

Referenced by libMesh::AdaptiveTimeSolver::calculate_norm(), and libMesh::UnsteadySolver::du().

1383 {
1384  //short circuit to save time
1385  if(norm_type == DISCRETE_L1 ||
1386  norm_type == DISCRETE_L2 ||
1387  norm_type == DISCRETE_L_INF)
1388  return discrete_var_norm(v,var,norm_type);
1389 
1390  // Not a discrete norm
1391  std::vector<FEMNormType> norms(this->n_vars(), L2);
1392  std::vector<Real> weights(this->n_vars(), 0.0);
1393  norms[var] = norm_type;
1394  weights[var] = 1.0;
1395  Real val = this->calculate_norm(v, SystemNorm(norms, weights));
1396  return val;
1397 }
Real libMesh::System::calculate_norm ( const NumericVector< Number > &  v,
const SystemNorm norm 
) 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 1401 of file system.C.

References libMesh::System::_dof_map, std::abs(), libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), libMesh::TypeVector< T >::add_scaled(), libMesh::TypeTensor< T >::add_scaled(), libMesh::NumericVector< T >::build(), libMesh::FEGenericBase< T >::build(), libMesh::ParallelObject::comm(), libMesh::FEType::default_quadrature_rule(), libMesh::dim, libMeshEnums::DISCRETE_L1, libMeshEnums::DISCRETE_L2, libMeshEnums::DISCRETE_L_INF, libMesh::System::discrete_var_norm(), libMesh::DofMap::dof_indices(), libMesh::AutoPtr< Tp >::get(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMeshEnums::H1, libMeshEnums::H1_SEMINORM, libMeshEnums::H2, libMeshEnums::H2_SEMINORM, libMesh::SystemNorm::is_discrete(), libMeshEnums::L1, libMesh::NumericVector< T >::l1_norm(), libMeshEnums::L2, libMesh::NumericVector< T >::l2_norm(), libMeshEnums::L_INF, libMesh::NumericVector< T >::linfty_norm(), libMesh::NumericVector< T >::localize(), std::max(), libMesh::Parallel::Communicator::max(), libMesh::MeshBase::mesh_dimension(), libMesh::System::n_vars(), libMesh::TensorTools::norm_sq(), libMesh::Real, libMeshEnums::SERIAL, libMesh::TypeVector< T >::size(), libMesh::TypeTensor< T >::size(), libMesh::NumericVector< T >::size(), libMesh::TypeVector< T >::size_sq(), libMesh::TypeTensor< T >::size_sq(), libMesh::START_LOG(), libMesh::STOP_LOG(), libMesh::Parallel::Communicator::sum(), libMesh::SystemNorm::type(), libMesh::DofMap::variable_type(), libMeshEnums::W1_INF_SEMINORM, libMeshEnums::W2_INF_SEMINORM, libMesh::SystemNorm::weight(), and libMesh::SystemNorm::weight_sq().

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

Clear this object.

Reimplemented from libMesh::RBConstruction.

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

Definition at line 86 of file parallel_object.h.

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_petsc_snes_jacobian(), libMesh::__libmesh_petsc_snes_residual(), libMesh::MeshRefinement::_coarsen_elements(), libMesh::ExactSolution::_compute_error(), libMesh::MetisPartitioner::_do_partition(), libMesh::ParmetisPartitioner::_do_repartition(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult_add(), libMesh::EquationSystems::_read_impl(), libMesh::MeshRefinement::_refine_elements(), libMesh::ParallelMesh::add_elem(), libMesh::ImplicitSystem::add_matrix(), libMesh::ParallelMesh::add_node(), libMesh::System::add_vector(), libMesh::UnstructuredMesh::all_second_order(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assemble_qoi(), libMesh::MeshCommunication::assign_global_indices(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::DofMap::attach_matrix(), libMesh::MeshTools::bounding_box(), libMesh::System::calculate_norm(), libMesh::MeshRefinement::coarsen_elements(), 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::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), DMlibMeshFunction(), DMlibMeshJacobian(), DMLibMeshSetSystem(), DMVariableBounds_libMesh(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::for(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::LocationMap< T >::init(), libMesh::PetscDiffSolver::init(), libMesh::TimeSolver::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::EigenSystem::init_data(), libMesh::EigenSystem::init_matrices(), libMesh::ParmetisPartitioner::initialize(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::ParallelMesh::libmesh_assert_valid_parallel_flags(), libMesh::MeshTools::libmesh_assert_valid_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshCommunication::make_elems_parallel_consistent(), libMesh::MeshRefinement::make_flags_parallel_consistent(), libMesh::MeshCommunication::make_node_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::MeshRefinement::make_refinement_compatible(), libMesh::FEMSystem::mesh_position_set(), libMesh::MeshSerializer::MeshSerializer(), libMesh::ParallelMesh::n_active_elem(), libMesh::MeshTools::n_active_levels(), libMesh::BoundaryInfo::n_boundary_conds(), 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::ParallelMesh::parallel_max_elem_id(), libMesh::ParallelMesh::parallel_max_node_id(), libMesh::ParallelMesh::parallel_n_elem(), libMesh::ParallelMesh::parallel_n_nodes(), libMesh::Partitioner::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::System::project_vector(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs(), 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::MeshBase::recalculate_n_partitions(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::MeshRefinement::refine_elements(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), libMesh::Parallel::sync_element_data_by_parent_id(), libMesh::MeshRefinement::test_level_one(), libMesh::MeshRefinement::test_unflagged(), libMesh::MeshTools::total_weight(), libMesh::CheckpointIO::write(), libMesh::XdrIO::write(), libMesh::UnstructuredMesh::write(), libMesh::LegacyXdrIO::write_mesh(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), and libMesh::DivaIO::write_stream().

87  { return _communicator; }
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 526 of file system.C.

References libMesh::System::_can_add_vectors, 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().

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

We compute the best fit of parametrized_function into the EIM space and then evaluate the error in the norm defined by inner_product_matrix.

Returns
the error in the best fit
virtual 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.

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

virtual void libMesh::RBConstruction::compute_output_dual_innerprods ( )
protectedvirtualinherited

Compute and store the dual norm of each output functional.

void libMesh::System::deactivate ( )
inlineinherited

Deactivates the system. Only active systems are solved.

Definition at line 1935 of file system.h.

References libMesh::System::_active.

1936 {
1937  _active = false;
1938 }
void libMesh::LinearImplicitSystem::detach_shell_matrix ( void  )
inlineinherited

Detaches a shell matrix. Same as attach_shell_matrix(NULL).

Definition at line 176 of file linear_implicit_system.h.

References libMesh::LinearImplicitSystem::attach_shell_matrix().

176 { attach_shell_matrix(NULL); }
void libMesh::ImplicitSystem::disable_cache ( )
virtualinherited

Assembles & solves the linear system Ax=b. Avoids use of any cached data that might affect any solve result. Should be overloaded in derived systems.

Reimplemented from libMesh::System.

Definition at line 313 of file implicit_system.C.

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

313  {
314  this->assemble_before_solve = true;
315  this->get_linear_solver()->reuse_preconditioner(false);
316 }
void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

Definition at line 106 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

107 {
108  _enable_print_counter = false;
109  return;
110 }
void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

Definition at line 106 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

107 {
108  _enable_print_counter = false;
109  return;
110 }
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.

References libMesh::ReferenceCounter::_enable_print_counter.

101 {
102  _enable_print_counter = true;
103  return;
104 }
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.

References libMesh::ReferenceCounter::_enable_print_counter.

101 {
102  _enable_print_counter = true;
103  return;
104 }
virtual void libMesh::RBEIMConstruction::enrich_RB_space ( )
protectedvirtual

Add a new basis function to the RB space. Overload to enrich with the EIM basis functions.

Reimplemented from libMesh::RBConstruction.

Number libMesh::RBEIMConstruction::evaluate_mesh_function ( unsigned int  var_number,
Point  p 
)

Evaluate the mesh function at the specified point and for the specified variable.

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

Returns the final residual for the linear system solve.

Definition at line 160 of file linear_implicit_system.h.

References libMesh::LinearImplicitSystem::_final_linear_residual.

160 { return _final_linear_residual; }
void libMesh::ImplicitSystem::forward_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].

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

References libMesh::SensitivityData::allocate_data(), libMesh::QoISet::has_index(), libMesh::Real, libMesh::ParameterVector::size(), and libMesh::TOLERANCE.

830 {
831  const unsigned int Np = libmesh_cast_int<unsigned int>
832  (parameters.size());
833  const unsigned int Nq = libmesh_cast_int<unsigned int>
834  (qoi.size());
835 
836  // We currently get partial derivatives via central differencing
837  const Real delta_p = TOLERANCE;
838 
839  // An introduction to the problem:
840  //
841  // Residual R(u(p),p) = 0
842  // partial R / partial u = J = system matrix
843  //
844  // This implies that:
845  // d/dp(R) = 0
846  // (partial R / partial p) +
847  // (partial R / partial u) * (partial u / partial p) = 0
848 
849  // We first solve for (partial u / partial p) for each parameter:
850  // J * (partial u / partial p) = - (partial R / partial p)
851 
852  this->sensitivity_solve(parameters);
853 
854  // Get ready to fill in senstivities:
855  sensitivities.allocate_data(qoi_indices, *this, parameters);
856 
857  // We use the identity:
858  // dq/dp = (partial q / partial p) + (partial q / partial u) *
859  // (partial u / partial p)
860 
861  // We get (partial q / partial u) from the user
862  this->assemble_qoi_derivative(qoi_indices);
863 
864  // FIXME: what do we do with adjoint boundary conditions here?
865 
866  // We don't need these to be closed() in this function, but libMesh
867  // standard practice is to have them closed() by the time the
868  // function exits
869  for (unsigned int i=0; i != this->qoi.size(); ++i)
870  if (qoi_indices.has_index(i))
871  this->get_adjoint_rhs(i).close();
872 
873  for (unsigned int j=0; j != Np; ++j)
874  {
875  // (partial q / partial p) ~= (q(p+dp)-q(p-dp))/(2*dp)
876 
877  Number old_parameter = *parameters[j];
878 
879  *parameters[j] = old_parameter - delta_p;
880  this->assemble_qoi();
881  std::vector<Number> qoi_minus = this->qoi;
882 
883  *parameters[j] = old_parameter + delta_p;
884  this->assemble_qoi();
885  std::vector<Number>& qoi_plus = this->qoi;
886 
887  std::vector<Number> partialq_partialp(Nq, 0);
888  for (unsigned int i=0; i != Nq; ++i)
889  if (qoi_indices.has_index(i))
890  partialq_partialp[i] = (qoi_plus[i] - qoi_minus[i]) / (2.*delta_p);
891 
892  // Don't leave the parameter changed
893  *parameters[j] = old_parameter;
894 
895  for (unsigned int i=0; i != Nq; ++i)
896  if (qoi_indices.has_index(i))
897  sensitivities[i][j] = partialq_partialp[i] +
898  this->get_adjoint_rhs(i).dot(this->get_sensitivity_solution(j));
899  }
900 
901  // All parameters have been reset.
902  // We didn't cache the original rhs or matrix for memory reasons,
903  // but we can restore them to a state consistent solution -
904  // principle of least surprise.
905  this->assembly(true, true);
906  this->rhs->close();
907  this->matrix->close();
908  this->assemble_qoi(qoi_indices);
909 }
static void libMesh::RBConstructionBase< LinearImplicitSystem >::generate_training_parameters_deterministic ( const Parallel::Communicator communicator,
std::map< std::string, bool >  log_param_scale,
std::map< std::string, 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.

static void libMesh::RBConstructionBase< LinearImplicitSystem >::generate_training_parameters_partially_random ( const Parallel::Communicator communicator,
const std::string &  deterministic_parameter_name,
const unsigned int  deterministic_parameter_repeats,
std::map< std::string, bool >  log_param_scale,
std::map< std::string, NumericVector< Number > * > &  training_parameters_in,
unsigned int  n_deterministic_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 "partially" random set of parameters, that is the parameter indicated by this->get_deterministic_training_parameter() will be deterministic.

static void libMesh::RBConstructionBase< LinearImplicitSystem >::generate_training_parameters_random ( const Parallel::Communicator communicator,
std::map< std::string, bool >  log_param_scale,
std::map< std::string, 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.

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

References libMesh::System::get_vector().

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

1028 {
1029  std::ostringstream adjoint_rhs_name;
1030  adjoint_rhs_name << "adjoint_rhs" << i;
1031 
1032  return this->get_vector(adjoint_rhs_name.str());
1033 }
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 1037 of file system.C.

References libMesh::System::get_vector().

1038 {
1039  std::ostringstream adjoint_rhs_name;
1040  adjoint_rhs_name << "adjoint_rhs" << i;
1041 
1042  return this->get_vector(adjoint_rhs_name.str());
1043 }
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 967 of file system.C.

References libMesh::System::get_vector().

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::ImplicitSystem::adjoint_solve(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), and libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().

968 {
969  std::ostringstream adjoint_name;
970  adjoint_name << "adjoint_solution" << i;
971 
972  return this->get_vector(adjoint_name.str());
973 }
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 977 of file system.C.

References libMesh::System::get_vector().

978 {
979  std::ostringstream adjoint_name;
980  adjoint_name << "adjoint_solution" << i;
981 
982  return this->get_vector(adjoint_name.str());
983 }
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 1260 of file system.C.

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

1261 {
1262  all_variable_numbers.resize(n_vars());
1263 
1264  // Make sure the variable exists
1265  std::map<std::string, unsigned short int>::const_iterator
1266  it = _variable_numbers.begin();
1267  std::map<std::string, unsigned short int>::const_iterator
1268  it_end = _variable_numbers.end();
1269 
1270  unsigned int count = 0;
1271  for( ; it != it_end; ++it)
1272  {
1273  all_variable_numbers[count] = it->second;
1274  count++;
1275  }
1276 }
SparseMatrix<Number>* libMesh::RBConstruction::get_Aq ( unsigned int  q)
inherited

Get a pointer to Aq.

ElemAssembly& libMesh::RBConstruction::get_constraint_assembly ( )
inherited
Returns
a reference to the constraint assembly object
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 373 of file rb_construction.h.

References libMesh::RBConstruction::delta_N.

373 { return delta_N; }
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.

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.

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

Definition at line 1903 of file system.h.

References libMesh::System::_dof_map.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_petsc_snes_jacobian(), libMesh::__libmesh_petsc_snes_residual(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::HPCoarsenTest::add_projection(), libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::ImplicitSystem::adjoint_solve(), libMesh::UnsteadySolver::advance_timestep(), libMesh::EquationSystems::allgather(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_solution_vector(), libMesh::System::calculate_norm(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), DMCreateDomainDecomposition_libMesh(), DMCreateFieldDecomposition_libMesh(), DMlibMeshFunction(), DMlibMeshJacobian(), DMLibMeshSetSystem(), libMesh::DofMap::enforce_constraints_exactly(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::for(), libMesh::System::get_info(), libMesh::EquationSystems::get_solution(), libMesh::SystemSubsetBySubdomain::init(), libMesh::UnsteadySolver::init_data(), libMesh::EigenSystem::init_matrices(), libMesh::ImplicitSystem::init_matrices(), libMesh::CondensedEigenSystem::initialize_condensed_dofs(), libMesh::System::local_dof_indices(), libMesh::DofMap::max_constraint_error(), libMesh::DGFEMContext::neighbor_side_fe_reinit(), libMesh::UnsteadySolver::old_nonlinear_solution(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::ProjectSolution::operator()(), libMesh::ProjectFEMSolution::operator()(), libMesh::BoundaryProjectSolution::operator()(), libMesh::ErrorVector::plot_error(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::FEMContext::pre_fe_reinit(), libMesh::System::project_vector(), libMesh::System::re_update(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::UnsteadySolver::reinit(), libMesh::ImplicitSystem::reinit(), libMesh::EigenSystem::reinit(), libMesh::EquationSystems::reinit(), libMesh::UnsteadySolver::retrieve_timestep(), libMesh::HPCoarsenTest::select_refinement(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::NewtonSolver::solve(), libMesh::PetscDiffSolver::solve(), libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve(), libMesh::ImplicitSystem::weighted_sensitivity_solve(), libMesh::System::write_parallel_data(), libMesh::EnsightIO::write_scalar_ascii(), libMesh::System::write_SCALAR_dofs(), and libMesh::EnsightIO::write_vector_ascii().

1904 {
1905  return *_dof_map;
1906 }
DofMap & libMesh::System::get_dof_map ( )
inlineinherited
Returns
a writeable reference to this system's _dof_map.

Definition at line 1911 of file system.h.

References libMesh::System::_dof_map.

1912 {
1913  return *_dof_map;
1914 }
std::vector<ElemAssembly*> libMesh::RBEIMConstruction::get_eim_assembly_objects ( )
Returns
the vector of assembly objects that point to this RBEIMConstruction.
EquationSystems& libMesh::System::get_equation_systems ( )
inlineinherited
Returns
a reference to this system's parent EquationSystems object.

Definition at line 686 of file system.h.

References libMesh::System::_equation_systems.

686 { return _equation_systems; }
numeric_index_type libMesh::RBConstructionBase< LinearImplicitSystem >::get_first_local_training_index ( ) const
inherited

Get the first local index of the training parameters.

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

Get a pointer to Fq.

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

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

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

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

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

Gets a string containing the reference information.

Definition at line 47 of file reference_counter.C.

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

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

48 {
49 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
50 
51  std::ostringstream oss;
52 
53  oss << '\n'
54  << " ---------------------------------------------------------------------------- \n"
55  << "| Reference count information |\n"
56  << " ---------------------------------------------------------------------------- \n";
57 
58  for (Counts::iterator it = _counts.begin();
59  it != _counts.end(); ++it)
60  {
61  const std::string name(it->first);
62  const unsigned int creations = it->second.first;
63  const unsigned int destructions = it->second.second;
64 
65  oss << "| " << name << " reference count information:\n"
66  << "| Creations: " << creations << '\n'
67  << "| Destructions: " << destructions << '\n';
68  }
69 
70  oss << " ---------------------------------------------------------------------------- \n";
71 
72  return oss.str();
73 
74 #else
75 
76  return "";
77 
78 #endif
79 }
std::string libMesh::ReferenceCounter::get_info ( )
staticinherited

Gets a string containing the reference information.

Definition at line 47 of file reference_counter.C.

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

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

48 {
49 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
50 
51  std::ostringstream oss;
52 
53  oss << '\n'
54  << " ---------------------------------------------------------------------------- \n"
55  << "| Reference count information |\n"
56  << " ---------------------------------------------------------------------------- \n";
57 
58  for (Counts::iterator it = _counts.begin();
59  it != _counts.end(); ++it)
60  {
61  const std::string name(it->first);
62  const unsigned int creations = it->second.first;
63  const unsigned int destructions = it->second.second;
64 
65  oss << "| " << name << " reference count information:\n"
66  << "| Creations: " << creations << '\n'
67  << "| Destructions: " << destructions << '\n';
68  }
69 
70  oss << " ---------------------------------------------------------------------------- \n";
71 
72  return oss.str();
73 
74 #else
75 
76  return "";
77 
78 #endif
79 }
std::string libMesh::System::get_info ( ) const
inherited
Returns
a string containing information about the system.

Definition at line 1635 of file system.C.

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

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

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

Get the last local index of the training 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 1393 of file implicit_system.C.

References libMesh::System::get_equation_systems(), 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().

1394 {
1395  return std::make_pair(this->get_equation_systems().parameters.get<unsigned int>("linear solver maximum iterations"),
1396  this->get_equation_systems().parameters.get<Real>("linear solver tolerance"));
1397 }
LinearSolver< Number > * libMesh::LinearImplicitSystem::get_linear_solver ( ) const
virtualinherited

Returns a pointer to a linear solver appropriate for use in adjoint and/or sensitivity solves

Reimplemented from libMesh::ImplicitSystem.

Definition at line 360 of file linear_implicit_system.C.

References libMesh::LinearImplicitSystem::linear_solver.

361 {
362  return linear_solver.get();
363 }
numeric_index_type libMesh::RBConstructionBase< LinearImplicitSystem >::get_local_n_training_samples ( ) const
inherited

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

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

References libMesh::ImplicitSystem::_matrices, and libMesh::err.

Referenced by libMesh::NewmarkSystem::compute_matrix(), libMesh::EigenTimeSolver::solve(), and libMesh::NewmarkSystem::update_rhs().

259 {
260  // Make sure the matrix exists
261  const_matrices_iterator pos = _matrices.find (mat_name);
262 
263  if (pos == _matrices.end())
264  {
265  libMesh::err << "ERROR: matrix "
266  << mat_name
267  << " does not exist in this system!"
268  << std::endl;
269  libmesh_error();
270  }
271 
272  return *(pos->second);
273 }
SparseMatrix< Number > & libMesh::ImplicitSystem::get_matrix ( const std::string &  mat_name)
inherited
Returns
a writeable 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 277 of file implicit_system.C.

References libMesh::ImplicitSystem::_matrices, and libMesh::err.

278 {
279  // Make sure the matrix exists
280  matrices_iterator pos = _matrices.find (mat_name);
281 
282  if (pos == _matrices.end())
283  {
284  libMesh::err << "ERROR: matrix "
285  << mat_name
286  << " does not exist in this system!"
287  << std::endl;
288  libmesh_error();
289  }
290 
291  return *(pos->second);
292 }
const MeshBase & libMesh::System::get_mesh ( ) const
inlineinherited
Returns
a constant reference to this systems's _mesh.

Definition at line 1887 of file system.h.

References libMesh::System::_mesh.

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::HPCoarsenTest::add_projection(), libMesh::FEMSystem::assemble_qoi(), libMesh::FEMSystem::assemble_qoi_derivative(), libMesh::FEMSystem::assembly(), libMesh::System::calculate_norm(), DMCreateDomainDecomposition_libMesh(), DMCreateFieldDecomposition_libMesh(), DMLibMeshSetSystem(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::SystemSubsetBySubdomain::init(), libMesh::System::init_data(), libMesh::EigenSystem::init_matrices(), libMesh::ImplicitSystem::init_matrices(), libMesh::System::local_dof_indices(), libMesh::DofMap::max_constraint_error(), libMesh::FEMSystem::mesh_position_get(), libMesh::FEMSystem::mesh_position_set(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::ProjectSolution::operator()(), libMesh::BoundaryProjectSolution::operator()(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::FEMSystem::postprocess(), libMesh::System::project_vector(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::System::read_parallel_data(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::ImplicitSystem::reinit(), libMesh::EigenSystem::reinit(), libMesh::HPSingularity::select_refinement(), libMesh::HPCoarsenTest::select_refinement(), libMesh::System::write_header(), libMesh::System::write_parallel_data(), libMesh::System::write_serialized_vector(), libMesh::System::write_serialized_vectors(), and libMesh::System::zero_variable().

1888 {
1889  return _mesh;
1890 }
MeshBase & libMesh::System::get_mesh ( )
inlineinherited
Returns
a reference to this systems's _mesh.

Definition at line 1895 of file system.h.

References libMesh::System::_mesh.

1896 {
1897  return _mesh;
1898 }
unsigned int libMesh::RBParametrized::get_n_params ( ) const
inherited

Get the number of parameters.

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

Get the total number of training samples.

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

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

Definition at line 182 of file rb_construction.h.

References libMesh::RBConstruction::Nmax.

182 { return Nmax; }
SparseMatrix<Number>* libMesh::RBConstruction::get_non_dirichlet_Aq ( unsigned int  q)
inherited

Get a pointer to non_dirichlet_Aq.

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

Get a pointer to non-Dirichlet Fq.

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

Get a pointer to non_dirichlet_inner_product_matrix. Accessing via this function, rather than directly through the class member allows us to do error checking (e.g. non_dirichlet_inner_product_matrix is not defined in low-memory mode, and we need store_non_dirichlet_operators==true).

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.

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

Get a pointer to the n^th output.

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

Get maximum allowable value of parameter param_name.

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

Get minimum allowable value of parameter param_name.

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

Get the current parameters.

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

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

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

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

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

Return the RBParameters in index index of training set.

RBAssemblyExpansion& libMesh::RBConstruction::get_rb_assembly_expansion ( )
inherited
Returns
a reference to the rb_assembly_expansion object
virtual Real libMesh::RBEIMConstruction::get_RB_error_bound ( )
protectedvirtual

Overload to return the best fit error. This function is used in the Greedy algorithm to select the next parameter.

Reimplemented from libMesh::RBConstruction.

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

Get a reference to the RBEvaluation object.

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

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

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

References libMesh::System::get_vector().

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

1058 {
1059  std::ostringstream sensitivity_rhs_name;
1060  sensitivity_rhs_name << "sensitivity_rhs" << i;
1061 
1062  return this->get_vector(sensitivity_rhs_name.str());
1063 }
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 1067 of file system.C.

References libMesh::System::get_vector().

1068 {
1069  std::ostringstream sensitivity_rhs_name;
1070  sensitivity_rhs_name << "sensitivity_rhs" << i;
1071 
1072  return this->get_vector(sensitivity_rhs_name.str());
1073 }
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 916 of file system.C.

References libMesh::System::get_vector().

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

917 {
918  std::ostringstream sensitivity_name;
919  sensitivity_name << "sensitivity_solution" << i;
920 
921  return this->get_vector(sensitivity_name.str());
922 }
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 926 of file system.C.

References libMesh::System::get_vector().

927 {
928  std::ostringstream sensitivity_name;
929  sensitivity_name << "sensitivity_solution" << i;
930 
931  return this->get_vector(sensitivity_name.str());
932 }
ShellMatrix<Number>* libMesh::LinearImplicitSystem::get_shell_matrix ( void  )
inlineinherited

Returns a pointer to the currently attached shell matrix, if any, or NULL else.

Definition at line 182 of file linear_implicit_system.h.

References libMesh::LinearImplicitSystem::_shell_matrix.

182 { return _shell_matrix; }
Real libMesh::RBConstruction::get_training_tolerance ( )
inlineinherited

Definition at line 176 of file rb_construction.h.

References libMesh::RBConstruction::training_tolerance.

176 { return training_tolerance; }
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 785 of file system.C.

References libMesh::System::_vectors, and libMesh::err.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::AdaptiveTimeSolver::advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), libMesh::System::compare(), 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(), 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().

786 {
787  // Make sure the vector exists
788  const_vectors_iterator pos = _vectors.find(vec_name);
789 
790  if (pos == _vectors.end())
791  {
792  libMesh::err << "ERROR: vector "
793  << vec_name
794  << " does not exist in this system!"
795  << std::endl;
796  libmesh_error();
797  }
798 
799  return *(pos->second);
800 }
NumericVector< Number > & libMesh::System::get_vector ( const std::string &  vec_name)
inherited
Returns
a writeable reference to this system's additional vector named vec_name. Access is only granted when the vector is already properly initialized.

Definition at line 804 of file system.C.

References libMesh::System::_vectors, and libMesh::err.

805 {
806  // Make sure the vector exists
807  vectors_iterator pos = _vectors.find(vec_name);
808 
809  if (pos == _vectors.end())
810  {
811  libMesh::err << "ERROR: vector "
812  << vec_name
813  << " does not exist in this system!"
814  << std::endl;
815  libmesh_error();
816  }
817 
818  return *(pos->second);
819 }
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 823 of file system.C.

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

824 {
827  unsigned int num = 0;
828  while((num<vec_num) && (v!=v_end))
829  {
830  num++;
831  ++v;
832  }
833  libmesh_assert (v != v_end);
834  return *(v->second);
835 }
NumericVector< Number > & libMesh::System::get_vector ( const unsigned int  vec_num)
inherited
Returns
a writeable reference to this system's additional vector number vec_num (where the vectors are counted starting with 0).

Definition at line 839 of file system.C.

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

840 {
842  vectors_iterator v_end = vectors_end();
843  unsigned int num = 0;
844  while((num<vec_num) && (v!=v_end))
845  {
846  num++;
847  ++v;
848  }
849  libmesh_assert (v != v_end);
850  return *(v->second);
851 }
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 997 of file system.C.

References libMesh::System::get_vector().

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

998 {
999  std::ostringstream adjoint_name;
1000  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
1001 
1002  return this->get_vector(adjoint_name.str());
1003 }
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 1007 of file system.C.

References libMesh::System::get_vector().

1008 {
1009  std::ostringstream adjoint_name;
1010  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
1011 
1012  return this->get_vector(adjoint_name.str());
1013 }
NumericVector< Number > & libMesh::System::get_weighted_sensitivity_solution ( )
inherited
Returns
a reference to the solution of the last weighted sensitivity solve

Definition at line 943 of file system.C.

References libMesh::System::get_vector().

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

944 {
945  return this->get_vector("weighted_sensitivity_solution");
946 }
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 950 of file system.C.

References libMesh::System::get_vector().

951 {
952  return this->get_vector("weighted_sensitivity_solution");
953 }
virtual bool libMesh::RBEIMConstruction::greedy_termination_test ( Real  training_greedy_error,
int  count 
)
protectedvirtual

Function that indicates when to terminate the Greedy basis training. Overload in subclasses to specialize.

Reimplemented from libMesh::RBConstruction.

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

References libMesh::System::_variable_numbers.

Referenced by libMesh::GMVIO::copy_nodal_solution().

1234 {
1235  return _variable_numbers.count(var);
1236 }
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 378 of file implicit_system.h.

References libMesh::ImplicitSystem::_matrices.

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

379 {
380  return (_matrices.count(mat_name));
381 }
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 2071 of file system.h.

References libMesh::System::_vectors.

Referenced by libMesh::System::add_vector(), and libMesh::System::remove_vector().

2072 {
2073  return (_vectors.count(vec_name));
2074 }
bool libMesh::System::identify_variable_groups ( ) const
inlineinherited
Returns
true when VariableGroup structures should be automatically identified, false otherwise.

Definition at line 2047 of file system.h.

References libMesh::System::_identify_variable_groups.

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

2048 {
2050 }
void libMesh::System::identify_variable_groups ( const bool  ivg)
inlineinherited

Toggle automatic VariableGroup identification.

Definition at line 2055 of file system.h.

References libMesh::System::_identify_variable_groups.

2056 {
2058 }
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 163 of file reference_counter.h.

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

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

164 {
165  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
166  std::pair<unsigned int, unsigned int>& p = _counts[name];
167 
168  p.first++;
169 }
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 163 of file reference_counter.h.

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

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

164 {
165  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
166  std::pair<unsigned int, unsigned int>& p = _counts[name];
167 
168  p.first++;
169 }
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 176 of file reference_counter.h.

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

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

177 {
178  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
179  std::pair<unsigned int, unsigned int>& p = _counts[name];
180 
181  p.second++;
182 }
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 176 of file reference_counter.h.

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

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

177 {
178  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
179  std::pair<unsigned int, unsigned int>& p = _counts[name];
180 
181  p.second++;
182 }
void libMesh::System::init ( )
inherited

Initializes degrees of freedom on the current mesh. Sets the

Definition at line 226 of file system.C.

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

227 {
228  // First initialize any required data:
229  // either only the basic System data
230  if (_basic_system_only)
232  // or all the derived class' data too
233  else
234  this->init_data();
235 
236  // If no variables have been added to this system
237  // don't do anything
238  if(!this->n_vars())
239  return;
240 
241  // Then call the user-provided intialization function
242  this->user_initialization();
243 }
virtual void libMesh::RBEIMConstruction::init_context ( FEMContext c)
virtual

Provide an implementation of init_context that is relevant to the projection calculations in load_calN_parametrized_function.

Reimplemented from libMesh::RBConstruction.

virtual void libMesh::RBEIMConstruction::init_data ( )
protectedvirtual

Override to initialize the coupling matrix to decouple variables in this system.

Reimplemented from libMesh::RBConstructionBase< LinearImplicitSystem >.

void libMesh::ImplicitSystem::init_matrices ( )
protectedvirtualinherited

Initializes the matrices associated with this system.

Definition at line 105 of file implicit_system.C.

References libMesh::ImplicitSystem::_can_add_matrices, libMesh::ImplicitSystem::_matrices, libMesh::DofMap::attach_matrix(), libMesh::DofMap::compute_sparsity(), libMesh::dof_map, 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().

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 (matrices_iterator pos = _matrices.begin();
123  pos != _matrices.end(); ++pos)
124  {
125  SparseMatrix<Number> &m = *(pos->second);
126  libmesh_assert (!m.initialized());
127 
128  // We want to allow repeated init() on systems, but we don't
129  // want to attach the same matrix to the DofMap twice
130  if (!dof_map.is_attached(m))
131  dof_map.attach_matrix (m);
132  }
133 
134  // Compute the sparsity pattern for the current
135  // mesh and DOF distribution. This also updates
136  // additional matrices, \p DofMap now knows them
137  dof_map.compute_sparsity (this->get_mesh());
138 
139  // Initialize matrices
140  for (matrices_iterator pos = _matrices.begin();
141  pos != _matrices.end(); ++pos)
142  pos->second->init ();
143 
144  // Set the additional matrices to 0.
145  for (matrices_iterator pos = _matrices.begin();
146  pos != _matrices.end(); ++pos)
147  pos->second->zero ();
148 }
virtual void libMesh::RBEIMConstruction::initialize_eim_assembly_objects ( )
virtual

Build a vector of ElemAssembly objects that accesses the basis functions stored in this RBEIMConstruction object. This is useful for performing the Offline stage of the Reduced Basis method where we want to use assembly functions based on this EIM approximation.

void libMesh::RBParametrized::initialize_parameters ( const RBParameters mu_min_in,
const RBParameters mu_max_in,
const RBParameters mu_in 
)
inherited

Initialize the parameter ranges and set current_parameters.

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

Initialize the parameter ranges and set current_parameters.

void libMesh::RBEIMConstruction::initialize_parametrized_functions_in_training_set ( )
protected

Loop over the training set and compute the parametrized function for each training index.

virtual void libMesh::RBEIMConstruction::initialize_rb_construction ( )
virtual

Initialize this system so that we can perform the Construction stage of the RB method.

Reimplemented from libMesh::RBConstruction.

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

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

Accessor for the adjoint_already_solved boolean

Definition at line 361 of file system.h.

References libMesh::System::adjoint_already_solved.

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

362  { return adjoint_already_solved;}
bool libMesh::RBConstruction::is_quiet ( ) const
inlineinherited

Is the system in quiet mode?

Definition at line 196 of file rb_construction.h.

References libMesh::RBConstruction::quiet_mode.

197  { return this->quiet_mode; }
bool libMesh::RBConstruction::is_rb_eval_initialized ( ) const
inherited
Returns
true if rb_eval is initialized. False, otherwise.
virtual void libMesh::RBConstruction::load_basis_function ( unsigned int  i)
virtualinherited

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

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

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

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

References libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), libMesh::DofMap::dof_indices(), libMesh::DofMap::end_dof(), libMesh::DofMap::first_dof(), libMesh::System::get_dof_map(), and libMesh::System::get_mesh().

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

1281 {
1282  // Make sure the set is clear
1283  var_indices.clear();
1284 
1285  std::vector<dof_id_type> dof_indices;
1286 
1287  // Begin the loop over the elements
1288  MeshBase::const_element_iterator el =
1290  const MeshBase::const_element_iterator end_el =
1292 
1293  const dof_id_type
1294  first_local = this->get_dof_map().first_dof(),
1295  end_local = this->get_dof_map().end_dof();
1296 
1297  for ( ; el != end_el; ++el)
1298  {
1299  const Elem* elem = *el;
1300  this->get_dof_map().dof_indices (elem, dof_indices, var);
1301 
1302  for(unsigned int i=0; i<dof_indices.size(); i++)
1303  {
1304  dof_id_type dof = dof_indices[i];
1305 
1306  //If the dof is owned by the local processor
1307  if(first_local <= dof && dof < end_local)
1308  var_indices.insert(dof_indices[i]);
1309  }
1310  }
1311 }
dof_id_type libMesh::System::n_active_dofs ( ) const
inlineinherited

Returns the number of active degrees of freedom for this System.

Definition at line 2063 of file system.h.

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

2064 {
2065  return this->n_dofs() - this->n_constrained_dofs();
2066 }
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 1967 of file system.h.

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

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

1968 {
1969  if (_variables.empty())
1970  return 0;
1971 
1972  const Variable& last = _variables.back();
1973  return last.first_scalar_number() + last.n_components();
1974 }
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 147 of file system.C.

References libMesh::System::_dof_map.

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

148 {
149 #ifdef LIBMESH_ENABLE_CONSTRAINTS
150 
151  return _dof_map->n_constrained_dofs();
152 
153 #else
154 
155  return 0;
156 
157 #endif
158 }
unsigned int libMesh::LinearImplicitSystem::n_linear_iterations ( ) const
inlineinherited

Returns the number of iterations taken for the most recent linear solve.

Definition at line 155 of file linear_implicit_system.h.

References libMesh::LinearImplicitSystem::_n_linear_iterations.

155 { return _n_linear_iterations; }
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 162 of file system.C.

References libMesh::System::_dof_map.

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

163 {
164 #ifdef LIBMESH_ENABLE_CONSTRAINTS
165 
166  return _dof_map->n_local_constrained_dofs();
167 
168 #else
169 
170  return 0;
171 
172 #endif
173 }
unsigned int libMesh::ImplicitSystem::n_matrices ( ) const
inlinevirtualinherited
Returns
the number of matrices handled by this system

Reimplemented from libMesh::System.

Definition at line 385 of file implicit_system.h.

References libMesh::ImplicitSystem::_matrices.

386 {
387  return libmesh_cast_int<unsigned int>(_matrices.size());
388 }
static unsigned int libMesh::ReferenceCounter::n_objects ( )
inlinestaticinherited

Prints the number of outstanding (created, but not yet destroyed) objects.

Definition at line 79 of file reference_counter.h.

References libMesh::ReferenceCounter::_n_objects.

80  { return _n_objects; }
static unsigned int libMesh::ReferenceCounter::n_objects ( )
inlinestaticinherited

Prints the number of outstanding (created, but not yet destroyed) objects.

Definition at line 79 of file reference_counter.h.

References libMesh::ReferenceCounter::_n_objects.

80  { return _n_objects; }
processor_id_type libMesh::ParallelObject::n_processors ( ) const
inlineinherited
Returns
the number of processors in the group.

Definition at line 92 of file parallel_object.h.

References libMesh::ParallelObject::_communicator, and libMesh::Parallel::Communicator::size().

Referenced by libMesh::ParmetisPartitioner::_do_repartition(), libMesh::ParallelMesh::add_elem(), libMesh::ParallelMesh::add_node(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::ParallelMesh::assign_unique_ids(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::ParallelMesh::clear(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::EnsightIO::EnsightIO(), libMesh::MeshBase::get_info(), libMesh::EquationSystems::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshBase::n_active_elem_on_proc(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), libMesh::Partitioner::partition(), libMesh::MeshBase::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::PetscLinearSolver< T >::PetscLinearSolver(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshTools::processor_bounding_box(), libMesh::System::project_vector(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::UnstructuredMesh::read(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::System::read_serialized_vector(), libMesh::Partitioner::repartition(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::BoundaryInfo::sync(), libMesh::ParallelMesh::update_parallel_id_counts(), libMesh::CheckpointIO::write(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

93  { return libmesh_cast_int<processor_id_type>(_communicator.size()); }
unsigned int libMesh::System::n_variable_groups ( ) const
inlineinherited
Returns
the number of VariableGroup variable groups in the system

Definition at line 1959 of file system.h.

References libMesh::System::_variable_groups.

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

1960 {
1961  return libmesh_cast_int<unsigned int>(_variable_groups.size());
1962 }
unsigned int libMesh::System::n_vars ( ) const
inlineinherited
Returns
the number of variables in the system

Definition at line 1951 of file system.h.

References libMesh::System::_variables.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::DiffContext::add_localized_vector(), libMesh::System::add_variable(), libMesh::System::add_variables(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_solution_vector(), libMesh::System::calculate_norm(), libMesh::DGFEMContext::DGFEMContext(), libMesh::DiffContext::DiffContext(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ErrorEstimator::estimate_errors(), libMesh::ExactSolution::ExactSolution(), libMesh::FEMContext::FEMContext(), libMesh::System::get_all_variable_numbers(), libMesh::EquationSystems::get_solution(), libMesh::System::init(), libMesh::FEMSystem::init_context(), libMesh::DGFEMContext::neighbor_side_fe_reinit(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::ProjectSolution::operator()(), libMesh::FEMContext::pre_fe_reinit(), libMesh::System::project_vector(), 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::EquationSystems::reinit(), libMesh::System::reinit(), libMesh::HPCoarsenTest::select_refinement(), libMesh::SystemSubsetBySubdomain::set_var_nums(), 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().

1952 {
1953  return libmesh_cast_int<unsigned int>(_variables.size());
1954 }
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 2079 of file system.h.

References libMesh::System::_vectors.

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

2080 {
2081  return libmesh_cast_int<unsigned int>(_vectors.size());
2082 }
Gradient libMesh::System::point_gradient ( unsigned int  var,
const Point p,
const bool  insist_on_success = true 
) 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 2063 of file system.C.

References libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::PointLocatorBase::enable_out_of_mesh_mode(), libMesh::System::get_mesh(), libMesh::libmesh_assert(), mesh, libMesh::Parallel::Communicator::min(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), libMesh::MeshBase::sub_point_locator(), and libMesh::Parallel::Communicator::verify().

2064 {
2065  // This function must be called on every processor; there's no
2066  // telling where in the partition p falls.
2067  parallel_object_only();
2068 
2069  // And every processor had better agree about which point we're
2070  // looking for
2071 #ifndef NDEBUG
2072  this->comm().verify(p);
2073 #endif // NDEBUG
2074 
2075  // Get a reference to the mesh object associated with the system object that calls this function
2076  const MeshBase &mesh = this->get_mesh();
2077 
2078  // Use an existing PointLocator or create a new one
2079  AutoPtr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2080  PointLocatorBase& locator = *locator_ptr;
2081 
2082  if (!insist_on_success)
2083  locator.enable_out_of_mesh_mode();
2084 
2085  // Get a pointer to the element that contains P
2086  const Elem *e = locator(p);
2087 
2088  Gradient grad_u;
2089 
2090  if (e && e->processor_id() == this->processor_id())
2091  grad_u = point_gradient(var, p, *e);
2092 
2093  // If I have an element containing p, then let's let everyone know
2094  processor_id_type lowest_owner =
2095  (e && (e->processor_id() == this->processor_id())) ?
2096  this->processor_id() : this->n_processors();
2097  this->comm().min(lowest_owner);
2098 
2099  // Everybody should get their value from a processor that was able
2100  // to compute it.
2101  // If nobody admits owning the point, we may have a problem.
2102  if (lowest_owner != this->n_processors())
2103  this->comm().broadcast(grad_u, lowest_owner);
2104  else
2105  libmesh_assert(!insist_on_success);
2106 
2107  return grad_u;
2108 }
Gradient libMesh::System::point_gradient ( unsigned int  var,
const Point p,
const Elem e 
) 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 2111 of file system.C.

References libMesh::TypeVector< T >::add_scaled(), libMesh::FEGenericBase< T >::build(), libMesh::Elem::contains_point(), libMesh::System::current_solution(), libMesh::Elem::dim(), libMesh::dof_map, libMesh::System::get_dof_map(), libMesh::FEInterface::inverse_map(), libMesh::libmesh_assert(), libMesh::ParallelObject::processor_id(), and libMesh::DofObject::processor_id().

2112 {
2113  libmesh_assert_equal_to (e.processor_id(), this->processor_id());
2114 
2115  // Ensuring that the given point is really in the element is an
2116  // expensive assert, but as long as debugging is turned on we might
2117  // as well try to catch a particularly nasty potential error
2118  libmesh_assert (e.contains_point(p));
2119 
2120  // Get the dof map to get the proper indices for our computation
2121  const DofMap& dof_map = this->get_dof_map();
2122 
2123  // Need dof_indices for phi[i][j]
2124  std::vector<dof_id_type> dof_indices;
2125 
2126  // Fill in the dof_indices for our element
2127  dof_map.dof_indices (&e, dof_indices, var);
2128 
2129  // Get the no of dofs assciated with this point
2130  const unsigned int num_dofs = libmesh_cast_int<unsigned int>
2131  (dof_indices.size());
2132 
2133  FEType fe_type = dof_map.variable_type(var);
2134 
2135  // Build a FE again so we can calculate u(p)
2136  AutoPtr<FEBase> fe (FEBase::build(e.dim(), fe_type));
2137 
2138  // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h
2139  // Build a vector of point co-ordinates to send to reinit
2140  std::vector<Point> coor(1, FEInterface::inverse_map(e.dim(), fe_type, &e, p));
2141 
2142  // Get the values of the shape function derivatives
2143  const std::vector<std::vector<RealGradient> >& dphi = fe->get_dphi();
2144 
2145  // Reinitialize the element and compute the shape function values at coor
2146  fe->reinit (&e, &coor);
2147 
2148  // Get ready to accumulate a gradient
2149  Gradient grad_u;
2150 
2151  for (unsigned int l=0; l<num_dofs; l++)
2152  {
2153  grad_u.add_scaled (dphi[l][0], this->current_solution (dof_indices[l]));
2154  }
2155 
2156  return grad_u;
2157 }
Tensor libMesh::System::point_hessian ( unsigned int  var,
const Point p,
const bool  insist_on_success = true 
) 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 2162 of file system.C.

References libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::PointLocatorBase::enable_out_of_mesh_mode(), libMesh::System::get_mesh(), libMesh::libmesh_assert(), mesh, libMesh::Parallel::Communicator::min(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), libMesh::MeshBase::sub_point_locator(), and libMesh::Parallel::Communicator::verify().

2163 {
2164  // This function must be called on every processor; there's no
2165  // telling where in the partition p falls.
2166  parallel_object_only();
2167 
2168  // And every processor had better agree about which point we're
2169  // looking for
2170 #ifndef NDEBUG
2171  this->comm().verify(p);
2172 #endif // NDEBUG
2173 
2174  // Get a reference to the mesh object associated with the system object that calls this function
2175  const MeshBase &mesh = this->get_mesh();
2176 
2177  // Use an existing PointLocator or create a new one
2178  AutoPtr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2179  PointLocatorBase& locator = *locator_ptr;
2180 
2181  if (!insist_on_success)
2182  locator.enable_out_of_mesh_mode();
2183 
2184  // Get a pointer to the element that contains P
2185  const Elem *e = locator(p);
2186 
2187  Tensor hess_u;
2188 
2189  if (e && e->processor_id() == this->processor_id())
2190  hess_u = point_hessian(var, p, *e);
2191 
2192  // If I have an element containing p, then let's let everyone know
2193  processor_id_type lowest_owner =
2194  (e && (e->processor_id() == this->processor_id())) ?
2195  this->processor_id() : this->n_processors();
2196  this->comm().min(lowest_owner);
2197 
2198  // Everybody should get their value from a processor that was able
2199  // to compute it.
2200  // If nobody admits owning the point, we may have a problem.
2201  if (lowest_owner != this->n_processors())
2202  this->comm().broadcast(hess_u, lowest_owner);
2203  else
2204  libmesh_assert(!insist_on_success);
2205 
2206  return hess_u;
2207 }
Tensor libMesh::System::point_hessian ( unsigned int  var,
const Point p,
const Elem e 
) 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 2209 of file system.C.

References libMesh::TypeTensor< T >::add_scaled(), libMesh::FEGenericBase< T >::build(), libMesh::Elem::contains_point(), libMesh::System::current_solution(), libMesh::Elem::dim(), libMesh::dof_map, libMesh::System::get_dof_map(), libMesh::FEInterface::inverse_map(), libMesh::libmesh_assert(), libMesh::ParallelObject::processor_id(), and libMesh::DofObject::processor_id().

2210 {
2211  libmesh_assert_equal_to (e.processor_id(), this->processor_id());
2212 
2213  // Ensuring that the given point is really in the element is an
2214  // expensive assert, but as long as debugging is turned on we might
2215  // as well try to catch a particularly nasty potential error
2216  libmesh_assert (e.contains_point(p));
2217 
2218  // Get the dof map to get the proper indices for our computation
2219  const DofMap& dof_map = this->get_dof_map();
2220 
2221  // Need dof_indices for phi[i][j]
2222  std::vector<dof_id_type> dof_indices;
2223 
2224  // Fill in the dof_indices for our element
2225  dof_map.dof_indices (&e, dof_indices, var);
2226 
2227  // Get the no of dofs assciated with this point
2228  const unsigned int num_dofs = libmesh_cast_int<unsigned int>
2229  (dof_indices.size());
2230 
2231  FEType fe_type = dof_map.variable_type(var);
2232 
2233  // Build a FE again so we can calculate u(p)
2234  AutoPtr<FEBase> fe (FEBase::build(e.dim(), fe_type));
2235 
2236  // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h
2237  // Build a vector of point co-ordinates to send to reinit
2238  std::vector<Point> coor(1, FEInterface::inverse_map(e.dim(), fe_type, &e, p));
2239 
2240  // Get the values of the shape function derivatives
2241  const std::vector<std::vector<RealTensor> >& d2phi = fe->get_d2phi();
2242 
2243  // Reinitialize the element and compute the shape function values at coor
2244  fe->reinit (&e, &coor);
2245 
2246  // Get ready to accumulate a hessian
2247  Tensor hess_u;
2248 
2249  for (unsigned int l=0; l<num_dofs; l++)
2250  {
2251  hess_u.add_scaled (d2phi[l][0], this->current_solution (dof_indices[l]));
2252  }
2253 
2254  return hess_u;
2255 }
Number libMesh::System::point_value ( unsigned int  var,
const Point p,
const bool  insist_on_success = true 
) 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.

Note that 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 . 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 1966 of file system.C.

References libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::PointLocatorBase::enable_out_of_mesh_mode(), libMesh::System::get_mesh(), libMesh::libmesh_assert(), mesh, libMesh::Parallel::Communicator::min(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), libMesh::MeshBase::sub_point_locator(), and libMesh::Parallel::Communicator::verify().

1967 {
1968  // This function must be called on every processor; there's no
1969  // telling where in the partition p falls.
1970  parallel_object_only();
1971 
1972  // And every processor had better agree about which point we're
1973  // looking for
1974 #ifndef NDEBUG
1975  this->comm().verify(p);
1976 #endif // NDEBUG
1977 
1978  // Get a reference to the mesh object associated with the system object that calls this function
1979  const MeshBase &mesh = this->get_mesh();
1980 
1981  // Use an existing PointLocator or create a new one
1982  AutoPtr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
1983  PointLocatorBase& locator = *locator_ptr;
1984 
1985  if (!insist_on_success)
1986  locator.enable_out_of_mesh_mode();
1987 
1988  // Get a pointer to the element that contains P
1989  const Elem *e = locator(p);
1990 
1991  Number u = 0;
1992 
1993  if (e && e->processor_id() == this->processor_id())
1994  u = point_value(var, p, *e);
1995 
1996  // If I have an element containing p, then let's let everyone know
1997  processor_id_type lowest_owner =
1998  (e && (e->processor_id() == this->processor_id())) ?
1999  this->processor_id() : this->n_processors();
2000  this->comm().min(lowest_owner);
2001 
2002  // Everybody should get their value from a processor that was able
2003  // to compute it.
2004  // If nobody admits owning the point, we have a problem.
2005  if (lowest_owner != this->n_processors())
2006  this->comm().broadcast(u, lowest_owner);
2007  else
2008  libmesh_assert(!insist_on_success);
2009 
2010  return u;
2011 }
Number libMesh::System::point_value ( unsigned int  var,
const Point p,
const Elem e 
) const
inherited

Returns the value of the solution variable var at the physical point p contained in local Elem e

This version of point_value can be run in serial, but assumes e is in the local mesh partition.

Definition at line 2013 of file system.C.

References libMesh::FEGenericBase< T >::build(), libMesh::Elem::contains_point(), libMesh::System::current_solution(), libMesh::Elem::dim(), libMesh::dof_map, libMesh::System::get_dof_map(), libMesh::FEInterface::inverse_map(), libMesh::libmesh_assert(), libMesh::ParallelObject::processor_id(), and libMesh::DofObject::processor_id().

2014 {
2015  libmesh_assert_equal_to (e.processor_id(), this->processor_id());
2016 
2017  // Ensuring that the given point is really in the element is an
2018  // expensive assert, but as long as debugging is turned on we might
2019  // as well try to catch a particularly nasty potential error
2020  libmesh_assert (e.contains_point(p));
2021 
2022  // Get the dof map to get the proper indices for our computation
2023  const DofMap& dof_map = this->get_dof_map();
2024 
2025  // Need dof_indices for phi[i][j]
2026  std::vector<dof_id_type> dof_indices;
2027 
2028  // Fill in the dof_indices for our element
2029  dof_map.dof_indices (&e, dof_indices, var);
2030 
2031  // Get the no of dofs assciated with this point
2032  const unsigned int num_dofs = libmesh_cast_int<unsigned int>
2033  (dof_indices.size());
2034 
2035  FEType fe_type = dof_map.variable_type(var);
2036 
2037  // Build a FE so we can calculate u(p)
2038  AutoPtr<FEBase> fe (FEBase::build(e.dim(), fe_type));
2039 
2040  // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h
2041  // Build a vector of point co-ordinates to send to reinit
2042  std::vector<Point> coor(1, FEInterface::inverse_map(e.dim(), fe_type, &e, p));
2043 
2044  // Get the shape function values
2045  const std::vector<std::vector<Real> >& phi = fe->get_phi();
2046 
2047  // Reinitialize the element and compute the shape function values at coor
2048  fe->reinit (&e, &coor);
2049 
2050  // Get ready to accumulate a value
2051  Number u = 0;
2052 
2053  for (unsigned int l=0; l<num_dofs; l++)
2054  {
2055  u += phi[l][0]*this->current_solution (dof_indices[l]);
2056  }
2057 
2058  return u;
2059 }
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.

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

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

Definition at line 88 of file reference_counter.C.

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

89 {
91 }
void libMesh::ReferenceCounter::print_info ( std::ostream &  out = libMesh::out)
staticinherited

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

Definition at line 88 of file reference_counter.C.

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

89 {
91 }
virtual void libMesh::RBEIMConstruction::print_info ( )
virtual

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

Reimplemented from libMesh::RBConstruction.

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

Print the current parameters.

virtual void libMesh::RBEIMConstruction::process_parameters_file ( const std::string &  parameters_filename)
virtual

Read parameters in from file and set up this system accordingly.

Reimplemented from libMesh::RBConstruction.

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

Definition at line 98 of file parallel_object.h.

References libMesh::ParallelObject::_communicator, and libMesh::Parallel::Communicator::rank().

Referenced by libMesh::MetisPartitioner::_do_partition(), libMesh::EquationSystems::_read_impl(), libMesh::SerialMesh::active_local_elements_begin(), libMesh::ParallelMesh::active_local_elements_begin(), libMesh::SerialMesh::active_local_elements_end(), libMesh::ParallelMesh::active_local_elements_end(), libMesh::SerialMesh::active_local_subdomain_elements_begin(), libMesh::ParallelMesh::active_local_subdomain_elements_begin(), libMesh::SerialMesh::active_local_subdomain_elements_end(), libMesh::ParallelMesh::active_local_subdomain_elements_end(), libMesh::SerialMesh::active_not_local_elements_begin(), libMesh::ParallelMesh::active_not_local_elements_begin(), libMesh::SerialMesh::active_not_local_elements_end(), libMesh::ParallelMesh::active_not_local_elements_end(), libMesh::ParallelMesh::add_elem(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::ParallelMesh::add_node(), libMesh::UnstructuredMesh::all_second_order(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::ParmetisPartitioner::build_graph(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::DofMap::build_sparsity(), libMesh::ParallelMesh::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::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_Helper::create(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DofMap::end_dof(), libMesh::DofMap::end_old_dof(), libMesh::EnsightIO::EnsightIO(), 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::MeshBase::get_info(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), 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::MeshFunction::gradient(), libMesh::MeshFunction::hessian(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_discontinuous(), libMesh::ExodusII_IO_Helper::initialize_element_variables(), libMesh::ExodusII_IO_Helper::initialize_global_variables(), libMesh::ExodusII_IO_Helper::initialize_nodal_variables(), libMesh::SparsityPattern::Build::join(), libMesh::DofMap::last_dof(), libMesh::MeshTools::libmesh_assert_valid_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_procids< Node >(), libMesh::SerialMesh::local_elements_begin(), libMesh::ParallelMesh::local_elements_begin(), libMesh::SerialMesh::local_elements_end(), libMesh::ParallelMesh::local_elements_end(), libMesh::SerialMesh::local_level_elements_begin(), libMesh::ParallelMesh::local_level_elements_begin(), libMesh::SerialMesh::local_level_elements_end(), libMesh::ParallelMesh::local_level_elements_end(), libMesh::SerialMesh::local_nodes_begin(), libMesh::ParallelMesh::local_nodes_begin(), libMesh::SerialMesh::local_nodes_end(), libMesh::ParallelMesh::local_nodes_end(), libMesh::SerialMesh::local_not_level_elements_begin(), libMesh::ParallelMesh::local_not_level_elements_begin(), libMesh::SerialMesh::local_not_level_elements_end(), libMesh::ParallelMesh::local_not_level_elements_end(), libMesh::MeshRefinement::make_coarsening_compatible(), 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::SerialMesh::not_local_elements_begin(), libMesh::ParallelMesh::not_local_elements_begin(), libMesh::SerialMesh::not_local_elements_end(), libMesh::ParallelMesh::not_local_elements_end(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SparsityPattern::Build::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::MeshFunction::operator()(), libMesh::ParallelMesh::ParallelMesh(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::System::project_vector(), 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::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::UnstructuredMesh::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs(), 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::MeshData::read_xdr(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::BoundaryInfo::sync(), libMesh::MeshTools::total_weight(), libMesh::ParallelMesh::update_parallel_id_counts(), libMesh::MeshTools::weight(), libMesh::ExodusII_IO::write(), libMesh::CheckpointIO::write(), libMesh::XdrIO::write(), libMesh::UnstructuredMesh::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_elements(), libMesh::ExodusII_IO_Helper::write_elements_discontinuous(), 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::ExodusII_IO_Helper::write_nodal_coordinates_discontinuous(), 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::ExodusII_IO_Helper::write_nodesets(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs(), 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_sidesets(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), and libMesh::ExodusII_IO_Helper::write_timestep().

99  { return libmesh_cast_int<processor_id_type>(_communicator.rank()); }
void libMesh::System::project_solution ( FunctionBase< Number > *  f,
FunctionBase< Gradient > *  g = NULL 
) const
inherited

Projects arbitrary functions onto the current solution. 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.

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

Definition at line 470 of file system_projection.C.

References libMesh::System::_dof_map, libMesh::System::current_local_solution, libMesh::System::project_vector(), and libMesh::System::solution.

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

472 {
473  this->project_vector(*solution, f, g);
474 
475  solution->localize(*current_local_solution, _dof_map->get_send_list());
476 }
void libMesh::System::project_solution ( FEMFunctionBase< Number > *  f,
FEMFunctionBase< Gradient > *  g = NULL 
) const
inherited

Projects arbitrary functions onto the current solution. 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.

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

Definition at line 483 of file system_projection.C.

References libMesh::System::_dof_map, libMesh::System::current_local_solution, libMesh::System::project_vector(), and libMesh::System::solution.

485 {
486  this->project_vector(*solution, f, g);
487 
488  solution->localize(*current_local_solution, _dof_map->get_send_list());
489 }
void libMesh::System::project_solution ( Number   fptrconst Point &p,const Parameters &parameters,const std::string &sys_name,const std::string &unknown_name,
Gradient   gptrconst Point &p,const Parameters &parameters,const std::string &sys_name,const std::string &unknown_name,
const Parameters parameters 
) const
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.

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

Definition at line 450 of file system_projection.C.

References libMesh::System::project_solution().

459 {
460  WrappedFunction<Number> f(*this, fptr, &parameters);
461  WrappedFunction<Gradient> g(*this, gptr, &parameters);
462  this->project_solution(&f, &g);
463 }
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 763 of file system.h.

References libMesh::System::_solution_projection.

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

764  { return _solution_projection; }
void libMesh::System::project_vector ( NumericVector< Number > &  new_vector,
FunctionBase< Number > *  f,
FunctionBase< Gradient > *  g = NULL 
) const
inherited

Projects arbitrary functions onto a vector of degree of freedom values for the current system. 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.

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

Definition at line 516 of file system_projection.C.

References libMesh::NumericVector< T >::close(), libMesh::dof_map, libMesh::DofMap::enforce_constraints_exactly(), libMesh::FEType::family, libMesh::System::get_dof_map(), libMesh::System::get_equation_systems(), libMesh::System::get_mesh(), libMesh::System::n_components(), libMesh::ParallelObject::n_processors(), libMesh::System::n_vars(), libMesh::Threads::parallel_for(), libMesh::ParallelObject::processor_id(), libMeshEnums::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), libMesh::NumericVector< T >::set(), libMesh::START_LOG(), libMesh::STOP_LOG(), libMesh::System::time, libMesh::Variable::type(), libMesh::System::variable(), and libMesh::System::variable_scalar_number().

Referenced by libMesh::System::project_solution(), libMesh::System::project_vector(), and libMesh::System::restrict_vectors().

519 {
520  START_LOG ("project_vector()", "System");
521 
523  (ConstElemRange (this->get_mesh().active_local_elements_begin(),
524  this->get_mesh().active_local_elements_end() ),
525  ProjectSolution(*this, f, g,
526  this->get_equation_systems().parameters,
527  new_vector)
528  );
529 
530  // Also, load values into the SCALAR dofs
531  // Note: We assume that all SCALAR dofs are on the
532  // processor with highest ID
533  if(this->processor_id() == (this->n_processors()-1))
534  {
535  // We get different scalars as different
536  // components from a new-style f functor.
537  DenseVector<Number> fout(this->n_components());
538  bool filled_fout = false;
539 
540  const DofMap& dof_map = this->get_dof_map();
541  for (unsigned int var=0; var<this->n_vars(); var++)
542  if(this->variable(var).type().family == SCALAR)
543  {
544  if (!filled_fout)
545  {
546  (*f) (Point(), this->time, fout);
547  filled_fout = true;
548  }
549 
550  std::vector<dof_id_type> SCALAR_indices;
551  dof_map.SCALAR_dof_indices (SCALAR_indices, var);
552  const unsigned int n_SCALAR_dofs =
553  libmesh_cast_int<unsigned int>(SCALAR_indices.size());
554 
555  for (unsigned int i=0; i<n_SCALAR_dofs; i++)
556  {
557  const dof_id_type global_index = SCALAR_indices[i];
558  const unsigned int component_index =
559  this->variable_scalar_number(var,i);
560  new_vector.set(global_index, fout(component_index));
561  }
562  }
563  }
564 
565  new_vector.close();
566 
567 #ifdef LIBMESH_ENABLE_CONSTRAINTS
568  this->get_dof_map().enforce_constraints_exactly(*this, &new_vector);
569 #endif
570 
571  STOP_LOG("project_vector()", "System");
572 }
void libMesh::System::project_vector ( NumericVector< Number > &  new_vector,
FEMFunctionBase< Number > *  f,
FEMFunctionBase< Gradient > *  g = NULL 
) const
inherited

Projects arbitrary functions onto a vector of degree of freedom values for the current system. 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.

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

Definition at line 579 of file system_projection.C.

References libMesh::MeshBase::active_local_elements_begin(), libMesh::NumericVector< T >::close(), libMesh::FEMFunctionBase< Output >::component(), libMesh::dof_map, libMesh::DofMap::enforce_constraints_exactly(), libMesh::FEType::family, libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::ParallelObject::n_processors(), libMesh::System::n_vars(), libMesh::Threads::parallel_for(), libMesh::FEMContext::pre_fe_reinit(), libMesh::ParallelObject::processor_id(), libMeshEnums::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), libMesh::NumericVector< T >::set(), libMesh::START_LOG(), libMesh::STOP_LOG(), libMesh::System::time, libMesh::Variable::type(), libMesh::System::variable(), and libMesh::System::variable_scalar_number().

582 {
583  START_LOG ("project_fem_vector()", "System");
584 
586  (ConstElemRange (this->get_mesh().active_local_elements_begin(),
587  this->get_mesh().active_local_elements_end() ),
588  ProjectFEMSolution(*this, f, g, new_vector)
589  );
590 
591  // Also, load values into the SCALAR dofs
592  // Note: We assume that all SCALAR dofs are on the
593  // processor with highest ID
594  if(this->processor_id() == (this->n_processors()-1))
595  {
596  // FIXME: Do we want to first check for SCALAR vars before building this? [PB]
597  FEMContext context( *this );
598 
599  const DofMap& dof_map = this->get_dof_map();
600  for (unsigned int var=0; var<this->n_vars(); var++)
601  if(this->variable(var).type().family == SCALAR)
602  {
603  // FIXME: We reinit with an arbitrary element in case the user
604  // doesn't override FEMFunctionBase::component. Is there
605  // any use case we're missing? [PB]
606  Elem *el = const_cast<Elem *>(*(this->get_mesh().active_local_elements_begin()));
607  context.pre_fe_reinit( *this, el );
608 
609  std::vector<dof_id_type> SCALAR_indices;
610  dof_map.SCALAR_dof_indices (SCALAR_indices, var);
611  const unsigned int n_SCALAR_dofs =
612  libmesh_cast_int<unsigned int>(SCALAR_indices.size());
613 
614  for (unsigned int i=0; i<n_SCALAR_dofs; i++)
615  {
616  const dof_id_type global_index = SCALAR_indices[i];
617  const unsigned int component_index =
618  this->variable_scalar_number(var,i);
619 
620  new_vector.set(global_index, f->component(context, component_index, Point(), this->time));
621  }
622  }
623  }
624 
625  new_vector.close();
626 
627 #ifdef LIBMESH_ENABLE_CONSTRAINTS
628  this->get_dof_map().enforce_constraints_exactly(*this, &new_vector);
629 #endif
630 
631  STOP_LOG("project_fem_vector()", "System");
632 }
void libMesh::System::project_vector ( Number   fptrconst Point &p,const Parameters &parameters,const std::string &sys_name,const std::string &unknown_name,
Gradient   gptrconst Point &p,const Parameters &parameters,const std::string &sys_name,const std::string &unknown_name,
const Parameters parameters,
NumericVector< Number > &  new_vector 
) const
inherited

Projects arbitrary functions onto a vector of degree of freedom values for the current system. 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.

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

Definition at line 496 of file system_projection.C.

References libMesh::System::project_vector().

506 {
507  WrappedFunction<Number> f(*this, fptr, &parameters);
508  WrappedFunction<Gradient> g(*this, gptr, &parameters);
509  this->project_vector(new_vector, &f, &g);
510 }
void libMesh::System::project_vector ( NumericVector< Number > &  vector) const
protectedinherited

Projects the vector defined on the old mesh onto the new mesh.

Definition at line 255 of file system_projection.C.

References libMesh::NumericVector< T >::clone(), and libMesh::System::project_vector().

256 {
257  // Create a copy of the vector, which currently
258  // contains the old data.
259  AutoPtr<NumericVector<Number> >
260  old_vector (vector.clone());
261 
262  // Project the old vector to the new vector
263  this->project_vector (*old_vector, vector);
264 }
void libMesh::System::project_vector ( const NumericVector< Number > &  old_v,
NumericVector< Number > &  new_v 
) const
protectedinherited

Projects the vector defined on the old mesh onto the new mesh. The original vector is unchanged and the new vector is passed through the second argument.

This method projects the vector via L2 projections or nodal interpolations on each element.

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

References libMesh::NumericVector< T >::build(), libMesh::NumericVector< T >::clear(), libMesh::NumericVector< T >::close(), libMesh::ParallelObject::comm(), libMesh::dof_map, libMesh::DofMap::enforce_constraints_exactly(), libMesh::err, libMesh::FEType::family, libMesh::AutoPtr< Tp >::get(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMeshEnums::GHOSTED, libMesh::NumericVector< T >::init(), libMesh::libmesh_assert(), libMesh::NumericVector< T >::local_size(), libMesh::NumericVector< T >::localize(), libMesh::System::n_dofs(), libMesh::System::n_local_dofs(), libMesh::ParallelObject::n_processors(), libMesh::System::n_vars(), libMeshEnums::PARALLEL, libMesh::Threads::parallel_for(), libMesh::Threads::parallel_reduce(), libMesh::ParallelObject::processor_id(), libMeshEnums::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), libMesh::BuildProjectionList::send_list, libMeshEnums::SERIAL, libMesh::NumericVector< T >::set(), libMesh::NumericVector< T >::size(), libMesh::START_LOG(), libMesh::STOP_LOG(), libMesh::Variable::type(), libMesh::NumericVector< T >::type(), libMesh::BuildProjectionList::unique(), and libMesh::System::variable().

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

Prolong vectors after the mesh has refined

Definition at line 371 of file system.C.

References libMesh::System::restrict_vectors().

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

372 {
373 #ifdef LIBMESH_ENABLE_AMR
374  // Currently project_vector handles both restriction and prolongation
375  this->restrict_vectors();
376 #endif
377 }
void libMesh::ImplicitSystem::qoi_parameter_hessian ( const QoISet qoi_indices,
const ParameterVector parameters,
SensitivityData hessian 
)
virtualinherited

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

Reimplemented from libMesh::System.

Definition at line 1114 of file implicit_system.C.

References libMesh::SensitivityData::allocate_hessian_data(), libMesh::QoISet::has_index(), libMesh::Real, libMesh::SensitivityData::second_derivative(), libMesh::ParameterVector::size(), and libMesh::TOLERANCE.

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

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

References libMesh::SensitivityData::allocate_data(), libMesh::ParameterVector::deep_copy(), libMesh::QoISet::has_index(), libMesh::Real, libMesh::ParameterVector::size(), libMesh::TOLERANCE, and libMesh::ParameterVector::value_copy().

918 {
919  // We currently get partial derivatives via finite differencing
920  const Real delta_p = TOLERANCE;
921 
922  // We'll use a single temporary vector for matrix-vector-vector products
923  AutoPtr<NumericVector<Number> > tempvec = this->solution->zero_clone();
924 
925  const unsigned int Np = libmesh_cast_int<unsigned int>
926  (parameters.size());
927  const unsigned int Nq = libmesh_cast_int<unsigned int>
928  (qoi.size());
929 
930  // For each quantity of interest q, the parameter sensitivity
931  // Hessian is defined as q''_{kl} = {d^2 q}/{d p_k d p_l}.
932  // Given a vector of parameter perturbation weights w_l, this
933  // function evaluates the hessian-vector product sum_l(q''_{kl}*w_l)
934  //
935  // We calculate it from values and partial derivatives of the
936  // quantity of interest function Q, solution u, adjoint solution z,
937  // parameter sensitivity adjoint solutions z^l, and residual R, as:
938  //
939  // sum_l(q''_{kl}*w_l) =
940  // sum_l(w_l * Q''_{kl}) + Q''_{uk}(u)*(sum_l(w_l u'_l)) -
941  // R'_k(u, sum_l(w_l*z^l)) - R'_{uk}(u,z)*(sum_l(w_l u'_l) -
942  // sum_l(w_l*R''_{kl}(u,z))
943  //
944  // See the adjoints model document for more details.
945 
946  // We first do an adjoint solve to get z for each quantity of
947  // interest
948  // if we havent already or dont have an initial condition for the adjoint
949  if (!this->is_adjoint_already_solved())
950  {
951  this->adjoint_solve(qoi_indices);
952  }
953 
954  // Get ready to fill in senstivities:
955  sensitivities.allocate_data(qoi_indices, *this, parameters);
956 
957  // We can't solve for all the solution sensitivities u'_l or for all
958  // of the parameter sensitivity adjoint solutions z^l without
959  // requiring O(Nq*Np) linear solves. So we'll solve directly for their
960  // weighted sum - this is just O(Nq) solves.
961 
962  // First solve for sum_l(w_l u'_l).
963  this->weighted_sensitivity_solve(parameters, vector);
964 
965  // Then solve for sum_l(w_l z^l).
966  this->weighted_sensitivity_adjoint_solve(parameters, vector, qoi_indices);
967 
968  for (unsigned int k=0; k != Np; ++k)
969  {
970  // We approximate sum_l(w_l * Q''_{kl}) with a central
971  // differencing pertubation:
972  // sum_l(w_l * Q''_{kl}) ~=
973  // (Q(p + dp*w_l*e_l + dp*e_k) - Q(p - dp*w_l*e_l + dp*e_k) -
974  // Q(p + dp*w_l*e_l - dp*e_k) + Q(p - dp*w_l*e_l - dp*e_k))/(4*dp^2)
975 
976  // The sum(w_l*R''_kl) term requires the same sort of pertubation,
977  // and so we subtract it in at the same time:
978  // sum_l(w_l * R''_{kl}) ~=
979  // (R(p + dp*w_l*e_l + dp*e_k) - R(p - dp*w_l*e_l + dp*e_k) -
980  // R(p + dp*w_l*e_l - dp*e_k) + R(p - dp*w_l*e_l - dp*e_k))/(4*dp^2)
981 
982  ParameterVector oldparameters, parameterperturbation;
983  parameters.deep_copy(oldparameters);
984  vector.deep_copy(parameterperturbation);
985  parameterperturbation *= delta_p;
986  parameters += parameterperturbation;
987 
988  Number old_parameter = *parameters[k];
989 
990  *parameters[k] = old_parameter + delta_p;
991  this->assemble_qoi(qoi_indices);
992  this->assembly(true, false);
993  this->rhs->close();
994  std::vector<Number> partial2q_term = this->qoi;
995  std::vector<Number> partial2R_term(this->qoi.size());
996  for (unsigned int i=0; i != Nq; ++i)
997  if (qoi_indices.has_index(i))
998  partial2R_term[i] = this->rhs->dot(this->get_adjoint_solution(i));
999 
1000  *parameters[k] = old_parameter - delta_p;
1001  this->assemble_qoi(qoi_indices);
1002  this->assembly(true, false);
1003  this->rhs->close();
1004  for (unsigned int i=0; i != Nq; ++i)
1005  if (qoi_indices.has_index(i))
1006  {
1007  partial2q_term[i] -= this->qoi[i];
1008  partial2R_term[i] -= this->rhs->dot(this->get_adjoint_solution(i));
1009  }
1010 
1011  oldparameters.value_copy(parameters);
1012  parameterperturbation *= -1.0;
1013  parameters += parameterperturbation;
1014 
1015  // Re-center old_parameter, which may be affected by vector
1016  old_parameter = *parameters[k];
1017 
1018  *parameters[k] = old_parameter + delta_p;
1019  this->assemble_qoi(qoi_indices);
1020  this->assembly(true, false);
1021  this->rhs->close();
1022  for (unsigned int i=0; i != Nq; ++i)
1023  if (qoi_indices.has_index(i))
1024  {
1025  partial2q_term[i] -= this->qoi[i];
1026  partial2R_term[i] -= this->rhs->dot(this->get_adjoint_solution(i));
1027  }
1028 
1029  *parameters[k] = old_parameter - delta_p;
1030  this->assemble_qoi(qoi_indices);
1031  this->assembly(true, false);
1032  this->rhs->