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

Manages consistently variables, degrees of freedom, and coefficient vectors. More...

#include <system.h>

Inheritance diagram for libMesh::System:
[legend]

Classes

class  Assembly
 Abstract base class to be used for system assembly. More...
 
class  Constraint
 Abstract base class to be used for system constraints. More...
 
class  Initialization
 Abstract base class to be used for system initialization. More...
 
class  QOI
 Abstract base class to be used for quantities of interest. More...
 
class  QOIDerivative
 Abstract base class to be used for derivatives of quantities of interest. More...
 

Public Types

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

Public Member Functions

 System (EquationSystems &es, const std::string &name, const unsigned int number)
 Constructor. More...
 
 System (const System &)=delete
 Special functions. More...
 
Systemoperator= (const System &)=delete
 
 System (System &&)=default
 
Systemoperator= (System &&)=delete
 
virtual ~System ()
 
sys_typesystem ()
 
virtual void clear ()
 Clear all the data structures associated with the system. More...
 
void init ()
 Initializes degrees of freedom on the current mesh. More...
 
virtual void reinit ()
 Reinitializes degrees of freedom and other required data on the current mesh. More...
 
virtual void reinit_constraints ()
 Reinitializes the constraints for this system. More...
 
virtual void reinit_mesh ()
 Reinitializes the system with a new mesh. More...
 
bool is_initialized ()
 
virtual void update ()
 Update the local values to reflect the solution on neighboring processors. More...
 
virtual void assemble ()
 Prepares matrix and _dof_map for matrix assembly. More...
 
virtual void assemble_qoi (const QoISet &qoi_indices=QoISet())
 Calls user qoi function. More...
 
virtual void assemble_qoi_derivative (const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true)
 Calls user qoi derivative function. More...
 
virtual void assemble_residual_derivatives (const ParameterVector &parameters)
 Calls residual parameter derivative function. More...
 
virtual void restrict_solve_to (const SystemSubset *subset, const SubsetSolveMode subset_solve_mode=SUBSET_ZERO)
 After calling this method, any solve will be restricted to the given subdomain. More...
 
virtual void solve ()
 Solves the system. More...
 
virtual std::pair< unsigned int, Realsensitivity_solve (const ParameterVector &parameters)
 Solves the sensitivity system, for the provided parameters. More...
 
virtual std::pair< unsigned int, Realweighted_sensitivity_solve (const ParameterVector &parameters, const ParameterVector &weights)
 Assembles & solves the linear system(s) (dR/du)*u_w = sum(w_p*-dR/dp), for those parameters p contained within parameters weighted by the values w_p found within weights. More...
 
virtual std::pair< unsigned int, Realadjoint_solve (const QoISet &qoi_indices=QoISet())
 Solves the adjoint system, for the specified qoi indices, or for every qoi if qoi_indices is nullptr. More...
 
virtual std::pair< unsigned int, Realweighted_sensitivity_adjoint_solve (const ParameterVector &parameters, const ParameterVector &weights, const QoISet &qoi_indices=QoISet())
 Assembles & solves the linear system(s) (dR/du)^T*z_w = sum(w_p*(d^2q/dudp - d^2R/dudp*z)), for those parameters p contained within parameters, weighted by the values w_p found within weights. More...
 
bool is_adjoint_already_solved () const
 Accessor for the adjoint_already_solved boolean. More...
 
void set_adjoint_already_solved (bool setting)
 Setter for the adjoint_already_solved boolean. More...
 
virtual void qoi_parameter_sensitivity (const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
 Solves for the derivative of each of the system's quantities of interest q in qoi[qoi_indices] with respect to each parameter in parameters, placing the result for qoi i and parameter j into sensitivities[i][j]. More...
 
virtual void adjoint_qoi_parameter_sensitivity (const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
 Solves for parameter sensitivities using the adjoint method. More...
 
virtual void forward_qoi_parameter_sensitivity (const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
 Solves for parameter sensitivities using the forward method. More...
 
virtual void qoi_parameter_hessian (const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &hessian)
 For each of the system's quantities of interest q in qoi[qoi_indices], and for a vector of parameters p, the parameter sensitivity Hessian H_ij is defined as H_ij = (d^2 q)/(d p_i d p_j) This Hessian is the output of this method, where for each q_i, H_jk is stored in hessian.second_derivative(i,j,k). More...
 
virtual void qoi_parameter_hessian_vector_product (const QoISet &qoi_indices, const ParameterVector &parameters, const ParameterVector &vector, SensitivityData &product)
 For each of the system's quantities of interest q in qoi[qoi_indices], and for a vector of parameters p, the parameter sensitivity Hessian H_ij is defined as H_ij = (d^2 q)/(d p_i d p_j) The Hessian-vector product, for a vector v_k in parameter space, is S_j = H_jk v_k This product is the output of this method, where for each q_i, S_j is stored in sensitivities[i][j]. More...
 
virtual bool compare (const System &other_system, const Real threshold, const bool verbose) const
 
const std::string & name () const
 
virtual std::string system_type () const
 
void project_solution (FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr) const
 Projects arbitrary functions onto the current solution. More...
 
void project_solution (FEMFunctionBase< Number > *f, FEMFunctionBase< Gradient > *g=nullptr) const
 Projects arbitrary functions onto the current solution. More...
 
void project_solution (ValueFunctionPointer fptr, GradientFunctionPointer gptr, const Parameters &parameters) const
 This method projects an arbitrary function onto the solution via L2 projections and nodal interpolations on each element. More...
 
void project_vector (NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
 Projects arbitrary functions onto a vector of degree of freedom values for the current system. More...
 
void project_vector (NumericVector< Number > &new_vector, FEMFunctionBase< Number > *f, FEMFunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
 Projects arbitrary functions onto a vector of degree of freedom values for the current system. More...
 
void project_vector (ValueFunctionPointer fptr, GradientFunctionPointer gptr, const Parameters &parameters, NumericVector< Number > &new_vector, int is_adjoint=-1) const
 Projects arbitrary functions onto a vector of degree of freedom values for the current system. More...
 
void boundary_project_solution (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr)
 Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system. More...
 
void boundary_project_solution (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, ValueFunctionPointer fptr, GradientFunctionPointer gptr, const Parameters &parameters)
 Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system. More...
 
void boundary_project_vector (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
 Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system. More...
 
void boundary_project_vector (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, ValueFunctionPointer fptr, GradientFunctionPointer gptr, const Parameters &parameters, NumericVector< Number > &new_vector, int is_adjoint=-1) const
 Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system. More...
 
unsigned int number () const
 
void update_global_solution (std::vector< Number > &global_soln) const
 Fill the input vector global_soln so that it contains the global solution on all processors. More...
 
void update_global_solution (std::vector< Number > &global_soln, const processor_id_type dest_proc) const
 Fill the input vector global_soln so that it contains the global solution on processor dest_proc. More...
 
const MeshBaseget_mesh () const
 
MeshBaseget_mesh ()
 
const DofMapget_dof_map () const
 
DofMapget_dof_map ()
 
const EquationSystemsget_equation_systems () const
 
EquationSystemsget_equation_systems ()
 
bool active () const
 
void activate ()
 Activates the system. More...
 
void deactivate ()
 Deactivates the system. More...
 
void set_basic_system_only ()
 Sets the system to be "basic only": i.e. More...
 
vectors_iterator vectors_begin ()
 Beginning of vectors container. More...
 
const_vectors_iterator vectors_begin () const
 Beginning of vectors container. More...
 
vectors_iterator vectors_end ()
 End of vectors container. More...
 
const_vectors_iterator vectors_end () const
 End of vectors container. More...
 
NumericVector< Number > & add_vector (std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
 Adds the additional vector vec_name to this system. More...
 
void remove_vector (std::string_view vec_name)
 Removes the additional vector vec_name from this system. More...
 
bool & project_solution_on_reinit (void)
 Tells the System whether or not to project the solution vector onto new grids when the system is reinitialized. More...
 
bool have_vector (std::string_view vec_name) const
 
const NumericVector< Number > * request_vector (std::string_view vec_name) const
 
NumericVector< Number > * request_vector (std::string_view vec_name)
 
const NumericVector< Number > * request_vector (const unsigned int vec_num) const
 
NumericVector< Number > * request_vector (const unsigned int vec_num)
 
const NumericVector< Number > & get_vector (std::string_view vec_name) const
 
NumericVector< Number > & get_vector (std::string_view vec_name)
 
const NumericVector< Number > & get_vector (const unsigned int vec_num) const
 
NumericVector< Number > & get_vector (const unsigned int vec_num)
 
const std::string & vector_name (const unsigned int vec_num) const
 
const std::string & vector_name (const NumericVector< Number > &vec_reference) const
 
void set_vector_as_adjoint (const std::string &vec_name, int qoi_num)
 Allows one to set the QoI index controlling whether the vector identified by vec_name represents a solution from the adjoint (qoi_num >= 0) or primal (qoi_num == -1) space. More...
 
int vector_is_adjoint (std::string_view vec_name) const
 
void set_vector_preservation (const std::string &vec_name, bool preserve)
 Allows one to set the boolean controlling whether the vector identified by vec_name should be "preserved": projected to new meshes, saved, etc. More...
 
bool vector_preservation (std::string_view vec_name) const
 
NumericVector< Number > & add_adjoint_solution (unsigned int i=0)
 
NumericVector< Number > & get_adjoint_solution (unsigned int i=0)
 
const NumericVector< Number > & get_adjoint_solution (unsigned int i=0) const
 
NumericVector< Number > & add_sensitivity_solution (unsigned int i=0)
 
NumericVector< Number > & get_sensitivity_solution (unsigned int i=0)
 
const NumericVector< Number > & get_sensitivity_solution (unsigned int i=0) const
 
NumericVector< Number > & add_weighted_sensitivity_adjoint_solution (unsigned int i=0)
 
NumericVector< Number > & get_weighted_sensitivity_adjoint_solution (unsigned int i=0)
 
const NumericVector< Number > & get_weighted_sensitivity_adjoint_solution (unsigned int i=0) const
 
NumericVector< Number > & add_weighted_sensitivity_solution ()
 
NumericVector< Number > & get_weighted_sensitivity_solution ()
 
const NumericVector< Number > & get_weighted_sensitivity_solution () const
 
NumericVector< Number > & add_adjoint_rhs (unsigned int i=0)
 
NumericVector< Number > & get_adjoint_rhs (unsigned int i=0)
 
const NumericVector< Number > & get_adjoint_rhs (unsigned int i=0) const
 
NumericVector< Number > & add_sensitivity_rhs (unsigned int i=0)
 
NumericVector< Number > & get_sensitivity_rhs (unsigned int i=0)
 
const NumericVector< Number > & get_sensitivity_rhs (unsigned int i=0) const
 
unsigned int n_vectors () const
 
unsigned int n_matrices () const
 
unsigned int n_vars () const
 
unsigned int n_variable_groups () const
 
unsigned int n_components () const
 
dof_id_type n_dofs () const
 
dof_id_type n_active_dofs () const
 
dof_id_type n_constrained_dofs () const
 
dof_id_type n_local_constrained_dofs () const
 
dof_id_type n_local_dofs () const
 
unsigned int add_variable (std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
 Adds the variable var to the list of variables for this system. More...
 
unsigned int add_variable (std::string_view var, const Order order=FIRST, const FEFamily=LAGRANGE, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
 Adds the variable var to the list of variables for this system. More...
 
unsigned int add_variables (const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
 Adds the variable var to the list of variables for this system. More...
 
unsigned int add_variables (const std::vector< std::string > &vars, const Order order=FIRST, const FEFamily=LAGRANGE, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
 Adds the variable var to the list of variables for this system. More...
 
const Variablevariable (unsigned int var) const
 Return a constant reference to Variable var. More...
 
const VariableGroupvariable_group (unsigned int vg) const
 Return a constant reference to VariableGroup vg. More...
 
bool has_variable (std::string_view var) const
 
const std::string & variable_name (const unsigned int i) const
 
unsigned int variable_number (std::string_view var) const
 
void get_all_variable_numbers (std::vector< unsigned int > &all_variable_numbers) const
 Fills all_variable_numbers with all the variable numbers for the variables that have been added to this system. More...
 
unsigned int variable_scalar_number (std::string_view var, unsigned int component) const
 
unsigned int variable_scalar_number (unsigned int var_num, unsigned int component) const
 
const FETypevariable_type (const unsigned int i) const
 
const FETypevariable_type (std::string_view var) const
 
bool identify_variable_groups () const
 
void identify_variable_groups (const bool)
 Toggle automatic VariableGroup identification. More...
 
Real calculate_norm (const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=nullptr) const
 
Real calculate_norm (const NumericVector< Number > &v, const SystemNorm &norm, std::set< unsigned int > *skip_dimensions=nullptr) const
 
void read_header (Xdr &io, std::string_view version, const bool read_header=true, const bool read_additional_data=true, const bool read_legacy_format=false)
 Reads the basic data header for this System. More...
 
void read_legacy_data (Xdr &io, const bool read_additional_data=true)
 Reads additional data, namely vectors, for this System. More...
 
template<typename ValType >
void read_serialized_data (Xdr &io, const bool read_additional_data=true)
 Reads additional data, namely vectors, for this System. More...
 
void read_serialized_data (Xdr &io, const bool read_additional_data=true)
 Non-templated version for backward compatibility. More...
 
template<typename InValType >
std::size_t read_serialized_vectors (Xdr &io, const std::vector< NumericVector< Number > *> &vectors) const
 Read a number of identically distributed vectors. More...
 
std::size_t read_serialized_vectors (Xdr &io, const std::vector< NumericVector< Number > *> &vectors) const
 Non-templated version for backward compatibility. More...
 
template<typename InValType >
void read_parallel_data (Xdr &io, const bool read_additional_data)
 Reads additional data, namely vectors, for this System. More...
 
void read_parallel_data (Xdr &io, const bool read_additional_data)
 Non-templated version for backward compatibility. More...
 
void write_header (Xdr &io, std::string_view version, const bool write_additional_data) const
 Writes the basic data header for this System. More...
 
void write_serialized_data (Xdr &io, const bool write_additional_data=true) const
 Writes additional data, namely vectors, for this System. More...
 
std::size_t write_serialized_vectors (Xdr &io, const std::vector< const NumericVector< Number > *> &vectors) const
 Serialize & write a number of identically distributed vectors. More...
 
void write_parallel_data (Xdr &io, const bool write_additional_data) const
 Writes additional data, namely vectors, for this System. More...
 
std::string get_info () const
 
void attach_init_function (void fptr(EquationSystems &es, const std::string &name))
 Register a user function to use in initializing the system. More...
 
void attach_init_object (Initialization &init)
 Register a user class to use to initialize the system. More...
 
void attach_assemble_function (void fptr(EquationSystems &es, const std::string &name))
 Register a user function to use in assembling the system matrix and RHS. More...
 
void attach_assemble_object (Assembly &assemble)
 Register a user object to use in assembling the system matrix and RHS. More...
 
void attach_constraint_function (void fptr(EquationSystems &es, const std::string &name))
 Register a user function for imposing constraints. More...
 
void attach_constraint_object (Constraint &constrain)
 Register a user object for imposing constraints. More...
 
bool has_constraint_object () const
 
Constraintget_constraint_object ()
 Return the user object for imposing constraints. More...
 
void attach_QOI_function (void fptr(EquationSystems &es, const std::string &name, const QoISet &qoi_indices))
 Register a user function for evaluating the quantities of interest, whose values should be placed in System::qoi. More...
 
void attach_QOI_object (QOI &qoi)
 Register a user object for evaluating the quantities of interest, whose values should be placed in System::qoi. More...
 
void attach_QOI_derivative (void fptr(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints))
 Register a user function for evaluating derivatives of a quantity of interest with respect to test functions, whose values should be placed in System::rhs. More...
 
void attach_QOI_derivative_object (QOIDerivative &qoi_derivative)
 Register a user object for evaluating derivatives of a quantity of interest with respect to test functions, whose values should be placed in System::rhs. More...
 
virtual void user_initialization ()
 Calls user's attached initialization function, or is overridden by the user in derived classes. More...
 
virtual void user_assembly ()
 Calls user's attached assembly function, or is overridden by the user in derived classes. More...
 
virtual void user_constrain ()
 Calls user's attached constraint function, or is overridden by the user in derived classes. More...
 
virtual void user_QOI (const QoISet &qoi_indices)
 Calls user's attached quantity of interest function, or is overridden by the user in derived classes. More...
 
virtual void user_QOI_derivative (const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true)
 Calls user's attached quantity of interest derivative function, or is overridden by the user in derived classes. More...
 
virtual void re_update ()
 Re-update the local values when the mesh has changed. More...
 
virtual void restrict_vectors ()
 Restrict vectors after the mesh has coarsened. More...
 
virtual void prolong_vectors ()
 Prolong vectors after the mesh has refined. More...
 
virtual void disable_cache ()
 Avoids use of any cached data that might affect any solve result. More...
 
Number current_solution (const dof_id_type global_dof_number) const
 
unsigned int n_qois () const
 Number of currently active quantities of interest. More...
 
void init_qois (unsigned int n_qois)
 Accessors for qoi and qoi_error_estimates vectors. More...
 
void set_qoi (unsigned int qoi_index, Number qoi_value)
 
Number get_qoi_value (unsigned int qoi_index) const
 
void set_qoi (std::vector< Number > new_qoi)
 
std::vector< Numberget_qoi_values () const
 Returns a copy of qoi, not a reference. More...
 
void set_qoi_error_estimate (unsigned int qoi_index, Number qoi_error_estimate)
 
Number get_qoi_error_estimate_value (unsigned int qoi_index) const
 
Number point_value (unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
 
Number point_value (unsigned int var, const Point &p, const Elem &e, const NumericVector< Number > *sol=nullptr) const
 
Number point_value (unsigned int var, const Point &p, const Elem *e) const
 Calls the version of point_value() which takes a reference. More...
 
Number point_value (unsigned int var, const Point &p, const NumericVector< Number > *sol) const
 Calls the parallel version of point_value(). More...
 
Gradient point_gradient (unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
 
Gradient point_gradient (unsigned int var, const Point &p, const Elem &e, const NumericVector< Number > *sol=nullptr) const
 
Gradient point_gradient (unsigned int var, const Point &p, const Elem *e) const
 Calls the version of point_gradient() which takes a reference. More...
 
Gradient point_gradient (unsigned int var, const Point &p, const NumericVector< Number > *sol) const
 Calls the parallel version of point_gradient(). More...
 
Tensor point_hessian (unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
 
Tensor point_hessian (unsigned int var, const Point &p, const Elem &e, const NumericVector< Number > *sol=nullptr) const
 
Tensor point_hessian (unsigned int var, const Point &p, const Elem *e) const
 Calls the version of point_hessian() which takes a reference. More...
 
Tensor point_hessian (unsigned int var, const Point &p, const NumericVector< Number > *sol) const
 Calls the parallel version of point_hessian(). More...
 
void local_dof_indices (const unsigned int var, std::set< dof_id_type > &var_indices) const
 Fills the std::set with the degrees of freedom on the local processor corresponding the the variable number passed in. More...
 
void zero_variable (NumericVector< Number > &v, unsigned int var_num) const
 Zeroes all dofs in v that correspond to variable number var_num. More...
 
bool get_project_with_constraints ()
 Setter and getter functions for project_with_constraints boolean. More...
 
void set_project_with_constraints (bool _project_with_constraints)
 
bool & hide_output ()
 
void projection_matrix (SparseMatrix< Number > &proj_mat) const
 This method creates a projection matrix which corresponds to the operation of project_vector between old and new solution spaces. More...
 
SparseMatrix< Number > & add_matrix (std::string_view mat_name, ParallelType type=PARALLEL, MatrixBuildType mat_build_type=MatrixBuildType::AUTOMATIC)
 Adds the additional matrix mat_name to this system. More...
 
template<template< typename > class>
SparseMatrix< Number > & add_matrix (std::string_view mat_name, ParallelType=PARALLEL)
 Adds the additional matrix mat_name to this system. More...
 
void remove_matrix (std::string_view mat_name)
 Removes the additional matrix mat_name from this system. More...
 
bool have_matrix (std::string_view mat_name) const
 
const SparseMatrix< Number > * request_matrix (std::string_view mat_name) const
 
SparseMatrix< Number > * request_matrix (std::string_view mat_name)
 
const SparseMatrix< Number > & get_matrix (std::string_view mat_name) const
 
SparseMatrix< Number > & get_matrix (std::string_view mat_name)
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static std::string get_info ()
 Gets a string containing the reference information. More...
 
static void print_info (std::ostream &out_stream=libMesh::out)
 Prints the reference information, by default to libMesh::out. More...
 
static unsigned int n_objects ()
 Prints the number of outstanding (created, but not yet destroyed) objects. More...
 
static void enable_print_counter_info ()
 Methods to enable/disable the reference counter output from print_info() More...
 
static void disable_print_counter_info ()
 

Public Attributes

bool assemble_before_solve
 Flag which tells the system to whether or not to call the user assembly function during each call to solve(). More...
 
bool use_fixed_solution
 A boolean to be set to true by systems using elem_fixed_solution, for optional use by e.g. More...
 
int extra_quadrature_order
 A member int that can be employed to indicate increased or reduced quadrature order. More...
 
std::unique_ptr< NumericVector< Number > > solution
 Data structure to hold solution values. More...
 
std::unique_ptr< NumericVector< Number > > current_local_solution
 All the values I need to compute my contribution to the simulation at hand. More...
 
Real time
 For time-dependent problems, this is the time t at the beginning of the current timestep. More...
 

Protected Types

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

Protected Member Functions

virtual void init_data ()
 Initializes the data for the system. More...
 
virtual void add_matrices ()
 Insertion point for adding matrices in derived classes before init_matrices() is called. More...
 
virtual void init_matrices ()
 Initializes the matrices associated with this system. More...
 
bool can_add_matrices () const
 
void project_vector (NumericVector< Number > &, int is_adjoint=-1) const
 Projects the vector defined on the old mesh onto the new mesh. More...
 
void project_vector (const NumericVector< Number > &, NumericVector< Number > &, int is_adjoint=-1) const
 Projects the vector defined on the old mesh onto the new mesh. More...
 
void solve_for_unconstrained_dofs (NumericVector< Number > &, int is_adjoint=-1) const
 
void increment_constructor_count (const std::string &name) noexcept
 Increments the construction counter. More...
 
void increment_destructor_count (const std::string &name) noexcept
 Increments the destruction counter. More...
 

Protected Attributes

const Parallel::Communicator_communicator
 

Static Protected Attributes

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

Private Member Functions

void late_matrix_init (SparseMatrix< Number > &mat, ParallelType type)
 Helper function to keep DofMap forward declarable in system.h. More...
 
Real discrete_var_norm (const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type) const
 Finds the discrete norm for the entries in the vector corresponding to Dofs associated with var. More...
 
template<typename iterator_type , typename InValType >
std::size_t read_serialized_blocked_dof_objects (const dof_id_type n_objects, const iterator_type begin, const iterator_type end, const InValType dummy, Xdr &io, const std::vector< NumericVector< Number > *> &vecs, const unsigned int var_to_read=libMesh::invalid_uint) const
 Reads an input vector from the stream io and assigns the values to a set of DofObjects. More...
 
unsigned int read_SCALAR_dofs (const unsigned int var, Xdr &io, NumericVector< Number > *vec) const
 Reads the SCALAR dofs from the stream io and assigns the values to the appropriate entries of vec. More...
 
template<typename InValType >
numeric_index_type read_serialized_vector (Xdr &io, NumericVector< Number > *vec)
 Reads a vector for this System. More...
 
numeric_index_type read_serialized_vector (Xdr &io, NumericVector< Number > &vec)
 Non-templated version for backward compatibility. More...
 
template<typename iterator_type >
std::size_t write_serialized_blocked_dof_objects (const std::vector< const NumericVector< Number > *> &vecs, const dof_id_type n_objects, const iterator_type begin, const iterator_type end, Xdr &io, const unsigned int var_to_write=libMesh::invalid_uint) const
 Writes an output vector to the stream io for a set of DofObjects. More...
 
unsigned int write_SCALAR_dofs (const NumericVector< Number > &vec, const unsigned int var, Xdr &io) const
 Writes the SCALAR dofs associated with var to the stream io. More...
 
dof_id_type write_serialized_vector (Xdr &io, const NumericVector< Number > &vec) const
 Writes a vector for this System. More...
 

Private Attributes

std::vector< Numberqoi
 Values of the quantities of interest. More...
 
std::vector< Numberqoi_error_estimates
 Vector to hold error estimates for qois, either from a steady state calculation, or from a single unsteady solver timestep. More...
 
void(* _init_system_function )(EquationSystems &es, const std::string &name)
 Function that initializes the system. More...
 
Initialization_init_system_object
 Object that initializes the system. More...
 
void(* _assemble_system_function )(EquationSystems &es, const std::string &name)
 Function that assembles the system. More...
 
Assembly_assemble_system_object
 Object that assembles the system. More...
 
void(* _constrain_system_function )(EquationSystems &es, const std::string &name)
 Function to impose constraints. More...
 
Constraint_constrain_system_object
 Object that constrains the system. More...
 
void(* _qoi_evaluate_function )(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
 Function to evaluate quantity of interest. More...
 
QOI_qoi_evaluate_object
 Object to compute quantities of interest. More...
 
void(* _qoi_evaluate_derivative_function )(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
 Function to evaluate quantity of interest derivative. More...
 
QOIDerivative_qoi_evaluate_derivative_object
 Object to compute derivatives of quantities of interest. More...
 
std::unique_ptr< DofMap_dof_map
 Data structure describing the relationship between nodes, variables, etc... More...
 
EquationSystems_equation_systems
 Constant reference to the EquationSystems object used for the simulation. More...
 
MeshBase_mesh
 Constant reference to the mesh data structure used for the simulation. More...
 
const std::string _sys_name
 A name associated with this system. More...
 
const unsigned int _sys_number
 The number associated with this system. More...
 
std::vector< Variable_variables
 The Variable in this System. More...
 
std::vector< VariableGroup_variable_groups
 The VariableGroup in this System. More...
 
std::map< std::string, unsigned int, std::less<> > _variable_numbers
 The variable numbers corresponding to user-specified names, useful for name-based lookups. More...
 
bool _active
 Flag stating if the system is active or not. More...
 
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
 Some systems need an arbitrary number of vectors. More...
 
std::map< std::string, bool, std::less<> > _vector_projections
 Holds true if a vector by that name should be projected onto a changed grid, false if it should be zeroed. More...
 
std::map< std::string, int, std::less<> > _vector_is_adjoint
 Holds non-negative if a vector by that name should be projected using adjoint constraints/BCs, -1 if primal. More...
 
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
 Some systems need an arbitrary number of matrices. More...
 
std::map< std::string, ParallelType, std::less<> > _matrix_types
 Holds the types of the matrices. More...
 
bool _matrices_initialized
 false when additional matrices being added require initialization, true otherwise. More...
 
bool _solution_projection
 Holds true if the solution vector should be projected onto a changed grid, false if it should be zeroed. More...
 
bool _basic_system_only
 Holds true if the components of more advanced system types (e.g. More...
 
bool _is_initialized
 true when additional vectors and variables do not require immediate initialization, false otherwise. More...
 
bool _identify_variable_groups
 true when VariableGroup structures should be automatically identified, false otherwise. More...
 
unsigned int _additional_data_written
 This flag is used only when reading in a system from file. More...
 
std::vector< unsigned int_written_var_indices
 This vector is used only when reading in a system from file. More...
 
bool adjoint_already_solved
 Has the adjoint problem already been solved? If the user sets adjoint_already_solved to true, we won't waste time solving it again. More...
 
bool _hide_output
 Are we allowed to write this system to file? If _hide_output is true, then EquationSystems::write will ignore this system. More...
 
bool project_with_constraints
 Do we want to apply constraints while projecting vectors ? More...
 

Detailed Description

Manages consistently variables, degrees of freedom, and coefficient vectors.

This is the base class for classes which contain information related to any physical process that might be simulated. Such information may range from the actual solution values to algorithmic flags that may be used to control the numerical methods employed. In general, use an EquationSystems object to handle one or more of the children of this class.

Especially, this class manages the variables of the differential equation, the coefficient vectors and the DofMap, and ensures that these are consistent. It provides storage for the solution. Furthermore, (de-) serialization functionality is provided.

Author
Benjamin S. Kirk
Date
2003-2004

Definition at line 96 of file system.h.

Member Typedef Documentation

◆ const_matrices_iterator

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

Definition at line 1810 of file system.h.

◆ const_vectors_iterator

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

Definition at line 767 of file system.h.

◆ Counts

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

Data structure to log the information.

The log is identified by the class name.

Definition at line 119 of file reference_counter.h.

◆ GradientFunctionPointer

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

Definition at line 542 of file system.h.

◆ matrices_iterator

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

Matrix iterator typedefs.

Definition at line 1809 of file system.h.

◆ sys_type

The type of system.

Definition at line 248 of file system.h.

◆ ValueFunctionPointer

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

Projects arbitrary functions onto the current solution.

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

Definition at line 538 of file system.h.

◆ vectors_iterator

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

Vector iterator typedefs.

Definition at line 766 of file system.h.

Constructor & Destructor Documentation

◆ System() [1/3]

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

Constructor.

Optionally initializes required data structures.

Definition at line 63 of file system.C.

Referenced by HeatSystem::init_context().

65  :
66 
67  ParallelObject (es),
68  assemble_before_solve (true),
69  use_fixed_solution (false),
73  time (0.),
74  qoi (0),
76  _init_system_function (nullptr),
77  _init_system_object (nullptr),
78  _assemble_system_function (nullptr),
79  _assemble_system_object (nullptr),
81  _constrain_system_object (nullptr),
82  _qoi_evaluate_function (nullptr),
83  _qoi_evaluate_object (nullptr),
86  _dof_map (std::make_unique<DofMap>(number_in, es.get_mesh())),
87  _equation_systems (es),
88  _mesh (es.get_mesh()),
89  _sys_name (name_in),
90  _sys_number (number_in),
91  _active (true),
92  _matrices_initialized (false),
93  _solution_projection (true),
94  _basic_system_only (false),
95  _is_initialized (false),
98  adjoint_already_solved (false),
99  _hide_output (false),
101 {
102 }
ParallelObject(const Parallel::Communicator &comm_in)
Constructor.
Real time
For time-dependent problems, this is the time t at the beginning of the current timestep.
Definition: system.h:1595
Assembly * _assemble_system_object
Object that assembles the system.
Definition: system.h:2070
bool _basic_system_only
Holds true if the components of more advanced system types (e.g.
Definition: system.h:2204
bool _is_initialized
true when additional vectors and variables do not require immediate initialization, false otherwise.
Definition: system.h:2210
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Function to impose constraints.
Definition: system.h:2075
int extra_quadrature_order
A member int that can be employed to indicate increased or reduced quadrature order.
Definition: system.h:1558
const unsigned int _sys_number
The number associated with this system.
Definition: system.h:2135
Constraint * _constrain_system_object
Object that constrains the system.
Definition: system.h:2081
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:2113
const Parallel::Communicator & comm() const
bool _active
Flag stating if the system is active or not.
Definition: system.h:2156
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Function to evaluate quantity of interest.
Definition: system.h:2086
bool adjoint_already_solved
Has the adjoint problem already been solved? If the user sets adjoint_already_solved to true...
Definition: system.h:2242
QOIDerivative * _qoi_evaluate_derivative_object
Object to compute derivatives of quantities of interest.
Definition: system.h:2107
std::vector< Number > qoi
Values of the quantities of interest.
Definition: system.h:1611
bool use_fixed_solution
A boolean to be set to true by systems using elem_fixed_solution, for optional use by e...
Definition: system.h:1543
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1573
bool project_with_constraints
Do we want to apply constraints while projecting vectors ?
Definition: system.h:2253
QOI * _qoi_evaluate_object
Object to compute quantities of interest.
Definition: system.h:2093
Initialization * _init_system_object
Object that initializes the system.
Definition: system.h:2059
bool _hide_output
Are we allowed to write this system to file? If _hide_output is true, then EquationSystems::write wil...
Definition: system.h:2248
unsigned int _additional_data_written
This flag is used only when reading in a system from file.
Definition: system.h:2223
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Function that initializes the system.
Definition: system.h:2053
std::vector< Number > qoi_error_estimates
Vector to hold error estimates for qois, either from a steady state calculation, or from a single uns...
Definition: system.h:1619
static std::unique_ptr< NumericVector< Number > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
Builds a NumericVector on the processors in communicator comm using the linear solver package specifi...
bool _solution_projection
Holds true if the solution vector should be projected onto a changed grid, false if it should be zero...
Definition: system.h:2198
EquationSystems & _equation_systems
Constant reference to the EquationSystems object used for the simulation.
Definition: system.h:2119
bool _identify_variable_groups
true when VariableGroup structures should be automatically identified, false otherwise.
Definition: system.h:2216
bool _matrices_initialized
false when additional matrices being added require initialization, true otherwise.
Definition: system.h:2191
const std::string _sys_name
A name associated with this system.
Definition: system.h:2130
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Definition: system.h:1585
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Function that assembles the system.
Definition: system.h:2064
bool assemble_before_solve
Flag which tells the system to whether or not to call the user assembly function during each call to ...
Definition: system.h:1527
MeshBase & _mesh
Constant reference to the mesh data structure used for the simulation.
Definition: system.h:2125
void(* _qoi_evaluate_derivative_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
Function to evaluate quantity of interest derivative.
Definition: system.h:2098

◆ System() [2/3]

libMesh::System::System ( const System )
delete

Special functions.

  • The copy constructor and assignment operator were previously declared as private libmesh_not_implemented() functions, this is the C++11 way of achieving the same effect.
  • The System holds references to Mesh and EquationSystems objects, therefore it can't be default move-assigned.
  • This class can be default move constructed.
  • The destructor dies with an error in dbg/devel modes if libMesh::closed()

◆ System() [3/3]

libMesh::System::System ( System &&  )
default

◆ ~System()

libMesh::System::~System ( )
virtual

Definition at line 106 of file system.C.

References libMesh::closed().

107 {
108  libmesh_exceptionless_assert (!libMesh::closed());
109 }
bool closed()
Checks that the library has been closed.
Definition: libmesh.C:273

Member Function Documentation

◆ activate()

void libMesh::System::activate ( )
inline

Activates the system.

Only active systems are solved.

Definition at line 2317 of file system.h.

References _active.

2318 {
2319  _active = true;
2320 }
bool _active
Flag stating if the system is active or not.
Definition: system.h:2156

◆ active()

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

Definition at line 2309 of file system.h.

References _active.

2310 {
2311  return _active;
2312 }
bool _active
Flag stating if the system is active or not.
Definition: system.h:2156

◆ add_adjoint_rhs()

NumericVector< Number > & libMesh::System::add_adjoint_rhs ( unsigned int  i = 0)
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 1245 of file system.C.

References add_vector().

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

1246 {
1247  std::ostringstream adjoint_rhs_name;
1248  adjoint_rhs_name << "adjoint_rhs" << i;
1249 
1250  return this->add_vector(adjoint_rhs_name.str(), false);
1251 }
NumericVector< Number > & add_vector(std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Adds the additional vector vec_name to this system.
Definition: system.C:751

◆ add_adjoint_solution()

NumericVector< Number > & libMesh::System::add_adjoint_solution ( unsigned int  i = 0)
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 1181 of file system.C.

References add_vector(), and set_vector_as_adjoint().

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

1182 {
1183  std::ostringstream adjoint_name;
1184  adjoint_name << "adjoint_solution" << i;
1185 
1186  NumericVector<Number> & returnval = this->add_vector(adjoint_name.str());
1187  this->set_vector_as_adjoint(adjoint_name.str(), i);
1188  return returnval;
1189 }
void set_vector_as_adjoint(const std::string &vec_name, int qoi_num)
Allows one to set the QoI index controlling whether the vector identified by vec_name represents a so...
Definition: system.C:1107
NumericVector< Number > & add_vector(std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Adds the additional vector vec_name to this system.
Definition: system.C:751
template class LIBMESH_EXPORT NumericVector< Number >

◆ add_matrices()

virtual void libMesh::System::add_matrices ( )
inlineprotectedvirtual

Insertion point for adding matrices in derived classes before init_matrices() is called.

Reimplemented in libMesh::EigenSystem, and libMesh::ImplicitSystem.

Definition at line 1903 of file system.h.

Referenced by libMesh::ImplicitSystem::add_matrices(), libMesh::EigenSystem::add_matrices(), and init_data().

1903 {}

◆ add_matrix() [1/2]

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

Adds the additional matrix mat_name to this system.

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

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

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

Definition at line 985 of file system.C.

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

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

988 {
989  parallel_object_only();
990 
991  libmesh_assert(this->comm().verify(std::string(mat_name)));
992  libmesh_assert(this->comm().verify(int(type)));
993  libmesh_assert(this->comm().verify(int(mat_build_type)));
994 
995  // Return the matrix if it is already there.
996  auto it = this->_matrices.find(mat_name);
997  if (it != this->_matrices.end())
998  return *it->second;
999 
1000  // Otherwise build the matrix to return.
1001  auto pr = _matrices.emplace
1002  (mat_name,
1003  SparseMatrix<Number>::build(this->comm(),
1005  mat_build_type));
1006 
1007  _matrix_types.emplace(mat_name, type);
1008 
1009  SparseMatrix<Number> & mat = *(pr.first->second);
1010 
1011  // Initialize it first if we've already initialized the others.
1012  this->late_matrix_init(mat, type);
1013 
1014  return mat;
1015 }
const Parallel::Communicator & comm() const
static std::unique_ptr< SparseMatrix< Number > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package(), const MatrixBuildType matrix_build_type=MatrixBuildType::AUTOMATIC)
Builds a SparseMatrix<T> using the linear solver package specified by solver_package.
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
Some systems need an arbitrary number of matrices.
Definition: system.h:2181
SolverPackage default_solver_package()
Definition: libmesh.C:1050
libmesh_assert(ctx)
std::map< std::string, ParallelType, std::less<> > _matrix_types
Holds the types of the matrices.
Definition: system.h:2186
template class LIBMESH_EXPORT SparseMatrix< Number >
void late_matrix_init(SparseMatrix< Number > &mat, ParallelType type)
Helper function to keep DofMap forward declarable in system.h.
Definition: system.C:1019

◆ add_matrix() [2/2]

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

Adds the additional matrix mat_name to this system.

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

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

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

Definition at line 2602 of file system.h.

References _matrices, _matrix_types, and late_matrix_init().

2604 {
2605  // Return the matrix if it is already there.
2606  auto it = this->_matrices.find(mat_name);
2607  if (it != this->_matrices.end())
2608  return *it->second;
2609 
2610  // Otherwise build the matrix to return.
2611  auto pr = _matrices.emplace(mat_name, std::make_unique<MatrixType<Number>>(this->comm()));
2612  _matrix_types.emplace(mat_name, type);
2613 
2614  SparseMatrix<Number> & mat = *(pr.first->second);
2615 
2616  // Initialize it first if we've already initialized the others.
2617  this->late_matrix_init(mat, type);
2618 
2619  return mat;
2620 }
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
Some systems need an arbitrary number of matrices.
Definition: system.h:2181
std::map< std::string, ParallelType, std::less<> > _matrix_types
Holds the types of the matrices.
Definition: system.h:2186
template class LIBMESH_EXPORT SparseMatrix< Number >
void late_matrix_init(SparseMatrix< Number > &mat, ParallelType type)
Helper function to keep DofMap forward declarable in system.h.
Definition: system.C:1019

◆ add_sensitivity_rhs()

NumericVector< Number > & libMesh::System::add_sensitivity_rhs ( unsigned int  i = 0)
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 1275 of file system.C.

References add_vector().

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

1276 {
1277  std::ostringstream sensitivity_rhs_name;
1278  sensitivity_rhs_name << "sensitivity_rhs" << i;
1279 
1280  return this->add_vector(sensitivity_rhs_name.str(), false);
1281 }
NumericVector< Number > & add_vector(std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Adds the additional vector vec_name to this system.
Definition: system.C:751

◆ add_sensitivity_solution()

NumericVector< Number > & libMesh::System::add_sensitivity_solution ( unsigned int  i = 0)
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 1130 of file system.C.

References add_vector().

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

1131 {
1132  std::ostringstream sensitivity_name;
1133  sensitivity_name << "sensitivity_solution" << i;
1134 
1135  return this->add_vector(sensitivity_name.str());
1136 }
NumericVector< Number > & add_vector(std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Adds the additional vector vec_name to this system.
Definition: system.C:751

◆ add_variable() [1/2]

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

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

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

Returns
The index number for the new variable.

Definition at line 1305 of file system.C.

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

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

1308 {
1309  parallel_object_only(); // Not strictly needed, but the only safe way to keep in sync
1310 
1311  libmesh_assert(this->comm().verify(std::string(var)));
1312  libmesh_assert(this->comm().verify(type));
1313  libmesh_assert(this->comm().verify((active_subdomains == nullptr)));
1314 
1315  if (active_subdomains)
1316  libmesh_assert(this->comm().verify(active_subdomains->size()));
1317 
1318  // Make sure the variable isn't there already
1319  // or if it is, that it's the type we want
1320  for (auto v : make_range(this->n_vars()))
1321  if (this->variable_name(v) == var)
1322  {
1323  if (this->variable_type(v) == type)
1324  {
1325  // Check whether the existing variable's active subdomains also matches
1326  // the incoming variable's active subdomains. If they don't match, then
1327  // either it is an error by the user or the user is trying to change the
1328  // subdomain restriction after the variable has already been added, which
1329  // is not supported.
1330  const Variable & existing_var = this->variable(v);
1331 
1332  // Check whether active_subdomains is not provided/empty and the existing_var is implicitly_active()
1333  bool check1 = (!active_subdomains || active_subdomains->empty()) && existing_var.implicitly_active();
1334 
1335  // Check if the provided active_subdomains is equal to the existing_var's active_subdomains
1336  bool check2 = (active_subdomains && (*active_subdomains == existing_var.active_subdomains()));
1337 
1338  // If either of these checks passed, then we already have this variable
1339  if (check1 || check2)
1340  return _variables[v].number();
1341  }
1342 
1343  libmesh_error_msg("ERROR: incompatible variable " << var << " has already been added for this system!");
1344  }
1345 
1346  libmesh_assert(!this->is_initialized());
1347 
1348  if (this->n_variable_groups())
1349  {
1350  // Optimize for VariableGroups here - if the user is adding multiple
1351  // variables of the same FEType and subdomain restriction, catch
1352  // that here and add them as members of the same VariableGroup.
1353  //
1354  // start by setting this flag to whatever the user has requested
1355  // and then consider the conditions which should negate it.
1356  bool should_be_in_vg = this->identify_variable_groups();
1357 
1358  VariableGroup & vg(_variable_groups.back());
1359 
1360  // get a pointer to their subdomain restriction, if any.
1361  const std::set<subdomain_id_type> * const
1362  their_active_subdomains (vg.implicitly_active() ?
1363  nullptr : &vg.active_subdomains());
1364 
1365  // Different types?
1366  if (vg.type() != type)
1367  should_be_in_vg = false;
1368 
1369  // they are restricted, we aren't?
1370  if (their_active_subdomains &&
1371  (!active_subdomains || (active_subdomains && active_subdomains->empty())))
1372  should_be_in_vg = false;
1373 
1374  // they aren't restricted, we are?
1375  if (!their_active_subdomains && (active_subdomains && !active_subdomains->empty()))
1376  should_be_in_vg = false;
1377 
1378  if (their_active_subdomains && active_subdomains)
1379  // restricted to different sets?
1380  if (*their_active_subdomains != *active_subdomains)
1381  should_be_in_vg = false;
1382 
1383  // OK, after all that, append the variable to the vg if none of the conditions
1384  // were violated
1385  if (should_be_in_vg)
1386  {
1387  const unsigned int curr_n_vars = this->n_vars();
1388 
1389  std::string varstr(var);
1390 
1391  _variable_numbers[varstr] = curr_n_vars;
1392  vg.append (std::move(varstr));
1393  _variables.push_back(vg(vg.n_variables()-1));
1394 
1395  return curr_n_vars;
1396  }
1397  }
1398 
1399  // otherwise, fall back to adding a single variable group
1400  return this->add_variables (std::vector<std::string>(1, std::string(var)),
1401  type,
1402  active_subdomains);
1403 }
unsigned int add_variables(const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system.
Definition: system.C:1419
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2377
unsigned int n_variable_groups() const
Definition: system.h:2357
const Parallel::Communicator & comm() const
std::vector< Variable > _variables
The Variable in this System.
Definition: system.h:2140
std::vector< VariableGroup > _variable_groups
The VariableGroup in this System.
Definition: system.h:2145
bool is_initialized()
Definition: system.h:2333
libmesh_assert(ctx)
const std::string & variable_name(const unsigned int i) const
Definition: system.h:2397
bool identify_variable_groups() const
Definition: system.h:2445
const FEType & variable_type(const unsigned int i) const
Definition: system.h:2427
std::map< std::string, unsigned int, std::less<> > _variable_numbers
The variable numbers corresponding to user-specified names, useful for name-based lookups...
Definition: system.h:2151
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:134
unsigned int n_vars() const
Definition: system.h:2349

◆ add_variable() [2/2]

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

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

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

Definition at line 1407 of file system.C.

References add_variable().

1411 {
1412  return this->add_variable(var,
1413  FEType(order, family),
1414  active_subdomains);
1415 }
unsigned int add_variable(std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system.
Definition: system.C:1305

◆ add_variables() [1/2]

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

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

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

Returns
The index number for the new variable.

Definition at line 1419 of file system.C.

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

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

1422 {
1423  parallel_object_only(); // Not strictly needed, but the only safe way to keep in sync
1424 
1425  libmesh_assert(!this->is_initialized());
1426 
1427  libmesh_assert(this->comm().verify(vars.size()));
1428  libmesh_assert(this->comm().verify(type));
1429  libmesh_assert(this->comm().verify((active_subdomains == nullptr)));
1430 
1431  if (active_subdomains)
1432  libmesh_assert(this->comm().verify(active_subdomains->size()));
1433 
1434  // Make sure the variable isn't there already
1435  // or if it is, that it's the type we want
1436  for (auto ovar : vars)
1437  {
1438  libmesh_assert(this->comm().verify(ovar));
1439 
1440  for (auto v : make_range(this->n_vars()))
1441  if (this->variable_name(v) == ovar)
1442  {
1443  if (this->variable_type(v) == type)
1444  return _variables[v].number();
1445 
1446  libmesh_error_msg("ERROR: incompatible variable " << ovar << " has already been added for this system!");
1447  }
1448  }
1449 
1450  if (this->n_variable_groups())
1451  {
1452  // Optimize for VariableGroups here - if the user is adding multiple
1453  // variables of the same FEType and subdomain restriction, catch
1454  // that here and add them as members of the same VariableGroup.
1455  //
1456  // start by setting this flag to whatever the user has requested
1457  // and then consider the conditions which should negate it.
1458  bool should_be_in_vg = this->identify_variable_groups();
1459 
1460  VariableGroup & vg(_variable_groups.back());
1461 
1462  // get a pointer to their subdomain restriction, if any.
1463  const std::set<subdomain_id_type> * const
1464  their_active_subdomains (vg.implicitly_active() ?
1465  nullptr : &vg.active_subdomains());
1466 
1467  // Different types?
1468  if (vg.type() != type)
1469  should_be_in_vg = false;
1470 
1471  // they are restricted, we aren't?
1472  if (their_active_subdomains &&
1473  (!active_subdomains || (active_subdomains && active_subdomains->empty())))
1474  should_be_in_vg = false;
1475 
1476  // they aren't restricted, we are?
1477  if (!their_active_subdomains && (active_subdomains && !active_subdomains->empty()))
1478  should_be_in_vg = false;
1479 
1480  if (their_active_subdomains && active_subdomains)
1481  // restricted to different sets?
1482  if (*their_active_subdomains != *active_subdomains)
1483  should_be_in_vg = false;
1484 
1485  // If after all that none of the conditions were violated,
1486  // append the variables to the vg and we're done
1487  if (should_be_in_vg)
1488  {
1489  unsigned int curr_n_vars = this->n_vars();
1490 
1491  for (auto ovar : vars)
1492  {
1493  curr_n_vars = this->n_vars();
1494 
1495  vg.append (ovar);
1496 
1497  _variables.push_back(vg(vg.n_variables()-1));
1498  _variable_numbers[ovar] = curr_n_vars;
1499  }
1500  return curr_n_vars;
1501  }
1502  }
1503 
1504  const unsigned int curr_n_vars = this->n_vars();
1505 
1506  const unsigned int next_first_component = this->n_components();
1507 
1508  // We weren't able to add to an existing variable group, so
1509  // add a new variable group to the list
1510  _variable_groups.push_back((active_subdomains == nullptr) ?
1511  VariableGroup(this, vars, curr_n_vars,
1512  next_first_component, type) :
1513  VariableGroup(this, vars, curr_n_vars,
1514  next_first_component, type, *active_subdomains));
1515 
1516  const VariableGroup & vg (_variable_groups.back());
1517 
1518  // Add each component of the group individually
1519  for (auto v : make_range(vars.size()))
1520  {
1521  _variables.push_back (vg(v));
1522  _variable_numbers[vars[v]] = curr_n_vars+v;
1523  }
1524 
1525  libmesh_assert_equal_to ((curr_n_vars+vars.size()), this->n_vars());
1526 
1527  // BSK - Defer this now to System::init_data() so we can detect
1528  // VariableGroups 12/28/2012
1529  // // Add the variable group to the _dof_map
1530  // _dof_map->add_variable_group (vg);
1531 
1532  // Return the number of the new variable
1533  return cast_int<unsigned int>(curr_n_vars+vars.size()-1);
1534 }
unsigned int n_components() const
Definition: system.h:2365
unsigned int n_variable_groups() const
Definition: system.h:2357
const Parallel::Communicator & comm() const
std::vector< Variable > _variables
The Variable in this System.
Definition: system.h:2140
std::vector< VariableGroup > _variable_groups
The VariableGroup in this System.
Definition: system.h:2145
bool is_initialized()
Definition: system.h:2333
libmesh_assert(ctx)
const std::string & variable_name(const unsigned int i) const
Definition: system.h:2397
bool identify_variable_groups() const
Definition: system.h:2445
const FEType & variable_type(const unsigned int i) const
Definition: system.h:2427
std::map< std::string, unsigned int, std::less<> > _variable_numbers
The variable numbers corresponding to user-specified names, useful for name-based lookups...
Definition: system.h:2151
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:134
unsigned int n_vars() const
Definition: system.h:2349

◆ add_variables() [2/2]

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

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

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

Definition at line 1538 of file system.C.

References add_variables().

1542 {
1543  return this->add_variables(vars,
1544  FEType(order, family),
1545  active_subdomains);
1546 }
unsigned int add_variables(const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system.
Definition: system.C:1419

◆ add_vector()

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

Adds the additional vector vec_name to this system.

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

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

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

Definition at line 751 of file system.C.

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

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

754 {
755  parallel_object_only();
756 
757  libmesh_assert(this->comm().verify(std::string(vec_name)));
758  libmesh_assert(this->comm().verify(int(type)));
759  libmesh_assert(this->comm().verify(projections));
760 
761  // Return the vector if it is already there.
762  auto it = this->_vectors.find(vec_name);
763  if (it != this->_vectors.end())
764  {
765  // If the projection setting has *upgraded*, change it.
766  if (projections) // only do expensive lookup if needed
767  libmesh_map_find(_vector_projections, vec_name) = projections;
768 
769  NumericVector<Number> & vec = *it->second;
770 
771  // If we're in serial, our vectors are effectively SERIAL, so
772  // we'll ignore any type setting. If we're in parallel, we
773  // might have a type change to deal with.
774 
775  if (this->n_processors() > 1)
776  {
777  // If the type setting has changed in a way we can't
778  // perceive as an upgrade or a downgrade, scream.
779  libmesh_assert_equal_to(type == SERIAL,
780  vec.type() == SERIAL);
781 
782  // If the type setting has *upgraded*, change it.
783  if (type == GHOSTED && vec.type() == PARALLEL)
784  {
785  // A *really* late upgrade is expensive, but better not
786  // to risk zeroing data.
787  if (vec.initialized())
788  {
789  if (!vec.closed())
790  vec.close();
791 
792  // Ideally we'd move parallel coefficients and then
793  // add ghosted coefficients, but copy and swap is
794  // simpler. If anyone actually ever uses this case
795  // for real we can look into optimizing it.
796  auto new_vec = NumericVector<Number>::build(this->comm());
797 #ifdef LIBMESH_ENABLE_GHOSTED
798  new_vec->init (this->n_dofs(), this->n_local_dofs(),
799  _dof_map->get_send_list(), /*fast=*/false,
800  GHOSTED);
801 #else
802  libmesh_error_msg("Cannot initialize ghosted vectors when they are not enabled.");
803 #endif
804 
805  *new_vec = vec;
806  vec.swap(*new_vec);
807  }
808  else
809  vec.type() = type;
810  }
811  }
812 
813  // Any upgrades are done; we're happy here.
814  return vec;
815  }
816 
817  // Otherwise build the vector
818  auto pr = _vectors.emplace(vec_name, NumericVector<Number>::build(this->comm()));
819  auto buf = pr.first->second.get();
820  _vector_projections.emplace(vec_name, projections);
821  buf->type() = type;
822 
823  // Vectors are primal by default
824  _vector_is_adjoint.emplace(vec_name, -1);
825 
826  // Initialize it if necessary
827  if (_is_initialized)
828  {
829  if (type == GHOSTED)
830  {
831 #ifdef LIBMESH_ENABLE_GHOSTED
832  buf->init (this->n_dofs(), this->n_local_dofs(),
833  _dof_map->get_send_list(), /*fast=*/false,
834  GHOSTED);
835 #else
836  libmesh_error_msg("Cannot initialize ghosted vectors when they are not enabled.");
837 #endif
838  }
839  else
840  buf->init (this->n_dofs(), this->n_local_dofs(), false, type);
841  }
842 
843  return *buf;
844 }
bool _is_initialized
true when additional vectors and variables do not require immediate initialization, false otherwise.
Definition: system.h:2210
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:2113
const Parallel::Communicator & comm() const
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2164
dof_id_type n_local_dofs() const
Definition: system.C:150
dof_id_type n_dofs() const
Definition: system.C:113
processor_id_type n_processors() const
std::map< std::string, int, std::less<> > _vector_is_adjoint
Holds non-negative if a vector by that name should be projected using adjoint constraints/BCs, -1 if primal.
Definition: system.h:2176
libmesh_assert(ctx)
static std::unique_ptr< NumericVector< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
Builds a NumericVector on the processors in communicator comm using the linear solver package specifi...
template class LIBMESH_EXPORT NumericVector< Number >
std::map< std::string, bool, std::less<> > _vector_projections
Holds true if a vector by that name should be projected onto a changed grid, false if it should be ze...
Definition: system.h:2170

◆ add_weighted_sensitivity_adjoint_solution()

NumericVector< Number > & libMesh::System::add_weighted_sensitivity_adjoint_solution ( unsigned int  i = 0)
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 1213 of file system.C.

References add_vector(), and set_vector_as_adjoint().

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

1214 {
1215  std::ostringstream adjoint_name;
1216  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
1217 
1218  NumericVector<Number> & returnval = this->add_vector(adjoint_name.str());
1219  this->set_vector_as_adjoint(adjoint_name.str(), i);
1220  return returnval;
1221 }
void set_vector_as_adjoint(const std::string &vec_name, int qoi_num)
Allows one to set the QoI index controlling whether the vector identified by vec_name represents a so...
Definition: system.C:1107
NumericVector< Number > & add_vector(std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Adds the additional vector vec_name to this system.
Definition: system.C:751
template class LIBMESH_EXPORT NumericVector< Number >

◆ add_weighted_sensitivity_solution()

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

Definition at line 1160 of file system.C.

References add_vector().

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

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

◆ adjoint_qoi_parameter_sensitivity()

void libMesh::System::adjoint_qoi_parameter_sensitivity ( const QoISet qoi_indices,
const ParameterVector parameters,
SensitivityData sensitivities 
)
inlinevirtual

Solves for parameter sensitivities using the adjoint method.

This method is only implemented in some derived classes.

Reimplemented in libMesh::ImplicitSystem.

Definition at line 2558 of file system.h.

Referenced by qoi_parameter_sensitivity().

2561 {
2562  libmesh_not_implemented();
2563 }

◆ adjoint_solve()

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

Solves the adjoint system, for the specified qoi indices, or for every qoi if qoi_indices is nullptr.

Must be overridden in derived systems.

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

This method is only implemented in some derived classes.

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

Definition at line 2542 of file system.h.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), and libMesh::AdjointResidualErrorEstimator::estimate_error().

2543 {
2544  libmesh_not_implemented();
2545 }

◆ assemble()

void libMesh::System::assemble ( )
virtual

Prepares matrix and _dof_map for matrix assembly.

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

Reimplemented in libMesh::LinearImplicitSystem, libMesh::DifferentiableSystem, libMesh::ImplicitSystem, libMesh::FrequencySystem, and libMesh::NewmarkSystem.

Definition at line 549 of file system.C.

References user_assembly().

Referenced by libMesh::ImplicitSystem::assemble(), libMesh::EigenSystem::solve(), libMesh::CondensedEigenSystem::solve(), and libMesh::ExplicitSystem::solve().

550 {
551  // Log how long the user's assembly code takes
552  LOG_SCOPE("assemble()", "System");
553 
554  // Call the user-specified assembly function
555  this->user_assembly();
556 }
virtual void user_assembly()
Calls user&#39;s attached assembly function, or is overridden by the user in derived classes.
Definition: system.C:2259

◆ assemble_qoi()

void libMesh::System::assemble_qoi ( const QoISet qoi_indices = QoISet())
virtual

Calls user qoi function.

Can be overridden in derived classes.

Reimplemented in libMesh::FEMSystem, and libMesh::ExplicitSystem.

Definition at line 560 of file system.C.

References user_QOI().

Referenced by libMesh::ExplicitSystem::assemble_qoi().

561 {
562  // Log how long the user's assembly code takes
563  LOG_SCOPE("assemble_qoi()", "System");
564 
565  // Call the user-specified quantity of interest function
566  this->user_QOI(qoi_indices);
567 }
virtual void user_QOI(const QoISet &qoi_indices)
Calls user&#39;s attached quantity of interest function, or is overridden by the user in derived classes...
Definition: system.C:2287

◆ assemble_qoi_derivative()

void libMesh::System::assemble_qoi_derivative ( const QoISet qoi_indices = QoISet(),
bool  include_liftfunc = true,
bool  apply_constraints = true 
)
virtual

Calls user qoi derivative function.

Can be overridden in derived classes.

Reimplemented in libMesh::FEMSystem, and libMesh::ExplicitSystem.

Definition at line 571 of file system.C.

References user_QOI_derivative().

Referenced by libMesh::ExplicitSystem::assemble_qoi_derivative().

574 {
575  // Log how long the user's assembly code takes
576  LOG_SCOPE("assemble_qoi_derivative()", "System");
577 
578  // Call the user-specified quantity of interest function
579  this->user_QOI_derivative(qoi_indices, include_liftfunc,
580  apply_constraints);
581 }
virtual void user_QOI_derivative(const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true)
Calls user&#39;s attached quantity of interest derivative function, or is overridden by the user in deriv...
Definition: system.C:2301

◆ assemble_residual_derivatives()

void libMesh::System::assemble_residual_derivatives ( const ParameterVector parameters)
inlinevirtual

Calls residual parameter derivative function.

Library subclasses use finite differences by default.

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

This method is only implemented in some derived classes.

Reimplemented in libMesh::ImplicitSystem.

Definition at line 2507 of file system.h.

2508 {
2509  libmesh_not_implemented();
2510 }

◆ attach_assemble_function()

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

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

Definition at line 2109 of file system.C.

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

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

2111 {
2113 
2114  if (_assemble_system_object != nullptr)
2115  {
2116  libmesh_warning("WARNING: Cannot specify both assembly function and object!");
2117 
2118  _assemble_system_object = nullptr;
2119  }
2120 
2122 }
Assembly * _assemble_system_object
Object that assembles the system.
Definition: system.h:2070
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:80
libmesh_assert(ctx)
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Function that assembles the system.
Definition: system.h:2064

◆ attach_assemble_object()

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

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

Definition at line 2126 of file system.C.

References _assemble_system_function, and _assemble_system_object.

Referenced by main().

2127 {
2128  if (_assemble_system_function != nullptr)
2129  {
2130  libmesh_warning("WARNING: Cannot specify both assembly object and function!");
2131 
2132  _assemble_system_function = nullptr;
2133  }
2134 
2135  _assemble_system_object = &assemble_in;
2136 }
Assembly * _assemble_system_object
Object that assembles the system.
Definition: system.h:2070
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Function that assembles the system.
Definition: system.h:2064

◆ attach_constraint_function()

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

Register a user function for imposing constraints.

Definition at line 2140 of file system.C.

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

2142 {
2144 
2145  if (_constrain_system_object != nullptr)
2146  {
2147  libmesh_warning("WARNING: Cannot specify both constraint function and object!");
2148 
2149  _constrain_system_object = nullptr;
2150  }
2151 
2153 }
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Function to impose constraints.
Definition: system.h:2075
Constraint * _constrain_system_object
Object that constrains the system.
Definition: system.h:2081
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:80
libmesh_assert(ctx)

◆ attach_constraint_object()

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

Register a user object for imposing constraints.

Definition at line 2157 of file system.C.

References _constrain_system_function, and _constrain_system_object.

Referenced by DofMapTest::testConstraintLoopDetection().

2158 {
2159  if (_constrain_system_function != nullptr)
2160  {
2161  libmesh_warning("WARNING: Cannot specify both constraint object and function!");
2162 
2163  _constrain_system_function = nullptr;
2164  }
2165 
2166  _constrain_system_object = &constrain;
2167 }
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Function to impose constraints.
Definition: system.h:2075
Constraint * _constrain_system_object
Object that constrains the system.
Definition: system.h:2081

◆ attach_init_function()

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

Register a user function to use in initializing the system.

Definition at line 2078 of file system.C.

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

Referenced by main().

2080 {
2082 
2083  if (_init_system_object != nullptr)
2084  {
2085  libmesh_warning("WARNING: Cannot specify both initialization function and object!");
2086 
2087  _init_system_object = nullptr;
2088  }
2089 
2091 }
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:80
libmesh_assert(ctx)
Initialization * _init_system_object
Object that initializes the system.
Definition: system.h:2059
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Function that initializes the system.
Definition: system.h:2053

◆ attach_init_object()

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

Register a user class to use to initialize the system.

Note
This is exclusive with the attach_init_function.

Definition at line 2095 of file system.C.

References _init_system_function, and _init_system_object.

2096 {
2097  if (_init_system_function != nullptr)
2098  {
2099  libmesh_warning("WARNING: Cannot specify both initialization object and function!");
2100 
2101  _init_system_function = nullptr;
2102  }
2103 
2104  _init_system_object = &init_in;
2105 }
Initialization * _init_system_object
Object that initializes the system.
Definition: system.h:2059
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Function that initializes the system.
Definition: system.h:2053

◆ attach_QOI_derivative()

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

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

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

2216 {
2218 
2219  if (_qoi_evaluate_derivative_object != nullptr)
2220  {
2221  libmesh_warning("WARNING: Cannot specify both QOI derivative function and object!");
2222 
2224  }
2225 
2227 }
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:80
QOIDerivative * _qoi_evaluate_derivative_object
Object to compute derivatives of quantities of interest.
Definition: system.h:2107
libmesh_assert(ctx)
void(* _qoi_evaluate_derivative_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
Function to evaluate quantity of interest derivative.
Definition: system.h:2098

◆ attach_QOI_derivative_object()

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

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

Definition at line 2231 of file system.C.

References _qoi_evaluate_derivative_function, and _qoi_evaluate_derivative_object.

2232 {
2233  if (_qoi_evaluate_derivative_function != nullptr)
2234  {
2235  libmesh_warning("WARNING: Cannot specify both QOI derivative object and function!");
2236 
2238  }
2239 
2240  _qoi_evaluate_derivative_object = &qoi_derivative;
2241 }
QOIDerivative * _qoi_evaluate_derivative_object
Object to compute derivatives of quantities of interest.
Definition: system.h:2107
void(* _qoi_evaluate_derivative_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
Function to evaluate quantity of interest derivative.
Definition: system.h:2098

◆ attach_QOI_function()

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

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

Definition at line 2182 of file system.C.

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

2185 {
2187 
2188  if (_qoi_evaluate_object != nullptr)
2189  {
2190  libmesh_warning("WARNING: Cannot specify both QOI function and object!");
2191 
2192  _qoi_evaluate_object = nullptr;
2193  }
2194 
2196 }
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Function to evaluate quantity of interest.
Definition: system.h:2086
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:80
libmesh_assert(ctx)
QOI * _qoi_evaluate_object
Object to compute quantities of interest.
Definition: system.h:2093

◆ attach_QOI_object()

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

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

Definition at line 2200 of file system.C.

References _qoi_evaluate_function, and _qoi_evaluate_object.

2201 {
2202  if (_qoi_evaluate_function != nullptr)
2203  {
2204  libmesh_warning("WARNING: Cannot specify both QOI object and function!");
2205 
2206  _qoi_evaluate_function = nullptr;
2207  }
2208 
2209  _qoi_evaluate_object = &qoi_in;
2210 }
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Function to evaluate quantity of interest.
Definition: system.h:2086
QOI * _qoi_evaluate_object
Object to compute quantities of interest.
Definition: system.h:2093

◆ boundary_project_solution() [1/2]

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

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

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

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

Definition at line 1253 of file system_projection.C.

Referenced by SystemsTest::testBoundaryProjectCube().

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

◆ boundary_project_solution() [2/2]

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

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

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

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

Definition at line 1236 of file system_projection.C.

References fptr(), and gptr().

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

◆ boundary_project_vector() [1/2]

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

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

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

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

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

Definition at line 1289 of file system_projection.C.

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

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

◆ boundary_project_vector() [2/2]

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

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

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

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

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

Definition at line 1271 of file system_projection.C.

References fptr(), and gptr().

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

◆ calculate_norm() [1/2]

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

Definition at line 1672 of file system.C.

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

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

1676 {
1677  //short circuit to save time
1678  if (norm_type == DISCRETE_L1 ||
1679  norm_type == DISCRETE_L2 ||
1680  norm_type == DISCRETE_L_INF)
1681  return discrete_var_norm(v,var,norm_type);
1682 
1683  // Not a discrete norm
1684  std::vector<FEMNormType> norms(this->n_vars(), L2);
1685  std::vector<Real> weights(this->n_vars(), 0.0);
1686  norms[var] = norm_type;
1687  weights[var] = 1.0;
1688  Real val = this->calculate_norm(v, SystemNorm(norms, weights), skip_dimensions);
1689  return val;
1690 }
Real calculate_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=nullptr) const
Definition: system.C:1672
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Real discrete_var_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type) const
Finds the discrete norm for the entries in the vector corresponding to Dofs associated with var...
Definition: system.C:1653
unsigned int n_vars() const
Definition: system.h:2349

◆ calculate_norm() [2/2]

Real libMesh::System::calculate_norm ( const NumericVector< Number > &  v,
const SystemNorm norm,
std::set< unsigned int > *  skip_dimensions = nullptr 
) const
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 1694 of file system.C.

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

1697 {
1698  // This function must be run on all processors at once
1699  parallel_object_only();
1700 
1701  LOG_SCOPE ("calculate_norm()", "System");
1702 
1703  // Zero the norm before summation
1704  Real v_norm = 0.;
1705 
1706  if (norm.is_discrete())
1707  {
1708  //Check to see if all weights are 1.0 and all types are equal
1709  FEMNormType norm_type0 = norm.type(0);
1710  unsigned int check_var = 0, check_end = this->n_vars();
1711  for (; check_var != check_end; ++check_var)
1712  if ((norm.weight(check_var) != 1.0) || (norm.type(check_var) != norm_type0))
1713  break;
1714 
1715  //All weights were 1.0 so just do the full vector discrete norm
1716  if (check_var == this->n_vars())
1717  {
1718  if (norm_type0 == DISCRETE_L1)
1719  return v.l1_norm();
1720  if (norm_type0 == DISCRETE_L2)
1721  return v.l2_norm();
1722  if (norm_type0 == DISCRETE_L_INF)
1723  return v.linfty_norm();
1724  else
1725  libmesh_error_msg("Invalid norm_type0 = " << Utility::enum_to_string(norm_type0));
1726  }
1727 
1728  for (auto var : make_range(this->n_vars()))
1729  {
1730  // Skip any variables we don't need to integrate
1731  if (norm.weight(var) == 0.0)
1732  continue;
1733 
1734  v_norm += norm.weight(var) * discrete_var_norm(v, var, norm.type(var));
1735  }
1736 
1737  return v_norm;
1738  }
1739 
1740  // Localize the potentially parallel vector
1741  std::unique_ptr<NumericVector<Number>> local_v = NumericVector<Number>::build(this->comm());
1742  local_v->init(v.size(), v.local_size(), _dof_map->get_send_list(),
1743  true, GHOSTED);
1744  v.localize (*local_v, _dof_map->get_send_list());
1745 
1746  // I'm not sure how best to mix Hilbert norms on some variables (for
1747  // which we'll want to square then sum then square root) with norms
1748  // like L_inf (for which we'll just want to take an absolute value
1749  // and then sum).
1750  bool using_hilbert_norm = true,
1751  using_nonhilbert_norm = true;
1752 
1753  // Loop over all variables
1754  for (auto var : make_range(this->n_vars()))
1755  {
1756  // Skip any variables we don't need to integrate
1757  Real norm_weight_sq = norm.weight_sq(var);
1758  if (norm_weight_sq == 0.0)
1759  continue;
1760  Real norm_weight = norm.weight(var);
1761 
1762  // Check for unimplemented norms (rather than just returning 0).
1763  FEMNormType norm_type = norm.type(var);
1764  if ((norm_type==H1) ||
1765  (norm_type==H2) ||
1766  (norm_type==L2) ||
1767  (norm_type==H1_SEMINORM) ||
1768  (norm_type==H2_SEMINORM))
1769  {
1770  if (!using_hilbert_norm)
1771  libmesh_not_implemented();
1772  using_nonhilbert_norm = false;
1773  }
1774  else if ((norm_type==L1) ||
1775  (norm_type==L_INF) ||
1776  (norm_type==W1_INF_SEMINORM) ||
1777  (norm_type==W2_INF_SEMINORM))
1778  {
1779  if (!using_nonhilbert_norm)
1780  libmesh_not_implemented();
1781  using_hilbert_norm = false;
1782  }
1783  else
1784  libmesh_not_implemented();
1785 
1786  const FEType & fe_type = this->get_dof_map().variable_type(var);
1787 
1788  // Allow space for dims 0-3, and for both scalar and vector
1789  // elements, even if we don't use them all
1790  std::vector<std::unique_ptr<FEBase>> fe_ptrs(4);
1791  std::vector<std::unique_ptr<FEVectorBase>> vec_fe_ptrs(4);
1792  std::vector<std::unique_ptr<QBase>> q_rules(4);
1793 
1794  const std::set<unsigned char> & elem_dims = _mesh.elem_dimensions();
1795 
1796  // Prepare finite elements for each dimension present in the mesh
1797  for (const auto & dim : elem_dims)
1798  {
1799  if (skip_dimensions && skip_dimensions->find(dim) != skip_dimensions->end())
1800  continue;
1801 
1802  // Construct quadrature and finite element objects
1803  q_rules[dim] = fe_type.default_quadrature_rule (dim);
1804 
1805  const FEFieldType field_type = FEInterface::field_type(fe_type);
1806  if (field_type == TYPE_SCALAR)
1807  {
1808  fe_ptrs[dim] = FEBase::build(dim, fe_type);
1809  fe_ptrs[dim]->attach_quadrature_rule (q_rules[dim].get());
1810  }
1811  else
1812  {
1813  vec_fe_ptrs[dim] = FEVectorBase::build(dim, fe_type);
1814  vec_fe_ptrs[dim]->attach_quadrature_rule (q_rules[dim].get());
1815  libmesh_assert_equal_to(field_type, TYPE_VECTOR);
1816  }
1817 
1818  }
1819 
1820  std::vector<dof_id_type> dof_indices;
1821 
1822  // Begin the loop over the elements
1823  for (const auto & elem : this->get_mesh().active_local_element_ptr_range())
1824  {
1825  const unsigned int dim = elem->dim();
1826 
1827  // One way for implementing this would be to exchange the fe with the FEInterface- class.
1828  // However, it needs to be discussed whether integral-norms make sense for infinite elements.
1829  // or in which sense they could make sense.
1830  if (elem->infinite() )
1831  libmesh_not_implemented();
1832 
1833  if (skip_dimensions && skip_dimensions->find(dim) != skip_dimensions->end())
1834  continue;
1835 
1836  QBase * qrule = q_rules[dim].get();
1837  libmesh_assert(qrule);
1838 
1839  this->get_dof_map().dof_indices (elem, dof_indices, var);
1840 
1841  auto element_calculation = [&dof_indices, &elem,
1842  norm_type, norm_weight, norm_weight_sq, &qrule,
1843  &local_v, &v_norm](auto & fe) {
1844  typedef typename std::remove_reference<decltype(fe)>::type::OutputShape OutputShape;
1845  typedef typename TensorTools::MakeNumber<OutputShape>::type OutputNumberShape;
1846  typedef typename std::remove_reference<decltype(fe)>::type::OutputGradient OutputGradient;
1847  typedef typename TensorTools::MakeNumber<OutputGradient>::type OutputNumberGradient;
1848 
1849  const std::vector<Real> & JxW = fe.get_JxW();
1850  const std::vector<std::vector<OutputShape>> * phi = nullptr;
1851  if (norm_type == H1 ||
1852  norm_type == H2 ||
1853  norm_type == L2 ||
1854  norm_type == L1 ||
1855  norm_type == L_INF)
1856  phi = &(fe.get_phi());
1857 
1858  const std::vector<std::vector<OutputGradient>> * dphi = nullptr;
1859  if (norm_type == H1 ||
1860  norm_type == H2 ||
1861  norm_type == H1_SEMINORM ||
1862  norm_type == W1_INF_SEMINORM)
1863  dphi = &(fe.get_dphi());
1864 
1865 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1866  typedef typename std::remove_reference<decltype(fe)>::type::OutputTensor OutputTensor;
1867 
1868  const std::vector<std::vector<OutputTensor>> * d2phi = nullptr;
1869  if (norm_type == H2 ||
1870  norm_type == H2_SEMINORM ||
1871  norm_type == W2_INF_SEMINORM)
1872  d2phi = &(fe.get_d2phi());
1873 #endif
1874 
1875  fe.reinit (elem);
1876 
1877  const unsigned int n_qp = qrule->n_points();
1878 
1879  const unsigned int n_sf = cast_int<unsigned int>
1880  (dof_indices.size());
1881 
1882  // Begin the loop over the Quadrature points.
1883  for (unsigned int qp=0; qp<n_qp; qp++)
1884  {
1885  if (norm_type == L1)
1886  {
1887  OutputNumberShape u_h = 0.;
1888  for (unsigned int i=0; i != n_sf; ++i)
1889  u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
1890  v_norm += norm_weight *
1891  JxW[qp] * TensorTools::norm(u_h);
1892  }
1893 
1894  if (norm_type == L_INF)
1895  {
1896  OutputNumberShape u_h = 0.;
1897  for (unsigned int i=0; i != n_sf; ++i)
1898  u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
1899  v_norm = std::max(v_norm, norm_weight * TensorTools::norm(u_h));
1900  }
1901 
1902  if (norm_type == H1 ||
1903  norm_type == H2 ||
1904  norm_type == L2)
1905  {
1906  OutputNumberShape u_h = 0.;
1907  for (unsigned int i=0; i != n_sf; ++i)
1908  u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
1909  v_norm += norm_weight_sq *
1910  JxW[qp] * TensorTools::norm_sq(u_h);
1911  }
1912 
1913  if (norm_type == H1 ||
1914  norm_type == H2 ||
1915  norm_type == H1_SEMINORM)
1916  {
1917  OutputNumberGradient grad_u_h;
1918  for (unsigned int i=0; i != n_sf; ++i)
1919  grad_u_h.add_scaled((*dphi)[i][qp], (*local_v)(dof_indices[i]));
1920  v_norm += norm_weight_sq *
1921  JxW[qp] * grad_u_h.norm_sq();
1922  }
1923 
1924  if (norm_type == W1_INF_SEMINORM)
1925  {
1926  OutputNumberGradient grad_u_h;
1927  for (unsigned int i=0; i != n_sf; ++i)
1928  grad_u_h.add_scaled((*dphi)[i][qp], (*local_v)(dof_indices[i]));
1929  v_norm = std::max(v_norm, norm_weight * grad_u_h.norm());
1930  }
1931 
1932 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1933  typedef typename TensorTools::MakeNumber<OutputTensor>::type OutputNumberTensor;
1934 
1935  if (norm_type == H2 ||
1936  norm_type == H2_SEMINORM)
1937  {
1938  OutputNumberTensor hess_u_h;
1939  for (unsigned int i=0; i != n_sf; ++i)
1940  hess_u_h.add_scaled((*d2phi)[i][qp], (*local_v)(dof_indices[i]));
1941  v_norm += norm_weight_sq *
1942  JxW[qp] * hess_u_h.norm_sq();
1943  }
1944 
1945  if (norm_type == W2_INF_SEMINORM)
1946  {
1947  OutputNumberTensor hess_u_h;
1948  for (unsigned int i=0; i != n_sf; ++i)
1949  hess_u_h.add_scaled((*d2phi)[i][qp], (*local_v)(dof_indices[i]));
1950  v_norm = std::max(v_norm, norm_weight * hess_u_h.norm());
1951  }
1952 #endif
1953  }
1954  };
1955 
1956  FEBase * scalar_fe = fe_ptrs[dim].get();
1957  FEVectorBase * vec_fe = vec_fe_ptrs[dim].get();
1958 
1959  if (scalar_fe)
1960  {
1961  libmesh_assert(!vec_fe);
1962  element_calculation(*scalar_fe);
1963  }
1964 
1965  if (vec_fe)
1966  {
1967  libmesh_assert(!scalar_fe);
1968  element_calculation(*vec_fe);
1969  }
1970  }
1971  }
1972 
1973  if (using_hilbert_norm)
1974  {
1975  this->comm().sum(v_norm);
1976  v_norm = std::sqrt(v_norm);
1977  }
1978  else
1979  {
1980  this->comm().max(v_norm);
1981  }
1982 
1983  return v_norm;
1984 }
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Fills the vector di with the global degree of freedom indices for the element.
Definition: dof_map.C:1992
unsigned int dim
virtual numeric_index_type size() const =0
const FEType & variable_type(const unsigned int c) const
Definition: dof_map.h:2144
void sum(T &r) const
static FEFieldType field_type(const FEType &fe_type)
FEMNormType
defines an enum for norms defined on vectors of finite element coefficients
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:2113
const Parallel::Communicator & comm() const
ADRealEigenVector< T, D, asd > sqrt(const ADRealEigenVector< T, D, asd > &)
Definition: type_vector.h:53
FEGenericBase< RealGradient > FEVectorBase
Definition: fe_base.h:818
const MeshBase & get_mesh() const
Definition: system.h:2277
virtual Real l2_norm() const =0
static std::unique_ptr< FEGenericBase > build(const unsigned int dim, const FEType &type)
Builds a specific finite element type.
libmesh_assert(ctx)
const std::set< unsigned char > & elem_dimensions() const
Definition: mesh_base.h:276
auto norm(const T &a) -> decltype(std::abs(a))
Definition: tensor_tools.h:74
FEGenericBase< Real > FEBase
virtual Real l1_norm() const =0
static std::unique_ptr< NumericVector< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
Builds a NumericVector on the processors in communicator comm using the linear solver package specifi...
std::string enum_to_string(const T e)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void max(const T &r, T &o, Request &req) const
auto norm_sq(const T &a) -> decltype(std::norm(a))
Definition: tensor_tools.h:104
virtual numeric_index_type local_size() const =0
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:134
Real discrete_var_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type) const
Finds the discrete norm for the entries in the vector corresponding to Dofs associated with var...
Definition: system.C:1653
unsigned int n_vars() const
Definition: system.h:2349
const DofMap & get_dof_map() const
Definition: system.h:2293
MeshBase & _mesh
Constant reference to the mesh data structure used for the simulation.
Definition: system.h:2125
virtual Real linfty_norm() const =0
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.
FEFieldType
defines an enum for finite element field types - i.e.

◆ can_add_matrices()

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

Definition at line 1914 of file system.h.

References _matrices_initialized.

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

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

◆ clear()

void libMesh::System::clear ( )
virtual

Clear all the data structures associated with the system.

Reimplemented in libMesh::NonlinearImplicitSystem, libMesh::OptimizationSystem, libMesh::RBConstruction, libMesh::RBEIMConstruction, libMesh::ImplicitSystem, libMesh::EigenSystem, libMesh::LinearImplicitSystem, libMesh::TransientSystem< RBConstruction >, libMesh::RBConstructionBase< LinearImplicitSystem >, libMesh::RBConstructionBase< System >, libMesh::RBConstructionBase< CondensedEigenSystem >, libMesh::DifferentiableSystem, libMesh::RBSCMConstruction, libMesh::FrequencySystem, libMesh::ContinuationSystem, libMesh::ExplicitSystem, libMesh::TransientRBConstruction, and libMesh::NewmarkSystem.

Definition at line 168 of file system.C.

References _dof_map, _is_initialized, _matrices, _matrices_initialized, _variable_numbers, _variables, _vector_is_adjoint, _vector_projections, _vectors, current_local_solution, and solution.

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

169 {
170  _variables.clear();
171  _variable_numbers.clear();
172  _dof_map->clear ();
173  solution->clear ();
174  current_local_solution->clear ();
175 
176  // clear any user-added vectors
177  _vectors.clear();
178  _vector_projections.clear();
179  _vector_is_adjoint.clear();
180  _is_initialized = false;
181 
182  // clear any user-added matrices
183  _matrices.clear();
184  _matrices_initialized = false;
185 }
bool _is_initialized
true when additional vectors and variables do not require immediate initialization, false otherwise.
Definition: system.h:2210
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:2113
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2164
std::vector< Variable > _variables
The Variable in this System.
Definition: system.h:2140
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
Some systems need an arbitrary number of matrices.
Definition: system.h:2181
std::map< std::string, int, std::less<> > _vector_is_adjoint
Holds non-negative if a vector by that name should be projected using adjoint constraints/BCs, -1 if primal.
Definition: system.h:2176
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1573
bool _matrices_initialized
false when additional matrices being added require initialization, true otherwise.
Definition: system.h:2191
std::map< std::string, unsigned int, std::less<> > _variable_numbers
The variable numbers corresponding to user-specified names, useful for name-based lookups...
Definition: system.h:2151
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Definition: system.h:1585
std::map< std::string, bool, std::less<> > _vector_projections
Holds true if a vector by that name should be projected onto a changed grid, false if it should be ze...
Definition: system.h:2170

◆ comm()

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

Definition at line 97 of file parallel_object.h.

References libMesh::ParallelObject::_communicator.

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

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

◆ compare()

bool libMesh::System::compare ( const System other_system,
const Real  threshold,
const bool  verbose 
) const
virtual
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 601 of file system.C.

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

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

◆ current_solution()

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

Definition at line 157 of file system.C.

References _dof_map, and current_local_solution.

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

158 {
159  // Check the sizes
160  libmesh_assert_less (global_dof_number, _dof_map->n_dofs());
161  libmesh_assert_less (global_dof_number, current_local_solution->size());
162 
163  return (*current_local_solution)(global_dof_number);
164 }
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:2113
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Definition: system.h:1585

◆ deactivate()

void libMesh::System::deactivate ( )
inline

Deactivates the system.

Only active systems are solved.

Definition at line 2325 of file system.h.

References _active.

2326 {
2327  _active = false;
2328 }
bool _active
Flag stating if the system is active or not.
Definition: system.h:2156

◆ disable_cache()

void libMesh::System::disable_cache ( )
inlinevirtual

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

Should be overridden in derived systems.

Reimplemented in libMesh::ImplicitSystem.

Definition at line 2513 of file system.h.

References assemble_before_solve.

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

2513 { assemble_before_solve = true; }
bool assemble_before_solve
Flag which tells the system to whether or not to call the user assembly function during each call to ...
Definition: system.h:1527

◆ disable_print_counter_info()

void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

Definition at line 100 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

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

◆ discrete_var_norm()

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

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

Definition at line 1653 of file system.C.

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

Referenced by calculate_norm().

1656 {
1657  std::set<dof_id_type> var_indices;
1658  local_dof_indices(var, var_indices);
1659 
1660  if (norm_type == DISCRETE_L1)
1661  return v.subset_l1_norm(var_indices);
1662  if (norm_type == DISCRETE_L2)
1663  return v.subset_l2_norm(var_indices);
1664  if (norm_type == DISCRETE_L_INF)
1665  return v.subset_linfty_norm(var_indices);
1666  else
1667  libmesh_error_msg("Invalid norm_type = " << Utility::enum_to_string(norm_type));
1668 }
void local_dof_indices(const unsigned int var, std::set< dof_id_type > &var_indices) const
Fills the std::set with the degrees of freedom on the local processor corresponding the the variable ...
Definition: system.C:1575
virtual Real subset_l2_norm(const std::set< numeric_index_type > &indices) const
virtual Real subset_linfty_norm(const std::set< numeric_index_type > &indices) const
virtual Real subset_l1_norm(const std::set< numeric_index_type > &indices) const
std::string enum_to_string(const T e)

◆ enable_print_counter_info()

void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

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

Definition at line 94 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

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

◆ forward_qoi_parameter_sensitivity()

void libMesh::System::forward_qoi_parameter_sensitivity ( const QoISet qoi_indices,
const ParameterVector parameters,
SensitivityData sensitivities 
)
inlinevirtual

Solves for parameter sensitivities using the forward method.

This method is only implemented in some derived classes.

Reimplemented in libMesh::ImplicitSystem.

Definition at line 2567 of file system.h.

Referenced by qoi_parameter_sensitivity().

2570 {
2571  libmesh_not_implemented();
2572 }

◆ get_adjoint_rhs() [1/2]

NumericVector< Number > & libMesh::System::get_adjoint_rhs ( unsigned int  i = 0)
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 1255 of file system.C.

References get_vector().

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

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

◆ get_adjoint_rhs() [2/2]

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

Definition at line 1265 of file system.C.

References get_vector().

1266 {
1267  std::ostringstream adjoint_rhs_name;
1268  adjoint_rhs_name << "adjoint_rhs" << i;
1269 
1270  return this->get_vector(adjoint_rhs_name.str());
1271 }
const NumericVector< Number > & get_vector(std::string_view vec_name) const
Definition: system.C:918

◆ get_adjoint_solution() [1/2]

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

◆ get_adjoint_solution() [2/2]

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

Definition at line 1203 of file system.C.

References get_vector().

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

◆ get_all_variable_numbers()

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

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

Definition at line 1565 of file system.C.

References _variable_numbers, and n_vars().

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

1566 {
1567  all_variable_numbers.resize(n_vars());
1568 
1569  unsigned int count = 0;
1570  for (auto vn : _variable_numbers)
1571  all_variable_numbers[count++] = vn.second;
1572 }
std::map< std::string, unsigned int, std::less<> > _variable_numbers
The variable numbers corresponding to user-specified names, useful for name-based lookups...
Definition: system.h:2151
unsigned int n_vars() const
Definition: system.h:2349

◆ get_constraint_object()

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

Return the user object for imposing constraints.

Definition at line 2174 of file system.C.

References _constrain_system_object.

2175 {
2176  libmesh_assert_msg(_constrain_system_object,"No constraint object available.");
2177  return *_constrain_system_object;
2178 }
Constraint * _constrain_system_object
Object that constrains the system.
Definition: system.h:2081

◆ get_dof_map() [1/2]

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

Definition at line 2293 of file system.h.

References _dof_map.

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

2294 {
2295  return *_dof_map;
2296 }
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:2113

◆ get_dof_map() [2/2]

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

Definition at line 2301 of file system.h.

References _dof_map.

2302 {
2303  return *_dof_map;
2304 }
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:2113

◆ get_equation_systems() [1/2]

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

Definition at line 730 of file system.h.

References _equation_systems.

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

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

◆ get_equation_systems() [2/2]

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

Definition at line 735 of file system.h.

References _equation_systems.

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

◆ get_info() [1/2]

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

Gets a string containing the reference information.

Definition at line 47 of file reference_counter.C.

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

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

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

◆ get_info() [2/2]

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

Definition at line 1988 of file system.C.

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

1989 {
1990  std::ostringstream oss;
1991 
1992 
1993  const std::string & sys_name = this->name();
1994 
1995  oss << " System #" << this->number() << ", \"" << sys_name << "\"\n"
1996  << " Type \"" << this->system_type() << "\"\n"
1997  << " Variables=";
1998 
1999  for (auto vg : make_range(this->n_variable_groups()))
2000  {
2001  const VariableGroup & vg_description (this->variable_group(vg));
2002 
2003  if (vg_description.n_variables() > 1) oss << "{ ";
2004  for (auto vn : make_range(vg_description.n_variables()))
2005  oss << "\"" << vg_description.name(vn) << "\" ";
2006  if (vg_description.n_variables() > 1) oss << "} ";
2007  }
2008 
2009  oss << '\n';
2010 
2011  oss << " Finite Element Types=";
2012 #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
2013  for (auto vg : make_range(this->n_variable_groups()))
2014  oss << "\""
2015  << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().family)
2016  << "\" ";
2017 #else
2018  for (auto vg : make_range(this->n_variable_groups()))
2019  {
2020  oss << "\""
2021  << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().family)
2022  << "\", \""
2023  << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().radial_family)
2024  << "\" ";
2025  }
2026 
2027  oss << '\n' << " Infinite Element Mapping=";
2028  for (auto vg : make_range(this->n_variable_groups()))
2029  oss << "\""
2030  << Utility::enum_to_string<InfMapType>(this->get_dof_map().variable_group(vg).type().inf_map)
2031  << "\" ";
2032 #endif
2033 
2034  oss << '\n';
2035 
2036  oss << " Approximation Orders=";
2037  for (auto vg : make_range(this->n_variable_groups()))
2038  {
2039 #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
2040  oss << "\""
2041  << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().order)
2042  << "\" ";
2043 #else
2044  oss << "\""
2045  << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().order)
2046  << "\", \""
2047  << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().radial_order)
2048  << "\" ";
2049 #endif
2050  }
2051 
2052  oss << '\n';
2053 
2054  oss << " n_dofs()=" << this->n_dofs() << '\n';
2055  dof_id_type local_dofs = this->n_local_dofs();
2056  oss << " n_local_dofs()=" << local_dofs << '\n';
2057  this->comm().max(local_dofs);
2058  oss << " max(n_local_dofs())=" << local_dofs << '\n';
2059 #ifdef LIBMESH_ENABLE_CONSTRAINTS
2060  oss << " n_constrained_dofs()=" << this->n_constrained_dofs() << '\n';
2061  oss << " n_local_constrained_dofs()=" << this->n_local_constrained_dofs() << '\n';
2062  dof_id_type local_unconstrained_dofs = this->n_local_dofs() - this->n_local_constrained_dofs();
2063  this->comm().max(local_unconstrained_dofs);
2064  oss << " max(local unconstrained dofs)=" << local_unconstrained_dofs << '\n';
2065 #endif
2066 
2067  oss << " " << "n_vectors()=" << this->n_vectors() << '\n';
2068  oss << " " << "n_matrices()=" << this->n_matrices() << '\n';
2069  // oss << " " << "n_additional_matrices()=" << this->n_additional_matrices() << '\n';
2070 
2071  oss << this->get_dof_map().get_info();
2072 
2073  return oss.str();
2074 }
FEFamily family
The type of finite element.
Definition: fe_type.h:207
OrderWrapper radial_order
The approximation order in radial direction of the infinite element.
Definition: fe_type.h:240
unsigned int n_variable_groups() const
Definition: system.h:2357
const Parallel::Communicator & comm() const
OrderWrapper order
The approximation order of the element.
Definition: fe_type.h:201
dof_id_type n_local_dofs() const
Definition: system.C:150
std::string get_info() const
Gets summary info about the sparsity bandwidth and constraints.
Definition: dof_map.C:2922
dof_id_type n_dofs() const
Definition: system.C:113
unsigned int number() const
Definition: system.h:2269
unsigned int n_vectors() const
Definition: system.h:2477
const VariableGroup & variable_group(const unsigned int c) const
Definition: dof_map.h:2104
InfMapType inf_map
The coordinate mapping type of the infinite element.
Definition: fe_type.h:261
unsigned int n_matrices() const
Definition: system.h:2594
FEFamily radial_family
The type of approximation in radial direction.
Definition: fe_type.h:253
virtual std::string system_type() const
Definition: system.h:505
void max(const T &r, T &o, Request &req) const
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:134
dof_id_type n_local_constrained_dofs() const
Definition: system.C:135
const std::string & name() const
Definition: system.h:2261
const DofMap & get_dof_map() const
Definition: system.h:2293
const VariableGroup & variable_group(unsigned int vg) const
Return a constant reference to VariableGroup vg.
Definition: system.h:2387
dof_id_type n_constrained_dofs() const
Definition: system.C:120
uint8_t dof_id_type
Definition: id_types.h:67
const FEType & type() const
Definition: variable.h:140

◆ get_matrix() [1/2]

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

Definition at line 1073 of file system.C.

References _matrices.

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

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

◆ get_matrix() [2/2]

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

Definition at line 1080 of file system.C.

References _matrices.

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

◆ get_mesh() [1/2]

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

Definition at line 2277 of file system.h.

References _mesh.

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

2278 {
2279  return _mesh;
2280 }
MeshBase & _mesh
Constant reference to the mesh data structure used for the simulation.
Definition: system.h:2125

◆ get_mesh() [2/2]

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

Definition at line 2285 of file system.h.

References _mesh.

2286 {
2287  return _mesh;
2288 }
MeshBase & _mesh
Constant reference to the mesh data structure used for the simulation.
Definition: system.h:2125

◆ get_project_with_constraints()

bool libMesh::System::get_project_with_constraints ( )
inline

Setter and getter functions for project_with_constraints boolean.

Definition at line 1775 of file system.h.

References project_with_constraints.

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

1776  {
1777  return project_with_constraints;
1778  }
bool project_with_constraints
Do we want to apply constraints while projecting vectors ?
Definition: system.h:2253

◆ get_qoi_error_estimate_value()

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

Definition at line 2361 of file system.C.

References libMesh::libmesh_assert(), and qoi_error_estimates.

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

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

◆ get_qoi_value()

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

◆ get_qoi_values()

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

Returns a copy of qoi, not a reference.

Definition at line 2341 of file system.C.

References qoi.

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

2342 {
2343  return this->qoi;
2344 }
std::vector< Number > qoi
Values of the quantities of interest.
Definition: system.h:1611

◆ get_sensitivity_rhs() [1/2]

NumericVector< Number > & libMesh::System::get_sensitivity_rhs ( unsigned int  i = 0)
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 1285 of file system.C.

References get_vector().

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

1286 {
1287  std::ostringstream sensitivity_rhs_name;
1288  sensitivity_rhs_name << "sensitivity_rhs" << i;
1289 
1290  return this->get_vector(sensitivity_rhs_name.str());
1291 }
const NumericVector< Number > & get_vector(std::string_view vec_name) const
Definition: system.C:918

◆ get_sensitivity_rhs() [2/2]

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

Definition at line 1295 of file system.C.

References get_vector().

1296 {
1297  std::ostringstream sensitivity_rhs_name;
1298  sensitivity_rhs_name << "sensitivity_rhs" << i;
1299 
1300  return this->get_vector(sensitivity_rhs_name.str());
1301 }
const NumericVector< Number > & get_vector(std::string_view vec_name) const
Definition: system.C:918

◆ get_sensitivity_solution() [1/2]

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

Definition at line 1140 of file system.C.

References get_vector().

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

1141 {
1142  std::ostringstream sensitivity_name;
1143  sensitivity_name << "sensitivity_solution" << i;
1144 
1145  return this->get_vector(sensitivity_name.str());
1146 }
const NumericVector< Number > & get_vector(std::string_view vec_name) const
Definition: system.C:918

◆ get_sensitivity_solution() [2/2]

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

Definition at line 1150 of file system.C.

References get_vector().

1151 {
1152  std::ostringstream sensitivity_name;
1153  sensitivity_name << "sensitivity_solution" << i;
1154 
1155  return this->get_vector(sensitivity_name.str());
1156 }
const NumericVector< Number > & get_vector(std::string_view vec_name) const
Definition: system.C:918

◆ get_vector() [1/4]

const NumericVector< Number > & libMesh::System::get_vector ( std::string_view  vec_name) const
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 918 of file system.C.

References _vectors.

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

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

◆ get_vector() [2/4]

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

Definition at line 925 of file system.C.

References _vectors.

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

◆ get_vector() [3/4]

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

Definition at line 932 of file system.C.

References _vectors, and vectors_begin().

933 {
934  // If we don't have that many vectors, throw an error
935  libmesh_assert_less(vec_num, _vectors.size());
936 
937  // Otherwise return a reference to the vec_num'th vector
938  auto it = vectors_begin();
939  std::advance(it, vec_num);
940  return *(it->second);
941 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2164
vectors_iterator vectors_begin()
Beginning of vectors container.
Definition: system.h:2483

◆ get_vector() [4/4]

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

Definition at line 945 of file system.C.

References _vectors, and vectors_begin().

946 {
947  // If we don't have that many vectors, throw an error
948  libmesh_assert_less(vec_num, _vectors.size());
949 
950  // Otherwise return a reference to the vec_num'th vector
951  auto it = vectors_begin();
952  std::advance(it, vec_num);
953  return *(it->second);
954 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2164
vectors_iterator vectors_begin()
Beginning of vectors container.
Definition: system.h:2483

◆ get_weighted_sensitivity_adjoint_solution() [1/2]

NumericVector< Number > & libMesh::System::get_weighted_sensitivity_adjoint_solution ( unsigned int  i = 0)
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 1225 of file system.C.

References get_vector().

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

1226 {
1227  std::ostringstream adjoint_name;
1228  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
1229 
1230  return this->get_vector(adjoint_name.str());
1231 }
const NumericVector< Number > & get_vector(std::string_view vec_name) const
Definition: system.C:918

◆ get_weighted_sensitivity_adjoint_solution() [2/2]

const NumericVector< Number > & libMesh::System::get_weighted_sensitivity_adjoint_solution ( unsigned int  i = 0) const
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 1235 of file system.C.

References get_vector().

1236 {
1237  std::ostringstream adjoint_name;
1238  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
1239 
1240  return this->get_vector(adjoint_name.str());
1241 }
const NumericVector< Number > & get_vector(std::string_view vec_name) const
Definition: system.C:918

◆ get_weighted_sensitivity_solution() [1/2]

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

Definition at line 1167 of file system.C.

References get_vector().

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

1168 {
1169  return this->get_vector("weighted_sensitivity_solution");
1170 }
const NumericVector< Number > & get_vector(std::string_view vec_name) const
Definition: system.C:918

◆ get_weighted_sensitivity_solution() [2/2]

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

Definition at line 1174 of file system.C.

References get_vector().

1175 {
1176  return this->get_vector("weighted_sensitivity_solution");
1177 }
const NumericVector< Number > & get_vector(std::string_view vec_name) const
Definition: system.C:918

◆ has_constraint_object()

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

Definition at line 2169 of file system.C.

References _constrain_system_object.

2170 {
2171  return _constrain_system_object != nullptr;
2172 }
Constraint * _constrain_system_object
Object that constrains the system.
Definition: system.h:2081

◆ has_variable()

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

Definition at line 1550 of file system.C.

References _variable_numbers.

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

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

◆ have_matrix()

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

Definition at line 1860 of file system.h.

References _matrices.

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

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

◆ have_vector()

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

Definition at line 2469 of file system.h.

References _vectors.

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

◆ hide_output()

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

Definition at line 1790 of file system.h.

References _hide_output.

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

◆ identify_variable_groups() [1/2]

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

Definition at line 2445 of file system.h.

References _identify_variable_groups.

Referenced by add_variable(), and add_variables().

2446 {
2448 }
bool _identify_variable_groups
true when VariableGroup structures should be automatically identified, false otherwise.
Definition: system.h:2216

◆ identify_variable_groups() [2/2]

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

Toggle automatic VariableGroup identification.

Definition at line 2453 of file system.h.

References _identify_variable_groups.

2454 {
2456 }
bool _identify_variable_groups
true when VariableGroup structures should be automatically identified, false otherwise.
Definition: system.h:2216

◆ increment_constructor_count()

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

Increments the construction counter.

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

Definition at line 183 of file reference_counter.h.

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

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

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

◆ increment_destructor_count()

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

Increments the destruction counter.

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

Definition at line 207 of file reference_counter.h.

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

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

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

◆ init()

void libMesh::System::init ( )

Initializes degrees of freedom on the current mesh.

Sets the

Definition at line 189 of file system.C.

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

190 {
191  parallel_object_only();
192 
193  // Calling init() twice on the same system currently works evil
194  // magic, whether done directly or via EquationSystems::read()
195  libmesh_assert(!this->is_initialized());
196 
197  // First initialize any required data:
198  // either only the basic System data
199  if (_basic_system_only)
201  // or all the derived class' data too
202  else
203  this->init_data();
204 
205  // If no variables have been added to this system
206  // don't do anything
207  if (!this->n_vars())
208  return;
209 
210  // Then call the user-provided initialization function
211  this->user_initialization();
212 }
bool _basic_system_only
Holds true if the components of more advanced system types (e.g.
Definition: system.h:2204
virtual void init_data()
Initializes the data for the system.
Definition: system.C:216
virtual void user_initialization()
Calls user&#39;s attached initialization function, or is overridden by the user in derived classes...
Definition: system.C:2245
bool is_initialized()
Definition: system.h:2333
libmesh_assert(ctx)
unsigned int n_vars() const
Definition: system.h:2349

◆ init_data()

void libMesh::System::init_data ( )
protectedvirtual

Initializes the data for the system.

Note
This is called before any user-supplied initialization function so that all required storage will be available.

Reimplemented in libMesh::DifferentiableSystem, libMesh::ContinuationSystem, libMesh::FEMSystem, libMesh::OptimizationSystem, libMesh::FrequencySystem, libMesh::RBConstructionBase< LinearImplicitSystem >, libMesh::RBConstructionBase< System >, libMesh::RBConstructionBase< CondensedEigenSystem >, SecondOrderScalarSystemSecondOrderTimeSolverBase, SimpleRBConstruction, FirstOrderScalarSystemBase, SimpleRBConstruction, SimpleRBConstruction, SimpleRBConstruction, SimpleRBConstruction, libMesh::LinearImplicitSystem, HeatSystem, SimpleRBConstruction, ElasticityRBConstruction, CoupledSystem, SimpleEIMConstruction, L2System, SimpleEIMConstruction, ElasticitySystem, ElasticitySystem, HeatSystem, LaplaceSystem, CurlCurlSystem, LaplaceSystem, PoissonSystem, LaplaceSystem, LaplaceSystem, CurlCurlSystem, SolidSystem, NavierSystem, and HeatSystem.

Definition at line 216 of file system.C.

References _basic_system_only, _dof_map, _is_initialized, _matrices, _vectors, add_matrices(), current_local_solution, get_mesh(), libMesh::GHOSTED, init_matrices(), libMesh::libmesh_assert(), libMesh::libmesh_ignore(), libMesh::make_range(), mesh, n_dofs(), n_local_dofs(), n_variable_groups(), libMesh::PARALLEL, reinit_constraints(), libMesh::SERIAL, solution, and variable_group().

Referenced by init(), libMesh::LinearImplicitSystem::init_data(), libMesh::OptimizationSystem::init_data(), libMesh::DifferentiableSystem::init_data(), and reinit_mesh().

217 {
218  parallel_object_only();
219 
220  MeshBase & mesh = this->get_mesh();
221 
222  // Add all variable groups to our underlying DofMap
223  unsigned int n_dof_map_vg = _dof_map->n_variable_groups();
224  for (auto vg : make_range(this->n_variable_groups()))
225  {
226  const VariableGroup & group = this->variable_group(vg);
227  if (vg < n_dof_map_vg)
228  libmesh_assert(group == _dof_map->variable_group(vg));
229  else
230  _dof_map->add_variable_group(group);
231  }
232 
233  // Distribute the degrees of freedom on the mesh
234  auto total_dofs = _dof_map->distribute_dofs (mesh);
235 
236  // Throw an error if the total number of DOFs is not capable of
237  // being indexed by our solution vector.
238  auto max_allowed_id = solution->max_allowed_id();
239  libmesh_error_msg_if(total_dofs > max_allowed_id,
240  "Cannot allocate a NumericVector with " << total_dofs << " degrees of freedom. "
241  "The vector can only index up to " << max_allowed_id << " entries.");
242 
243  // Recreate any user or internal constraints
244  this->reinit_constraints();
245 
246  // And clean up the send_list before we first use it
247  _dof_map->prepare_send_list();
248 
249  // Resize the solution conformal to the current mesh
250  solution->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
251 
252  // Resize the current_local_solution for the current mesh
253 #ifdef LIBMESH_ENABLE_GHOSTED
254  current_local_solution->init (this->n_dofs(), this->n_local_dofs(),
255  _dof_map->get_send_list(), /*fast=*/false,
256  GHOSTED);
257 #else
258  current_local_solution->init (this->n_dofs(), false, SERIAL);
259 #endif
260 
261  // from now on, adding additional vectors or variables can't be done
262  // without immediately initializing them
263  _is_initialized = true;
264 
265  // initialize & zero other vectors, if necessary
266  for (auto & [vec_name, vec] : _vectors)
267  {
268  libmesh_ignore(vec_name); // spurious warning from old gcc
269  const ParallelType type = vec->type();
270 
271  if (type == GHOSTED)
272  {
273 #ifdef LIBMESH_ENABLE_GHOSTED
274  vec->init (this->n_dofs(), this->n_local_dofs(),
275  _dof_map->get_send_list(), /*fast=*/false,
276  GHOSTED);
277 #else
278  libmesh_error_msg("Cannot initialize ghosted vectors when they are not enabled.");
279 #endif
280  }
281  else if (type == SERIAL)
282  {
283  vec->init (this->n_dofs(), false, type);
284  }
285  else
286  {
287  libmesh_assert_equal_to(type, PARALLEL);
288  vec->init (this->n_dofs(), this->n_local_dofs(), false, type);
289  }
290  }
291 
292  // Add matrices
293  this->add_matrices();
294 
295  // Clear any existing matrices
296  for (auto & pr : _matrices)
297  pr.second->clear();
298 
299  // Initialize the matrices for the system
300  if (!_basic_system_only)
301  this->init_matrices();
302 }
bool _basic_system_only
Holds true if the components of more advanced system types (e.g.
Definition: system.h:2204
virtual void init_matrices()
Initializes the matrices associated with this system.
Definition: system.C:326
bool _is_initialized
true when additional vectors and variables do not require immediate initialization, false otherwise.
Definition: system.h:2210
unsigned int n_variable_groups() const
Definition: system.h:2357
MeshBase & mesh
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:2113
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2164
dof_id_type n_local_dofs() const
Definition: system.C:150
const MeshBase & get_mesh() const
Definition: system.h:2277
dof_id_type n_dofs() const
Definition: system.C:113
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
Some systems need an arbitrary number of matrices.
Definition: system.h:2181
void libmesh_ignore(const Args &...)
virtual void add_matrices()
Insertion point for adding matrices in derived classes before init_matrices() is called.
Definition: system.h:1903
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1573
libmesh_assert(ctx)
virtual void reinit_constraints()
Reinitializes the constraints for this system.
Definition: system.C:480
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:134
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Definition: system.h:1585
const VariableGroup & variable_group(unsigned int vg) const
Return a constant reference to VariableGroup vg.
Definition: system.h:2387
ParallelType
Defines an enum for parallel data structure types.

◆ init_matrices()

void libMesh::System::init_matrices ( )
protectedvirtual

Initializes the matrices associated with this system.

Reimplemented in libMesh::EigenSystem.

Definition at line 326 of file system.C.

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

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

327 {
328  parallel_object_only();
329 
330  // No matrices to init
331  if (_matrices.empty())
332  {
333  // any future matrices to be added will need their own
334  // initialization
335  _matrices_initialized = true;
336 
337  return;
338  }
339 
340  // Check for quick return in case the first matrix
341  // (and by extension all the matrices) has already
342  // been initialized
343  if (_matrices.begin()->second->initialized())
344  {
346  return;
347  }
348 
349  _matrices_initialized = true;
350 
351  // Tell the matrices about the dof map, and vice versa
352  for (auto & pr : _matrices)
353  {
354  SparseMatrix<Number> & m = *(pr.second);
355  libmesh_assert (!m.initialized());
356 
357  // We want to allow repeated init() on systems, but we don't
358  // want to attach the same matrix to the DofMap twice
359  if (!this->get_dof_map().is_attached(m))
360  this->get_dof_map().attach_matrix(m);
361  }
362 
363  // Compute the sparsity pattern for the current
364  // mesh and DOF distribution. This also updates
365  // additional matrices, \p DofMap now knows them
366  this->get_dof_map().compute_sparsity(this->get_mesh());
367 
368  // Initialize matrices and set to zero
369  for (auto & pr : _matrices)
370  {
371  pr.second->init(_matrix_types[pr.first]);
372  pr.second->zero();
373  }
374 }
bool is_attached(SparseMatrix< Number > &matrix)
Matrices should not be attached more than once.
Definition: dof_map.C:333
void attach_matrix(SparseMatrix< Number > &matrix)
Additional matrices may be attached to this DofMap.
Definition: dof_map.C:278
const MeshBase & get_mesh() const
Definition: system.h:2277
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
Some systems need an arbitrary number of matrices.
Definition: system.h:2181
libmesh_assert(ctx)
std::map< std::string, ParallelType, std::less<> > _matrix_types
Holds the types of the matrices.
Definition: system.h:2186
template class LIBMESH_EXPORT SparseMatrix< Number >
bool _matrices_initialized
false when additional matrices being added require initialization, true otherwise.
Definition: system.h:2191
void compute_sparsity(const MeshBase &)
Computes the sparsity pattern for the matrices corresponding to proc_id and sends that data to Linear...
Definition: dof_map.C:1816
const DofMap & get_dof_map() const
Definition: system.h:2293

◆ init_qois()

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

Accessors for qoi and qoi_error_estimates vectors.

Definition at line 2319 of file system.C.

References n_qois(), qoi, and qoi_error_estimates.

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

2320 {
2321  qoi.resize(n_qois);
2322  qoi_error_estimates.resize(n_qois);
2323 }
unsigned int n_qois() const
Number of currently active quantities of interest.
Definition: system.h:2516
std::vector< Number > qoi
Values of the quantities of interest.
Definition: system.h:1611
std::vector< Number > qoi_error_estimates
Vector to hold error estimates for qois, either from a steady state calculation, or from a single uns...
Definition: system.h:1619

◆ is_adjoint_already_solved()

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

Accessor for the adjoint_already_solved boolean.

Definition at line 406 of file system.h.

References adjoint_already_solved.

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

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

◆ is_initialized()

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

Definition at line 2333 of file system.h.

References _is_initialized.

Referenced by add_variable(), add_variables(), and init().

2334 {
2335  return _is_initialized;
2336 }
bool _is_initialized
true when additional vectors and variables do not require immediate initialization, false otherwise.
Definition: system.h:2210

◆ late_matrix_init()

void libMesh::System::late_matrix_init ( SparseMatrix< Number > &  mat,
ParallelType  type 
)
private

Helper function to keep DofMap forward declarable in system.h.

Definition at line 1019 of file system.C.

References _matrices_initialized, libMesh::DofMap::attach_matrix(), get_dof_map(), and libMesh::SparseMatrix< T >::init().

Referenced by add_matrix().

1021 {
1023  {
1024  this->get_dof_map().attach_matrix(mat);
1025  mat.init(type);
1026  }
1027 }
void attach_matrix(SparseMatrix< Number > &matrix)
Additional matrices may be attached to this DofMap.
Definition: dof_map.C:278
bool _matrices_initialized
false when additional matrices being added require initialization, true otherwise.
Definition: system.h:2191
const DofMap & get_dof_map() const
Definition: system.h:2293
virtual void init(const numeric_index_type m, const numeric_index_type n, const numeric_index_type m_l, const numeric_index_type n_l, const numeric_index_type nnz=30, const numeric_index_type noz=10, const numeric_index_type blocksize=1)=0
Initialize SparseMatrix with the specified sizes.

◆ local_dof_indices()

void libMesh::System::local_dof_indices ( const unsigned int  var,
std::set< dof_id_type > &  var_indices 
) const

Fills the std::set with the degrees of freedom on the local processor corresponding the the variable number passed in.

Definition at line 1575 of file system.C.

References libMesh::DofMap::dof_indices(), libMesh::DofMap::end_dof(), libMesh::DofMap::first_dof(), get_dof_map(), get_mesh(), and libMesh::libmesh_assert().

Referenced by discrete_var_norm(), SystemsTest::testBlockRestrictedVarNDofs(), and libMesh::DirectSolutionTransfer::transfer().

1577 {
1578  // Make sure the set is clear
1579  var_indices.clear();
1580 
1581  std::vector<dof_id_type> dof_indices;
1582 
1583  const dof_id_type
1584  first_local = this->get_dof_map().first_dof(),
1585  end_local = this->get_dof_map().end_dof();
1586 
1587  // Begin the loop over the elements
1588  for (const auto & elem : this->get_mesh().active_local_element_ptr_range())
1589  {
1590  this->get_dof_map().dof_indices (elem, dof_indices, var);
1591 
1592  for (dof_id_type dof : dof_indices)
1593  //If the dof is owned by the local processor
1594  if (first_local <= dof && dof < end_local)
1595  var_indices.insert(dof);
1596  }
1597 
1598  // we may have missed assigning DOFs to nodes that we own
1599  // but to which we have no connected elements matching our
1600  // variable restriction criterion. this will happen, for example,
1601  // if variable V is restricted to subdomain S. We may not own
1602  // any elements which live in S, but we may own nodes which are
1603  // *connected* to elements which do.
1604  for (const auto & node : this->get_mesh().local_node_ptr_range())
1605  {
1606  libmesh_assert(node);
1607  this->get_dof_map().dof_indices (node, dof_indices, var);
1608  for (auto dof : dof_indices)
1609  if (first_local <= dof && dof < end_local)
1610  var_indices.insert(dof);
1611  }
1612 }
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Fills the vector di with the global degree of freedom indices for the element.
Definition: dof_map.C:1992
const MeshBase & get_mesh() const
Definition: system.h:2277
libmesh_assert(ctx)
dof_id_type first_dof(const processor_id_type proc) const
Definition: dof_map.h:684
dof_id_type end_dof(const processor_id_type proc) const
Definition: dof_map.h:708
const DofMap & get_dof_map() const
Definition: system.h:2293
uint8_t dof_id_type
Definition: id_types.h:67

◆ n_active_dofs()

dof_id_type libMesh::System::n_active_dofs ( ) const
inline
Returns
The number of active degrees of freedom for this System.

Definition at line 2461 of file system.h.

References n_constrained_dofs(), and n_dofs().

2462 {
2463  return this->n_dofs() - this->n_constrained_dofs();
2464 }
dof_id_type n_dofs() const
Definition: system.C:113
dof_id_type n_constrained_dofs() const
Definition: system.C:120

◆ n_components()

unsigned int libMesh::System::n_components ( ) const
inline
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 2365 of file system.h.

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

Referenced by add_variables().

2366 {
2367  if (_variables.empty())
2368  return 0;
2369 
2370  const Variable & last = _variables.back();
2371  return last.first_scalar_number() + last.n_components();
2372 }
std::vector< Variable > _variables
The Variable in this System.
Definition: system.h:2140

◆ n_constrained_dofs()

dof_id_type libMesh::System::n_constrained_dofs ( ) const
Returns
The total number of constrained degrees of freedom in the system.

Definition at line 120 of file system.C.

References _dof_map.

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

121 {
122 #ifdef LIBMESH_ENABLE_CONSTRAINTS
123 
124  return _dof_map->n_constrained_dofs();
125 
126 #else
127 
128  return 0;
129 
130 #endif
131 }
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:2113

◆ n_dofs()

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

Definition at line 113 of file system.C.

References _dof_map.

Referenced by libMesh::TransientRBConstruction::add_IC_to_RB_space(), add_vector(), libMesh::TransientRBConstruction::allocate_data_structures(), libMesh::RBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), libMesh::TransientRBConstruction::enrich_RB_space(), libMesh::AdjointRefinementEstimator::estimate_error(), get_info(), libMesh::SecondOrderUnsteadySolver::init_data(), libMesh::UnsteadySolver::init_data(), init_data(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), main(), libMesh::TransientRBConstruction::mass_matrix_scaled_matvec(), n_active_dofs(), libMesh::CondensedEigenSystem::n_global_non_condensed_dofs(), libMesh::FEMSystem::numerical_jacobian(), libMesh::RBSCMConstruction::perform_SCM_greedy(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), read_legacy_data(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::SecondOrderUnsteadySolver::reinit(), libMesh::UnsteadySolver::reinit(), restrict_vectors(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), libMesh::TransientRBConstruction::set_error_temporal_data(), SystemsTest::test100KVariables(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), SystemsTest::testPostInitAddVector(), SystemsTest::testPostInitAddVectorTypeChange(), SystemsTest::testProjectCubeWithMeshFunction(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), libMesh::RBConstruction::train_reduced_basis_with_POD(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::TransientRBConstruction::update_RB_system_matrices(), libMesh::RBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_residual_terms(), and libMesh::RBConstruction::update_residual_terms().

114 {
115  return _dof_map->n_dofs();
116 }
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:2113

◆ n_local_constrained_dofs()

dof_id_type libMesh::System::n_local_constrained_dofs ( ) const
Returns
The number of constrained degrees of freedom on this processor.

Definition at line 135 of file system.C.

References _dof_map.

Referenced by get_info().

136 {
137 #ifdef LIBMESH_ENABLE_CONSTRAINTS
138 
139  return _dof_map->n_local_constrained_dofs();
140 
141 #else
142 
143  return 0;
144 
145 #endif
146 }
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:2113

◆ n_local_dofs()

dof_id_type libMesh::System::n_local_dofs ( ) const
Returns
The number of degrees of freedom local to this processor

Definition at line 150 of file system.C.

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

Referenced by libMesh::TransientRBConstruction::add_IC_to_RB_space(), add_vector(), libMesh::TransientRBConstruction::allocate_data_structures(), libMesh::RBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::PetscDMWrapper::build_section(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), libMesh::TransientRBConstruction::enrich_RB_space(), libMesh::AdjointRefinementEstimator::estimate_error(), get_info(), libMesh::SecondOrderUnsteadySolver::init_data(), libMesh::UnsteadySolver::init_data(), init_data(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), main(), libMesh::TransientRBConstruction::mass_matrix_scaled_matvec(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::SecondOrderUnsteadySolver::reinit(), libMesh::UnsteadySolver::reinit(), restrict_vectors(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), libMesh::TransientRBConstruction::set_error_temporal_data(), MeshFunctionTest::test_p_level(), libMesh::RBConstruction::train_reduced_basis_with_POD(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::TransientRBConstruction::update_RB_system_matrices(), libMesh::RBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_residual_terms(), and libMesh::RBConstruction::update_residual_terms().

151 {
152  return _dof_map->n_dofs_on_processor (this->processor_id());
153 }
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:2113
processor_id_type processor_id() const

◆ n_matrices()

unsigned int libMesh::System::n_matrices ( ) const
inline
Returns
The number of matrices handled by this system. This is the size of the _matrices map

Definition at line 2594 of file system.h.

References _matrices.

Referenced by libMesh::ImplicitSystem::add_matrices(), and get_info().

2595 {
2596  return cast_int<unsigned int>(_matrices.size());
2597 }
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
Some systems need an arbitrary number of matrices.
Definition: system.h:2181

◆ n_objects()

static unsigned int libMesh::ReferenceCounter::n_objects ( )
inlinestaticinherited

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

Definition at line 85 of file reference_counter.h.

References libMesh::ReferenceCounter::_n_objects.

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

86  { return _n_objects; }
static Threads::atomic< unsigned int > _n_objects
The number of objects.

◆ n_processors()

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

Definition at line 103 of file parallel_object.h.

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

Referenced by libMesh::Partitioner::_find_global_index_by_pid_map(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::DofMap::add_constraints_to_send_list(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), add_vector(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::FEMSystem::assembly(), libMesh::Nemesis_IO::assert_symmetric_cmaps(), libMesh::Partitioner::assign_partitioning(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::DistributedMesh::clear(), libMesh::DistributedMesh::clear_elems(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_scalar_dofs(), libMesh::DistributedMesh::DistributedMesh(), libMesh::EnsightIO::EnsightIO(), libMesh::RBEIMEvaluation::gather_bfs(), libMesh::MeshBase::get_info(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::DistributedMesh::insert_elem(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::DofMap::local_variable_indices(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_elem_on_proc(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), libMesh::RBEIMEvaluation::node_gather_bfs(), libMesh::Partitioner::partition(), libMesh::MeshBase::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), point_gradient(), point_hessian(), point_value(), libMesh::DofMap::prepare_send_list(), libMesh::DofMap::print_dof_constraints(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::XdrIO::read_header(), libMesh::CheckpointIO::read_nodes(), read_parallel_data(), read_SCALAR_dofs(), read_serialized_blocked_dof_objects(), read_serialized_vector(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::Partitioner::repartition(), OverlappingFunctorTest::run_partitioner_test(), libMesh::DofMap::scatter_constraints(), libMesh::DistributedMesh::set_next_unique_id(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), WriteVecAndScalar::setupTests(), libMesh::RBEIMEvaluation::side_gather_bfs(), DistributedMeshTest::testRemoteElemError(), CheckpointIOTest::testSplitter(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::VTKIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), write_parallel_data(), write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs_helper(), write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

104  {
105  processor_id_type returnval =
106  cast_int<processor_id_type>(_communicator.size());
107  libmesh_assert(returnval); // We never have an empty comm
108  return returnval;
109  }
const Parallel::Communicator & _communicator
processor_id_type size() const
uint8_t processor_id_type
libmesh_assert(ctx)

◆ n_qois()

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

Number of currently active quantities of interest.

Definition at line 2516 of file system.h.

References qoi, and qoi_error_estimates.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::AdaptiveTimeSolver::adjoint_advance_timestep(), libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::ImplicitSystem::adjoint_qoi_parameter_sensitivity(), libMesh::TwostepTimeSolver::adjoint_solve(), libMesh::ImplicitSystem::adjoint_solve(), libMesh::SensitivityData::allocate_data(), libMesh::SensitivityData::allocate_hessian_data(), libMesh::ExplicitSystem::assemble_qoi(), libMesh::FEMSystem::assemble_qoi(), libMesh::ExplicitSystem::assemble_qoi_derivative(), libMesh::FEMSystem::assemble_qoi_derivative(), libMesh::DiffContext::DiffContext(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::FileSolutionHistory::FileSolutionHistory(), libMesh::ImplicitSystem::forward_qoi_parameter_sensitivity(), libMesh::UnsteadySolver::init_adjoints(), libMesh::TimeSolver::init_adjoints(), init_qois(), libMesh::Euler2Solver::integrate_adjoint_refinement_error_estimate(), libMesh::TwostepTimeSolver::integrate_adjoint_refinement_error_estimate(), libMesh::EulerSolver::integrate_adjoint_refinement_error_estimate(), libMesh::Euler2Solver::integrate_qoi_timestep(), libMesh::TwostepTimeSolver::integrate_qoi_timestep(), libMesh::EulerSolver::integrate_qoi_timestep(), main(), libMesh::FEMContext::pre_fe_reinit(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), libMesh::FileSolutionHistory::retrieve(), libMesh::QoISet::size(), libMesh::UnsteadySolver::UnsteadySolver(), and libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().

2517 {
2518 #ifndef LIBMESH_ENABLE_DEPRECATED
2519  libmesh_assert_equal_to(this->qoi.size(), this->qoi_error_estimates.size());
2520 #endif
2521 
2522  return cast_int<unsigned int>(this->qoi.size());
2523 }
std::vector< Number > qoi
Values of the quantities of interest.
Definition: system.h:1611
std::vector< Number > qoi_error_estimates
Vector to hold error estimates for qois, either from a steady state calculation, or from a single uns...
Definition: system.h:1619

◆ n_variable_groups()

unsigned int libMesh::System::n_variable_groups ( ) const
inline
Returns
The number of VariableGroup variable groups in the system

Definition at line 2357 of file system.h.

References _variable_groups.

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

2358 {
2359  return cast_int<unsigned int>(_variable_groups.size());
2360 }
std::vector< VariableGroup > _variable_groups
The VariableGroup in this System.
Definition: system.h:2145

◆ n_vars()

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

Definition at line 2349 of file system.h.

References _variables.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::PetscDMWrapper::add_dofs_helper(), libMesh::DiffContext::add_localized_vector(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), add_variable(), add_variables(), libMesh::TwostepTimeSolver::adjoint_solve(), libMesh::FEMContext::attach_quadrature_rules(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::PetscDMWrapper::build_section(), calculate_norm(), compute_stresses(), LinearElasticityWithContact::compute_stresses(), LinearElasticity::compute_stresses(), LargeDeformationElasticity::compute_stresses(), libMesh::DGFEMContext::DGFEMContext(), libMesh::DiffContext::DiffContext(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::ErrorEstimator::estimate_errors(), libMesh::ExactSolution::ExactSolution(), libMesh::FEMContext::find_hardest_fe_type(), libMesh::EquationSystems::find_variable_numbers(), get_all_variable_numbers(), init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::FEMSystem::init_context(), libMesh::RBEIMConstruction::init_context(), libMesh::FEMContext::init_internal_data(), libMesh::DifferentiablePhysics::init_physics(), AssemblyA0::interior_assembly(), AssemblyA1::interior_assembly(), AssemblyA2::interior_assembly(), InnerProductAssembly::interior_assembly(), main(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), output_norms(), libMesh::petsc_auto_fieldsplit(), libMesh::FEMContext::pre_fe_reinit(), libMesh::RBEIMEvaluation::project_qp_data_map_onto_system(), libMesh::InterMeshProjection::project_system_vectors(), re_update(), read_legacy_data(), read_parallel_data(), read_serialized_blocked_dof_objects(), read_serialized_vector(), read_serialized_vectors(), reinit_mesh(), libMesh::HPCoarsenTest::select_refinement(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::SystemSubsetBySubdomain::set_var_nums(), OverlappingTestBase::setup_coupling_matrix(), SystemsTest::testDofCouplingWithVarGroups(), SlitMeshRefinedSystemTest::testRestart(), SlitMeshRefinedSystemTest::testSystem(), write_header(), write_parallel_data(), write_serialized_blocked_dof_objects(), write_serialized_vector(), write_serialized_vectors(), and zero_variable().

2350 {
2351  return cast_int<unsigned int>(_variables.size());
2352 }
std::vector< Variable > _variables
The Variable in this System.
Definition: system.h:2140

◆ n_vectors()

unsigned int libMesh::System::n_vectors ( ) const
inline
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 2477 of file system.h.

References _vectors.

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

2478 {
2479  return cast_int<unsigned int>(_vectors.size());
2480 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2164

◆ name()

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

◆ number()

unsigned int libMesh::System::number ( ) const
inline
Returns
The system number.

Definition at line 2269 of file system.h.

References _sys_number.

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::PetscDMWrapper::add_dofs_helper(), assemble_matrix_and_rhs(), assemble_shell(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::Nemesis_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::Nemesis_IO::copy_nodal_solution(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::find_squared_element_error(), libMesh::EquationSystems::find_variable_numbers(), get_info(), main(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SortAndCopy::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectVertices::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectEdges::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectSides::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectInteriors::operator()(), read_legacy_data(), read_parallel_data(), read_serialized_blocked_dof_objects(), LinearElasticityWithContact::residual_and_jacobian(), SolidSystem::save_initial_mesh(), libMesh::HPCoarsenTest::select_refinement(), libMesh::PetscDMWrapper::set_point_range_in_section(), MeshInputTest::testCopyElementVectorImpl(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), libMesh::BoundaryVolumeSolutionTransfer::transfer_volume_boundary(), libMesh::DTKAdapter::update_variable_values(), write_parallel_data(), write_serialized_blocked_dof_objects(), and zero_variable().

2270 {
2271  return _sys_number;
2272 }
const unsigned int _sys_number
The number associated with this system.
Definition: system.h:2135

◆ operator=() [1/2]

System& libMesh::System::operator= ( const System )
delete

◆ operator=() [2/2]

System& libMesh::System::operator= ( System &&  )
delete

◆ point_gradient() [1/4]

Gradient libMesh::System::point_gradient ( unsigned int  var,
const Point p,
const bool  insist_on_success = true,
const NumericVector< Number > *  sol = nullptr 
) const
Returns
The gradient of the solution variable var at the physical point p in the mesh, similarly to point_value.

Definition at line 2498 of file system.C.

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

Referenced by line_print(), and point_gradient().

2502 {
2503  // This function must be called on every processor; there's no
2504  // telling where in the partition p falls.
2505  parallel_object_only();
2506 
2507  // And every processor had better agree about which point we're
2508  // looking for
2509 #ifndef NDEBUG
2510  libmesh_assert(this->comm().verify(p(0)));
2511 #if LIBMESH_DIM > 1
2512  libmesh_assert(this->comm().verify(p(1)));
2513 #endif
2514 #if LIBMESH_DIM > 2
2515  libmesh_assert(this->comm().verify(p(2)));
2516 #endif
2517 #endif // NDEBUG
2518 
2519  // Get a reference to the mesh object associated with the system object that calls this function
2520  const MeshBase & mesh = this->get_mesh();
2521 
2522  // Use an existing PointLocator or create a new one
2523  std::unique_ptr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2524  PointLocatorBase & locator = *locator_ptr;
2525 
2526  if (!insist_on_success || !mesh.is_serial())
2527  locator.enable_out_of_mesh_mode();
2528 
2529  // Get a pointer to an element that contains p and allows us to
2530  // evaluate var
2531  const std::set<subdomain_id_type> & raw_subdomains =
2532  this->variable(var).active_subdomains();
2533  const std::set<subdomain_id_type> * implicit_subdomains =
2534  raw_subdomains.empty() ? nullptr : &raw_subdomains;
2535  const Elem * e = locator(p, implicit_subdomains);
2536 
2537  Gradient grad_u;
2538 
2539  if (e && this->get_dof_map().is_evaluable(*e, var))
2540  grad_u = point_gradient(var, p, *e, sol);
2541 
2542  // If I have an element containing p, then let's let everyone know
2543  processor_id_type lowest_owner =
2544  (e && (e->processor_id() == this->processor_id())) ?
2545  this->processor_id() : this->n_processors();
2546  this->comm().min(lowest_owner);
2547 
2548  // Everybody should get their value from a processor that was able
2549  // to compute it.
2550  // If nobody admits owning the point, we may have a problem.
2551  if (lowest_owner != this->n_processors())
2552  this->comm().broadcast(grad_u, lowest_owner);
2553  else
2554  libmesh_assert(!insist_on_success);
2555 
2556  return grad_u;
2557 }
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2377
Gradient point_gradient(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:2498
MeshBase & mesh
const Parallel::Communicator & comm() const
const MeshBase & get_mesh() const
Definition: system.h:2277
uint8_t processor_id_type
processor_id_type n_processors() const
const std::set< subdomain_id_type > & active_subdomains() const
Definition: variable.h:171
void min(const T &r, T &o, Request &req) const
NumberVectorValue Gradient
libmesh_assert(ctx)
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
processor_id_type processor_id() const
const DofMap & get_dof_map() const
Definition: system.h:2293

◆ point_gradient() [2/4]

Gradient libMesh::System::point_gradient ( unsigned int  var,
const Point p,
const Elem e,
const NumericVector< Number > *  sol = nullptr 
) const
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 2560 of file system.C.

References libMesh::FEInterface::compute_data(), libMesh::Elem::contains_point(), current_local_solution, dim, libMesh::Elem::dim(), libMesh::DofMap::dof_indices(), libMesh::FEComputeData::dshape, libMesh::FEComputeData::enable_derivative(), get_dof_map(), get_equation_systems(), libMesh::FEMap::inverse_map(), libMesh::DofMap::is_evaluable(), libMesh::libmesh_assert(), libMesh::FEComputeData::local_transform, and libMesh::DofMap::variable_type().

2564 {
2565  // Ensuring that the given point is really in the element is an
2566  // expensive assert, but as long as debugging is turned on we might
2567  // as well try to catch a particularly nasty potential error
2568  libmesh_assert (e.contains_point(p));
2569 
2570  if (!sol)
2571  sol = this->current_local_solution.get();
2572 
2573  // Get the dof map to get the proper indices for our computation
2574  const DofMap & dof_map = this->get_dof_map();
2575 
2576  // write the element dimension into a separate variable.
2577  const unsigned int dim = e.dim();
2578 
2579  // Make sure we can evaluate on this element.
2580  libmesh_assert (dof_map.is_evaluable(e, var));
2581 
2582  // Need dof_indices for phi[i][j]
2583  std::vector<dof_id_type> dof_indices;
2584 
2585  // Fill in the dof_indices for our element
2586  dof_map.dof_indices (&e, dof_indices, var);
2587 
2588  // Get the no of dofs associated with this point
2589  const unsigned int num_dofs = cast_int<unsigned int>
2590  (dof_indices.size());
2591 
2592  FEType fe_type = dof_map.variable_type(var);
2593 
2594  // Map the physical co-ordinates to the master co-ordinates
2595  Point coor = FEMap::inverse_map(dim, &e, p);
2596 
2597  // get the shape function value via the FEInterface to also handle the case
2598  // of infinite elements correctly, the shape function is not fe->phi().
2599  FEComputeData fe_data(this->get_equation_systems(), coor);
2600  fe_data.enable_derivative();
2601  FEInterface::compute_data(dim, fe_type, &e, fe_data);
2602 
2603  // Get ready to accumulate a gradient
2604  Gradient grad_u;
2605 
2606  for (unsigned int l=0; l<num_dofs; l++)
2607  {
2608  // Chartesian coordinates have always LIBMESH_DIM entries,
2609  // local coordinates have as many coordinates as the element has.
2610  for (std::size_t v=0; v<dim; v++)
2611  for (std::size_t xyz=0; xyz<LIBMESH_DIM; xyz++)
2612  {
2613  // FIXME: this needs better syntax: It is matrix-vector multiplication.
2614  grad_u(xyz) += fe_data.local_transform[v][xyz]
2615  * fe_data.dshape[l](v)
2616  * (*sol)(dof_indices[l]);
2617  }
2618  }
2619 
2620  return grad_u;
2621 }
unsigned int dim
static Point inverse_map(const unsigned int dim, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true, const bool extra_checks=true)
Definition: fe_map.C:1626
const EquationSystems & get_equation_systems() const
Definition: system.h:730
static void compute_data(const unsigned int dim, const FEType &fe_t, const Elem *elem, FEComputeData &data)
Lets the appropriate child of FEBase compute the requested data for the input specified in data...
NumberVectorValue Gradient
libmesh_assert(ctx)
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Definition: system.h:1585
const DofMap & get_dof_map() const
Definition: system.h:2293

◆ point_gradient() [3/4]

Gradient libMesh::System::point_gradient ( unsigned int  var,
const Point p,
const Elem e 
) const

Calls the version of point_gradient() which takes a reference.

This function exists only to prevent people from calling the version of point_gradient() that has a boolean third argument, which would result in unnecessary PointLocator calls.

Definition at line 2625 of file system.C.

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

2626 {
2627  libmesh_assert(e);
2628  return this->point_gradient(var, p, *e);
2629 }
Gradient point_gradient(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:2498
libmesh_assert(ctx)

◆ point_gradient() [4/4]

Gradient libMesh::System::point_gradient ( unsigned int  var,
const Point p,
const NumericVector< Number > *  sol 
) const

Calls the parallel version of point_gradient().

This function exists only to prevent people from accidentally calling the version of point_gradient() that has a boolean third argument, which would result in incorrect output.

Definition at line 2633 of file system.C.

References point_gradient().

2634 {
2635  return this->point_gradient(var, p, true, sol);
2636 }
Gradient point_gradient(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:2498

◆ point_hessian() [1/4]

Tensor libMesh::System::point_hessian ( unsigned int  var,
const Point p,
const bool  insist_on_success = true,
const NumericVector< Number > *  sol = nullptr 
) const
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 2642 of file system.C.

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

Referenced by point_hessian().

2646 {
2647  // This function must be called on every processor; there's no
2648  // telling where in the partition p falls.
2649  parallel_object_only();
2650 
2651  // And every processor had better agree about which point we're
2652  // looking for
2653 #ifndef NDEBUG
2654  libmesh_assert(this->comm().verify(p(0)));
2655 #if LIBMESH_DIM > 1
2656  libmesh_assert(this->comm().verify(p(1)));
2657 #endif
2658 #if LIBMESH_DIM > 2
2659  libmesh_assert(this->comm().verify(p(2)));
2660 #endif
2661 #endif // NDEBUG
2662 
2663  // Get a reference to the mesh object associated with the system object that calls this function
2664  const MeshBase & mesh = this->get_mesh();
2665 
2666  // Use an existing PointLocator or create a new one
2667  std::unique_ptr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2668  PointLocatorBase & locator = *locator_ptr;
2669 
2670  if (!insist_on_success || !mesh.is_serial())
2671  locator.enable_out_of_mesh_mode();
2672 
2673  // Get a pointer to an element that contains p and allows us to
2674  // evaluate var
2675  const std::set<subdomain_id_type> & raw_subdomains =
2676  this->variable(var).active_subdomains();
2677  const std::set<subdomain_id_type> * implicit_subdomains =
2678  raw_subdomains.empty() ? nullptr : &raw_subdomains;
2679  const Elem * e = locator(p, implicit_subdomains);
2680 
2681  Tensor hess_u;
2682 
2683  if (e && this->get_dof_map().is_evaluable(*e, var))
2684  hess_u = point_hessian(var, p, *e, sol);
2685 
2686  // If I have an element containing p, then let's let everyone know
2687  processor_id_type lowest_owner =
2688  (e && (e->processor_id() == this->processor_id())) ?
2689  this->processor_id() : this->n_processors();
2690  this->comm().min(lowest_owner);
2691 
2692  // Everybody should get their value from a processor that was able
2693  // to compute it.
2694  // If nobody admits owning the point, we may have a problem.
2695  if (lowest_owner != this->n_processors())
2696  this->comm().broadcast(hess_u, lowest_owner);
2697  else
2698  libmesh_assert(!insist_on_success);
2699 
2700  return hess_u;
2701 }
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2377
MeshBase & mesh
const Parallel::Communicator & comm() const
const MeshBase & get_mesh() const
Definition: system.h:2277
uint8_t processor_id_type
processor_id_type n_processors() const
const std::set< subdomain_id_type > & active_subdomains() const
Definition: variable.h:171
void min(const T &r, T &o, Request &req) const
libmesh_assert(ctx)
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
NumberTensorValue Tensor
Tensor point_hessian(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:2642
processor_id_type processor_id() const
const DofMap & get_dof_map() const
Definition: system.h:2293

◆ point_hessian() [2/4]

Tensor libMesh::System::point_hessian ( unsigned int  var,
const Point p,
const Elem e,
const NumericVector< Number > *  sol = nullptr 
) const
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 2703 of file system.C.

References libMesh::TypeTensor< T >::add_scaled(), libMesh::FEGenericBase< OutputType >::build(), libMesh::Elem::contains_point(), current_local_solution, libMesh::Elem::dim(), libMesh::DofMap::dof_indices(), get_dof_map(), libMesh::Elem::infinite(), libMesh::FEMap::inverse_map(), libMesh::DofMap::is_evaluable(), libMesh::libmesh_assert(), and libMesh::DofMap::variable_type().

2707 {
2708  // Ensuring that the given point is really in the element is an
2709  // expensive assert, but as long as debugging is turned on we might
2710  // as well try to catch a particularly nasty potential error
2711  libmesh_assert (e.contains_point(p));
2712 
2713  if (!sol)
2714  sol = this->current_local_solution.get();
2715 
2716  if (e.infinite())
2717  libmesh_not_implemented();
2718 
2719  // Get the dof map to get the proper indices for our computation
2720  const DofMap & dof_map = this->get_dof_map();
2721 
2722  // Make sure we can evaluate on this element.
2723  libmesh_assert (dof_map.is_evaluable(e, var));
2724 
2725  // Need dof_indices for phi[i][j]
2726  std::vector<dof_id_type> dof_indices;
2727 
2728  // Fill in the dof_indices for our element
2729  dof_map.dof_indices (&e, dof_indices, var);
2730 
2731  // Get the no of dofs associated with this point
2732  const unsigned int num_dofs = cast_int<unsigned int>
2733  (dof_indices.size());
2734 
2735  FEType fe_type = dof_map.variable_type(var);
2736 
2737  // Build a FE again so we can calculate u(p)
2738  std::unique_ptr<FEBase> fe (FEBase::build(e.dim(), fe_type));
2739 
2740  // Map the physical co-ordinates to the master co-ordinates
2741  // Build a vector of point co-ordinates to send to reinit
2742  std::vector<Point> coor(1, FEMap::inverse_map(e.dim(), &e, p));
2743 
2744  // Get the values of the shape function derivatives
2745  const std::vector<std::vector<RealTensor>> & d2phi = fe->get_d2phi();
2746 
2747  // Reinitialize the element and compute the shape function values at coor
2748  fe->reinit (&e, &coor);
2749 
2750  // Get ready to accumulate a hessian
2751  Tensor hess_u;
2752 
2753  for (unsigned int l=0; l<num_dofs; l++)
2754  {
2755  hess_u.add_scaled (d2phi[l][0], (*sol)(dof_indices[l]));
2756  }
2757 
2758  return hess_u;
2759 }
static Point inverse_map(const unsigned int dim, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true, const bool extra_checks=true)
Definition: fe_map.C:1626
static std::unique_ptr< FEGenericBase > build(const unsigned int dim, const FEType &type)
Builds a specific finite element type.
libmesh_assert(ctx)
void add_scaled(const TypeTensor< T2 > &, const T &)
Add a scaled tensor to this tensor without creating a temporary.
Definition: type_tensor.h:851
NumberTensorValue Tensor
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Definition: system.h:1585
const DofMap & get_dof_map() const
Definition: system.h:2293

◆ point_hessian() [3/4]

Tensor libMesh::System::point_hessian ( unsigned int  var,
const Point p,
const Elem e 
) const

Calls the version of point_hessian() which takes a reference.

This function exists only to prevent people from calling the version of point_hessian() that has a boolean third argument, which would result in unnecessary PointLocator calls.

Definition at line 2763 of file system.C.

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

2764 {
2765  libmesh_assert(e);
2766  return this->point_hessian(var, p, *e);
2767 }
libmesh_assert(ctx)
Tensor point_hessian(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:2642

◆ point_hessian() [4/4]

Tensor libMesh::System::point_hessian ( unsigned int  var,
const Point p,
const NumericVector< Number > *  sol 
) const

Calls the parallel version of point_hessian().

This function exists only to prevent people from accidentally calling the version of point_hessian() that has a boolean third argument, which would result in incorrect output.

Definition at line 2771 of file system.C.

References point_hessian().

2772 {
2773  return this->point_hessian(var, p, true, sol);
2774 }
Tensor point_hessian(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:2642

◆ point_value() [1/4]

Number libMesh::System::point_value ( unsigned int  var,
const Point p,
const bool  insist_on_success = true,
const NumericVector< Number > *  sol = nullptr 
) const
Returns
The value of the solution variable var at the physical point p in the mesh, without knowing a priori which element contains p, using the degree of freedom coefficients in sol (or in current_local_solution if sol is left null).
Note
This function uses MeshBase::sub_point_locator(); users may or may not want to call MeshBase::clear_point_locator() afterward. Also, point_locator() is expensive (N log N for initial construction, log N for evaluations). Avoid using this function in any context where you are already looping over elements.

Because the element containing p may lie on any processor, this function is parallel-only.

By default this method expects the point to reside inside the domain and will abort if no element can be found which contains p. The optional parameter insist_on_success can be set to false to allow the method to return 0 when the point is not located.

Definition at line 2369 of file system.C.

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

Referenced by line_print(), main(), point_value(), MeshInputTest::testCopyElementSolutionImpl(), MeshInputTest::testCopyElementVectorImpl(), MeshInputTest::testCopyNodalSolutionImpl(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), PeriodicBCTest::testPeriodicBC(), SystemsTest::testProjectCubeWithMeshFunction(), and EquationSystemsTest::testRepartitionThenReinit().

2373 {
2374  // This function must be called on every processor; there's no
2375  // telling where in the partition p falls.
2376  parallel_object_only();
2377 
2378  // And every processor had better agree about which point we're
2379  // looking for
2380 #ifndef NDEBUG
2381  libmesh_assert(this->comm().verify(p(0)));
2382 #if LIBMESH_DIM > 1
2383  libmesh_assert(this->comm().verify(p(1)));
2384 #endif
2385 #if LIBMESH_DIM > 2
2386  libmesh_assert(this->comm().verify(p(2)));
2387 #endif
2388 #endif // NDEBUG
2389 
2390  // Get a reference to the mesh object associated with the system object that calls this function
2391  const MeshBase & mesh = this->get_mesh();
2392 
2393  // Use an existing PointLocator or create a new one
2394  std::unique_ptr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2395  PointLocatorBase & locator = *locator_ptr;
2396 
2397  if (!insist_on_success || !mesh.is_serial())
2398  locator.enable_out_of_mesh_mode();
2399 
2400  // Get a pointer to an element that contains p and allows us to
2401  // evaluate var
2402  const std::set<subdomain_id_type> & raw_subdomains =
2403  this->variable(var).active_subdomains();
2404  const std::set<subdomain_id_type> * implicit_subdomains =
2405  raw_subdomains.empty() ? nullptr : &raw_subdomains;
2406  const Elem * e = locator(p, implicit_subdomains);
2407 
2408  Number u = 0;
2409 
2410  if (e && this->get_dof_map().is_evaluable(*e, var))
2411  u = point_value(var, p, *e, sol);
2412 
2413  // If I have an element containing p, then let's let everyone know
2414  processor_id_type lowest_owner =
2415  (e && (e->processor_id() == this->processor_id())) ?
2416  this->processor_id() : this->n_processors();
2417  this->comm().min(lowest_owner);
2418 
2419  // Everybody should get their value from a processor that was able
2420  // to compute it.
2421  // If nobody admits owning the point, we have a problem.
2422  if (lowest_owner != this->n_processors())
2423  this->comm().broadcast(u, lowest_owner);
2424  else
2425  libmesh_assert(!insist_on_success);
2426 
2427  return u;
2428 }
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2377
MeshBase & mesh
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:2369
const Parallel::Communicator & comm() const
const MeshBase & get_mesh() const
Definition: system.h:2277
uint8_t processor_id_type
processor_id_type n_processors() const
const std::set< subdomain_id_type > & active_subdomains() const
Definition: variable.h:171
void min(const T &r, T &o, Request &req) const
libmesh_assert(ctx)
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
processor_id_type processor_id() const
const DofMap & get_dof_map() const
Definition: system.h:2293

◆ point_value() [2/4]

Number libMesh::System::point_value ( unsigned int  var,
const Point p,
const Elem e,
const NumericVector< Number > *  sol = nullptr 
) const
Returns
The value of the solution variable var at the physical point p contained in local Elem e, using the degree of freedom coefficients in sol (or in current_local_solution if sol is left null).

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

Definition at line 2430 of file system.C.

References libMesh::FEInterface::compute_data(), libMesh::Elem::contains_point(), current_local_solution, libMesh::Elem::dim(), libMesh::DofMap::dof_indices(), get_dof_map(), get_equation_systems(), libMesh::FEMap::inverse_map(), libMesh::DofMap::is_evaluable(), libMesh::libmesh_assert(), and libMesh::DofMap::variable_type().

2434 {
2435  // Ensuring that the given point is really in the element is an
2436  // expensive assert, but as long as debugging is turned on we might
2437  // as well try to catch a particularly nasty potential error
2438  libmesh_assert (e.contains_point(p));
2439 
2440  if (!sol)
2441  sol = this->current_local_solution.get();
2442 
2443  // Get the dof map to get the proper indices for our computation
2444  const DofMap & dof_map = this->get_dof_map();
2445 
2446  // Make sure we can evaluate on this element.
2447  libmesh_assert (dof_map.is_evaluable(e, var));
2448 
2449  // Need dof_indices for phi[i][j]
2450  std::vector<dof_id_type> dof_indices;
2451 
2452  // Fill in the dof_indices for our element
2453  dof_map.dof_indices (&e, dof_indices, var);
2454 
2455  // Get the no of dofs associated with this point
2456  const unsigned int num_dofs = cast_int<unsigned int>
2457  (dof_indices.size());
2458 
2459  FEType fe_type = dof_map.variable_type(var);
2460 
2461  // Map the physical co-ordinates to the master co-ordinates
2462  Point coor = FEMap::inverse_map(e.dim(), &e, p);
2463 
2464  // get the shape function value via the FEInterface to also handle the case
2465  // of infinite elements correctly, the shape function is not fe->phi().
2466  FEComputeData fe_data(this->get_equation_systems(), coor);
2467  FEInterface::compute_data(e.dim(), fe_type, &e, fe_data);
2468 
2469  // Get ready to accumulate a value
2470  Number u = 0;
2471 
2472  for (unsigned int l=0; l<num_dofs; l++)
2473  {
2474  u += fe_data.shape[l] * (*sol)(dof_indices[l]);
2475  }
2476 
2477  return u;
2478 }
static Point inverse_map(const unsigned int dim, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true, const bool extra_checks=true)
Definition: fe_map.C:1626
const EquationSystems & get_equation_systems() const
Definition: system.h:730
static void compute_data(const unsigned int dim, const FEType &fe_t, const Elem *elem, FEComputeData &data)
Lets the appropriate child of FEBase compute the requested data for the input specified in data...
libmesh_assert(ctx)
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Definition: system.h:1585
const DofMap & get_dof_map() const
Definition: system.h:2293

◆ point_value() [3/4]

Number libMesh::System::point_value ( unsigned int  var,
const Point p,
const Elem e 
) const

Calls the version of point_value() which takes a reference.

This function exists only to prevent people from calling the version of point_value() that has a boolean third argument, which would result in unnecessary PointLocator calls.

Definition at line 2482 of file system.C.

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

2483 {
2484  libmesh_assert(e);
2485  return this->point_value(var, p, *e);
2486 }
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:2369
libmesh_assert(ctx)

◆ point_value() [4/4]

Number libMesh::System::point_value ( unsigned int  var,
const Point p,
const NumericVector< Number > *  sol 
) const

Calls the parallel version of point_value().

This function exists only to prevent people from accidentally calling the version of point_value() that has a boolean third argument, which would result in incorrect output.

Definition at line 2490 of file system.C.

References point_value().

2491 {
2492  return this->point_value(var, p, true, sol);
2493 }
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:2369

◆ print_info()

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

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

Definition at line 81 of file reference_counter.C.

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

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

82 {
84  out_stream << ReferenceCounter::get_info();
85 }
static std::string get_info()
Gets a string containing the reference information.
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called...

◆ processor_id()

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

Definition at line 114 of file parallel_object.h.

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

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::MeshTools::Modification::all_tri(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::FEMSystem::assembly(), libMesh::Nemesis_IO::assert_symmetric_cmaps(), libMesh::Partitioner::assign_partitioning(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::Partitioner::build_graph(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::DistributedMesh::clear(), libMesh::DistributedMesh::clear_elems(), libMesh::ExodusII_IO_Helper::close(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::compute_communication_map_parameters(), libMesh::Nemesis_IO_Helper::compute_internal_and_border_elems_and_internal_nodes(), libMesh::RBConstruction::compute_max_error_bound(), libMesh::Nemesis_IO_Helper::compute_node_communication_maps(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::ExodusII_IO_Helper::create(), libMesh::DistributedMesh::delete_elem(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DofMap::distribute_scalar_dofs(), libMesh::DistributedMesh::DistributedMesh(), libMesh::DofMap::end_dof(), libMesh::DofMap::end_old_dof(), libMesh::EnsightIO::EnsightIO(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::find_dofs_to_send(), libMesh::MeshFunction::find_element(), libMesh::MeshFunction::find_elements(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::DofMap::first_dof(), libMesh::DofMap::first_old_dof(), libMesh::RBEIMEvaluation::gather_bfs(), libMesh::Nemesis_IO_Helper::get_cmap_params(), libMesh::Nemesis_IO_Helper::get_eb_info_global(), libMesh::Nemesis_IO_Helper::get_elem_cmap(), libMesh::Nemesis_IO_Helper::get_elem_map(), libMesh::MeshBase::get_info(), libMesh::DofMap::get_info(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), libMesh::DofMap::get_local_constraints(), libMesh::Nemesis_IO_Helper::get_node_cmap(), libMesh::Nemesis_IO_Helper::get_node_map(), libMesh::Nemesis_IO_Helper::get_ns_param_global(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), libMesh::SparsityPattern::Build::handle_vi_vj(), libMesh::LaplaceMeshSmoother::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), HeatSystem::init_data(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_element_variables(), libMesh::ExodusII_IO_Helper::initialize_global_variables(), libMesh::ExodusII_IO_Helper::initialize_nodal_variables(), libMesh::DistributedMesh::insert_elem(), libMesh::DofMap::is_evaluable(), libMesh::SparsityPattern::Build::join(), libMesh::TransientRBEvaluation::legacy_write_offline_data_to_files(), libMesh::RBSCMEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEvaluation::legacy_write_offline_data_to_files(), libMesh::MeshTools::libmesh_assert_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DofMap::local_variable_indices(), main(), libMesh::MeshRefinement::make_coarsening_compatible(), AugmentSparsityOnInterface::mesh_reinit(), libMesh::TriangulatorInterface::MeshedHole::MeshedHole(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::DofMap::n_local_dofs(), n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::RBEIMEvaluation::node_gather_bfs(), libMesh::SparsityPattern::Build::operator()(), libMesh::DistributedMesh::own_node(), libMesh::BoundaryInfo::parallel_sync_node_ids(), libMesh::BoundaryInfo::parallel_sync_side_ids(), point_gradient(), point_hessian(), point_value(), libMesh::DofMap::print_dof_constraints(), libMesh::DofMap::process_mesh_constraint_rows(), libMesh::Nemesis_IO_Helper::put_cmap_params(), libMesh::Nemesis_IO_Helper::put_elem_cmap(), libMesh::Nemesis_IO_Helper::put_elem_map(), libMesh::Nemesis_IO_Helper::put_loadbal_param(), libMesh::Nemesis_IO_Helper::put_node_cmap(), libMesh::Nemesis_IO_Helper::put_node_map(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read(), libMesh::EquationSystems::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::ExodusII_IO_Helper::read_global_values(), libMesh::ExodusII_IO::read_header(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), read_header(), read_legacy_data(), libMesh::DynaIO::read_mesh(), libMesh::ExodusII_IO_Helper::read_node_num_map(), read_parallel_data(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), read_serialized_data(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), read_serialized_vector(), read_serialized_vectors(), libMesh::Nemesis_IO_Helper::read_var_names_impl(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::DistributedMesh::renumber_nodes_and_elements(), libMesh::DofMap::scatter_constraints(), libMesh::CheckpointIO::select_split_config(), libMesh::DistributedMesh::set_next_unique_id(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::RBEIMEvaluation::side_gather_bfs(), ExodusTest< elem_type >::test_read_gold(), ExodusTest< elem_type >::test_write(), MeshInputTest::testAbaqusRead(), MeshInputTest::testCopyElementSolutionImpl(), MeshInputTest::testCopyElementVectorImpl(), MeshInputTest::testCopyNodalSolutionImpl(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), MeshInputTest::testDynaFileMappings(), MeshInputTest::testDynaNoSplines(), MeshInputTest::testDynaReadElem(), MeshInputTest::testDynaReadPatch(), MeshInputTest::testExodusFileMappings(), MeshInputTest::testExodusIGASidesets(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), MeshInputTest::testLowOrderEdgeBlocks(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), BoundaryInfoTest::testShellFaceConstraints(), MeshInputTest::testSingleElementImpl(), WriteVecAndScalar::testSolution(), CheckpointIOTest::testSplitter(), MeshInputTest::testTetgenIO(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::DTKAdapter::update_variable_values(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::CheckpointIO::write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::ExodusII_IO_Helper::write_element_values_element_major(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO_Helper::write_elemset_data(), libMesh::ExodusII_IO_Helper::write_elemsets(), libMesh::ExodusII_IO::write_global_data(), libMesh::ExodusII_IO_Helper::write_global_values(), write_header(), libMesh::ExodusII_IO::write_information_records(), libMesh::ExodusII_IO_Helper::write_information_records(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::UCDIO::write_nodal_data(), libMesh::VTKIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_common(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::ExodusII_IO_Helper::write_nodal_values(), libMesh::ExodusII_IO_Helper::write_nodeset_data(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::RBEIMEvaluation::write_out_interior_basis_functions(), libMesh::RBEIMEvaluation::write_out_node_basis_functions(), libMesh::RBEIMEvaluation::write_out_side_basis_functions(), write_output_solvedata(), write_parallel_data(), libMesh::RBConstruction::write_riesz_representors_to_files(), write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs_helper(), write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), write_serialized_data(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), write_serialized_vector(), write_serialized_vectors(), libMesh::ExodusII_IO_Helper::write_sideset_data(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), libMesh::ExodusII_IO_Helper::write_timestep(), and libMesh::ExodusII_IO::write_timestep_discontinuous().

115  { return cast_int<processor_id_type>(_communicator.rank()); }
processor_id_type rank() const
const Parallel::Communicator & _communicator

◆ project_solution() [1/3]

void libMesh::System::project_solution ( FunctionBase< Number > *  f,
FunctionBase< Gradient > *  g = nullptr 
) const

Projects arbitrary functions onto the current solution.

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

The function value f and its gradient g are user-provided cloneable functors. A gradient g is only required/used for projecting onto finite element spaces with continuous derivatives. If non-default Parameters are to be used, they can be provided in the parameters argument.

Definition at line 1041 of file system_projection.C.

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

1043 {
1044  this->project_vector(*solution, f, g);
1045 
1046  solution->localize(*current_local_solution, _dof_map->get_send_list());
1047 }
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:2113
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1573
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Definition: system.h:1585
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
Projects arbitrary functions onto a vector of degree of freedom values for the current system...

◆ project_solution() [2/3]

void libMesh::System::project_solution ( FEMFunctionBase< Number > *  f,
FEMFunctionBase< Gradient > *  g = nullptr 
) const

Projects arbitrary functions onto the current solution.

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

The function value f and its gradient g are user-provided cloneable functors. A gradient g is only required/used for projecting onto finite element spaces with continuous derivatives. If non-default Parameters are to be used, they can be provided in the parameters argument.

Definition at line 1054 of file system_projection.C.

1056 {
1057  this->project_vector(*solution, f, g);
1058 
1059  solution->localize(*current_local_solution, _dof_map->get_send_list());
1060 }
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:2113
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1573
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Definition: system.h:1585
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
Projects arbitrary functions onto a vector of degree of freedom values for the current system...

◆ project_solution() [3/3]

void libMesh::System::project_solution ( ValueFunctionPointer  fptr,
GradientFunctionPointer  gptr,
const Parameters parameters 
) const

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

Definition at line 1027 of file system_projection.C.

References fptr(), and gptr().

1030 {
1031  WrappedFunction<Number> f(*this, fptr, &parameters);
1032  WrappedFunction<Gradient> g(*this, gptr, &parameters);
1033  this->project_solution(&f, &g);
1034 }
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:80
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr) const
Projects arbitrary functions onto the current solution.
Gradient gptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:95

◆ project_solution_on_reinit()

bool& libMesh::System::project_solution_on_reinit ( void  )
inline

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

References _solution_projection.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), and libMesh::MemoryHistoryData::store_vectors().

822  { return _solution_projection; }
bool _solution_projection
Holds true if the solution vector should be projected onto a changed grid, false if it should be zero...
Definition: system.h:2198

◆ project_vector() [1/5]

void libMesh::System::project_vector ( NumericVector< Number > &  new_vector,
FunctionBase< Number > *  f,
FunctionBase< Gradient > *  g = nullptr,
int  is_adjoint = -1 
) const

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

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

The function value f and its gradient g are user-provided cloneable functors. A gradient g is only required/used for projecting onto finite element spaces with continuous derivatives. If non-default Parameters are to be used, they can be provided in the parameters argument.

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

Definition at line 1082 of file system_projection.C.

References libMesh::libmesh_assert().

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

1086 {
1087  LOG_SCOPE ("project_vector(FunctionBase)", "System");
1088 
1089  libmesh_assert(f);
1090 
1091  WrappedFunctor<Number> f_fem(*f);
1092 
1093  if (g)
1094  {
1095  WrappedFunctor<Gradient> g_fem(*g);
1096 
1097  this->project_vector(new_vector, &f_fem, &g_fem, is_adjoint);
1098  }
1099  else
1100  this->project_vector(new_vector, &f_fem, nullptr, is_adjoint);
1101 }
libmesh_assert(ctx)
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
Projects arbitrary functions onto a vector of degree of freedom values for the current system...

◆ project_vector() [2/5]

void libMesh::System::project_vector ( NumericVector< Number > &  new_vector,
FEMFunctionBase< Number > *  f,
FEMFunctionBase< Gradient > *  g = nullptr,
int  is_adjoint = -1 
) const

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

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

The function value f and its gradient g are user-provided cloneable functors. A gradient g is only required/used for projecting onto finite element spaces with continuous derivatives. If non-default Parameters are to be used, they can be provided in the parameters argument.

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

Definition at line 1108 of file system_projection.C.

References libMesh::NumericVector< T >::close(), libMesh::FEMFunctionBase< Output >::component(), libMesh::FEType::family, libMesh::Utility::iota(), libMesh::libmesh_assert(), libMesh::libmesh_ignore(), libMesh::make_range(), n_vars, libMesh::NODEELEM, libMesh::FEMContext::pre_fe_reinit(), libMesh::RATIONAL_BERNSTEIN, libMesh::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), libMesh::NumericVector< T >::set(), and libMesh::Variable::type().

1112 {
1113  LOG_SCOPE ("project_fem_vector()", "System");
1114 
1115  libmesh_assert (f);
1116 
1117  ConstElemRange active_local_range
1118  (this->get_mesh().active_local_elements_begin(),
1119  this->get_mesh().active_local_elements_end() );
1120 
1121  VectorSetAction<Number> setter(new_vector);
1122 
1123  const unsigned int n_variables = this->n_vars();
1124 
1125  std::vector<unsigned int> vars(n_variables);
1126  std::iota(vars.begin(), vars.end(), 0);
1127 
1128  // Use a typedef to make the calling sequence for parallel_for() a bit more readable
1129  typedef
1130  GenericProjector<FEMFunctionWrapper<Number>, FEMFunctionWrapper<Gradient>,
1131  Number, VectorSetAction<Number>> FEMProjector;
1132 
1133  FEMFunctionWrapper<Number> fw(*f);
1134 
1135  if (g)
1136  {
1137  FEMFunctionWrapper<Gradient> gw(*g);
1138 
1139  FEMProjector projector(*this, fw, &gw, setter, vars);
1140  projector.project(active_local_range);
1141  }
1142  else
1143  {
1144  FEMProjector projector(*this, fw, nullptr, setter, vars);
1145  projector.project(active_local_range);
1146  }
1147 
1148  // Also, load values into the SCALAR dofs
1149  // Note: We assume that all SCALAR dofs are on the
1150  // processor with highest ID
1151  if (this->processor_id() == (this->n_processors()-1))
1152  {
1153  // FIXME: Do we want to first check for SCALAR vars before building this? [PB]
1154  FEMContext context( *this );
1155 
1156  const DofMap & dof_map = this->get_dof_map();
1157  for (auto var : make_range(this->n_vars()))
1158  if (this->variable(var).type().family == SCALAR)
1159  {
1160  // FIXME: We reinit with an arbitrary element in case the user
1161  // doesn't override FEMFunctionBase::component. Is there
1162  // any use case we're missing? [PB]
1163  context.pre_fe_reinit(*this, *(this->get_mesh().active_local_elements_begin()));
1164 
1165  std::vector<dof_id_type> SCALAR_indices;
1166  dof_map.SCALAR_dof_indices (SCALAR_indices, var);
1167  const unsigned int n_SCALAR_dofs =
1168  cast_int<unsigned int>(SCALAR_indices.size());
1169 
1170  for (unsigned int i=0; i<n_SCALAR_dofs; i++)
1171  {
1172  const dof_id_type global_index = SCALAR_indices[i];
1173  const unsigned int component_index =
1174  this->variable_scalar_number(var,i);
1175 
1176  new_vector.set(global_index, f->component(context, component_index, Point(), this->time));
1177  }
1178  }
1179  }
1180 
1181  new_vector.close();
1182 
1183  // Look for spline bases, in which case we need to backtrack
1184  // to calculate the spline DoF values.
1185  std::vector<const Variable *> rational_vars;
1186  for (auto varnum : vars)
1187  {
1188  const Variable & var = this->get_dof_map().variable(varnum);
1189  if (var.type().family == RATIONAL_BERNSTEIN)
1190  rational_vars.push_back(&var);
1191  }
1192 
1193  // Okay, but are we really using any *spline* bases, or just
1194  // unconstrained rational bases?
1195  bool using_spline_bases = false;
1196  if (!rational_vars.empty())
1197  {
1198  // Look for a spline node: a NodeElem with a rational variable
1199  // on it.
1200  for (auto & elem : active_local_range)
1201  if (elem->type() == NODEELEM)
1202  for (auto rational_var : rational_vars)
1203  if (rational_var->active_on_subdomain(elem->subdomain_id()))
1204  {
1205  using_spline_bases = true;
1206  goto checked_on_splines;
1207  }
1208  }
1209 
1210 checked_on_splines:
1211 
1212  // Not every processor may have a NodeElem, especially while
1213  // we're not partitioning them efficiently yet.
1214  this->comm().max(using_spline_bases);
1215 
1216  if (using_spline_bases)
1217  this->solve_for_unconstrained_dofs(new_vector, is_adjoint);
1218 
1219 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1220  if (is_adjoint == -1)
1221  this->get_dof_map().enforce_constraints_exactly(*this, &new_vector);
1222  else if (is_adjoint >= 0)
1224  is_adjoint);
1225 #else
1226  libmesh_ignore(is_adjoint);
1227 #endif
1228 }
Real time
For time-dependent problems, this is the time t at the beginning of the current timestep.
Definition: system.h:1595
unsigned int variable_scalar_number(std::string_view var, unsigned int component) const
Definition: system.h:2408
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2377
const Parallel::Communicator & comm() const
const MeshBase & get_mesh() const
Definition: system.h:2277
void iota(ForwardIter first, ForwardIter last, T value)
Utility::iota was created back when std::iota was just an SGI STL extension.
Definition: utility.h:229
StoredRange< MeshBase::const_element_iterator, const Elem * > ConstElemRange
Definition: elem_range.h:34
void enforce_adjoint_constraints_exactly(NumericVector< Number > &v, unsigned int q) const
Heterogeneously constrains the numeric vector v, which represents an adjoint solution defined on the ...
Definition: dof_map.h:2278
processor_id_type n_processors() const
void libmesh_ignore(const Args &...)
const Variable & variable(const unsigned int c) const
Definition: dof_map.h:2114
libmesh_assert(ctx)
virtual void close()=0
Calls the NumericVector&#39;s internal assembly routines, ensuring that the values are consistent across ...
void max(const T &r, T &o, Request &req) const
virtual Output component(const FEMContext &, unsigned int i, const Point &p, Real time=0.)
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:134
virtual void set(const numeric_index_type i, const T value)=0
Sets v(i) = value.
unsigned int n_vars() const
Definition: system.h:2349
processor_id_type processor_id() const
const DofMap & get_dof_map() const
Definition: system.h:2293
void solve_for_unconstrained_dofs(NumericVector< Number > &, int is_adjoint=-1) const
uint8_t dof_id_type
Definition: id_types.h:67
void enforce_constraints_exactly(const System &system, NumericVector< Number > *v=nullptr, bool homogeneous=false) const
Constrains the numeric vector v, which represents a solution defined on the mesh. ...
Definition: dof_map.h:2274

◆ project_vector() [3/5]

void libMesh::System::project_vector ( ValueFunctionPointer  fptr,
GradientFunctionPointer  gptr,
const Parameters parameters,
NumericVector< Number > &  new_vector,
int  is_adjoint = -1 
) const

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

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

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

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

Definition at line 1067 of file system_projection.C.

References fptr(), and gptr().

1072 {
1073  WrappedFunction<Number> f(*this, fptr, &parameters);
1074  WrappedFunction<Gradient> g(*this, gptr, &parameters);
1075  this->project_vector(new_vector, &f, &g, is_adjoint);
1076 }
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:80
Gradient gptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:95
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
Projects arbitrary functions onto a vector of degree of freedom values for the current system...

◆ project_vector() [4/5]

void libMesh::System::project_vector ( NumericVector< Number > &  vector,
int  is_adjoint = -1 
) const
protected

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

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

Definition at line 247 of file system_projection.C.

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

249 {
250  // Create a copy of the vector, which currently
251  // contains the old data.
252  std::unique_ptr<NumericVector<Number>>
253  old_vector (vector.clone());
254 
255  // Project the old vector to the new vector
256  this->project_vector (*old_vector, vector, is_adjoint);
257 }
virtual std::unique_ptr< NumericVector< T > > clone() const =0
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
Projects arbitrary functions onto a vector of degree of freedom values for the current system...

◆ project_vector() [5/5]

void libMesh::System::project_vector ( const NumericVector< Number > &  old_v,
NumericVector< Number > &  new_v,
int  is_adjoint = -1 
) const
protected

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

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

The original vector is unchanged and the new vector is passed through the second argument.

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

This method projects a solution from an old mesh to a current, refined mesh. The input vector old_v gives the solution on the old mesh, while the new_v gives the solution (to be computed) on the new mesh.

Definition at line 265 of file system_projection.C.

References libMesh::NumericVector< T >::clear(), libMesh::NumericVector< T >::close(), libMesh::NumericVector< T >::get(), libMesh::GHOSTED, libMesh::index_range(), libMesh::NumericVector< T >::init(), libMesh::Utility::iota(), libMesh::libmesh_assert(), libMesh::libmesh_ignore(), libMesh::NumericVector< T >::local_size(), libMesh::NumericVector< T >::localize(), libMesh::make_range(), n_vars, libMesh::PARALLEL, libMesh::Threads::parallel_reduce(), libMesh::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), libMesh::BuildProjectionList::send_list, libMesh::SERIAL, libMesh::NumericVector< T >::set(), libMesh::NumericVector< T >::size(), libMesh::NumericVector< T >::type(), libMesh::TYPE_SCALAR, and libMesh::BuildProjectionList::unique().

268 {
269  LOG_SCOPE ("project_vector(old,new)", "System");
270 
277  new_v.clear();
278 
279 #ifdef LIBMESH_ENABLE_AMR
280 
281  // Resize the new vector and get a serial version.
282  NumericVector<Number> * new_vector_ptr = nullptr;
283  std::unique_ptr<NumericVector<Number>> new_vector_built;
284  NumericVector<Number> * local_old_vector;
285  std::unique_ptr<NumericVector<Number>> local_old_vector_built;
286  const NumericVector<Number> * old_vector_ptr = nullptr;
287 
288  ConstElemRange active_local_elem_range
289  (this->get_mesh().active_local_elements_begin(),
290  this->get_mesh().active_local_elements_end());
291 
292  // If the old vector was uniprocessor, make the new
293  // vector uniprocessor
294  if (old_v.type() == SERIAL)
295  {
296  new_v.init (this->n_dofs(), false, SERIAL);
297  new_vector_ptr = &new_v;
298  old_vector_ptr = &old_v;
299  }
300 
301  // Otherwise it is a parallel, distributed vector, which
302  // we need to localize.
303  else if (old_v.type() == PARALLEL)
304  {
305  // Build a send list for efficient localization
306  BuildProjectionList projection_list(*this);
307  Threads::parallel_reduce (active_local_elem_range,
308  projection_list);
309 
310  // Create a sorted, unique send_list
311  projection_list.unique();
312 
313  new_v.init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
314  new_vector_built = NumericVector<Number>::build(this->comm());
315  local_old_vector_built = NumericVector<Number>::build(this->comm());
316  new_vector_ptr = new_vector_built.get();
317  local_old_vector = local_old_vector_built.get();
318  new_vector_ptr->init(this->n_dofs(), this->n_local_dofs(),
319  this->get_dof_map().get_send_list(), false,
320  GHOSTED);
321  local_old_vector->init(old_v.size(), old_v.local_size(),
322  projection_list.send_list, false, GHOSTED);
323  old_v.localize(*local_old_vector, projection_list.send_list);
324  local_old_vector->close();
325  old_vector_ptr = local_old_vector;
326  }
327  else if (old_v.type() == GHOSTED)
328  {
329  // Build a send list for efficient localization
330  BuildProjectionList projection_list(*this);
331  Threads::parallel_reduce (active_local_elem_range,
332  projection_list);
333 
334  // Create a sorted, unique send_list
335  projection_list.unique();
336 
337  new_v.init (this->n_dofs(), this->n_local_dofs(),
338  this->get_dof_map().get_send_list(), false, GHOSTED);
339 
340  local_old_vector_built = NumericVector<Number>::build(this->comm());
341  new_vector_ptr = &new_v;
342  local_old_vector = local_old_vector_built.get();
343  local_old_vector->init(old_v.size(), old_v.local_size(),
344  projection_list.send_list, false, GHOSTED);
345  old_v.localize(*local_old_vector, projection_list.send_list);
346  local_old_vector->close();
347  old_vector_ptr = local_old_vector;
348  }
349  else // unknown old_v.type()
350  libmesh_error_msg("ERROR: Unknown old_v.type() == " << old_v.type());
351 
352  // Note that the above will have zeroed the new_vector.
353  // Just to be sure, assert that new_vector_ptr and old_vector_ptr
354  // were successfully set before trying to deref them.
355  libmesh_assert(new_vector_ptr);
356  libmesh_assert(old_vector_ptr);
357 
358  NumericVector<Number> & new_vector = *new_vector_ptr;
359  const NumericVector<Number> & old_vector = *old_vector_ptr;
360 
361  const unsigned int n_variables = this->n_vars();
362 
363  if (n_variables)
364  {
365  std::vector<unsigned int> vars(n_variables);
366  std::iota(vars.begin(), vars.end(), 0);
367  std::vector<unsigned int> regular_vars, vector_vars;
368  for (auto var : vars)
369  {
371  regular_vars.push_back(var);
372  else
373  vector_vars.push_back(var);
374  }
375 
376  VectorSetAction<Number> setter(new_vector);
377 
378  if (!regular_vars.empty())
379  {
380  // Use a typedef to make the calling sequence for parallel_for() a bit more readable
381  typedef
382  GenericProjector<OldSolutionValue<Number, &FEMContext::point_value>,
383  OldSolutionValue<Gradient, &FEMContext::point_gradient>,
384  Number, VectorSetAction<Number>> FEMProjector;
385 
386  OldSolutionValue<Number, &FEMContext::point_value>
387  f(*this, old_vector, &regular_vars);
388  OldSolutionValue<Gradient, &FEMContext::point_gradient>
389  g(*this, old_vector, &regular_vars);
390 
391  FEMProjector projector(*this, f, &g, setter, regular_vars);
392  projector.project(active_local_elem_range);
393  }
394 
395  if (!vector_vars.empty())
396  {
397  typedef
398  GenericProjector<OldSolutionValue<Gradient, &FEMContext::point_value>,
399  OldSolutionValue<Tensor, &FEMContext::point_gradient>,
400  Gradient, VectorSetAction<Number>> FEMVectorProjector;
401 
402  OldSolutionValue<Gradient, &FEMContext::point_value> f_vector(*this, old_vector, &vector_vars);
403  OldSolutionValue<Tensor, &FEMContext::point_gradient> g_vector(*this, old_vector, &vector_vars);
404 
405  FEMVectorProjector vector_projector(*this, f_vector, &g_vector, setter, vector_vars);
406  vector_projector.project(active_local_elem_range);
407  }
408 
409  // Copy the SCALAR dofs from old_vector to new_vector
410  // Note: We assume that all SCALAR dofs are on the
411  // processor with highest ID
412  if (this->processor_id() == (this->n_processors()-1))
413  {
414  const DofMap & dof_map = this->get_dof_map();
415  for (auto var : make_range(this->n_vars()))
416  if (this->variable(var).type().family == SCALAR)
417  {
418  // We can just map SCALAR dofs directly across
419  std::vector<dof_id_type> new_SCALAR_indices, old_SCALAR_indices;
420  dof_map.SCALAR_dof_indices (new_SCALAR_indices, var, false);
421  dof_map.SCALAR_dof_indices (old_SCALAR_indices, var, true);
422  for (auto i : index_range(new_SCALAR_indices))
423  new_vector.set(new_SCALAR_indices[i], old_vector(old_SCALAR_indices[i]));
424  }
425  }
426  }
427 
428  new_vector.close();
429 
430  // If the old vector was serial, we probably need to send our values
431  // to other processors
432  //
433  // FIXME: I'm not sure how to make a NumericVector do that without
434  // creating a temporary parallel vector to use localize! - RHS
435  if (old_v.type() == SERIAL)
436  {
437  std::unique_ptr<NumericVector<Number>> dist_v = NumericVector<Number>::build(this->comm());
438  dist_v->init(this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
439  dist_v->close();
440 
441  for (auto i : make_range(dist_v->size()))
442  if (new_vector(i) != 0.0)
443  dist_v->set(i, new_vector(i));
444 
445  dist_v->close();
446 
447  dist_v->localize (new_v, this->get_dof_map().get_send_list());
448  new_v.close();
449  }
450  // If the old vector was parallel, we need to update it
451  // and free the localized copies
452  else if (old_v.type() == PARALLEL)
453  {
454  // We may have to set dof values that this processor doesn't
455  // own in certain special cases, like LAGRANGE FIRST or
456  // HERMITE THIRD elements on second-order meshes?
457  new_v = new_vector;
458  new_v.close();
459  }
460 
461 
462  // Apply constraints only if we we are asked to
463  if(this->project_with_constraints)
464  {
465  if (is_adjoint == -1)
466  {
467  this->get_dof_map().enforce_constraints_exactly(*this, &new_v);
468  }
469  else if (is_adjoint >= 0)
470  {
472  is_adjoint);
473  }
474  }
475 #else
476 
477  // AMR is disabled: simply copy the vector
478  new_v = old_v;
479 
480  libmesh_ignore(is_adjoint);
481 
482 #endif // #ifdef LIBMESH_ENABLE_AMR
483 }
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2377
virtual void get(const std::vector< numeric_index_type > &index, T *values) const
Access multiple components at once.
virtual numeric_index_type size() const =0
static FEFieldType field_type(const FEType &fe_type)
const Parallel::Communicator & comm() const
dof_id_type n_local_dofs() const
Definition: system.C:150
const MeshBase & get_mesh() const
Definition: system.h:2277
virtual void init(const numeric_index_type n, const numeric_index_type n_local, const bool fast=false, const ParallelType ptype=AUTOMATIC)=0
Change the dimension of the vector to n.
void iota(ForwardIter first, ForwardIter last, T value)
Utility::iota was created back when std::iota was just an SGI STL extension.
Definition: utility.h:229
dof_id_type n_dofs() const
Definition: system.C:113
StoredRange< MeshBase::const_element_iterator, const Elem * > ConstElemRange
Definition: elem_range.h:34
void enforce_adjoint_constraints_exactly(NumericVector< Number > &v, unsigned int q) const
Heterogeneously constrains the numeric vector v, which represents an adjoint solution defined on the ...
Definition: dof_map.h:2278
processor_id_type n_processors() const
void libmesh_ignore(const Args &...)
NumberVectorValue Gradient
bool project_with_constraints
Do we want to apply constraints while projecting vectors ?
Definition: system.h:2253
libmesh_assert(ctx)
virtual void close()=0
Calls the NumericVector&#39;s internal assembly routines, ensuring that the values are consistent across ...
static std::unique_ptr< NumericVector< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
Builds a NumericVector on the processors in communicator comm using the linear solver package specifi...
ParallelType type() const
const FEType & variable_type(const unsigned int i) const
Definition: system.h:2427
virtual numeric_index_type local_size() const =0
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:134
void parallel_reduce(const Range &range, Body &body)
Execute the provided reduction operation in parallel on the specified range.
Definition: threads_none.h:101
virtual void clear()
Restores the NumericVector<T> to a pristine state.
unsigned int n_vars() const
Definition: system.h:2349
processor_id_type processor_id() const
const DofMap & get_dof_map() const
Definition: system.h:2293
template class LIBMESH_EXPORT NumericVector< Number >
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:111
void enforce_constraints_exactly(const System &system, NumericVector< Number > *v=nullptr, bool homogeneous=false) const
Constrains the numeric vector v, which represents a solution defined on the mesh. ...
Definition: dof_map.h:2274
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.

◆ projection_matrix()

void libMesh::System::projection_matrix ( SparseMatrix< Number > &  proj_mat) const

This method creates a projection matrix which corresponds to the operation of project_vector between old and new solution spaces.

Heterogeneous Dirichlet boundary conditions are not taken into account here; if this matrix is used for prolongation (mesh refinement) on a side with a heterogeneous BC, the newly created degrees of freedom on that side will still match the coarse grid approximation of the BC, not the fine grid approximation.

Definition at line 961 of file system_projection.C.

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

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

962 {
963  LOG_SCOPE ("projection_matrix()", "System");
964 
965  const unsigned int n_variables = this->n_vars();
966 
967  if (n_variables)
968  {
969  ConstElemRange active_local_elem_range
970  (this->get_mesh().active_local_elements_begin(),
971  this->get_mesh().active_local_elements_end());
972 
973  std::vector<unsigned int> vars(n_variables);
974  std::iota(vars.begin(), vars.end(), 0);
975 
976  // Use a typedef to make the calling sequence for parallel_for() a bit more readable
977  typedef OldSolutionCoefs<Real, &FEMContext::point_value> OldSolutionValueCoefs;
978  typedef OldSolutionCoefs<RealGradient, &FEMContext::point_gradient> OldSolutionGradientCoefs;
979 
980  typedef
981  GenericProjector<OldSolutionValueCoefs,
982  OldSolutionGradientCoefs,
983  DynamicSparseNumberArray<Real,dof_id_type>,
984  MatrixFillAction<Real, Number> > ProjMatFiller;
985 
986  OldSolutionValueCoefs f(*this, &vars);
987  OldSolutionGradientCoefs g(*this, &vars);
988  MatrixFillAction<Real, Number> setter(proj_mat);
989 
990  ProjMatFiller mat_filler(*this, f, &g, setter, vars);
991  mat_filler.project(active_local_elem_range);
992 
993  // Set the SCALAR dof transfer entries too.
994  // Note: We assume that all SCALAR dofs are on the
995  // processor with highest ID
996  if (this->processor_id() == (this->n_processors()-1))
997  {
998  const DofMap & dof_map = this->get_dof_map();
999  for (auto var : make_range(this->n_vars()))
1000  if (this->variable(var).type().family == SCALAR)
1001  {
1002  // We can just map SCALAR dofs directly across
1003  std::vector<dof_id_type> new_SCALAR_indices, old_SCALAR_indices;
1004  dof_map.SCALAR_dof_indices (new_SCALAR_indices, var, false);
1005  dof_map.SCALAR_dof_indices (old_SCALAR_indices, var, true);
1006  const unsigned int new_n_dofs =
1007  cast_int<unsigned int>(new_SCALAR_indices.size());
1008 
1009  for (unsigned int i=0; i<new_n_dofs; i++)
1010  {
1011  proj_mat.set( new_SCALAR_indices[i],
1012  old_SCALAR_indices[i], 1);
1013  }
1014  }
1015  }
1016  }
1017 }
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2377
const MeshBase & get_mesh() const
Definition: system.h:2277
void iota(ForwardIter first, ForwardIter last, T value)
Utility::iota was created back when std::iota was just an SGI STL extension.
Definition: utility.h:229
StoredRange< MeshBase::const_element_iterator, const Elem * > ConstElemRange
Definition: elem_range.h:34
virtual void set(const numeric_index_type i, const numeric_index_type j, const T value)=0
Set the element (i,j) to value.
processor_id_type n_processors() const
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:134
unsigned int n_vars() const
Definition: system.h:2349
processor_id_type processor_id() const
const DofMap & get_dof_map() const
Definition: system.h:2293

◆ prolong_vectors()

void libMesh::System::prolong_vectors ( )
virtual

Prolong vectors after the mesh has refined.

Definition at line 436 of file system.C.

References restrict_vectors().

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

437 {
438 #ifdef LIBMESH_ENABLE_AMR
439  // Currently project_vector handles both restriction and prolongation
440  this->restrict_vectors();
441 #endif
442 }
virtual void restrict_vectors()
Restrict vectors after the mesh has coarsened.
Definition: system.C:378

◆ qoi_parameter_hessian()

void libMesh::System::qoi_parameter_hessian ( const QoISet qoi_indices,
const ParameterVector parameters,
SensitivityData hessian 
)
inlinevirtual

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

This method is only implemented in some derived classes.

Reimplemented in libMesh::ImplicitSystem.

Definition at line 2576 of file system.h.

2579 {
2580  libmesh_not_implemented();
2581 }

◆ qoi_parameter_hessian_vector_product()

void libMesh::System::qoi_parameter_hessian_vector_product ( const QoISet qoi_indices,
const ParameterVector parameters,
const ParameterVector vector,
SensitivityData product 
)
inlinevirtual

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

This method is only implemented in some derived classes.

Reimplemented in libMesh::ImplicitSystem.

Definition at line 2585 of file system.h.

2589 {
2590  libmesh_not_implemented();
2591 }

◆ qoi_parameter_sensitivity()

void libMesh::System::qoi_parameter_sensitivity ( const QoISet qoi_indices,
const ParameterVector parameters,
SensitivityData sensitivities 
)
virtual

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

Note
parameters is a const vector, not a vector-of-const; parameter values in this vector need to be mutable for finite differencing to work.

Automatically chooses the forward method for problems with more quantities of interest than parameters, or the adjoint method otherwise.

This method is only usable in derived classes which override an implementation.

Definition at line 585 of file system.C.

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

588 {
589  // Forward sensitivities are more efficient for Nq > Np
590  if (qoi_indices.size(*this) > parameters.size())
591  forward_qoi_parameter_sensitivity(qoi_indices, parameters, sensitivities);
592  // Adjoint sensitivities are more efficient for Np > Nq,
593  // and an adjoint may be more reusable than a forward
594  // solution sensitivity in the Np == Nq case.
595  else
596  adjoint_qoi_parameter_sensitivity(qoi_indices, parameters, sensitivities);
597 }
virtual void forward_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
Solves for parameter sensitivities using the forward method.
Definition: system.h:2567
virtual void adjoint_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
Solves for parameter sensitivities using the adjoint method.
Definition: system.h:2558

◆ re_update()

void libMesh::System::re_update ( )
virtual

Re-update the local values when the mesh has changed.

This method takes the data updated by update() and makes it up-to-date on the current mesh.

Reimplemented in libMesh::TransientSystem< RBConstruction >.

Definition at line 516 of file system.C.

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

517 {
518  parallel_object_only();
519 
520  // If this system is empty... don't do anything!
521  if (!this->n_vars())
522  return;
523 
524  const std::vector<dof_id_type> & send_list = this->get_dof_map().get_send_list ();
525 
526  // Check sizes
527  libmesh_assert_equal_to (current_local_solution->size(), solution->size());
528  // Not true with ghosted vectors
529  // libmesh_assert_equal_to (current_local_solution->local_size(), solution->size());
530  // libmesh_assert (!send_list.empty());
531  libmesh_assert_less_equal (send_list.size(), solution->size());
532 
533  // Create current_local_solution from solution. This will
534  // put a local copy of solution into current_local_solution.
535  solution->localize (*current_local_solution, send_list);
536 }
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1573
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Definition: system.h:1585
unsigned int n_vars() const
Definition: system.h:2349
const DofMap & get_dof_map() const
Definition: system.h:2293
const std::vector< dof_id_type > & get_send_list() const
Definition: dof_map.h:511

◆ read_header()

void libMesh::System::read_header ( Xdr io,
std::string_view  version,
const bool  read_header = true,
const bool  read_additional_data = true,
const bool  read_legacy_format = false 
)

Reads the basic data header for this System.

Definition at line 97 of file system_io.C.

References _additional_data_written, _written_var_indices, add_variable(), add_vector(), TIMPI::Communicator::broadcast(), clear(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::FEType::family, get_mesh(), libMesh::OrderWrapper::get_order(), libMesh::FEType::inf_map, libMesh::libmesh_assert(), libMesh::MeshBase::mesh_dimension(), libMesh::MONOMIAL, libMesh::on_command_line(), libMesh::FEType::order, libMesh::out, libMesh::ParallelObject::processor_id(), libMesh::FEType::radial_family, libMesh::FEType::radial_order, libMesh::Xdr::reading(), variable_number(), libMesh::Xdr::version(), and libMesh::XYZ.

Referenced by libMesh::EquationSystems::read(), and libMesh::RBEvaluation::read_in_vectors_from_multiple_files().

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

◆ read_legacy_data()

void libMesh::System::read_legacy_data ( Xdr io,
const bool  read_additional_data = true 
)

Reads additional data, namely vectors, for this System.

Definition at line 302 of file system_io.C.

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

304 {
305  libmesh_deprecated();
306 
307  // This method implements the output of the vectors
308  // contained in this System object, embedded in the
309  // output of an EquationSystems<T_sys>.
310  //
311  // 10.) The global solution vector, re-ordered to be node-major
312  // (More on this later.)
313  //
314  // for each additional vector in the object
315  //
316  // 11.) The global additional vector, re-ordered to be
317  // node-major (More on this later.)
318  libmesh_assert (io.reading());
319 
320  // directly-read and reordered buffers, declared here for reuse
321  // without heap juggling.
322  std::vector<Number> global_vector;
323  std::vector<Number> reordered_vector;
324 
325  auto reorder_vector_into =
326  [this, &global_vector, &reordered_vector]
327  (NumericVector<Number> & vec)
328  {
329  this->comm().broadcast(global_vector);
330 
331  // If we have been reading multiple vectors, they should all be
332  // the same size.
333  libmesh_assert (reordered_vector.empty() ||
334  reordered_vector.size() == global_vector.size());
335 
336  // Remember that the stored vector is node-major.
337  // We need to put it into whatever application-specific
338  // ordering we may have using the dof_map.
339  reordered_vector.resize(global_vector.size());
340 
341  //libMesh::out << "global_vector.size()=" << global_vector.size() << std::endl;
342  //libMesh::out << "this->n_dofs()=" << this->n_dofs() << std::endl;
343 
344  libmesh_assert_equal_to (global_vector.size(), this->n_dofs());
345 
346  dof_id_type cnt=0;
347 
348  const unsigned int sys = this->number();
349  const unsigned int nv = cast_int<unsigned int>
350  (this->_written_var_indices.size());
351  libmesh_assert_less_equal (nv, this->n_vars());
352 
353  for (unsigned int data_var=0; data_var<nv; data_var++)
354  {
355  const unsigned int var = _written_var_indices[data_var];
356 
357  // First reorder the nodal DOF values
358  for (auto & node : this->get_mesh().node_ptr_range())
359  for (auto index : make_range(node->n_comp(sys,var)))
360  {
361  libmesh_assert_not_equal_to (node->dof_number(sys, var, index),
363 
364  libmesh_assert_less (cnt, global_vector.size());
365 
366  reordered_vector[node->dof_number(sys, var, index)] =
367  global_vector[cnt++];
368  }
369 
370  // Then reorder the element DOF values
371  for (auto & elem : this->get_mesh().active_element_ptr_range())
372  for (auto index : make_range(elem->n_comp(sys,var)))
373  {
374  libmesh_assert_not_equal_to (elem->dof_number(sys, var, index),
376 
377  libmesh_assert_less (cnt, global_vector.size());
378 
379  reordered_vector[elem->dof_number(sys, var, index)] =
380  global_vector[cnt++];
381  }
382  }
383 
384  // use the overloaded operator=(std::vector) to assign the values
385  vec = reordered_vector;
386  };
387 
388  // 10.)
389  // Read and set the solution vector
390  if (this->processor_id() == 0)
391  io.data (global_vector);
392  reorder_vector_into(*(this->solution));
393 
394  // For each additional vector, simply go through the list.
395  // ONLY attempt to do this IF additional data was actually
396  // written to the file for this system (controlled by the
397  // _additional_data_written flag).
398  if (this->_additional_data_written)
399  {
400  const std::size_t nvecs = this->_vectors.size();
401 
402  // If the number of additional vectors written is non-zero, and
403  // the number of additional vectors we have is non-zero, and
404  // they don't match, then something is wrong and we can't be
405  // sure we're reading data into the correct places.
406  if (read_additional_data && nvecs &&
407  nvecs != this->_additional_data_written)
408  libmesh_error_msg
409  ("Additional vectors in file do not match system");
410 
411  auto pos = this->_vectors.begin();
412 
413  for (std::size_t i = 0; i != this->_additional_data_written; ++i)
414  {
415  // 11.)
416  // Read the values of the vec-th additional vector.
417  // Prior do _not_ clear, but fill with zero, since the
418  // additional vectors _have_ to have the same size
419  // as the solution vector
420  std::fill (global_vector.begin(), global_vector.end(), libMesh::zero);
421 
422  if (this->processor_id() == 0)
423  io.data (global_vector);
424 
425  // If read_additional_data==true and we have additional vectors,
426  // then we will keep this vector data; otherwise we are going to
427  // throw it away.
428  if (read_additional_data && nvecs)
429  {
430  std::fill (reordered_vector.begin(),
431  reordered_vector.end(),
432  libMesh::zero);
433 
434  reorder_vector_into(*(pos->second));
435  }
436 
437  // If we've got vectors then we need to be iterating through
438  // those too
439  if (pos != this->_vectors.end())
440  ++pos;
441  }
442  } // end if (_additional_data_written)
443 }
const Parallel::Communicator & comm() const
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2164
const Number zero
.
Definition: libmesh.h:280
const MeshBase & get_mesh() const
Definition: system.h:2277
dof_id_type n_dofs() const
Definition: system.C:113
unsigned int number() const
Definition: system.h:2269
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1573
libmesh_assert(ctx)
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:477
unsigned int _additional_data_written
This flag is used only when reading in a system from file.
Definition: system.h:2223
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:134
unsigned int n_vars() const
Definition: system.h:2349
processor_id_type processor_id() const
template class LIBMESH_EXPORT NumericVector< Number >
std::vector< unsigned int > _written_var_indices
This vector is used only when reading in a system from file.
Definition: system.h:2235
uint8_t dof_id_type
Definition: id_types.h:67

◆ read_parallel_data() [1/2]

template<typename InValType >
void libMesh::System::read_parallel_data ( Xdr io,
const bool  read_additional_data 
)

Reads additional data, namely vectors, for this System.

This method may safely be called on a distributed-memory mesh. This method will read an individual file for each processor in the simulation where the local solution components for that processor are stored.

This method implements the output of the vectors contained in this System object, embedded in the output of an EquationSystems<T_sys>.

9.) The global solution vector, re-ordered to be node-major (More on this later.)

for each additional vector in the object

10.) The global additional vector, re-ordered to be node-major (More on this later.)

Note that the actual IO is handled through the Xdr class (to be renamed later?) which provides a uniform interface to both the XDR (eXternal Data Representation) interface and standard ASCII output. Thus this one section of code will read XDR or ASCII files with no changes.

Definition at line 449 of file system_io.C.

References _additional_data_written, _vectors, _written_var_indices, libMesh::Xdr::data(), libMesh::FEType::family, get_dof_map(), get_mesh(), libMesh::DofObject::invalid_id, libMesh::Xdr::is_open(), libMesh::libmesh_assert(), libMesh::make_range(), libMesh::ParallelObject::n_processors(), n_vars(), number(), libMesh::ParallelObject::processor_id(), libMesh::Xdr::reading(), libMesh::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), solution, libMesh::Variable::type(), and variable().

451 {
471  // PerfLog pl("IO Performance",false);
472  // pl.push("read_parallel_data");
473  dof_id_type total_read_size = 0;
474 
475  libmesh_assert (io.reading());
476  libmesh_assert (io.is_open());
477 
478  // build the ordered nodes and element maps.
479  // when writing/reading parallel files we need to iterate
480  // over our nodes/elements in order of increasing global id().
481  // however, this is not guaranteed to be ordering we obtain
482  // by using the node_iterators/element_iterators directly.
483  // so build a set, sorted by id(), that provides the ordering.
484  // further, for memory economy build the set but then transfer
485  // its contents to vectors, which will be sorted.
486  std::vector<const DofObject *> ordered_nodes, ordered_elements;
487  {
488  std::set<const DofObject *, CompareDofObjectsByID>
489  ordered_nodes_set (this->get_mesh().local_nodes_begin(),
490  this->get_mesh().local_nodes_end());
491 
492  ordered_nodes.insert(ordered_nodes.end(),
493  ordered_nodes_set.begin(),
494  ordered_nodes_set.end());
495  }
496  {
497  std::set<const DofObject *, CompareDofObjectsByID>
498  ordered_elements_set (this->get_mesh().local_elements_begin(),
499  this->get_mesh().local_elements_end());
500 
501  ordered_elements.insert(ordered_elements.end(),
502  ordered_elements_set.begin(),
503  ordered_elements_set.end());
504  }
505 
506  // std::vector<Number> io_buffer;
507  std::vector<InValType> io_buffer;
508 
509  // 9.)
510  //
511  // Actually read the solution components
512  // for the ith system to disk
513  io.data(io_buffer);
514 
515  total_read_size += cast_int<dof_id_type>(io_buffer.size());
516 
517  const unsigned int sys_num = this->number();
518  const unsigned int nv = cast_int<unsigned int>
519  (this->_written_var_indices.size());
520  libmesh_assert_less_equal (nv, this->n_vars());
521 
522  dof_id_type cnt=0;
523 
524  // Loop over each non-SCALAR variable and each node, and read out the value.
525  for (unsigned int data_var=0; data_var<nv; data_var++)
526  {
527  const unsigned int var = _written_var_indices[data_var];
528  if (this->variable(var).type().family != SCALAR)
529  {
530  // First read the node DOF values
531  for (const auto & node : ordered_nodes)
532  for (auto comp : make_range(node->n_comp(sys_num,var)))
533  {
534  libmesh_assert_not_equal_to (node->dof_number(sys_num, var, comp),
536  libmesh_assert_less (cnt, io_buffer.size());
537  this->solution->set(node->dof_number(sys_num, var, comp), io_buffer[cnt++]);
538  }
539 
540  // Then read the element DOF values
541  for (const auto & elem : ordered_elements)
542  for (auto comp : make_range(elem->n_comp(sys_num,var)))
543  {
544  libmesh_assert_not_equal_to (elem->dof_number(sys_num, var, comp),
546  libmesh_assert_less (cnt, io_buffer.size());
547  this->solution->set(elem->dof_number(sys_num, var, comp), io_buffer[cnt++]);
548  }
549  }
550  }
551 
552  // Finally, read the SCALAR variables on the last processor
553  for (unsigned int data_var=0; data_var<nv; data_var++)
554  {
555  const unsigned int var = _written_var_indices[data_var];
556  if (this->variable(var).type().family == SCALAR)
557  {
558  if (this->processor_id() == (this->n_processors()-1))
559  {
560  const DofMap & dof_map = this->get_dof_map();
561  std::vector<dof_id_type> SCALAR_dofs;
562  dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
563 
564  for (auto dof : SCALAR_dofs)
565  this->solution->set(dof, io_buffer[cnt++]);
566  }
567  }
568  }
569 
570  // And we're done setting solution entries
571  this->solution->close();
572 
573  // For each additional vector, simply go through the list.
574  // ONLY attempt to do this IF additional data was actually
575  // written to the file for this system (controlled by the
576  // _additional_data_written flag).
577  if (this->_additional_data_written)
578  {
579  const std::size_t nvecs = this->_vectors.size();
580 
581  // If the number of additional vectors written is non-zero, and
582  // the number of additional vectors we have is non-zero, and
583  // they don't match, then something is wrong and we can't be
584  // sure we're reading data into the correct places.
585  if (read_additional_data && nvecs &&
586  nvecs != this->_additional_data_written)
587  libmesh_error_msg
588  ("Additional vectors in file do not match system");
589 
590  auto pos = _vectors.begin();
591 
592  for (std::size_t i = 0; i != this->_additional_data_written; ++i)
593  {
594  cnt=0;
595  io_buffer.clear();
596 
597  // 10.)
598  //
599  // Actually read the additional vector components
600  // for the ith system from disk
601  io.data(io_buffer);
602 
603  total_read_size += cast_int<dof_id_type>(io_buffer.size());
604 
605  // If read_additional_data==true and we have additional vectors,
606  // then we will keep this vector data; otherwise we are going to
607  // throw it away.
608  if (read_additional_data && nvecs)
609  {
610  // Loop over each non-SCALAR variable and each node, and read out the value.
611  for (unsigned int data_var=0; data_var<nv; data_var++)
612  {
613  const unsigned int var = _written_var_indices[data_var];
614  if (this->variable(var).type().family != SCALAR)
615  {
616  // First read the node DOF values
617  for (const auto & node : ordered_nodes)
618  for (auto comp : make_range(node->n_comp(sys_num,var)))
619  {
620  libmesh_assert_not_equal_to (node->dof_number(sys_num, var, comp),
622  libmesh_assert_less (cnt, io_buffer.size());
623  pos->second->set(node->dof_number(sys_num, var, comp), io_buffer[cnt++]);
624  }
625 
626  // Then read the element DOF values
627  for (const auto & elem : ordered_elements)
628  for (auto comp : make_range(elem->n_comp(sys_num,var)))
629  {
630  libmesh_assert_not_equal_to (elem->dof_number(sys_num, var, comp),
632  libmesh_assert_less (cnt, io_buffer.size());
633  pos->second->set(elem->dof_number(sys_num, var, comp), io_buffer[cnt++]);
634  }
635  }
636  }
637 
638  // Finally, read the SCALAR variables on the last processor
639  for (unsigned int data_var=0; data_var<nv; data_var++)
640  {
641  const unsigned int var = _written_var_indices[data_var];
642  if (this->variable(var).type().family == SCALAR)
643  {
644  if (this->processor_id() == (this->n_processors()-1))
645  {
646  const DofMap & dof_map = this->get_dof_map();
647  std::vector<dof_id_type> SCALAR_dofs;
648  dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
649 
650  for (auto dof : SCALAR_dofs)
651  pos->second->set(dof, io_buffer[cnt++]);
652  }
653  }
654  }
655 
656  // And we're done setting entries for this variable
657  pos->second->close();
658  }
659 
660  // If we've got vectors then we need to be iterating through
661  // those too
662  if (pos != this->_vectors.end())
663  ++pos;
664  }
665  }
666 
667  // const Real
668  // dt = pl.get_elapsed_time(),
669  // rate = total_read_size*sizeof(Number)/dt;
670 
671  // libMesh::err << "Read " << total_read_size << " \"Number\" values\n"
672  // << " Elapsed time = " << dt << '\n'
673  // << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";
674 
675  // pl.pop("read_parallel_data");
676 }
FEFamily family
The type of finite element.
Definition: fe_type.h:207
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2377
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2164
const MeshBase & get_mesh() const
Definition: system.h:2277
processor_id_type n_processors() const
unsigned int number() const
Definition: system.h:2269
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1573
libmesh_assert(ctx)
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:477
unsigned int _additional_data_written
This flag is used only when reading in a system from file.
Definition: system.h:2223
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:134
unsigned int n_vars() const
Definition: system.h:2349
processor_id_type processor_id() const
const DofMap & get_dof_map() const
Definition: system.h:2293
std::vector< unsigned int > _written_var_indices
This vector is used only when reading in a system from file.
Definition: system.h:2235
uint8_t dof_id_type
Definition: id_types.h:67
const FEType & type() const
Definition: variable.h:140

◆ read_parallel_data() [2/2]

template LIBMESH_EXPORT void libMesh::System::read_parallel_data< Real > ( Xdr io,
const bool  read_additional_data 
)
inline

Non-templated version for backward compatibility.

Reads additional data, namely vectors, for this System. This method may safely be called on a distributed-memory mesh. This method will read an individual file for each processor in the simulation where the local solution components for that processor are stored.

Definition at line 1333 of file system.h.

1335  { read_parallel_data<Number>(io, read_additional_data); }

◆ read_SCALAR_dofs()

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

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

Returns
The number of dofs read.

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

Definition at line 1089 of file system_io.C.

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

Referenced by read_serialized_vector(), and read_serialized_vectors().

1092 {
1093  unsigned int n_assigned_vals = 0; // the number of values assigned, this will be returned.
1094 
1095  // Processor 0 will read the block from the buffer stream and send it to the last processor
1096  const unsigned int n_SCALAR_dofs = this->variable(var).type().order.get_order();
1097  std::vector<Number> input_buffer(n_SCALAR_dofs);
1098  if (this->processor_id() == 0)
1099  io.data_stream(input_buffer.data(), n_SCALAR_dofs);
1100 
1101 #ifdef LIBMESH_HAVE_MPI
1102  if (this->n_processors() > 1)
1103  {
1104  const Parallel::MessageTag val_tag = this->comm().get_unique_tag();
1105 
1106  // Post the receive on the last processor
1107  if (this->processor_id() == (this->n_processors()-1))
1108  this->comm().receive(0, input_buffer, val_tag);
1109 
1110  // Send the data to processor 0
1111  if (this->processor_id() == 0)
1112  this->comm().send(this->n_processors()-1, input_buffer, val_tag);
1113  }
1114 #endif
1115 
1116  // Finally, set the SCALAR values
1117  if (this->processor_id() == (this->n_processors()-1))
1118  {
1119  const DofMap & dof_map = this->get_dof_map();
1120  std::vector<dof_id_type> SCALAR_dofs;
1121  dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
1122 
1123  for (auto i : index_range(SCALAR_dofs))
1124  {
1125  if (vec)
1126  vec->set (SCALAR_dofs[i], input_buffer[i]);
1127  ++n_assigned_vals;
1128  }
1129  }
1130 
1131  return n_assigned_vals;
1132 }
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2377
MessageTag get_unique_tag(int tagvalue=MessageTag::invalid_tag) const
const Parallel::Communicator & comm() const
OrderWrapper order
The approximation order of the element.
Definition: fe_type.h:201
processor_id_type n_processors() const
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_tag) const
int get_order() const
Explicitly request the order as an int.
Definition: fe_type.h:80
void send(const unsigned int dest_processor_id, const T &buf, const MessageTag &tag=no_tag) const
virtual void set(const numeric_index_type i, const T value)=0
Sets v(i) = value.
processor_id_type processor_id() const
const DofMap & get_dof_map() const
Definition: system.h:2293
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:111
const FEType & type() const
Definition: variable.h:140

◆ read_serialized_blocked_dof_objects()

template<typename iterator_type , typename InValType >
std::size_t libMesh::System::read_serialized_blocked_dof_objects ( const dof_id_type  n_objects,
const iterator_type  begin,
const iterator_type  end,
const InValType  dummy,
Xdr io,
const std::vector< NumericVector< Number > *> &  vecs,
const unsigned int  var_to_read = libMesh::invalid_uint 
) const
private

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

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

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

Definition at line 765 of file system_io.C.

References _written_var_indices, libMesh::ParallelObject::comm(), TIMPI::Communicator::get_unique_tag(), libMesh::MeshTools::Generation::Private::idx(), libMesh::index_range(), libMesh::invalid_uint, libMesh::Threads::NonConcurrentThread::join(), libMesh::libmesh_assert(), libMesh::make_range(), libMesh::ParallelObject::n_processors(), n_vars(), number(), libMesh::ParallelObject::processor_id(), TIMPI::Communicator::receive(), TIMPI::Communicator::send(), TIMPI::Status::source(), and TIMPI::Communicator::sum().

Referenced by read_serialized_vector(), and read_serialized_vectors().

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

◆ read_serialized_data() [1/2]

template<typename InValType >
void libMesh::System::read_serialized_data ( Xdr io,
const bool  read_additional_data = true 
)

Reads additional data, namely vectors, for this System.

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

Definition at line 680 of file system_io.C.

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

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

682 {
683  // This method implements the input of the vectors
684  // contained in this System object, embedded in the
685  // output of an EquationSystems<T_sys>.
686  //
687  // 10.) The global solution vector, re-ordered to be node-major
688  // (More on this later.)
689  //
690  // for each additional vector in the object
691  //
692  // 11.) The global additional vector, re-ordered to be
693  // node-major (More on this later.)
694  parallel_object_only();
695  std::string comment;
696 
697  // PerfLog pl("IO Performance",false);
698  // pl.push("read_serialized_data");
699  // std::size_t total_read_size = 0;
700 
701  // 10.)
702  // Read the global solution vector
703  {
704  // total_read_size +=
705  this->read_serialized_vector<InValType>(io, this->solution.get());
706 
707  // get the comment
708  if (this->processor_id() == 0)
709  io.comment (comment);
710  }
711 
712  // 11.)
713  // Only read additional vectors if data is available, and only use
714  // that data to fill our vectors if the user requested it.
715  if (this->_additional_data_written)
716  {
717  const std::size_t nvecs = this->_vectors.size();
718 
719  // If the number of additional vectors written is non-zero, and
720  // the number of additional vectors we have is non-zero, and
721  // they don't match, then we can't read additional vectors
722  // and be sure we're reading data into the correct places.
723  if (read_additional_data && nvecs &&
724  nvecs != this->_additional_data_written)
725  libmesh_error_msg
726  ("Additional vectors in file do not match system");
727 
728  auto pos = _vectors.begin();
729 
730  for (std::size_t i = 0; i != this->_additional_data_written; ++i)
731  {
732  // Read data, but only put it into a vector if we've been
733  // asked to and if we have a corresponding vector to read.
734 
735  // total_read_size +=
736  this->read_serialized_vector<InValType>
737  (io, (read_additional_data && nvecs) ? pos->second.get() : nullptr);
738 
739  // get the comment
740  if (this->processor_id() == 0)
741  io.comment (comment);
742 
743 
744  // If we've got vectors then we need to be iterating through
745  // those too
746  if (pos != this->_vectors.end())
747  ++pos;
748  }
749  }
750 
751  // const Real
752  // dt = pl.get_elapsed_time(),
753  // rate = total_read_size*sizeof(Number)/dt;
754 
755  // libMesh::out << "Read " << total_read_size << " \"Number\" values\n"
756  // << " Elapsed time = " << dt << '\n'
757  // << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";
758 
759  // pl.pop("read_serialized_data");
760 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2164
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1573
unsigned int _additional_data_written
This flag is used only when reading in a system from file.
Definition: system.h:2223
processor_id_type processor_id() const

◆ read_serialized_data() [2/2]

template LIBMESH_EXPORT void libMesh::System::read_serialized_data< Real > ( Xdr io,
const bool  read_additional_data = true 
)
inline

Non-templated version for backward compatibility.

Reads additional data, namely vectors, for this System. This method may safely be called on a distributed-memory mesh.

Definition at line 1291 of file system.h.

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

◆ read_serialized_vector() [1/2]

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

Reads a vector for this System.

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

Returns
The length of the vector read.

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

Definition at line 1136 of file system_io.C.

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

1138 {
1139  parallel_object_only();
1140 
1141 #ifndef NDEBUG
1142  // In parallel we better be reading a parallel vector -- if not
1143  // we will not set all of its components below!!
1144  if (this->n_processors() > 1 && vec)
1145  {
1146  libmesh_assert (vec->type() == PARALLEL ||
1147  vec->type() == GHOSTED);
1148  }
1149 #endif
1150 
1151  libmesh_assert (io.reading());
1152 
1153  // vector length
1154  unsigned int vector_length=0; // FIXME? size_t would break binary compatibility...
1155 #ifndef NDEBUG
1156  std::size_t n_assigned_vals=0;
1157 #endif
1158 
1159  // Get the buffer size
1160  if (this->processor_id() == 0)
1161  io.data(vector_length, "# vector length");
1162  this->comm().broadcast(vector_length);
1163 
1164  const unsigned int nv = cast_int<unsigned int>
1165  (this->_written_var_indices.size());
1166  const dof_id_type
1167  n_nodes = this->get_mesh().n_nodes(),
1168  n_elem = this->get_mesh().n_elem();
1169 
1170  libmesh_assert_less_equal (nv, this->n_vars());
1171 
1172  // for newer versions, read variables node/elem major
1173  if (io.version() >= LIBMESH_VERSION_ID(0,7,4))
1174  {
1175  //---------------------------------
1176  // Collect the values for all nodes
1177 #ifndef NDEBUG
1178  n_assigned_vals +=
1179 #endif
1180  this->read_serialized_blocked_dof_objects (n_nodes,
1181  this->get_mesh().local_nodes_begin(),
1182  this->get_mesh().local_nodes_end(),
1183  InValType(),
1184  io,
1185  std::vector<NumericVector<Number> *> (1,vec));
1186 
1187 
1188  //------------------------------------
1189  // Collect the values for all elements
1190 #ifndef NDEBUG
1191  n_assigned_vals +=
1192 #endif
1194  this->get_mesh().local_elements_begin(),
1195  this->get_mesh().local_elements_end(),
1196  InValType(),
1197  io,
1198  std::vector<NumericVector<Number> *> (1,vec));
1199  }
1200 
1201  // for older versions, read variables var-major
1202  else
1203  {
1204  // Loop over each variable in the system, and then each node/element in the mesh.
1205  for (unsigned int data_var=0; data_var<nv; data_var++)
1206  {
1207  const unsigned int var = _written_var_indices[data_var];
1208  if (this->variable(var).type().family != SCALAR)
1209  {
1210  //---------------------------------
1211  // Collect the values for all nodes
1212 #ifndef NDEBUG
1213  n_assigned_vals +=
1214 #endif
1215  this->read_serialized_blocked_dof_objects (n_nodes,
1216  this->get_mesh().local_nodes_begin(),
1217  this->get_mesh().local_nodes_end(),
1218  InValType(),
1219  io,
1220  std::vector<NumericVector<Number> *> (1,vec),
1221  var);
1222 
1223 
1224  //------------------------------------
1225  // Collect the values for all elements
1226 #ifndef NDEBUG
1227  n_assigned_vals +=
1228 #endif
1230  this->get_mesh().local_elements_begin(),
1231  this->get_mesh().local_elements_end(),
1232  InValType(),
1233  io,
1234  std::vector<NumericVector<Number> *> (1,vec),
1235  var);
1236  } // end variable loop
1237  }
1238  }
1239 
1240  //-------------------------------------------
1241  // Finally loop over all the SCALAR variables
1242  for (unsigned int data_var=0; data_var<nv; data_var++)
1243  {
1244  const unsigned int var = _written_var_indices[data_var];
1245  if (this->variable(var).type().family == SCALAR)
1246  {
1247 #ifndef NDEBUG
1248  n_assigned_vals +=
1249 #endif
1250  this->read_SCALAR_dofs (var, io, vec);
1251  }
1252  }
1253 
1254  if (vec)
1255  vec->close();
1256 
1257 #ifndef NDEBUG
1258  this->comm().sum (n_assigned_vals);
1259  libmesh_assert_equal_to (n_assigned_vals, vector_length);
1260 #endif
1261 
1262  return vector_length;
1263 }
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2377
dof_id_type n_elem(const MeshBase::const_element_iterator &begin, const MeshBase::const_element_iterator &end)
Count up the number of elements of a specific type (as defined by an iterator range).
Definition: mesh_tools.C:850
std::size_t read_serialized_blocked_dof_objects(const dof_id_type n_objects, const iterator_type begin, const iterator_type end, const InValType dummy, Xdr &io, const std::vector< NumericVector< Number > *> &vecs, const unsigned int var_to_read=libMesh::invalid_uint) const
Reads an input vector from the stream io and assigns the values to a set of DofObjects.
Definition: system_io.C:765
void sum(T &r) const
const Parallel::Communicator & comm() const
const MeshBase & get_mesh() const
Definition: system.h:2277
processor_id_type n_processors() const
const dof_id_type n_nodes
Definition: tecplot_io.C:67
libmesh_assert(ctx)
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
virtual void close()=0
Calls the NumericVector&#39;s internal assembly routines, ensuring that the values are consistent across ...
ParallelType type() const
unsigned int read_SCALAR_dofs(const unsigned int var, Xdr &io, NumericVector< Number > *vec) const
Reads the SCALAR dofs from the stream io and assigns the values to the appropriate entries of vec...
Definition: system_io.C:1089
unsigned int n_vars() const
Definition: system.h:2349
virtual dof_id_type n_elem() const =0
processor_id_type processor_id() const
template class LIBMESH_EXPORT NumericVector< Number >
virtual dof_id_type n_nodes() const =0
std::vector< unsigned int > _written_var_indices
This vector is used only when reading in a system from file.
Definition: system.h:2235
uint8_t dof_id_type
Definition: id_types.h:67

◆ read_serialized_vector() [2/2]

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

Non-templated version for backward compatibility.

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

Returns
The length of the vector read.

Definition at line 2014 of file system.h.

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

◆ read_serialized_vectors() [1/2]

template<typename InValType >
std::size_t libMesh::System::read_serialized_vectors ( Xdr io,
const std::vector< NumericVector< Number > *> &  vectors 
) const

Read a number of identically distributed vectors.

This method allows for optimization for the multiple vector case by only communicating the metadata once.

Definition at line 2165 of file system_io.C.

References libMesh::Xdr::data(), get_mesh(), libMesh::libmesh_assert(), libMesh::make_range(), libMesh::MeshTools::n_elem(), libMesh::MeshBase::n_elem(), n_nodes, libMesh::MeshBase::n_nodes(), n_vars(), libMesh::ParallelObject::processor_id(), read_SCALAR_dofs(), read_serialized_blocked_dof_objects(), libMesh::Xdr::reading(), libMesh::SCALAR, and variable().

Referenced by libMesh::RBEvaluation::read_in_vectors_from_multiple_files().

2167 {
2168  parallel_object_only();
2169 
2170  // Error checking
2171  // #ifndef NDEBUG
2172  // // In parallel we better be reading a parallel vector -- if not
2173  // // we will not set all of its components below!!
2174  // if (this->n_processors() > 1)
2175  // {
2176  // libmesh_assert (vec.type() == PARALLEL ||
2177  // vec.type() == GHOSTED);
2178  // }
2179  // #endif
2180 
2181  libmesh_assert (io.reading());
2182 
2183  if (this->processor_id() == 0)
2184  {
2185  // sizes
2186  unsigned int num_vecs=0;
2187  dof_id_type vector_length=0;
2188 
2189  // Get the number of vectors
2190  io.data(num_vecs);
2191  // Get the buffer size
2192  io.data(vector_length);
2193 
2194  libmesh_error_msg_if (num_vecs != vectors.size(), "Unexpected value of num_vecs");
2195 
2196  if (num_vecs != 0)
2197  {
2198  libmesh_error_msg_if (vectors[0] == nullptr, "vectors[0] should not be null");
2199  libmesh_error_msg_if (vectors[0]->size() != vector_length, "Inconsistent vector sizes");
2200  }
2201  }
2202 
2203  // no need to actually communicate these.
2204  // this->comm().broadcast(num_vecs);
2205  // this->comm().broadcast(vector_length);
2206 
2207  // Cache these - they are not free!
2208  const dof_id_type
2209  n_nodes = this->get_mesh().n_nodes(),
2210  n_elem = this->get_mesh().n_elem();
2211 
2212  std::size_t read_length = 0;
2213 
2214  //---------------------------------
2215  // Collect the values for all nodes
2216  read_length +=
2217  this->read_serialized_blocked_dof_objects (n_nodes,
2218  this->get_mesh().local_nodes_begin(),
2219  this->get_mesh().local_nodes_end(),
2220  InValType(),
2221  io,
2222  vectors);
2223 
2224  //------------------------------------
2225  // Collect the values for all elements
2226  read_length +=
2228  this->get_mesh().local_elements_begin(),
2229  this->get_mesh().local_elements_end(),
2230  InValType(),
2231  io,
2232  vectors);
2233 
2234  //-------------------------------------------
2235  // Finally loop over all the SCALAR variables
2236  for (NumericVector<Number> * vec : vectors)
2237  for (auto var : make_range(this->n_vars()))
2238  if (this->variable(var).type().family == SCALAR)
2239  {
2240  libmesh_assert_not_equal_to (vec, 0);
2241 
2242  read_length +=
2243  this->read_SCALAR_dofs (var, io, vec);
2244  }
2245 
2246  //---------------------------------------
2247  // last step - must close all the vectors
2248  for (NumericVector<Number> * vec : vectors)
2249  {
2250  libmesh_assert_not_equal_to (vec, 0);
2251  vec->close();
2252  }
2253 
2254  return read_length;
2255 }
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2377
dof_id_type n_elem(const MeshBase::const_element_iterator &begin, const MeshBase::const_element_iterator &end)
Count up the number of elements of a specific type (as defined by an iterator range).
Definition: mesh_tools.C:850
std::size_t read_serialized_blocked_dof_objects(const dof_id_type n_objects, const iterator_type begin, const iterator_type end, const InValType dummy, Xdr &io, const std::vector< NumericVector< Number > *> &vecs, const unsigned int var_to_read=libMesh::invalid_uint) const
Reads an input vector from the stream io and assigns the values to a set of DofObjects.
Definition: system_io.C:765
const MeshBase & get_mesh() const
Definition: system.h:2277
const dof_id_type n_nodes
Definition: tecplot_io.C:67
libmesh_assert(ctx)
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:134
unsigned int read_SCALAR_dofs(const unsigned int var, Xdr &io, NumericVector< Number > *vec) const
Reads the SCALAR dofs from the stream io and assigns the values to the appropriate entries of vec...
Definition: system_io.C:1089
unsigned int n_vars() const
Definition: system.h:2349
virtual dof_id_type n_elem() const =0
processor_id_type processor_id() const
template class LIBMESH_EXPORT NumericVector< Number >
virtual dof_id_type n_nodes() const =0
uint8_t dof_id_type
Definition: id_types.h:67

◆ read_serialized_vectors() [2/2]

template LIBMESH_EXPORT std::size_t libMesh::System::read_serialized_vectors< Real > ( Xdr io,
const std::vector< NumericVector< Number > *> &  vectors 
) const
inline

Non-templated version for backward compatibility.

Read a number of identically distributed vectors. This method allows for optimization for the multiple vector case by only communicating the metadata once.

Definition at line 1311 of file system.h.

1313  { return read_serialized_vectors<Number>(io, vectors); }

◆ reinit()

void libMesh::System::reinit ( )
virtual

Reinitializes degrees of freedom and other required data on the current mesh.

Note
The matrix is not initialized at this time since it may not be required for all applications. Should be overridden in derived classes.

Reimplemented in libMesh::NonlinearImplicitSystem, libMesh::OptimizationSystem, libMesh::LinearImplicitSystem, libMesh::EigenSystem, libMesh::DifferentiableSystem, and libMesh::NewmarkSystem.

Definition at line 446 of file system.C.

References _basic_system_only, _matrices, libMesh::DofMap::clear_sparsity(), libMesh::DofMap::compute_sparsity(), current_local_solution, get_dof_map(), get_mesh(), and solution.

Referenced by alternative_fe_assembly(), libMesh::RBEIMConstruction::initialize_qp_data(), libMesh::DifferentiableSystem::reinit(), libMesh::EigenSystem::reinit(), libMesh::LinearImplicitSystem::reinit(), libMesh::OptimizationSystem::reinit(), and libMesh::NonlinearImplicitSystem::reinit().

447 {
448  parallel_object_only();
449 
450  // project_vector handles vector initialization now
451  libmesh_assert_equal_to (solution->size(), current_local_solution->size());
452 
453  if (!_matrices.empty() && !_basic_system_only)
454  {
455  // Clear the matrices
456  for (auto & pr : _matrices)
457  {
458  pr.second->clear();
459  pr.second->attach_dof_map(this->get_dof_map());
460  }
461 
462  // Clear the sparsity pattern
463  this->get_dof_map().clear_sparsity();
464 
465  // Compute the sparsity pattern for the current
466  // mesh and DOF distribution. This also updates
467  // additional matrices, \p DofMap now knows them
468  this->get_dof_map().compute_sparsity (this->get_mesh());
469 
470  // Initialize matrices and set to zero
471  for (auto & pr : _matrices)
472  {
473  pr.second->init();
474  pr.second->zero();
475  }
476  }
477 }
bool _basic_system_only
Holds true if the components of more advanced system types (e.g.
Definition: system.h:2204
const MeshBase & get_mesh() const
Definition: system.h:2277
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
Some systems need an arbitrary number of matrices.
Definition: system.h:2181
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1573
void clear_sparsity()
Clears the sparsity pattern.
Definition: dof_map.C:1837
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Definition: system.h:1585
void compute_sparsity(const MeshBase &)
Computes the sparsity pattern for the matrices corresponding to proc_id and sends that data to Linear...
Definition: dof_map.C:1816
const DofMap & get_dof_map() const
Definition: system.h:2293

◆ reinit_constraints()

void libMesh::System::reinit_constraints ( )
virtual

Reinitializes the constraints for this system.

Definition at line 480 of file system.C.

References _mesh, libMesh::DofMap::create_dof_constraints(), get_dof_map(), libMesh::DofMap::prepare_send_list(), libMesh::DofMap::process_constraints(), time, and user_constrain().

Referenced by libMesh::EquationSystems::allgather(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), init_data(), and libMesh::EquationSystems::reinit_solutions().

481 {
482  parallel_object_only();
483 
484 #ifdef LIBMESH_ENABLE_CONSTRAINTS
486  user_constrain();
488 #endif
490 }
Real time
For time-dependent problems, this is the time t at the beginning of the current timestep.
Definition: system.h:1595
void process_constraints(MeshBase &)
Postprocesses any constrained degrees of freedom to be constrained only in terms of unconstrained dof...
void create_dof_constraints(const MeshBase &, Real time=0)
Rebuilds the raw degree of freedom and DofObject constraints, based on attached DirichletBoundary obj...
void prepare_send_list()
Takes the _send_list vector (which may have duplicate entries) and sorts it.
Definition: dof_map.C:1692
virtual void user_constrain()
Calls user&#39;s attached constraint function, or is overridden by the user in derived classes...
Definition: system.C:2273
const DofMap & get_dof_map() const
Definition: system.h:2293
MeshBase & _mesh
Constant reference to the mesh data structure used for the simulation.
Definition: system.h:2125

◆ reinit_mesh()

void libMesh::System::reinit_mesh ( )
virtual

Reinitializes the system with a new mesh.

Definition at line 304 of file system.C.

References _basic_system_only, init_data(), n_vars(), and user_initialization().

305 {
306  parallel_object_only();
307 
308  // First initialize any required data:
309  // either only the basic System data
310  if (_basic_system_only)
312  // or all the derived class' data too
313  else
314  this->init_data();
315 
316  // If no variables have been added to this system
317  // don't do anything
318  if (!this->n_vars())
319  return;
320 
321  // Then call the user-provided initialization function
322  this->user_initialization();
323 
324 }
bool _basic_system_only
Holds true if the components of more advanced system types (e.g.
Definition: system.h:2204
virtual void init_data()
Initializes the data for the system.
Definition: system.C:216
virtual void user_initialization()
Calls user&#39;s attached initialization function, or is overridden by the user in derived classes...
Definition: system.C:2245
unsigned int n_vars() const
Definition: system.h:2349

◆ remove_matrix()

void libMesh::System::remove_matrix ( std::string_view  mat_name)

Removes the additional matrix mat_name from this system.

Definition at line 1032 of file system.C.

References _matrices.

1033 {
1034  parallel_object_only(); // Not strictly needed, but the only safe way to keep in sync
1035 
1036  matrices_iterator pos = _matrices.find(mat_name);
1037 
1038  // Return if the matrix does not exist
1039  if (pos == _matrices.end())
1040  return;
1041 
1042  _matrices.erase(pos); // erase()'d entries are destroyed
1043 }
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> >::iterator matrices_iterator
Matrix iterator typedefs.
Definition: system.h:1809
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
Some systems need an arbitrary number of matrices.
Definition: system.h:2181

◆ remove_vector()

void libMesh::System::remove_vector ( std::string_view  vec_name)

Removes the additional vector vec_name from this system.

Definition at line 846 of file system.C.

References _vector_is_adjoint, _vector_projections, _vectors, and libMesh::libmesh_assert().

Referenced by libMesh::AdjointRefinementEstimator::estimate_error(), and libMesh::UnsteadySolver::integrate_adjoint_sensitivity().

847 {
848  parallel_object_only(); // Not strictly needed, but the only safe way to keep in sync
849 
850  vectors_iterator pos = _vectors.find(vec_name);
851 
852  //Return if the vector does not exist
853  if (pos == _vectors.end())
854  return;
855 
856  _vectors.erase(pos);
857  auto proj_it = _vector_projections.find(vec_name);
858  libmesh_assert(proj_it != _vector_projections.end());
859  _vector_projections.erase(proj_it);
860 
861  auto adj_it = _vector_is_adjoint.find(vec_name);
862  libmesh_assert(adj_it != _vector_is_adjoint.end());
863  _vector_is_adjoint.erase(adj_it);
864 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> >::iterator vectors_iterator
Vector iterator typedefs.
Definition: system.h:766
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2164
std::map< std::string, int, std::less<> > _vector_is_adjoint
Holds non-negative if a vector by that name should be projected using adjoint constraints/BCs, -1 if primal.
Definition: system.h:2176
libmesh_assert(ctx)
std::map< std::string, bool, std::less<> > _vector_projections
Holds true if a vector by that name should be projected onto a changed grid, false if it should be ze...
Definition: system.h:2170

◆ request_matrix() [1/2]

const SparseMatrix< Number > * libMesh::System::request_matrix ( std::string_view  mat_name) const
Returns
A const pointer to this system's additional matrix named mat_name, or nullptr if no matrix by that name exists.

Definition at line 1047 of file system.C.

References _matrices.

Referenced by libMesh::EigenSystem::has_matrix_A(), libMesh::EigenSystem::has_matrix_B(), libMesh::EigenSystem::has_precond_matrix(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::NewtonSolver::solve(), and libMesh::LinearImplicitSystem::solve().

1048 {
1049  // Make sure the matrix exists
1050  const_matrices_iterator pos = _matrices.find(mat_name);
1051 
1052  if (pos == _matrices.end())
1053  return nullptr;
1054 
1055  return pos->second.get();
1056 }
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> >::const_iterator const_matrices_iterator
Definition: system.h:1810
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
Some systems need an arbitrary number of matrices.
Definition: system.h:2181

◆ request_matrix() [2/2]

SparseMatrix< Number > * libMesh::System::request_matrix ( std::string_view  mat_name)
Returns
A writable pointer to this system's additional matrix named mat_name, or nullptr if no matrix by that name exists.

Definition at line 1060 of file system.C.

References _matrices.

1061 {
1062  // Make sure the matrix exists
1063  matrices_iterator pos = _matrices.find(mat_name);
1064 
1065  if (pos == _matrices.end())
1066  return nullptr;
1067 
1068  return pos->second.get();
1069 }
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> >::iterator matrices_iterator
Matrix iterator typedefs.
Definition: system.h:1809
std::map< std::string, std::unique_ptr< SparseMatrix< Number > >, std::less<> > _matrices
Some systems need an arbitrary number of matrices.
Definition: system.h:2181

◆ request_vector() [1/4]

const NumericVector< Number > * libMesh::System::request_vector ( std::string_view  vec_name) const
Returns
A const pointer to the vector if this System has a vector associated with the given name, nullptr otherwise.

Definition at line 866 of file system.C.

References _vectors.

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

867 {
868  const_vectors_iterator pos = _vectors.find(vec_name);
869 
870  if (pos == _vectors.end())
871  return nullptr;
872 
873  return pos->second.get();
874 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2164
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> >::const_iterator const_vectors_iterator
Definition: system.h:767

◆ request_vector() [2/4]

NumericVector< Number > * libMesh::System::request_vector ( std::string_view  vec_name)
Returns
A pointer to the vector if this System has a vector associated with the given name, nullptr otherwise.

Definition at line 878 of file system.C.

References _vectors.

879 {
880  vectors_iterator pos = _vectors.find(vec_name);
881 
882  if (pos == _vectors.end())
883  return nullptr;
884 
885  return pos->second.get();
886 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> >::iterator vectors_iterator
Vector iterator typedefs.
Definition: system.h:766
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2164

◆ request_vector() [3/4]

const NumericVector< Number > * libMesh::System::request_vector ( const unsigned int  vec_num) const
Returns
A const pointer to this system's additional vector number vec_num (where the vectors are counted starting with 0), or nullptr if the system has no such vector.

Definition at line 890 of file system.C.

References _vectors, and vectors_begin().

891 {
892  // If we don't have that many vectors, return nullptr
893  if (vec_num >= _vectors.size())
894  return nullptr;
895 
896  // Otherwise return a pointer to the vec_num'th vector
897  auto it = vectors_begin();
898  std::advance(it, vec_num);
899  return it->second.get();
900 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2164
vectors_iterator vectors_begin()
Beginning of vectors container.
Definition: system.h:2483

◆ request_vector() [4/4]

NumericVector< Number > * libMesh::System::request_vector ( const unsigned int  vec_num)
Returns
A writable pointer to this system's additional vector number vec_num (where the vectors are counted starting with 0), or nullptr if the system has no such vector.

Definition at line 904 of file system.C.

References _vectors, and vectors_begin().

905 {
906  // If we don't have that many vectors, return nullptr
907  if (vec_num >= _vectors.size())
908  return nullptr;
909 
910  // Otherwise return a pointer to the vec_num'th vector
911  auto it = vectors_begin();
912  std::advance(it, vec_num);
913  return it->second.get();
914 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2164
vectors_iterator vectors_begin()
Beginning of vectors container.
Definition: system.h:2483

◆ restrict_solve_to()

void libMesh::System::restrict_solve_to ( const SystemSubset subset,
const SubsetSolveMode  subset_solve_mode = SUBSET_ZERO 
)
virtual

After calling this method, any solve will be restricted to the given subdomain.

To disable this mode, call this method with subset being a nullptr.

Reimplemented in libMesh::LinearImplicitSystem.

Definition at line 540 of file system.C.

542 {
543  if (subset != nullptr)
544  libmesh_not_implemented();
545 }

◆ restrict_vectors()

void libMesh::System::restrict_vectors ( )
virtual

Restrict vectors after the mesh has coarsened.

Definition at line 378 of file system.C.

References _dof_map, _solution_projection, _vector_projections, _vectors, current_local_solution, libMesh::NumericVector< T >::get(), libMesh::GHOSTED, n_dofs(), n_local_dofs(), libMesh::PARALLEL, project_vector(), solution, and vector_is_adjoint().

Referenced by prolong_vectors(), and libMesh::EquationSystems::reinit_solutions().

379 {
380  parallel_object_only();
381 
382 #ifdef LIBMESH_ENABLE_AMR
383  // Restrict the _vectors on the coarsened cells
384  for (auto & [vec_name, vec] : _vectors)
385  {
386  NumericVector<Number> * v = vec.get();
387 
388  if (_vector_projections[vec_name])
389  {
390  this->project_vector (*v, this->vector_is_adjoint(vec_name));
391  }
392  else
393  {
394  const ParallelType type = vec->type();
395 
396  if (type == GHOSTED)
397  {
398 #ifdef LIBMESH_ENABLE_GHOSTED
399  vec->init (this->n_dofs(), this->n_local_dofs(),
400  _dof_map->get_send_list(), /*fast=*/false,
401  GHOSTED);
402 #else
403  libmesh_error_msg("Cannot initialize ghosted vectors when they are not enabled.");
404 #endif
405  }
406  else
407  vec->init (this->n_dofs(), this->n_local_dofs(), false, type);
408  }
409  }
410 
411  const std::vector<dof_id_type> & send_list = _dof_map->get_send_list ();
412 
413  // Restrict the solution on the coarsened cells
415  this->project_vector (*solution);
416  // Or at least make sure the solution vector is the correct size
417  else
418  solution->init (this->n_dofs(), this->n_local_dofs(), true, PARALLEL);
419 
420 #ifdef LIBMESH_ENABLE_GHOSTED
421  current_local_solution->init(this->n_dofs(),
422  this->n_local_dofs(), send_list,
423  false, GHOSTED);
424 #else
425  current_local_solution->init(this->n_dofs());
426 #endif
427 
429  solution->localize (*current_local_solution, send_list);
430 
431 #endif // LIBMESH_ENABLE_AMR
432 }
int vector_is_adjoint(std::string_view vec_name) const
Definition: system.C:1120
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:2113
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2164
dof_id_type n_local_dofs() const
Definition: system.C:150
dof_id_type n_dofs() const
Definition: system.C:113
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1573
bool _solution_projection
Holds true if the solution vector should be projected onto a changed grid, false if it should be zero...
Definition: system.h:2198
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Definition: system.h:1585
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
Projects arbitrary functions onto a vector of degree of freedom values for the current system...
template class LIBMESH_EXPORT NumericVector< Number >
std::map< std::string, bool, std::less<> > _vector_projections
Holds true if a vector by that name should be projected onto a changed grid, false if it should be ze...
Definition: system.h:2170
ParallelType
Defines an enum for parallel data structure types.

◆ sensitivity_solve()

std::pair< unsigned int, Real > libMesh::System::sensitivity_solve ( const ParameterVector parameters)
inlinevirtual

Solves the sensitivity system, for the provided parameters.

Must be overridden in derived systems.

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

This method is only implemented in some derived classes.

Reimplemented in libMesh::ImplicitSystem.

Definition at line 2527 of file system.h.

2528 {
2529  libmesh_not_implemented();
2530 }

◆ set_adjoint_already_solved()

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

Setter for the adjoint_already_solved boolean.

Definition at line 412 of file system.h.

References adjoint_already_solved.

Referenced by main().

413  { adjoint_already_solved = setting;}
bool adjoint_already_solved
Has the adjoint problem already been solved? If the user sets adjoint_already_solved to true...
Definition: system.h:2242

◆ set_basic_system_only()

void libMesh::System::set_basic_system_only ( )
inline

Sets the system to be "basic only": i.e.

advanced system components such as ImplicitSystem matrices may not be initialized. This is useful for efficiency in certain utility programs that never use System::solve(). This method must be called after the System or derived class is created but before it is initialized; e.g. from within EquationSystems::read()

Definition at line 2341 of file system.h.

References _basic_system_only.

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

2342 {
2343  _basic_system_only = true;
2344 }
bool _basic_system_only
Holds true if the components of more advanced system types (e.g.
Definition: system.h:2204

◆ set_project_with_constraints()

void libMesh::System::set_project_with_constraints ( bool  _project_with_constraints)
inline

Definition at line 1780 of file system.h.

References project_with_constraints.

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

1781  {
1782  project_with_constraints = _project_with_constraints;
1783  }
bool project_with_constraints
Do we want to apply constraints while projecting vectors ?
Definition: system.h:2253

◆ set_qoi() [1/2]

void libMesh::System::set_qoi ( unsigned int  qoi_index,
Number  qoi_value 
)

Definition at line 2326 of file system.C.

References libMesh::libmesh_assert(), and qoi.

Referenced by libMesh::ExplicitSystem::assemble_qoi(), libMesh::FEMSystem::assemble_qoi(), libMesh::Euler2Solver::integrate_qoi_timestep(), libMesh::TwostepTimeSolver::integrate_qoi_timestep(), and libMesh::EulerSolver::integrate_qoi_timestep().

2327 {
2328  libmesh_assert(qoi_index < qoi.size());
2329 
2330  qoi[qoi_index] = qoi_value;
2331 }
std::vector< Number > qoi
Values of the quantities of interest.
Definition: system.h:1611
libmesh_assert(ctx)

◆ set_qoi() [2/2]

void libMesh::System::set_qoi ( std::vector< Number new_qoi)

Definition at line 2347 of file system.C.

References qoi.

2348 {
2349  libmesh_assert_equal_to(this->qoi.size(), new_qoi.size());
2350  this->qoi = std::move(new_qoi);
2351 }
std::vector< Number > qoi
Values of the quantities of interest.
Definition: system.h:1611

◆ set_qoi_error_estimate()

void libMesh::System::set_qoi_error_estimate ( unsigned int  qoi_index,
Number  qoi_error_estimate 
)

Definition at line 2354 of file system.C.

References libMesh::libmesh_assert(), and qoi_error_estimates.

Referenced by libMesh::Euler2Solver::integrate_adjoint_refinement_error_estimate(), libMesh::TwostepTimeSolver::integrate_adjoint_refinement_error_estimate(), and libMesh::EulerSolver::integrate_adjoint_refinement_error_estimate().

2355 {
2356  libmesh_assert(qoi_index < qoi_error_estimates.size());
2357 
2358  qoi_error_estimates[qoi_index] = qoi_error_estimate;
2359 }
libmesh_assert(ctx)
std::vector< Number > qoi_error_estimates
Vector to hold error estimates for qois, either from a steady state calculation, or from a single uns...
Definition: system.h:1619

◆ set_vector_as_adjoint()

void libMesh::System::set_vector_as_adjoint ( const std::string &  vec_name,
int  qoi_num 
)

Allows one to set the QoI index controlling whether the vector identified by vec_name represents a solution from the adjoint (qoi_num >= 0) or primal (qoi_num == -1) space.

This becomes significant if those spaces have differing heterogeneous Dirichlet constraints.

qoi_num == -2 can be used to indicate a vector which should not be affected by constraints during projection operations.

Definition at line 1107 of file system.C.

References _vector_is_adjoint.

Referenced by add_adjoint_solution(), and add_weighted_sensitivity_adjoint_solution().

1109 {
1110  parallel_object_only(); // Not strictly needed, but the only safe way to keep in sync
1111 
1112  // We reserve -1 for vectors which get primal constraints, -2 for
1113  // vectors which get no constraints
1114  libmesh_assert_greater_equal(qoi_num, -2);
1115  _vector_is_adjoint[vec_name] = qoi_num;
1116 }
std::map< std::string, int, std::less<> > _vector_is_adjoint
Holds non-negative if a vector by that name should be projected using adjoint constraints/BCs, -1 if primal.
Definition: system.h:2176

◆ set_vector_preservation()

void libMesh::System::set_vector_preservation ( const std::string &  vec_name,
bool  preserve 
)

Allows one to set the boolean controlling whether the vector identified by vec_name should be "preserved": projected to new meshes, saved, etc.

Definition at line 1087 of file system.C.

References _vector_projections.

Referenced by libMesh::AdjointRefinementEstimator::estimate_error(), and main().

1089 {
1090  parallel_object_only(); // Not strictly needed, but the only safe way to keep in sync
1091 
1092  _vector_projections[vec_name] = preserve;
1093 }
std::map< std::string, bool, std::less<> > _vector_projections
Holds true if a vector by that name should be projected onto a changed grid, false if it should be ze...
Definition: system.h:2170

◆ solve()

virtual void libMesh::System::solve ( )
inlinevirtual

◆ solve_for_unconstrained_dofs()

void libMesh::System::solve_for_unconstrained_dofs ( NumericVector< Number > &  vec,
int  is_adjoint = -1 
) const
protected

Definition at line 2041 of file system_projection.C.

References libMesh::DofMap::build_sparsity(), libMesh::DofMap::computed_sparsity_already(), libMesh::DofMap::end_dof(), libMesh::DofMap::first_dof(), libMesh::NumericVector< T >::get(), libMesh::DofMap::heterogenously_constrain_element_matrix_and_vector(), libMesh::DofMap::is_constrained_dof(), libMesh::NumericVector< T >::local_size(), libMesh::DofMap::n_dofs(), libMesh::DofMap::n_local_dofs(), libMesh::PARALLEL, libMesh::Real, libMesh::NumericVector< T >::size(), and libMesh::DofMap::update_sparsity_pattern().

2043 {
2044  const DofMap & dof_map = this->get_dof_map();
2045 
2046  std::unique_ptr<SparseMatrix<Number>> mat =
2048 
2049  std::unique_ptr<SparsityPattern::Build> sp;
2050 
2051  if (dof_map.computed_sparsity_already())
2052  dof_map.update_sparsity_pattern(*mat);
2053  else
2054  {
2055  mat->attach_dof_map(dof_map);
2056  sp = dof_map.build_sparsity(this->get_mesh());
2057  mat->attach_sparsity_pattern(*sp);
2058  }
2059 
2060  mat->init();
2061 
2062  libmesh_assert_equal_to(vec.size(), dof_map.n_dofs());
2063  libmesh_assert_equal_to(vec.local_size(), dof_map.n_local_dofs());
2064 
2065  std::unique_ptr<NumericVector<Number>> rhs =
2067 
2068  rhs->init(dof_map.n_dofs(), dof_map.n_local_dofs(), false,
2069  PARALLEL);
2070 
2071  // Here we start with the unconstrained (and indeterminate) linear
2072  // system, K*u = f, where K is the identity matrix for constrained
2073  // DoFs and 0 elsewhere, and f is the current solution values for
2074  // constrained DoFs and 0 elsewhere.
2075  // We then apply the usual heterogeneous constraint matrix C and
2076  // offset h, where u = C*x + h,
2077  // to get C^T*K*C*x = C^T*f - C^T*K*h
2078  // - a constrained and no-longer-singular system that finds the
2079  // closest approximation for the unconstrained degrees of freedom.
2080  //
2081  // Here, though "closest" is in an algebraic sense; we're
2082  // effectively using a pseudoinverse that optimizes in a
2083  // discretization-dependent norm. That only seems to give ~0.1%
2084  // excess error even in coarse unit test cases, but at some point it
2085  // might be reasonable to weight K and f properly.
2086 
2087  for (dof_id_type d : IntRange<dof_id_type>(dof_map.first_dof(),
2088  dof_map.end_dof()))
2089  {
2090  if (dof_map.is_constrained_dof(d))
2091  {
2092  DenseMatrix<Number> K(1,1);
2093  DenseVector<Number> F(1);
2094  std::vector<dof_id_type> dof_indices(1, d);
2095  K(0,0) = 1;
2096  F(0) = (*this->solution)(d);
2097  dof_map.heterogenously_constrain_element_matrix_and_vector
2098  (K, F, dof_indices, false, is_adjoint);
2099  mat->add_matrix(K, dof_indices);
2100  rhs->add_vector(F, dof_indices);
2101  }
2102  }
2103 
2104  std::unique_ptr<LinearSolver<Number>> linear_solver =
2106 
2107  linear_solver->solve(*mat, vec, *rhs,
2108  double(this->get_equation_systems().parameters.get<Real>("linear solver tolerance")),
2109  this->get_equation_systems().parameters.get<unsigned int>("linear solver maximum iterations"));
2110 }
static std::unique_ptr< LinearSolver< T > > build(const libMesh::Parallel::Communicator &comm_in, const SolverPackage solver_package=libMesh::default_solver_package())
Builds a LinearSolver using the linear solver package specified by solver_package.
Definition: linear_solver.C:59
virtual numeric_index_type size() const =0
const EquationSystems & get_equation_systems() const
Definition: system.h:730
const Parallel::Communicator & comm() const
const MeshBase & get_mesh() const
Definition: system.h:2277
static std::unique_ptr< SparseMatrix< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package(), const MatrixBuildType matrix_build_type=MatrixBuildType::AUTOMATIC)
Builds a SparseMatrix<T> using the linear solver package specified by solver_package.
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1573
static std::unique_ptr< NumericVector< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
Builds a NumericVector on the processors in communicator comm using the linear solver package specifi...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual numeric_index_type local_size() const =0
const DofMap & get_dof_map() const
Definition: system.h:2293
uint8_t dof_id_type
Definition: id_types.h:67

◆ system()

sys_type& libMesh::System::system ( )
inline
Returns
A reference to *this.

Definition at line 253 of file system.h.

253 { return *this; }

◆ system_type()

virtual std::string libMesh::System::system_type ( ) const
inlinevirtual
Returns
The type of system, helpful in identifying which system type to use when reading equation system data from file. Should be overridden in derived classes.

Reimplemented in libMesh::NonlinearImplicitSystem, libMesh::OptimizationSystem, libMesh::LinearImplicitSystem, libMesh::RBConstruction, libMesh::EigenSystem, libMesh::FrequencySystem, libMesh::ExplicitSystem, libMesh::ImplicitSystem, libMesh::TransientSystem< RBConstruction >, libMesh::NewmarkSystem, and SolidSystem.

Definition at line 505 of file system.h.

Referenced by get_info().

505 { return "Basic"; }

◆ update()

void libMesh::System::update ( )
virtual

Update the local values to reflect the solution on neighboring processors.

Reimplemented in SolidSystem.

Definition at line 493 of file system.C.

References _dof_map, current_local_solution, libMesh::libmesh_assert(), and solution.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::UniformRefinementEstimator::_estimate_error(), HDGProblem::assemble(), libMesh::FEMSystem::assemble_qoi(), libMesh::FEMSystem::assemble_qoi_derivative(), libMesh::NonlinearImplicitSystem::assembly(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::NewmarkSolver::compute_initial_accel(), compute_stresses(), LinearElasticityWithContact::compute_stresses(), LinearElasticity::compute_stresses(), LargeDeformationElasticity::compute_stresses(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::Nemesis_IO::copy_elemental_solution(), libMesh::GMVIO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::Nemesis_IO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), DMlibMeshFunction(), DMlibMeshJacobian(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::TransientRBConstruction::initialize_truth(), libMesh::Euler2Solver::integrate_adjoint_refinement_error_estimate(), libMesh::EulerSolver::integrate_adjoint_refinement_error_estimate(), libMesh::libmesh_petsc_snes_fd_residual(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_mffd_residual(), libMesh::libmesh_petsc_snes_residual(), libMesh::libmesh_petsc_snes_residual_helper(), libMesh::NewtonSolver::line_search(), libMesh::RBConstruction::load_basis_function(), libMesh::TransientRBConstruction::load_rb_solution(), libMesh::RBConstruction::load_rb_solution(), main(), libMesh::FEMSystem::mesh_position_get(), HeatSystem::perturb_accumulate_residuals(), libMesh::FEMSystem::postprocess(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::MemorySolutionHistory::retrieve(), libMesh::FileSolutionHistory::retrieve(), libMesh::NewtonSolver::solve(), libMesh::ExplicitSystem::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::OptimizationSystem::solve(), libMesh::NonlinearImplicitSystem::solve(), libMesh::RBConstruction::solve_for_matrix_and_rhs(), libMesh::MeshFunctionSolutionTransfer::transfer(), and libMesh::DirectSolutionTransfer::transfer().

494 {
495  parallel_object_only();
496 
497  libmesh_assert(solution->closed());
498 
499  const std::vector<dof_id_type> & send_list = _dof_map->get_send_list ();
500 
501  // Check sizes
502  libmesh_assert_equal_to (current_local_solution->size(), solution->size());
503  // More processors than elements => empty send_list
504  // libmesh_assert (!send_list.empty());
505  libmesh_assert_less_equal (send_list.size(), solution->size());
506 
507  // Create current_local_solution from solution. This will
508  // put a local copy of solution into current_local_solution.
509  // Only the necessary values (specified by the send_list)
510  // are copied to minimize communication
511  solution->localize (*current_local_solution, send_list);
512 }
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:2113
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1573
libmesh_assert(ctx)
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Definition: system.h:1585

◆ update_global_solution() [1/2]

void libMesh::System::update_global_solution ( std::vector< Number > &  global_soln) const

Fill the input vector global_soln so that it contains the global solution on all processors.

Requires communication with all other processors.

Definition at line 728 of file system.C.

References solution.

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::ExactErrorEstimator::estimate_error(), main(), and libMesh::InterMeshProjection::project_system_vectors().

729 {
730  parallel_object_only();
731 
732  global_soln.resize (solution->size());
733 
734  solution->localize (global_soln);
735 }
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1573

◆ update_global_solution() [2/2]

void libMesh::System::update_global_solution ( std::vector< Number > &  global_soln,
const processor_id_type  dest_proc 
) const

Fill the input vector global_soln so that it contains the global solution on processor dest_proc.

Requires communication with all other processors.

Definition at line 739 of file system.C.

References solution.

741 {
742  parallel_object_only();
743 
744  global_soln.resize (solution->size());
745 
746  solution->localize_to_one (global_soln, dest_proc);
747 }
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1573

◆ user_assembly()

void libMesh::System::user_assembly ( )
virtual

Calls user's attached assembly function, or is overridden by the user in derived classes.

Definition at line 2259 of file system.C.

References _assemble_system_function, _assemble_system_object, _equation_systems, libMesh::System::Assembly::assemble(), and name().

Referenced by assemble().

2260 {
2261  // Call the user-provided assembly function,
2262  // if it was provided
2263  if (_assemble_system_function != nullptr)
2265 
2266  // ...or the user-provided assembly object.
2267  else if (_assemble_system_object != nullptr)
2269 }
Assembly * _assemble_system_object
Object that assembles the system.
Definition: system.h:2070
virtual void assemble()=0
Assembly function.
EquationSystems & _equation_systems
Constant reference to the EquationSystems object used for the simulation.
Definition: system.h:2119
const std::string & name() const
Definition: system.h:2261
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Function that assembles the system.
Definition: system.h:2064

◆ user_constrain()

void libMesh::System::user_constrain ( )
virtual

Calls user's attached constraint function, or is overridden by the user in derived classes.

Definition at line 2273 of file system.C.

References _constrain_system_function, _constrain_system_object, _equation_systems, libMesh::System::Constraint::constrain(), and name().

Referenced by reinit_constraints().

2274 {
2275  // Call the user-provided constraint function,
2276  // if it was provided
2277  if (_constrain_system_function!= nullptr)
2279 
2280  // ...or the user-provided constraint object.
2281  else if (_constrain_system_object != nullptr)
2283 }
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Function to impose constraints.
Definition: system.h:2075
Constraint * _constrain_system_object
Object that constrains the system.
Definition: system.h:2081
EquationSystems & _equation_systems
Constant reference to the EquationSystems object used for the simulation.
Definition: system.h:2119
virtual void constrain()=0
Constraint function.
const std::string & name() const
Definition: system.h:2261

◆ user_initialization()

void libMesh::System::user_initialization ( )
virtual

Calls user's attached initialization function, or is overridden by the user in derived classes.

Definition at line 2245 of file system.C.

References _equation_systems, _init_system_function, _init_system_object, libMesh::System::Initialization::initialize(), and name().

Referenced by init(), libMesh::NewmarkSystem::initial_conditions(), and reinit_mesh().

2246 {
2247  // Call the user-provided initialization function,
2248  // if it was provided
2249  if (_init_system_function != nullptr)
2250  this->_init_system_function (_equation_systems, this->name());
2251 
2252  // ...or the user-provided initialization object.
2253  else if (_init_system_object != nullptr)
2255 }
virtual void initialize()=0
Initialization function.
Initialization * _init_system_object
Object that initializes the system.
Definition: system.h:2059
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Function that initializes the system.
Definition: system.h:2053
EquationSystems & _equation_systems
Constant reference to the EquationSystems object used for the simulation.
Definition: system.h:2119
const std::string & name() const
Definition: system.h:2261

◆ user_QOI()

void libMesh::System::user_QOI ( const QoISet qoi_indices)
virtual

Calls user's attached quantity of interest function, or is overridden by the user in derived classes.

Definition at line 2287 of file system.C.

References _equation_systems, _qoi_evaluate_function, _qoi_evaluate_object, name(), and libMesh::System::QOI::qoi().

Referenced by assemble_qoi().

2288 {
2289  // Call the user-provided quantity of interest function,
2290  // if it was provided
2291  if (_qoi_evaluate_function != nullptr)
2292  this->_qoi_evaluate_function(_equation_systems, this->name(), qoi_indices);
2293 
2294  // ...or the user-provided QOI function object.
2295  else if (_qoi_evaluate_object != nullptr)
2296  this->_qoi_evaluate_object->qoi(qoi_indices);
2297 }
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Function to evaluate quantity of interest.
Definition: system.h:2086
virtual void qoi(const QoISet &qoi_indices)=0
Quantity of interest function.
QOI * _qoi_evaluate_object
Object to compute quantities of interest.
Definition: system.h:2093
EquationSystems & _equation_systems
Constant reference to the EquationSystems object used for the simulation.
Definition: system.h:2119
const std::string & name() const
Definition: system.h:2261

◆ user_QOI_derivative()

void libMesh::System::user_QOI_derivative ( const QoISet qoi_indices = QoISet(),
bool  include_liftfunc = true,
bool  apply_constraints = true 
)
virtual

Calls user's attached quantity of interest derivative function, or is overridden by the user in derived classes.

Definition at line 2301 of file system.C.

References _equation_systems, _qoi_evaluate_derivative_function, _qoi_evaluate_derivative_object, name(), and libMesh::System::QOIDerivative::qoi_derivative().

Referenced by assemble_qoi_derivative().

2304 {
2305  // Call the user-provided quantity of interest derivative,
2306  // if it was provided
2307  if (_qoi_evaluate_derivative_function != nullptr)
2309  (_equation_systems, this->name(), qoi_indices, include_liftfunc,
2310  apply_constraints);
2311 
2312  // ...or the user-provided QOI derivative function object.
2313  else if (_qoi_evaluate_derivative_object != nullptr)
2315  (qoi_indices, include_liftfunc, apply_constraints);
2316 }
QOIDerivative * _qoi_evaluate_derivative_object
Object to compute derivatives of quantities of interest.
Definition: system.h:2107
virtual void qoi_derivative(const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)=0
Quantity of interest derivative function.
EquationSystems & _equation_systems
Constant reference to the EquationSystems object used for the simulation.
Definition: system.h:2119
const std::string & name() const
Definition: system.h:2261
void(* _qoi_evaluate_derivative_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
Function to evaluate quantity of interest derivative.
Definition: system.h:2098

◆ variable()

const Variable & libMesh::System::variable ( unsigned int  var) const
inline

Return a constant reference to Variable var.

Definition at line 2377 of file system.h.

References _variables.

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DifferentiableSystem::add_second_order_dot_vars(), add_variable(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::FirstOrderUnsteadySolver::compute_second_order_eqns(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::find_dofs_to_send(), libMesh::DifferentiableSystem::have_first_order_scalar_vars(), libMesh::DifferentiableSystem::have_second_order_scalar_vars(), main(), libMesh::DifferentiablePhysics::nonlocal_mass_residual(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SortAndCopy::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectVertices::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectEdges::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectSides::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectInteriors::operator()(), point_gradient(), point_hessian(), point_value(), read_parallel_data(), read_SCALAR_dofs(), read_serialized_vector(), read_serialized_vectors(), libMesh::PetscDMWrapper::set_point_range_in_section(), write_header(), libMesh::Nemesis_IO_Helper::write_nodal_solution(), write_parallel_data(), write_serialized_vector(), and write_serialized_vectors().

2378 {
2379  libmesh_assert_less (i, _variables.size());
2380 
2381  return _variables[i];
2382 }
std::vector< Variable > _variables
The Variable in this System.
Definition: system.h:2140

◆ variable_group()

const VariableGroup & libMesh::System::variable_group ( unsigned int  vg) const
inline

Return a constant reference to VariableGroup vg.

Definition at line 2387 of file system.h.

References _variable_groups.

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

2388 {
2389  libmesh_assert_less (vg, _variable_groups.size());
2390 
2391  return _variable_groups[vg];
2392 }
std::vector< VariableGroup > _variable_groups
The VariableGroup in this System.
Definition: system.h:2145

◆ variable_name()

const std::string & libMesh::System::variable_name ( const unsigned int  i) const
inline

◆ variable_number()

unsigned int libMesh::System::variable_number ( std::string_view  var) const
Returns
The variable number associated with the user-specified variable named var.

Definition at line 1557 of file system.C.

References _variable_numbers, _variables, and name().

Referenced by libMesh::ExactSolution::_compute_error(), alternative_fe_assembly(), LinearElasticity::assemble(), HDGProblem::assemble(), AssembleOptimization::assemble_A_and_F(), assemble_divgrad(), assemble_elasticity(), assemble_matrix_and_rhs(), assemble_shell(), assemble_stokes(), compute_enriched_soln(), compute_stresses(), LinearElasticityWithContact::compute_stresses(), LinearElasticity::compute_stresses(), LargeDeformationElasticity::compute_stresses(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::Nemesis_IO::copy_elemental_solution(), libMesh::GMVIO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::Nemesis_IO::copy_nodal_solution(), libMesh::ExactErrorEstimator::estimate_error(), fe_assembly(), libMesh::ExactErrorEstimator::find_squared_element_error(), CoupledSystemQoI::init_context(), LargeDeformationElasticity::jacobian(), line_print(), main(), LinearElasticityWithContact::move_mesh(), read_header(), LargeDeformationElasticity::residual(), LinearElasticityWithContact::residual_and_jacobian(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), OverlappingTestBase::setup_coupling_matrix(), libMesh::DTKAdapter::update_variable_values(), variable_scalar_number(), variable_type(), libMesh::EnsightIO::write_scalar_ascii(), and libMesh::EnsightIO::write_vector_ascii().

1558 {
1559  auto var_num = libmesh_map_find(_variable_numbers, var);
1560  libmesh_assert_equal_to (_variables[var_num].name(), var);
1561  return var_num;
1562 }
std::vector< Variable > _variables
The Variable in this System.
Definition: system.h:2140
std::map< std::string, unsigned int, std::less<> > _variable_numbers
The variable numbers corresponding to user-specified names, useful for name-based lookups...
Definition: system.h:2151
const std::string & name() const
Definition: system.h:2261

◆ variable_scalar_number() [1/2]

unsigned int libMesh::System::variable_scalar_number ( std::string_view  var,
unsigned int  component 
) const
inline
Returns
An index, starting from 0 for the first component of the first variable, and incrementing for each component of each (potentially vector-valued) variable in the system in order. For systems with only scalar-valued variables, this will be the same as variable_number(var)

Irony: currently our only non-scalar-valued variable type is SCALAR.

Definition at line 2408 of file system.h.

References variable_number().

Referenced by libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), libMesh::ExactErrorEstimator::find_squared_element_error(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectVertices::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectEdges::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectSides::operator()(), and libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectInteriors::operator()().

2410 {
2411  return variable_scalar_number(this->variable_number(var), component);
2412 }
unsigned int variable_scalar_number(std::string_view var, unsigned int component) const
Definition: system.h:2408
unsigned int variable_number(std::string_view var) const
Definition: system.C:1557

◆ variable_scalar_number() [2/2]

unsigned int libMesh::System::variable_scalar_number ( unsigned int  var_num,
unsigned int  component 
) const
inline
Returns
An index, starting from 0 for the first component of the first variable, and incrementing for each component of each (potentially vector-valued) variable in the system in order. For systems with only scalar-valued variables, this will be the same as var_num

Irony: currently our only non-scalar-valued variable type is SCALAR.

Definition at line 2418 of file system.h.

References _variables.

2420 {
2421  return _variables[var_num].first_scalar_number() + component;
2422 }
std::vector< Variable > _variables
The Variable in this System.
Definition: system.h:2140

◆ variable_type() [1/2]

const FEType & libMesh::System::variable_type ( const unsigned int  i) const
inline

◆ variable_type() [2/2]

const FEType & libMesh::System::variable_type ( std::string_view  var) const
inline
Returns
The finite element type for variable var.

Definition at line 2437 of file system.h.

References _variables, and variable_number().

2438 {
2439  return _variables[this->variable_number(var)].type();
2440 }
std::vector< Variable > _variables
The Variable in this System.
Definition: system.h:2140
unsigned int variable_number(std::string_view var) const
Definition: system.C:1557

◆ vector_is_adjoint()

int libMesh::System::vector_is_adjoint ( std::string_view  vec_name) const
Returns
The integer describing whether the vector identified by vec_name represents a solution from an adjoint (non-negative) or the primal (-1) space.

Definition at line 1120 of file system.C.

References _vector_is_adjoint, and libMesh::libmesh_assert().

Referenced by libMesh::InterMeshProjection::project_system_vectors(), and restrict_vectors().

1121 {
1122  libmesh_assert(_vector_is_adjoint.find(vec_name) !=
1123  _vector_is_adjoint.end());
1124 
1125  return _vector_is_adjoint.find(vec_name)->second;
1126 }
std::map< std::string, int, std::less<> > _vector_is_adjoint
Holds non-negative if a vector by that name should be projected using adjoint constraints/BCs, -1 if primal.
Definition: system.h:2176
libmesh_assert(ctx)

◆ vector_name() [1/2]

const std::string & libMesh::System::vector_name ( const unsigned int  vec_num) const
Returns
The name of this system's additional vector number vec_num (where the vectors are counted starting with 0).

Definition at line 958 of file system.C.

References _vectors, and vectors_begin().

Referenced by libMesh::AdjointRefinementEstimator::estimate_error(), and main().

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

◆ vector_name() [2/2]

const std::string & libMesh::System::vector_name ( const NumericVector< Number > &  vec_reference) const
Returns
The name of a system vector, given a reference to that vector

Definition at line 969 of file system.C.

References _vectors, libMesh::NumericVector< T >::get(), libMesh::libmesh_assert(), vectors_begin(), and vectors_end().

970 {
971  // Linear search for a vector whose pointer matches vec_reference
972  auto it = std::find_if(vectors_begin(), vectors_end(),
973  [&vec_reference](const decltype(_vectors)::value_type & pr)
974  { return &vec_reference == pr.second.get(); });
975 
976  // Before returning, make sure we didn't loop till the end and not find any match
977  libmesh_assert (it != vectors_end());
978 
979  // Return the string associated with the current vector
980  return it->first;
981 }
vectors_iterator vectors_end()
End of vectors container.
Definition: system.h:2495
virtual void get(const std::vector< numeric_index_type > &index, T *values) const
Access multiple components at once.
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2164
vectors_iterator vectors_begin()
Beginning of vectors container.
Definition: system.h:2483
libmesh_assert(ctx)

◆ vector_preservation()

bool libMesh::System::vector_preservation ( std::string_view  vec_name) const
Returns
The boolean describing whether the vector identified by vec_name should be "preserved": projected to new meshes, saved, etc.

Definition at line 1097 of file system.C.

References _vector_projections.

Referenced by libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::MemoryHistoryData::store_vectors(), SystemsTest::testAddVectorProjChange(), SystemsTest::testAddVectorTypeChange(), and SystemsTest::testPostInitAddVectorTypeChange().

1098 {
1099  if (_vector_projections.find(vec_name) == _vector_projections.end())
1100  return false;
1101 
1102  return _vector_projections.find(vec_name)->second;
1103 }
std::map< std::string, bool, std::less<> > _vector_projections
Holds true if a vector by that name should be projected onto a changed grid, false if it should be ze...
Definition: system.h:2170

◆ vectors_begin() [1/2]

System::vectors_iterator libMesh::System::vectors_begin ( )
inline

Beginning of vectors container.

Definition at line 2483 of file system.h.

References _vectors.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), get_vector(), libMesh::InterMeshProjection::project_system_vectors(), request_vector(), libMesh::MemoryHistoryData::store_vectors(), and vector_name().

2484 {
2485  return _vectors.begin();
2486 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2164

◆ vectors_begin() [2/2]

System::const_vectors_iterator libMesh::System::vectors_begin ( ) const
inline

Beginning of vectors container.

Definition at line 2489 of file system.h.

References _vectors.

2490 {
2491  return _vectors.begin();
2492 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2164

◆ vectors_end() [1/2]

System::vectors_iterator libMesh::System::vectors_end ( )
inline

End of vectors container.

Definition at line 2495 of file system.h.

References _vectors.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::InterMeshProjection::project_system_vectors(), libMesh::MemoryHistoryData::store_vectors(), and vector_name().

2496 {
2497  return _vectors.end();
2498 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2164

◆ vectors_end() [2/2]

System::const_vectors_iterator libMesh::System::vectors_end ( ) const
inline

End of vectors container.

Definition at line 2501 of file system.h.

References _vectors.

2502 {
2503  return _vectors.end();
2504 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2164

◆ weighted_sensitivity_adjoint_solve()

std::pair< unsigned int, Real > libMesh::System::weighted_sensitivity_adjoint_solve ( const ParameterVector parameters,
const ParameterVector weights,
const QoISet qoi_indices = QoISet() 
)
inlinevirtual

Assembles & solves the linear system(s) (dR/du)^T*z_w = sum(w_p*(d^2q/dudp - d^2R/dudp*z)), for those parameters p contained within parameters, weighted by the values w_p found within weights.

Assumes that adjoint_solve has already calculated z for each qoi in qoi_indices.

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

This method is only implemented in some derived classes.

Reimplemented in libMesh::ImplicitSystem.

Definition at line 2549 of file system.h.

2552 {
2553  libmesh_not_implemented();
2554 }

◆ weighted_sensitivity_solve()

std::pair< unsigned int, Real > libMesh::System::weighted_sensitivity_solve ( const ParameterVector parameters,
const ParameterVector weights 
)
inlinevirtual

Assembles & solves the linear system(s) (dR/du)*u_w = sum(w_p*-dR/dp), for those parameters p contained within parameters weighted by the values w_p found within weights.

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

This method is only implemented in some derived classes.

Reimplemented in libMesh::ImplicitSystem.

Definition at line 2534 of file system.h.

2536 {
2537  libmesh_not_implemented();
2538 }

◆ write_header()

void libMesh::System::write_header ( Xdr io,
std::string_view  version,
const bool  write_additional_data 
) const

Writes the basic data header for this System.

This method implements the output of a System object, embedded in the output of an EquationSystems<T_sys>. This warrants some documentation. The output of this part consists of 5 sections:

for this system

5.) The number of variables in the system (unsigned int)

for each variable in the system

6.) The name of the variable (string)

6.1.) subdomain where the variable lives

7.) Combined in an FEType:

  • The approximation order(s) of the variable (Order Enum, cast to int/s)
  • The finite element family/ies of the variable (FEFamily Enum, cast to int/s)

end variable loop

8.) The number of additional vectors (unsigned int),

for each additional vector in the system object

9.) the name of the additional vector (string)

end system

Definition at line 1267 of file system_io.C.

References _vector_projections, _vectors, libMesh::Variable::active_subdomains(), libMesh::Xdr::data(), libMesh::FEType::family, get_mesh(), libMesh::FEType::inf_map, libMesh::libmesh_assert(), libMesh::make_range(), n_vars(), n_vectors(), name(), libMesh::FEType::order, libMesh::ParallelObject::processor_id(), libMesh::FEType::radial_family, libMesh::FEType::radial_order, variable(), variable_name(), variable_type(), and libMesh::Xdr::writing().

Referenced by libMesh::RBEvaluation::write_out_vectors().

1270 {
1304  libmesh_assert (io.writing());
1305 
1306 
1307  // Only write the header information
1308  // if we are processor 0.
1309  if (this->get_mesh().processor_id() != 0)
1310  return;
1311 
1312  std::string comment;
1313 
1314  // 5.)
1315  // Write the number of variables in the system
1316 
1317  {
1318  // set up the comment
1319  comment = "# No. of Variables in System \"";
1320  comment += this->name();
1321  comment += "\"";
1322 
1323  unsigned int nv = this->n_vars();
1324  io.data (nv, comment);
1325  }
1326 
1327 
1328  for (auto var : make_range(this->n_vars()))
1329  {
1330  // 6.)
1331  // Write the name of the var-th variable
1332  {
1333  // set up the comment
1334  comment = "# Name, Variable No. ";
1335  comment += std::to_string(var);
1336  comment += ", System \"";
1337  comment += this->name();
1338  comment += "\"";
1339 
1340  std::string var_name = this->variable_name(var);
1341  io.data (var_name, comment);
1342  }
1343 
1344  // 6.1.) Variable subdomains
1345  {
1346  // set up the comment
1347  comment = "# Subdomains, Variable \"";
1348  comment += this->variable_name(var);
1349  comment += "\", System \"";
1350  comment += this->name();
1351  comment += "\"";
1352 
1353  const std::set<subdomain_id_type> & domains = this->variable(var).active_subdomains();
1354  std::vector<subdomain_id_type> domain_array;
1355  domain_array.assign(domains.begin(), domains.end());
1356  io.data (domain_array, comment);
1357  }
1358 
1359  // 7.)
1360  // Write the approximation order of the var-th variable
1361  // in this system
1362  {
1363  // set up the comment
1364  comment = "# Approximation Order, Variable \"";
1365  comment += this->variable_name(var);
1366  comment += "\", System \"";
1367  comment += this->name();
1368  comment += "\"";
1369 
1370  int order = static_cast<int>(this->variable_type(var).order);
1371  io.data (order, comment);
1372  }
1373 
1374 
1375 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1376 
1377  // do the same for radial_order
1378  {
1379  comment = "# Radial Approximation Order, Variable \"";
1380  comment += this->variable_name(var);
1381  comment += "\", System \"";
1382  comment += this->name();
1383  comment += "\"";
1384 
1385  int rad_order = static_cast<int>(this->variable_type(var).radial_order);
1386  io.data (rad_order, comment);
1387  }
1388 
1389 #endif
1390 
1391  // Write the Finite Element type of the var-th variable
1392  // in this System
1393  {
1394  // set up the comment
1395  comment = "# FE Family, Variable \"";
1396  comment += this->variable_name(var);
1397  comment += "\", System \"";
1398  comment += this->name();
1399  comment += "\"";
1400 
1401  const FEType & type = this->variable_type(var);
1402  int fam = static_cast<int>(type.family);
1403  io.data (fam, comment);
1404 
1405 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1406 
1407  comment = "# Radial FE Family, Variable \"";
1408  comment += this->variable_name(var);
1409  comment += "\", System \"";
1410  comment += this->name();
1411  comment += "\"";
1412 
1413  int radial_fam = static_cast<int>(type.radial_family);
1414  io.data (radial_fam, comment);
1415 
1416  comment = "# Infinite Mapping Type, Variable \"";
1417  comment += this->variable_name(var);
1418  comment += "\", System \"";
1419  comment += this->name();
1420  comment += "\"";
1421 
1422  int i_map = static_cast<int>(type.inf_map);
1423  io.data (i_map, comment);
1424 #endif
1425  }
1426  } // end of the variable loop
1427 
1428  // 8.)
1429  // Write the number of additional vectors in the System.
1430  // If write_additional_data==false, then write zero for
1431  // the number of additional vectors.
1432  {
1433  {
1434  // set up the comment
1435  comment = "# No. of Additional Vectors, System \"";
1436  comment += this->name();
1437  comment += "\"";
1438 
1439  unsigned int nvecs = write_additional_data ? this->n_vectors () : 0;
1440  io.data (nvecs, comment);
1441  }
1442 
1443  if (write_additional_data)
1444  {
1445  unsigned int cnt=0;
1446  for (const auto & [vec_name, vec] : _vectors)
1447  {
1448  // 9.)
1449  // write the name of the cnt-th additional vector
1450  const std::string dth_vector = std::to_string(cnt++)+"th vector";
1451  comment = "# Name of " + dth_vector;
1452  std::string nonconst_vec_name = vec_name; // Stupid XDR API
1453 
1454  io.data (nonconst_vec_name, comment);
1455  int vec_projection = _vector_projections.at(vec_name);
1456  comment = "# Whether to do projections for " + dth_vector;
1457  io.data (vec_projection, comment);
1458  int vec_type = vec->type();
1459  comment = "# Parallel type of " + dth_vector;
1460  io.data (vec_type, comment);
1461  }
1462  }
1463  }
1464 }
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2377
OrderWrapper radial_order
The approximation order in radial direction of the infinite element.
Definition: fe_type.h:240
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2164
OrderWrapper order
The approximation order of the element.
Definition: fe_type.h:201
const MeshBase & get_mesh() const
Definition: system.h:2277
const std::set< subdomain_id_type > & active_subdomains() const
Definition: variable.h:171
unsigned int n_vectors() const
Definition: system.h:2477
libmesh_assert(ctx)
const std::string & variable_name(const unsigned int i) const
Definition: system.h:2397
const FEType & variable_type(const unsigned int i) const
Definition: system.h:2427
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:134
const std::string & name() const
Definition: system.h:2261
unsigned int n_vars() const
Definition: system.h:2349
processor_id_type processor_id() const
std::map< std::string, bool, std::less<> > _vector_projections
Holds true if a vector by that name should be projected onto a changed grid, false if it should be ze...
Definition: system.h:2170

◆ write_parallel_data()

void libMesh::System::write_parallel_data ( Xdr io,
const bool  write_additional_data 
) const

Writes additional data, namely vectors, for this System.

This method may safely be called on a distributed-memory mesh. This method will create an individual file for each processor in the simulation where the local solution components for that processor will be stored.

This method implements the output of the vectors contained in this System object, embedded in the output of an EquationSystems<T_sys>.

9.) The global solution vector, re-ordered to be node-major (More on this later.)

for each additional vector in the object

10.) The global additional vector, re-ordered to be node-major (More on this later.)

Note that the actual IO is handled through the Xdr class (to be renamed later?) which provides a uniform interface to both the XDR (eXternal Data Representation) interface and standard ASCII output. Thus this one section of code will read XDR or ASCII files with no changes.

Definition at line 1468 of file system_io.C.

References _vectors, libMesh::Xdr::data(), libMesh::FEType::family, get_dof_map(), get_mesh(), libMesh::DofObject::invalid_id, libMesh::libmesh_assert(), libMesh::make_range(), libMesh::ParallelObject::n_processors(), n_vars(), name(), number(), libMesh::ParallelObject::processor_id(), libMesh::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), solution, libMesh::Variable::type(), variable(), and libMesh::Xdr::writing().

1470 {
1490  // PerfLog pl("IO Performance",false);
1491  // pl.push("write_parallel_data");
1492  // std::size_t total_written_size = 0;
1493 
1494  std::string comment;
1495 
1496  libmesh_assert (io.writing());
1497 
1498  std::vector<Number> io_buffer; io_buffer.reserve(this->solution->local_size());
1499 
1500  // build the ordered nodes and element maps.
1501  // when writing/reading parallel files we need to iterate
1502  // over our nodes/elements in order of increasing global id().
1503  // however, this is not guaranteed to be ordering we obtain
1504  // by using the node_iterators/element_iterators directly.
1505  // so build a set, sorted by id(), that provides the ordering.
1506  // further, for memory economy build the set but then transfer
1507  // its contents to vectors, which will be sorted.
1508  std::vector<const DofObject *> ordered_nodes, ordered_elements;
1509  {
1510  std::set<const DofObject *, CompareDofObjectsByID>
1511  ordered_nodes_set (this->get_mesh().local_nodes_begin(),
1512  this->get_mesh().local_nodes_end());
1513 
1514  ordered_nodes.insert(ordered_nodes.end(),
1515  ordered_nodes_set.begin(),
1516  ordered_nodes_set.end());
1517  }
1518  {
1519  std::set<const DofObject *, CompareDofObjectsByID>
1520  ordered_elements_set (this->get_mesh().local_elements_begin(),
1521  this->get_mesh().local_elements_end());
1522 
1523  ordered_elements.insert(ordered_elements.end(),
1524  ordered_elements_set.begin(),
1525  ordered_elements_set.end());
1526  }
1527 
1528  const unsigned int sys_num = this->number();
1529  const unsigned int nv = this->n_vars();
1530 
1531  // Loop over each non-SCALAR variable and each node, and write out the value.
1532  for (unsigned int var=0; var<nv; var++)
1533  if (this->variable(var).type().family != SCALAR)
1534  {
1535  // First write the node DOF values
1536  for (const auto & node : ordered_nodes)
1537  for (auto comp : make_range(node->n_comp(sys_num,var)))
1538  {
1539  libmesh_assert_not_equal_to (node->dof_number(sys_num, var, comp),
1541 
1542  io_buffer.push_back((*this->solution)(node->dof_number(sys_num, var, comp)));
1543  }
1544 
1545  // Then write the element DOF values
1546  for (const auto & elem : ordered_elements)
1547  for (auto comp : make_range(elem->n_comp(sys_num,var)))
1548  {
1549  libmesh_assert_not_equal_to (elem->dof_number(sys_num, var, comp),
1551 
1552  io_buffer.push_back((*this->solution)(elem->dof_number(sys_num, var, comp)));
1553  }
1554  }
1555 
1556  // Finally, write the SCALAR data on the last processor
1557  for (auto var : make_range(this->n_vars()))
1558  if (this->variable(var).type().family == SCALAR)
1559  {
1560  if (this->processor_id() == (this->n_processors()-1))
1561  {
1562  const DofMap & dof_map = this->get_dof_map();
1563  std::vector<dof_id_type> SCALAR_dofs;
1564  dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
1565 
1566  for (auto dof : SCALAR_dofs)
1567  io_buffer.push_back((*this->solution)(dof));
1568  }
1569  }
1570 
1571  // 9.)
1572  //
1573  // Actually write the reordered solution vector
1574  // for the ith system to disk
1575 
1576  // set up the comment
1577  {
1578  comment = "# System \"";
1579  comment += this->name();
1580  comment += "\" Solution Vector";
1581  }
1582 
1583  io.data (io_buffer, comment);
1584 
1585  // total_written_size += io_buffer.size();
1586 
1587  // Only write additional vectors if wanted
1588  if (write_additional_data)
1589  {
1590  for (auto & [vec_name, vec] : _vectors)
1591  {
1592  io_buffer.clear();
1593  io_buffer.reserve(vec->local_size());
1594 
1595  // Loop over each non-SCALAR variable and each node, and write out the value.
1596  for (unsigned int var=0; var<nv; var++)
1597  if (this->variable(var).type().family != SCALAR)
1598  {
1599  // First write the node DOF values
1600  for (const auto & node : ordered_nodes)
1601  for (auto comp : make_range(node->n_comp(sys_num,var)))
1602  {
1603  libmesh_assert_not_equal_to (node->dof_number(sys_num, var, comp),
1605 
1606  io_buffer.push_back((*vec)(node->dof_number(sys_num, var, comp)));
1607  }
1608 
1609  // Then write the element DOF values
1610  for (const auto & elem : ordered_elements)
1611  for (auto comp : make_range(elem->n_comp(sys_num,var)))
1612  {
1613  libmesh_assert_not_equal_to (elem->dof_number(sys_num, var, comp),
1615 
1616  io_buffer.push_back((*vec)(elem->dof_number(sys_num, var, comp)));
1617  }
1618  }
1619 
1620  // Finally, write the SCALAR data on the last processor
1621  for (auto var : make_range(this->n_vars()))
1622  if (this->variable(var).type().family == SCALAR)
1623  {
1624  if (this->processor_id() == (this->n_processors()-1))
1625  {
1626  const DofMap & dof_map = this->get_dof_map();
1627  std::vector<dof_id_type> SCALAR_dofs;
1628  dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
1629 
1630  for (auto dof : SCALAR_dofs)
1631  io_buffer.push_back((*vec)(dof));
1632  }
1633  }
1634 
1635  // 10.)
1636  //
1637  // Actually write the reordered additional vector
1638  // for this system to disk
1639 
1640  // set up the comment
1641  {
1642  comment = "# System \"";
1643  comment += this->name();
1644  comment += "\" Additional Vector \"";
1645  comment += vec_name;
1646  comment += "\"";
1647  }
1648 
1649  io.data (io_buffer, comment);
1650 
1651  // total_written_size += io_buffer.size();
1652  }
1653  }
1654 
1655  // const Real
1656  // dt = pl.get_elapsed_time(),
1657  // rate = total_written_size*sizeof(Number)/dt;
1658 
1659  // libMesh::err << "Write " << total_written_size << " \"Number\" values\n"
1660  // << " Elapsed time = " << dt << '\n'
1661  // << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";
1662 
1663  // pl.pop("write_parallel_data");
1664 }
FEFamily family
The type of finite element.
Definition: fe_type.h:207
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2377
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2164
const MeshBase & get_mesh() const
Definition: system.h:2277
processor_id_type n_processors() const
unsigned int number() const
Definition: system.h:2269
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1573
libmesh_assert(ctx)
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:477
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:134
const std::string & name() const
Definition: system.h:2261
unsigned int n_vars() const
Definition: system.h:2349
processor_id_type processor_id() const
const DofMap & get_dof_map() const
Definition: system.h:2293
const FEType & type() const
Definition: variable.h:140

◆ write_SCALAR_dofs()

unsigned int libMesh::System::write_SCALAR_dofs ( const NumericVector< Number > &  vec,
const unsigned int  var,
Xdr io 
) const
private

Writes the SCALAR dofs associated with var to the stream io.

Returns
The number of values written.

Definition at line 2062 of file system_io.C.

References libMesh::ParallelObject::comm(), libMesh::Xdr::data_stream(), get_dof_map(), TIMPI::Communicator::get_unique_tag(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), TIMPI::Communicator::receive(), libMesh::DofMap::SCALAR_dof_indices(), and TIMPI::Communicator::send().

Referenced by write_serialized_vector(), and write_serialized_vectors().

2065 {
2066  unsigned int written_length=0;
2067  std::vector<Number> vals; // The raw values for the local objects in the current block
2068  // Collect the SCALARs for the current variable
2069  if (this->processor_id() == (this->n_processors()-1))
2070  {
2071  const DofMap & dof_map = this->get_dof_map();
2072  std::vector<dof_id_type> SCALAR_dofs;
2073  dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
2074  const unsigned int n_scalar_dofs = cast_int<unsigned int>
2075  (SCALAR_dofs.size());
2076 
2077  for (unsigned int i=0; i<n_scalar_dofs; i++)
2078  {
2079  vals.push_back( vec(SCALAR_dofs[i]) );
2080  }
2081  }
2082 
2083 #ifdef LIBMESH_HAVE_MPI
2084  if (this->n_processors() > 1)
2085  {
2086  const Parallel::MessageTag val_tag =
2087  this->comm().get_unique_tag(1);
2088 
2089  // Post the receive on processor 0
2090  if (this->processor_id() == 0)
2091  {
2092  this->comm().receive(this->n_processors()-1, vals, val_tag);
2093  }
2094 
2095  // Send the data to processor 0
2096  if (this->processor_id() == (this->n_processors()-1))
2097  {
2098  this->comm().send(0, vals, val_tag);
2099  }
2100  }
2101 #endif
2102 
2103  // -------------------------------------------------------
2104  // Write the output on processor 0.
2105  if (this->processor_id() == 0)
2106  {
2107  const unsigned int vals_size =
2108  cast_int<unsigned int>(vals.size());
2109  io.data_stream (vals.data(), vals_size);
2110  written_length += vals_size;
2111  }
2112 
2113  return written_length;
2114 }
MessageTag get_unique_tag(int tagvalue=MessageTag::invalid_tag) const
const Parallel::Communicator & comm() const
processor_id_type n_processors() const
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_tag) const
void send(const unsigned int dest_processor_id, const T &buf, const MessageTag &tag=no_tag) const
processor_id_type processor_id() const
const DofMap & get_dof_map() const
Definition: system.h:2293

◆ write_serialized_blocked_dof_objects()

template<typename iterator_type >
std::size_t libMesh::System::write_serialized_blocked_dof_objects ( const std::vector< const NumericVector< Number > *> &  vecs,
const dof_id_type  n_objects,
const iterator_type  begin,
const iterator_type  end,
Xdr io,
const unsigned int  var_to_write = libMesh::invalid_uint 
) const
private

Writes an output vector to the stream io for a set of DofObjects.

This method uses blocked output and is safe to call on a distributed memory-mesh.

Returns
The number of values written

Definition at line 1776 of file system_io.C.

References TIMPI::Communicator::broadcast(), libMesh::ParallelObject::comm(), TIMPI::Communicator::get_unique_tag(), libMesh::MeshTools::Generation::Private::idx(), libMesh::invalid_uint, libMesh::libmesh_assert(), libMesh::make_range(), libMesh::ParallelObject::n_processors(), n_vars(), number(), libMesh::ParallelObject::processor_id(), TIMPI::Communicator::receive(), TIMPI::Communicator::send(), and TIMPI::Status::source().

Referenced by write_serialized_vector(), and write_serialized_vectors().

1782 {
1783  parallel_object_only();
1784 
1785  //-------------------------------------------------------
1786  // General order: (IO format 0.7.4 & greater)
1787  //
1788  // for (objects ...)
1789  // for (vecs ....)
1790  // for (vars ....)
1791  // for (comps ...)
1792  //
1793  // where objects are nodes or elements, sorted to be
1794  // partition independent,
1795  // vecs are one or more *identically distributed* solution
1796  // coefficient vectors, vars are one or more variables
1797  // to write, and comps are all the components for said
1798  // vars on the object.
1799 
1800  // We will write all variables unless requested otherwise.
1801  std::vector<unsigned int> vars_to_write(1, var_to_write);
1802 
1803  if (var_to_write == libMesh::invalid_uint)
1804  {
1805  vars_to_write.clear(); vars_to_write.reserve(this->n_vars());
1806  for (auto var : make_range(this->n_vars()))
1807  vars_to_write.push_back(var);
1808  }
1809 
1810  const dof_id_type io_blksize = cast_int<dof_id_type>
1811  (std::min(max_io_blksize, static_cast<std::size_t>(n_objs)));
1812 
1813  const unsigned int
1814  sys_num = this->number(),
1815  num_vecs = cast_int<unsigned int>(vecs.size()),
1816  num_blks = cast_int<unsigned int>(std::ceil(static_cast<double>(n_objs)/
1817  static_cast<double>(io_blksize)));
1818 
1819  // libMesh::out << "io_blksize = " << io_blksize
1820  // << ", num_objects = " << n_objs
1821  // << ", num_blks = " << num_blks
1822  // << std::endl;
1823 
1824  std::size_t written_length=0; // The numer of values written. This will be returned
1825  std::vector<std::vector<dof_id_type>> xfer_ids(num_blks); // The global IDs and # of components for the local objects in all blocks
1826  std::vector<std::vector<Number>> send_vals(num_blks); // The raw values for the local objects in all blocks
1827  std::vector<Parallel::Request>
1828  id_requests(num_blks), val_requests(num_blks); // send request handle for each block
1829  std::vector<Parallel::MessageTag>
1830  id_tags(num_blks), val_tags(num_blks); // tag number for each block
1831 
1832  // ------------------------------------------------------
1833  // First pass - count the number of objects in each block
1834  // traverse all the objects and figure out which block they
1835  // will ultimately live in.
1836  std::vector<unsigned int>
1837  xfer_ids_size (num_blks,0),
1838  send_vals_size (num_blks,0);
1839 
1840  for (iterator_type it=begin; it!=end; ++it)
1841  {
1842  const dof_id_type
1843  id = (*it)->id(),
1844  block = id/io_blksize;
1845 
1846  libmesh_assert_less (block, num_blks);
1847 
1848  xfer_ids_size[block] += 2; // for each object, we store its id, as well as the total number of components for all variables
1849 
1850  unsigned int n_comp_tot=0;
1851 
1852  for (const auto & var : vars_to_write)
1853  n_comp_tot += (*it)->n_comp(sys_num, var); // for each variable, we will store the nonzero components
1854 
1855  send_vals_size[block] += n_comp_tot*num_vecs;
1856  }
1857 
1858  //-----------------------------------------
1859  // Collect the values for all local objects,
1860  // binning them into 'blocks' that will be
1861  // sent to processor 0
1862  for (unsigned int blk=0; blk<num_blks; blk++)
1863  {
1864  // libMesh::out << "Writing object block " << blk << std::endl;
1865 
1866  // Each processor should build up its transfer buffers for its
1867  // local objects in [first_object,last_object).
1868  const dof_id_type
1869  first_object = blk*io_blksize,
1870  last_object = std::min(cast_int<dof_id_type>((blk+1)*io_blksize), n_objs);
1871 
1872  // convenience
1873  std::vector<dof_id_type> & ids (xfer_ids[blk]);
1874  std::vector<Number> & vals (send_vals[blk]);
1875 
1876  // we now know the number of values we will store for each block,
1877  // so we can do efficient preallocation
1878  ids.clear(); ids.reserve (xfer_ids_size[blk]);
1879  vals.clear(); vals.reserve (send_vals_size[blk]);
1880 
1881  if (send_vals_size[blk] != 0) // only send if we have nonzero components to write
1882  for (iterator_type it=begin; it!=end; ++it)
1883  if (((*it)->id() >= first_object) && // object in [first_object,last_object)
1884  ((*it)->id() < last_object))
1885  {
1886  ids.push_back((*it)->id());
1887 
1888  // count the total number of nonzeros transferred for this object
1889  {
1890  unsigned int n_comp_tot=0;
1891 
1892  for (const auto & var : vars_to_write)
1893  n_comp_tot += (*it)->n_comp(sys_num, var);
1894 
1895  ids.push_back (n_comp_tot*num_vecs); // even if 0 - processor 0 has no way of knowing otherwise...
1896  }
1897 
1898  // pack the values to send
1899  for (const auto & vec : vecs)
1900  for (const auto & var : vars_to_write)
1901  {
1902  const unsigned int n_comp = (*it)->n_comp(sys_num, var);
1903 
1904  for (unsigned int comp=0; comp<n_comp; comp++)
1905  {
1906  libmesh_assert_greater_equal ((*it)->dof_number(sys_num, var, comp), vec->first_local_index());
1907  libmesh_assert_less ((*it)->dof_number(sys_num, var, comp), vec->last_local_index());
1908  vals.push_back((*vec)((*it)->dof_number(sys_num, var, comp)));
1909  }
1910  }
1911  }
1912 
1913 #ifdef LIBMESH_HAVE_MPI
1914  id_tags[blk] = this->comm().get_unique_tag(100*num_blks + blk);
1915  val_tags[blk] = this->comm().get_unique_tag(200*num_blks + blk);
1916 
1917  // nonblocking send the data for this block
1918  this->comm().send (0, ids, id_requests[blk], id_tags[blk]);
1919  this->comm().send (0, vals, val_requests[blk], val_tags[blk]);
1920 #endif
1921  }
1922 
1923 
1924  if (this->processor_id() == 0)
1925  {
1926  std::vector<std::vector<dof_id_type>> recv_ids (this->n_processors());
1927  std::vector<std::vector<Number>> recv_vals (this->n_processors());
1928  std::vector<unsigned int> obj_val_offsets; // map to traverse entry-wise rather than processor-wise
1929  std::vector<Number> output_vals; // The output buffer for the current block
1930 
1931  // a ThreadedIO object to perform asynchronous file IO
1932  ThreadedIO<Number> threaded_io(io, output_vals);
1933  std::unique_ptr<Threads::Thread> async_io;
1934 
1935  for (unsigned int blk=0; blk<num_blks; blk++)
1936  {
1937  // Each processor should build up its transfer buffers for its
1938  // local objects in [first_object,last_object).
1939  const dof_id_type
1940  first_object = cast_int<dof_id_type>(blk*io_blksize),
1941  last_object = std::min(cast_int<dof_id_type>((blk+1)*io_blksize), n_objs),
1942  n_objects_blk = last_object - first_object;
1943 
1944  // offset array. this will define where each object's values
1945  // map into the actual output_vals buffer. this must get
1946  // 0-initialized because 0-component objects are not actually sent
1947  obj_val_offsets.resize (n_objects_blk); std::fill (obj_val_offsets.begin(), obj_val_offsets.end(), 0);
1948 
1949  std::size_t n_val_recvd_blk=0;
1950 
1951  // receive this block of data from all processors.
1952  for (processor_id_type comm_step=0, tnp=this->n_processors(); comm_step != tnp; ++comm_step)
1953  {
1954 #ifdef LIBMESH_HAVE_MPI
1955  // blocking receive indices for this block, imposing no particular order on processor
1956  Parallel::Status id_status (this->comm().probe (Parallel::any_source, id_tags[blk]));
1957  std::vector<dof_id_type> & ids (recv_ids[id_status.source()]);
1958  this->comm().receive (id_status.source(), ids, id_tags[blk]);
1959 #else
1960  std::vector<dof_id_type> & ids (recv_ids[0]);
1961  ids = xfer_ids[blk];
1962 #endif
1963 
1964  // note its possible we didn't receive values for objects in
1965  // this block if they have no components allocated.
1966  for (std::size_t idx=0, sz=ids.size(); idx<sz; idx+=2)
1967  {
1968  const dof_id_type
1969  local_idx = ids[idx+0]-first_object,
1970  n_vals_tot_allvecs = ids[idx+1];
1971 
1972  libmesh_assert_less (local_idx, n_objects_blk);
1973  libmesh_assert_less (local_idx, obj_val_offsets.size());
1974 
1975  obj_val_offsets[local_idx] = n_vals_tot_allvecs;
1976  }
1977 
1978 #ifdef LIBMESH_HAVE_MPI
1979  // blocking receive values for this block, imposing no particular order on processor
1980  Parallel::Status val_status (this->comm().probe (Parallel::any_source, val_tags[blk]));
1981  std::vector<Number> & vals (recv_vals[val_status.source()]);
1982  this->comm().receive (val_status.source(), vals, val_tags[blk]);
1983 #else
1984  // straight copy without MPI
1985  std::vector<Number> & vals (recv_vals[0]);
1986  vals = send_vals[blk];
1987 #endif
1988 
1989  n_val_recvd_blk += vals.size();
1990  }
1991 
1992  // We need the offsets into the output_vals vector for each object.
1993  // fortunately, this is simply the partial sum of the total number
1994  // of components for each object
1995  std::partial_sum(obj_val_offsets.begin(), obj_val_offsets.end(),
1996  obj_val_offsets.begin());
1997 
1998  // wait on any previous asynchronous IO - this *must* complete before
1999  // we start messing with the output_vals buffer!
2000  if (async_io.get()) async_io->join();
2001 
2002  // this is the actual output buffer that will be written to disk.
2003  // at ths point we finally know wha size it will be.
2004  output_vals.resize(n_val_recvd_blk);
2005 
2006  // pack data from all processors into output values
2007  for (auto proc : make_range(this->n_processors()))
2008  {
2009  const std::vector<dof_id_type> & ids (recv_ids [proc]);
2010  const std::vector<Number> & vals(recv_vals[proc]);
2011  std::vector<Number>::const_iterator proc_vals(vals.begin());
2012 
2013  for (std::size_t idx=0, sz=ids.size(); idx<sz; idx+=2)
2014  {
2015  const dof_id_type
2016  local_idx = ids[idx+0]-first_object,
2017  n_vals_tot_allvecs = ids[idx+1];
2018 
2019  // put this object's data into the proper location
2020  // in the output buffer
2021  std::vector<Number>::iterator out_vals(output_vals.begin());
2022  if (local_idx != 0)
2023  std::advance (out_vals, obj_val_offsets[local_idx-1]);
2024 
2025  for (unsigned int val=0; val<n_vals_tot_allvecs; val++, ++out_vals, ++proc_vals)
2026  {
2027  libmesh_assert (out_vals != output_vals.end());
2028  libmesh_assert (proc_vals != vals.end());
2029  *out_vals = *proc_vals;
2030  }
2031  }
2032  }
2033 
2034  // output_vals buffer is now filled for this block.
2035  // write it to disk
2036  async_io = std::make_unique<Threads::Thread>(threaded_io);
2037  written_length += output_vals.size();
2038  }
2039 
2040  // wait on any previous asynchronous IO - this *must* complete before
2041  // our stuff goes out of scope
2042  async_io->join();
2043  }
2044 
2045  Parallel::wait(id_requests);
2046  Parallel::wait(val_requests);
2047 
2048  // we need some synchronization here. Because this method
2049  // can be called for a range of nodes, then a range of elements,
2050  // we need some mechanism to prevent processors from racing past
2051  // to the next range and overtaking ongoing communication. one
2052  // approach would be to figure out unique tags for each range,
2053  // but for now we just impose a barrier here. And might as
2054  // well have it do some useful work.
2055  this->comm().broadcast(written_length);
2056 
2057  return written_length;
2058 }
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
Definition: libmesh.h:286
MessageTag get_unique_tag(int tagvalue=MessageTag::invalid_tag) const
const Parallel::Communicator & comm() const
uint8_t processor_id_type
processor_id_type n_processors() const
unsigned int number() const
Definition: system.h:2269
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_tag) const
libmesh_assert(ctx)
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const
void send(const unsigned int dest_processor_id, const T &buf, const MessageTag &tag=no_tag) const
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:134
unsigned int n_vars() const
Definition: system.h:2349
processor_id_type processor_id() const
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)
A useful inline function which replaces the macros used previously.
uint8_t dof_id_type
Definition: id_types.h:67

◆ write_serialized_data()

void libMesh::System::write_serialized_data ( Xdr io,
const bool  write_additional_data = true 
) const

Writes additional data, namely vectors, for this System.

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

This method implements the output of the vectors contained in this System object, embedded in the output of an EquationSystems<T_sys>.

9.) The global solution vector, re-ordered to be node-major (More on this later.)

for each additional vector in the object

10.) The global additional vector, re-ordered to be node-major (More on this later.)

Definition at line 1668 of file system_io.C.

References _vectors, libMesh::Xdr::comment(), name(), libMesh::ParallelObject::processor_id(), solution, and write_serialized_vector().

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

1670 {
1684  parallel_object_only();
1685  std::string comment;
1686 
1687  // PerfLog pl("IO Performance",false);
1688  // pl.push("write_serialized_data");
1689  // std::size_t total_written_size = 0;
1690 
1691  // total_written_size +=
1692  this->write_serialized_vector(io, *this->solution);
1693 
1694  // set up the comment
1695  if (this->processor_id() == 0)
1696  {
1697  comment = "# System \"";
1698  comment += this->name();
1699  comment += "\" Solution Vector";
1700 
1701  io.comment (comment);
1702  }
1703 
1704  // Only write additional vectors if wanted
1705  if (write_additional_data)
1706  {
1707  for (auto & pair : this->_vectors)
1708  {
1709  // total_written_size +=
1710  this->write_serialized_vector(io, *pair.second);
1711 
1712  // set up the comment
1713  if (this->processor_id() == 0)
1714  {
1715  comment = "# System \"";
1716  comment += this->name();
1717  comment += "\" Additional Vector \"";
1718  comment += pair.first;
1719  comment += "\"";
1720  io.comment (comment);
1721  }
1722  }
1723  }
1724 
1725  // const Real
1726  // dt = pl.get_elapsed_time(),
1727  // rate = total_written_size*sizeof(Number)/dt;
1728 
1729  // libMesh::out << "Write " << total_written_size << " \"Number\" values\n"
1730  // << " Elapsed time = " << dt << '\n'
1731  // << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";
1732 
1733  // pl.pop("write_serialized_data");
1734 
1735 
1736 
1737 
1738  // // test the new method
1739  // {
1740  // std::vector<std::string> names;
1741  // std::vector<NumericVector<Number> *> vectors_to_write;
1742 
1743  // names.push_back("Solution Vector");
1744  // vectors_to_write.push_back(this->solution.get());
1745 
1746  // // Only write additional vectors if wanted
1747  // if (write_additional_data)
1748  // {
1749  // std::map<std::string, NumericVector<Number> *>::const_iterator
1750  // pos = _vectors.begin();
1751 
1752  // for (; pos != this->_vectors.end(); ++pos)
1753  // {
1754  // names.push_back("Additional Vector " + pos->first);
1755  // vectors_to_write.push_back(pos->second);
1756  // }
1757  // }
1758 
1759  // total_written_size =
1760  // this->write_serialized_vectors (io, names, vectors_to_write);
1761 
1762  // const Real
1763  // dt2 = pl.get_elapsed_time(),
1764  // rate2 = total_written_size*sizeof(Number)/(dt2-dt);
1765 
1766  // libMesh::out << "Write (new) " << total_written_size << " \"Number\" values\n"
1767  // << " Elapsed time = " << (dt2-dt) << '\n'
1768  // << " Rate = " << rate2/1.e6 << "(MB/sec)\n\n";
1769 
1770  // }
1771 }
std::map< std::string, std::unique_ptr< NumericVector< Number > >, std::less<> > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:2164
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1573
const std::string & name() const
Definition: system.h:2261
processor_id_type processor_id() const
dof_id_type write_serialized_vector(Xdr &io, const NumericVector< Number > &vec) const
Writes a vector for this System.
Definition: system_io.C:2118

◆ write_serialized_vector()

dof_id_type libMesh::System::write_serialized_vector ( Xdr io,
const NumericVector< Number > &  vec 
) const
private

Writes a vector for this System.

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

Returns
The number of values written.

Definition at line 2118 of file system_io.C.

References libMesh::Xdr::data(), libMesh::FEType::family, get_mesh(), libMesh::libmesh_assert(), libMesh::make_range(), libMesh::MeshTools::n_elem(), n_nodes, n_vars(), libMesh::ParallelObject::processor_id(), libMesh::SCALAR, libMesh::NumericVector< T >::size(), libMesh::Variable::type(), variable(), write_SCALAR_dofs(), write_serialized_blocked_dof_objects(), and libMesh::Xdr::writing().

Referenced by write_serialized_data().

2120 {
2121  parallel_object_only();
2122 
2123  libmesh_assert (io.writing());
2124 
2125  dof_id_type vec_length = vec.size();
2126  if (this->processor_id() == 0) io.data (vec_length, "# vector length");
2127 
2128  dof_id_type written_length = 0;
2129 
2130  //---------------------------------
2131  // Collect the values for all nodes
2132  written_length += cast_int<dof_id_type>
2133  (this->write_serialized_blocked_dof_objects (std::vector<const NumericVector<Number> *>(1,&vec),
2134  this->get_mesh().n_nodes(),
2135  this->get_mesh().local_nodes_begin(),
2136  this->get_mesh().local_nodes_end(),
2137  io));
2138 
2139  //------------------------------------
2140  // Collect the values for all elements
2141  written_length += cast_int<dof_id_type>
2142  (this->write_serialized_blocked_dof_objects (std::vector<const NumericVector<Number> *>(1,&vec),
2143  this->get_mesh().n_elem(),
2144  this->get_mesh().local_elements_begin(),
2145  this->get_mesh().local_elements_end(),
2146  io));
2147 
2148  //-------------------------------------------
2149  // Finally loop over all the SCALAR variables
2150  for (auto var : make_range(this->n_vars()))
2151  if (this->variable(var).type().family == SCALAR)
2152  {
2153  written_length +=
2154  this->write_SCALAR_dofs (vec, var, io);
2155  }
2156 
2157  if (this->processor_id() == 0)
2158  libmesh_assert_equal_to (written_length, vec_length);
2159 
2160  return written_length;
2161 }
FEFamily family
The type of finite element.
Definition: fe_type.h:207
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2377
dof_id_type n_elem(const MeshBase::const_element_iterator &begin, const MeshBase::const_element_iterator &end)
Count up the number of elements of a specific type (as defined by an iterator range).
Definition: mesh_tools.C:850
virtual numeric_index_type size() const =0
unsigned int write_SCALAR_dofs(const NumericVector< Number > &vec, const unsigned int var, Xdr &io) const
Writes the SCALAR dofs associated with var to the stream io.
Definition: system_io.C:2062
const MeshBase & get_mesh() const
Definition: system.h:2277
const dof_id_type n_nodes
Definition: tecplot_io.C:67
libmesh_assert(ctx)
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:134
unsigned int n_vars() const
Definition: system.h:2349
processor_id_type processor_id() const
template class LIBMESH_EXPORT NumericVector< Number >
std::size_t write_serialized_blocked_dof_objects(const std::vector< const NumericVector< Number > *> &vecs, const dof_id_type n_objects, const iterator_type begin, const iterator_type end, Xdr &io, const unsigned int var_to_write=libMesh::invalid_uint) const
Writes an output vector to the stream io for a set of DofObjects.
Definition: system_io.C:1776
uint8_t dof_id_type
Definition: id_types.h:67
const FEType & type() const
Definition: variable.h:140

◆ write_serialized_vectors()

std::size_t libMesh::System::write_serialized_vectors ( Xdr io,
const std::vector< const NumericVector< Number > *> &  vectors 
) const

Serialize & write a number of identically distributed vectors.

This method allows for optimization for the multiple vector case by only communicating the metadata once.

Definition at line 2259 of file system_io.C.

References libMesh::Xdr::data(), get_mesh(), libMesh::libmesh_assert(), libMesh::make_range(), libMesh::MeshTools::n_elem(), libMesh::MeshBase::n_elem(), n_nodes, libMesh::MeshBase::n_nodes(), n_vars(), libMesh::ParallelObject::processor_id(), libMesh::SCALAR, variable(), write_SCALAR_dofs(), write_serialized_blocked_dof_objects(), and libMesh::Xdr::writing().

Referenced by libMesh::RBEvaluation::write_out_vectors().

2261 {
2262  parallel_object_only();
2263 
2264  libmesh_assert (io.writing());
2265 
2266  // Cache these - they are not free!
2267  const dof_id_type
2268  n_nodes = this->get_mesh().n_nodes(),
2269  n_elem = this->get_mesh().n_elem();
2270 
2271  std::size_t written_length = 0;
2272 
2273  if (this->processor_id() == 0)
2274  {
2275  unsigned int
2276  n_vec = cast_int<unsigned int>(vectors.size());
2277  dof_id_type
2278  vec_size = vectors.empty() ? 0 : vectors[0]->size();
2279  // Set the number of vectors
2280  io.data(n_vec, "# number of vectors");
2281  // Set the buffer size
2282  io.data(vec_size, "# vector length");
2283  }
2284 
2285  //---------------------------------
2286  // Collect the values for all nodes
2287  written_length +=
2288  this->write_serialized_blocked_dof_objects (vectors,
2289  n_nodes,
2290  this->get_mesh().local_nodes_begin(),
2291  this->get_mesh().local_nodes_end(),
2292  io);
2293 
2294  //------------------------------------
2295  // Collect the values for all elements
2296  written_length +=
2297  this->write_serialized_blocked_dof_objects (vectors,
2298  n_elem,
2299  this->get_mesh().local_elements_begin(),
2300  this->get_mesh().local_elements_end(),
2301  io);
2302 
2303  //-------------------------------------------
2304  // Finally loop over all the SCALAR variables
2305  for (const NumericVector<Number> * vec : vectors)
2306  for (auto var : make_range(this->n_vars()))
2307  if (this->variable(var).type().family == SCALAR)
2308  {
2309  libmesh_assert_not_equal_to (vec, 0);
2310 
2311  written_length +=
2312  this->write_SCALAR_dofs (*vec, var, io);
2313  }
2314 
2315  return written_length;
2316 }
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2377
dof_id_type n_elem(const MeshBase::const_element_iterator &begin, const MeshBase::const_element_iterator &end)
Count up the number of elements of a specific type (as defined by an iterator range).
Definition: mesh_tools.C:850
unsigned int write_SCALAR_dofs(const NumericVector< Number > &vec, const unsigned int var, Xdr &io) const
Writes the SCALAR dofs associated with var to the stream io.
Definition: system_io.C:2062
const MeshBase & get_mesh() const
Definition: system.h:2277
const dof_id_type n_nodes
Definition: tecplot_io.C:67
libmesh_assert(ctx)
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition: int_range.h:134
unsigned int n_vars() const
Definition: system.h:2349
virtual dof_id_type n_elem() const =0
processor_id_type processor_id() const
template class LIBMESH_EXPORT NumericVector< Number >
virtual dof_id_type n_nodes() const =0
std::size_t write_serialized_blocked_dof_objects(const std::vector< const NumericVector< Number > *> &vecs, const dof_id_type n_objects, const iterator_type begin, const iterator_type end, Xdr &io, const unsigned int var_to_write=libMesh::invalid_uint) const
Writes an output vector to the stream io for a set of DofObjects.
Definition: system_io.C:1776
uint8_t dof_id_type
Definition: id_types.h:67

◆ zero_variable()

void libMesh::System::zero_variable ( NumericVector< Number > &  v,
unsigned int  var_num 
) const

Zeroes all dofs in v that correspond to variable number var_num.

Definition at line 1616 of file system.C.

References get_mesh(), mesh, n_vars(), number(), and libMesh::NumericVector< T >::set().

1618 {
1619  /* Make sure the call makes sense. */
1620  libmesh_assert_less (var_num, this->n_vars());
1621 
1622  /* Get a reference to the mesh. */
1623  const MeshBase & mesh = this->get_mesh();
1624 
1625  /* Check which system we are. */
1626  const unsigned int sys_num = this->number();
1627 
1628  // Loop over nodes.
1629  for (const auto & node : mesh.local_node_ptr_range())
1630  {
1631  unsigned int n_comp = node->n_comp(sys_num,var_num);
1632  for (unsigned int i=0; i<n_comp; i++)
1633  {
1634  const dof_id_type index = node->dof_number(sys_num,var_num,i);
1635  v.set(index,0.0);
1636  }
1637  }
1638 
1639  // Loop over elements.
1640  for (const auto & elem : mesh.active_local_element_ptr_range())
1641  {
1642  unsigned int n_comp = elem->n_comp(sys_num,var_num);
1643  for (unsigned int i=0; i<n_comp; i++)
1644  {
1645  const dof_id_type index = elem->dof_number(sys_num,var_num,i);
1646  v.set(index,0.0);
1647  }
1648  }
1649 }
MeshBase & mesh
const MeshBase & get_mesh() const
Definition: system.h:2277
unsigned int number() const
Definition: system.h:2269
virtual void set(const numeric_index_type i, const T value)=0
Sets v(i) = value.
unsigned int n_vars() const
Definition: system.h:2349
uint8_t dof_id_type
Definition: id_types.h:67

Member Data Documentation

◆ _active

bool libMesh::System::_active
private

Flag stating if the system is active or not.

Definition at line 2156 of file system.h.

Referenced by activate(), active(), and deactivate().

◆ _additional_data_written

unsigned int libMesh::System::_additional_data_written
private

This flag is used only when reading in a system from file.

Based on the system header, it keeps track of how many additional vectors were actually written for this file.

Definition at line 2223 of file system.h.

Referenced by read_header(), read_legacy_data(), read_parallel_data(), and read_serialized_data().

◆ _assemble_system_function

void(* libMesh::System::_assemble_system_function) (EquationSystems &es, const std::string &name)
private

Function that assembles the system.

Definition at line 2064 of file system.h.

Referenced by attach_assemble_function(), attach_assemble_object(), and user_assembly().

◆ _assemble_system_object

Assembly* libMesh::System::_assemble_system_object
private

Object that assembles the system.

Definition at line 2070 of file system.h.

Referenced by attach_assemble_function(), attach_assemble_object(), and user_assembly().

◆ _basic_system_only

bool libMesh::System::_basic_system_only
private

Holds true if the components of more advanced system types (e.g.

system matrices) should not be initialized.

Definition at line 2204 of file system.h.

Referenced by init(), init_data(), reinit(), reinit_mesh(), and set_basic_system_only().

◆ _communicator

const Parallel::Communicator& libMesh::ParallelObject::_communicator
protectedinherited

◆ _constrain_system_function

void(* libMesh::System::_constrain_system_function) (EquationSystems &es, const std::string &name)
private

Function to impose constraints.

Definition at line 2075 of file system.h.

Referenced by attach_constraint_function(), attach_constraint_object(), and user_constrain().

◆ _constrain_system_object

Constraint* libMesh::System::_constrain_system_object
private

Object that constrains the system.

Definition at line 2081 of file system.h.

Referenced by attach_constraint_function(), attach_constraint_object(), get_constraint_object(), has_constraint_object(), and user_constrain().

◆ _counts

ReferenceCounter::Counts libMesh::ReferenceCounter::_counts
staticprotectedinherited

Actually holds the data.

Definition at line 124 of file reference_counter.h.

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

◆ _dof_map

std::unique_ptr<DofMap> libMesh::System::_dof_map
private

Data structure describing the relationship between nodes, variables, etc...

and degrees of freedom.

Definition at line 2113 of file system.h.

Referenced by add_vector(), calculate_norm(), clear(), current_solution(), get_dof_map(), init_data(), n_constrained_dofs(), n_dofs(), n_local_constrained_dofs(), n_local_dofs(), restrict_vectors(), and update().

◆ _enable_print_counter

bool libMesh::ReferenceCounter::_enable_print_counter = true
staticprotectedinherited

Flag to control whether reference count information is printed when print_info is called.

Definition at line 143 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::disable_print_counter_info(), libMesh::ReferenceCounter::enable_print_counter_info(), and libMesh::ReferenceCounter::print_info().

◆ _equation_systems

EquationSystems& libMesh::System::_equation_systems
private

Constant reference to the EquationSystems object used for the simulation.

Definition at line 2119 of file system.h.

Referenced by get_equation_systems(), user_assembly(), user_constrain(), user_initialization(), user_QOI(), and user_QOI_derivative().

◆ _hide_output

bool libMesh::System::_hide_output
private

Are we allowed to write this system to file? If _hide_output is true, then EquationSystems::write will ignore this system.

Definition at line 2248 of file system.h.

Referenced by hide_output().

◆ _identify_variable_groups

bool libMesh::System::_identify_variable_groups
private

true when VariableGroup structures should be automatically identified, false otherwise.

Defaults to true.

Definition at line 2216 of file system.h.

Referenced by identify_variable_groups().

◆ _init_system_function

void(* libMesh::System::_init_system_function) (EquationSystems &es, const std::string &name)
private

Function that initializes the system.

Definition at line 2053 of file system.h.

Referenced by attach_init_function(), attach_init_object(), and user_initialization().

◆ _init_system_object

Initialization* libMesh::System::_init_system_object
private

Object that initializes the system.

Definition at line 2059 of file system.h.

Referenced by attach_init_function(), attach_init_object(), and user_initialization().

◆ _is_initialized

bool libMesh::System::_is_initialized
private

true when additional vectors and variables do not require immediate initialization, false otherwise.

Definition at line 2210 of file system.h.

Referenced by add_vector(), clear(), compare(), init_data(), and is_initialized().

◆ _matrices

std::map<std::string, std::unique_ptr<SparseMatrix<Number> >, std::less<> > libMesh::System::_matrices
private

Some systems need an arbitrary number of matrices.

Definition at line 2181 of file system.h.

Referenced by add_matrix(), clear(), get_matrix(), have_matrix(), init_data(), init_matrices(), n_matrices(), reinit(), remove_matrix(), and request_matrix().

◆ _matrices_initialized

bool libMesh::System::_matrices_initialized
private

false when additional matrices being added require initialization, true otherwise.

Definition at line 2191 of file system.h.

Referenced by can_add_matrices(), clear(), init_matrices(), and late_matrix_init().

◆ _matrix_types

std::map<std::string, ParallelType, std::less<> > libMesh::System::_matrix_types
private

Holds the types of the matrices.

Definition at line 2186 of file system.h.

Referenced by add_matrix(), and init_matrices().

◆ _mesh

MeshBase& libMesh::System::_mesh
private

Constant reference to the mesh data structure used for the simulation.

Definition at line 2125 of file system.h.

Referenced by calculate_norm(), get_mesh(), and reinit_constraints().

◆ _mutex

Threads::spin_mutex libMesh::ReferenceCounter::_mutex
staticprotectedinherited

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 137 of file reference_counter.h.

◆ _n_objects

Threads::atomic< unsigned int > libMesh::ReferenceCounter::_n_objects
staticprotectedinherited

The number of objects.

Print the reference count information when the number returns to 0.

Definition at line 132 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::n_objects(), libMesh::ReferenceCounter::ReferenceCounter(), and libMesh::ReferenceCounter::~ReferenceCounter().

◆ _qoi_evaluate_derivative_function

void(* libMesh::System::_qoi_evaluate_derivative_function) (EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
private

Function to evaluate quantity of interest derivative.

Definition at line 2098 of file system.h.

Referenced by attach_QOI_derivative(), attach_QOI_derivative_object(), and user_QOI_derivative().

◆ _qoi_evaluate_derivative_object

QOIDerivative* libMesh::System::_qoi_evaluate_derivative_object
private

Object to compute derivatives of quantities of interest.

Definition at line 2107 of file system.h.

Referenced by attach_QOI_derivative(), attach_QOI_derivative_object(), and user_QOI_derivative().

◆ _qoi_evaluate_function

void(* libMesh::System::_qoi_evaluate_function) (EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
private

Function to evaluate quantity of interest.

Definition at line 2086 of file system.h.

Referenced by attach_QOI_function(), attach_QOI_object(), and user_QOI().

◆ _qoi_evaluate_object

QOI* libMesh::System::_qoi_evaluate_object
private

Object to compute quantities of interest.

Definition at line 2093 of file system.h.

Referenced by attach_QOI_function(), attach_QOI_object(), and user_QOI().

◆ _solution_projection

bool libMesh::System::_solution_projection
private

Holds true if the solution vector should be projected onto a changed grid, false if it should be zeroed.

This is true by default.

Definition at line 2198 of file system.h.

Referenced by project_solution_on_reinit(), and restrict_vectors().

◆ _sys_name

const std::string libMesh::System::_sys_name
private

A name associated with this system.

Definition at line 2130 of file system.h.

Referenced by compare(), and name().

◆ _sys_number

const unsigned int libMesh::System::_sys_number
private

The number associated with this system.

Definition at line 2135 of file system.h.

Referenced by number().

◆ _variable_groups

std::vector<VariableGroup> libMesh::System::_variable_groups
private

The VariableGroup in this System.

Definition at line 2145 of file system.h.

Referenced by add_variable(), add_variables(), n_variable_groups(), and variable_group().

◆ _variable_numbers

std::map<std::string, unsigned int, std::less<> > libMesh::System::_variable_numbers
private

The variable numbers corresponding to user-specified names, useful for name-based lookups.

Definition at line 2151 of file system.h.

Referenced by add_variable(), add_variables(), clear(), get_all_variable_numbers(), has_variable(), and variable_number().

◆ _variables

std::vector<Variable> libMesh::System::_variables
private

◆ _vector_is_adjoint

std::map<std::string, int, std::less<> > libMesh::System::_vector_is_adjoint
private

Holds non-negative if a vector by that name should be projected using adjoint constraints/BCs, -1 if primal.

Definition at line 2176 of file system.h.

Referenced by add_vector(), clear(), remove_vector(), set_vector_as_adjoint(), and vector_is_adjoint().

◆ _vector_projections

std::map<std::string, bool, std::less<> > libMesh::System::_vector_projections
private

Holds true if a vector by that name should be projected onto a changed grid, false if it should be zeroed.

Definition at line 2170 of file system.h.

Referenced by add_vector(), clear(), remove_vector(), restrict_vectors(), set_vector_preservation(), vector_preservation(), and write_header().

◆ _vectors

std::map<std::string, std::unique_ptr<NumericVector<Number> >, std::less<> > libMesh::System::_vectors
private

Some systems need an arbitrary number of vectors.

This map allows names to be associated with arbitrary vectors. All the vectors in this map will be distributed in the same way as the solution vector.

Definition at line 2164 of file system.h.

Referenced by add_vector(), clear(), compare(), get_vector(), have_vector(), init_data(), n_vectors(), read_legacy_data(), read_parallel_data(), read_serialized_data(), remove_vector(), request_vector(), restrict_vectors(), vector_name(), vectors_begin(), vectors_end(), write_header(), write_parallel_data(), and write_serialized_data().

◆ _written_var_indices

std::vector<unsigned int> libMesh::System::_written_var_indices
private

This vector is used only when reading in a system from file.

Based on the system header, it keeps track of any index remapping between variable names in the data file and variable names in the already-constructed system. I.e. if we have a system with variables "A1", "A2", "B1", and "B2", but we read in a data file with only "A1" and "B1" defined, then we don't want to try and read in A2 or B2, and we don't want to assign A1 and B1 values to different dof indices.

Definition at line 2235 of file system.h.

Referenced by read_header(), read_legacy_data(), read_parallel_data(), read_serialized_blocked_dof_objects(), and read_serialized_vector().

◆ adjoint_already_solved

bool libMesh::System::adjoint_already_solved
private

Has the adjoint problem already been solved? If the user sets adjoint_already_solved to true, we won't waste time solving it again.

Definition at line 2242 of file system.h.

Referenced by is_adjoint_already_solved(), and set_adjoint_already_solved().

◆ assemble_before_solve

bool libMesh::System::assemble_before_solve

Flag which tells the system to whether or not to call the user assembly function during each call to solve().

By default, every call to solve() begins with a call to the user assemble, so this flag is true. (For explicit systems, "solving" the system occurs during the assembly step, so this flag is always true for explicit systems.)

You will only want to set this to false if you need direct control over when the system is assembled, and are willing to track the state of its assembly yourself. An example of such a case is an implicit system with multiple right hand sides. In this instance, a single assembly would likely be followed with multiple calls to solve.

The frequency system and Newmark system have their own versions of this flag, called _finished_assemble, which might be able to be replaced with this more general concept.

Definition at line 1527 of file system.h.

Referenced by libMesh::ImplicitSystem::adjoint_solve(), libMesh::ImplicitSystem::disable_cache(), disable_cache(), main(), libMesh::RBConstruction::RBConstruction(), libMesh::RBSCMConstruction::RBSCMConstruction(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::EigenSystem::solve(), libMesh::CondensedEigenSystem::solve(), and libMesh::LinearImplicitSystem::solve().

◆ current_local_solution

std::unique_ptr<NumericVector<Number> > libMesh::System::current_local_solution

All the values I need to compute my contribution to the simulation at hand.

Think of this as the current solution with any ghost values needed from other processors. This vector is necessarily larger than the solution vector in the case of a parallel simulation. The update() member is used to synchronize the contents of the solution and current_local_solution vectors.

Definition at line 1585 of file system.h.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::UniformRefinementEstimator::_estimate_error(), alternative_fe_assembly(), HDGProblem::assemble(), libMesh::NonlinearImplicitSystem::assembly(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), clear(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), current_solution(), DMlibMeshFunction(), DMlibMeshJacobian(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), fe_assembly(), init_data(), libMesh::libmesh_petsc_snes_fd_residual(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_mffd_residual(), libMesh::libmesh_petsc_snes_residual(), libMesh::libmesh_petsc_snes_residual_helper(), point_gradient(), point_hessian(), point_value(), libMesh::FEMContext::pre_fe_reinit(), libMesh::RBEIMEvaluation::project_qp_data_map_onto_system(), re_update(), reinit(), restrict_vectors(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), SolidSystem::save_initial_mesh(), libMesh::RBConstruction::set_context_solution_vec(), setup(), MeshFunctionTest::test_subdomain_id_sets(), MeshInputTest::testCopyElementVectorImpl(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::TransientRBConstruction::truth_solve(), update(), libMesh::Nemesis_IO_Helper::write_element_values(), and libMesh::Nemesis_IO_Helper::write_nodal_solution().

◆ extra_quadrature_order

int libMesh::System::extra_quadrature_order

A member int that can be employed to indicate increased or reduced quadrature order.

Note
For FEMSystem users, by default, when calling the user-defined residual functions, the FEMSystem will first set up an appropriate FEType::default_quadrature_rule() object for performing the integration. This rule will integrate elements of order up to 2*p+1 exactly (where p is the sum of the base FEType and local p refinement levels), but if additional (or reduced) quadrature accuracy is desired then this extra_quadrature_order (default 0) will be added.

Definition at line 1558 of file system.h.

Referenced by CurlCurlSystem::init_data(), and set_system_parameters().

◆ project_with_constraints

bool libMesh::System::project_with_constraints
private

Do we want to apply constraints while projecting vectors ?

Definition at line 2253 of file system.h.

Referenced by get_project_with_constraints(), and set_project_with_constraints().

◆ qoi

std::vector<Number> libMesh::System::qoi
private

Values of the quantities of interest.

This vector needs to be both resized and filled by the user before any quantity of interest assembly is done and before any sensitivities are calculated.

Definition at line 1611 of file system.h.

Referenced by libMesh::DifferentiableSystem::attach_qoi(), get_qoi_value(), get_qoi_values(), init_qois(), n_qois(), and set_qoi().

◆ qoi_error_estimates

std::vector<Number> libMesh::System::qoi_error_estimates
private

Vector to hold error estimates for qois, either from a steady state calculation, or from a single unsteady solver timestep.

Used by the library after resizing to match the size of the qoi vector. User code can use this for accumulating error estimates for example.

Definition at line 1619 of file system.h.

Referenced by get_qoi_error_estimate_value(), init_qois(), n_qois(), and set_qoi_error_estimate().

◆ solution

std::unique_ptr<NumericVector<Number> > libMesh::System::solution

Data structure to hold solution values.

Definition at line 1573 of file system.h.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::TransientRBConstruction::add_IC_to_RB_space(), libMesh::NewmarkSolver::advance_timestep(), libMesh::AdaptiveTimeSolver::advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), libMesh::ContinuationSystem::apply_predictor(), HDGProblem::assemble(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::FEMSystem::assembly(), libMesh::LinearImplicitSystem::assembly(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::RBConstruction::check_if_zero_truth_solve(), clear(), compare(), compute_enriched_soln(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::NewmarkSolver::compute_initial_accel(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), compute_stresses(), LinearElasticityWithContact::compute_stresses(), LinearElasticity::compute_stresses(), LargeDeformationElasticity::compute_stresses(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ContinuationSystem::continuation_solve(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::Nemesis_IO::copy_elemental_solution(), libMesh::GMVIO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::Nemesis_IO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), DMCreateGlobalVector_libMesh(), DMlibMeshFunction(), DMlibMeshJacobian(), libMesh::UnsteadySolver::du(), libMesh::RBConstruction::enrich_RB_space(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::RBSCMConstruction::evaluate_stability_constant(), libMesh::EigenSystem::get_eigenpair(), libMesh::CondensedEigenSystem::get_eigenpair(), LinearElasticityWithContact::get_least_and_max_gap_function(), init_data(), libMesh::ContinuationSystem::initialize_tangent(), libMesh::TransientRBConstruction::initialize_truth(), libMesh::libmesh_petsc_snes_fd_residual(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_mffd_residual(), libMesh::libmesh_petsc_snes_residual(), libMesh::libmesh_petsc_snes_residual_helper(), libMesh::RBConstruction::load_basis_function(), libMesh::TransientRBConstruction::load_rb_solution(), libMesh::RBConstruction::load_rb_solution(), main(), libMesh::DofMap::max_constraint_error(), libMesh::FEMSystem::mesh_position_get(), libMesh::ErrorVector::plot_error(), libMesh::RBConstruction::print_basis_function_orthogonality(), libMesh::RBEIMEvaluation::project_qp_data_map_onto_system(), libMesh::InterMeshProjection::project_system_vectors(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), re_update(), read_legacy_data(), read_parallel_data(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), read_serialized_data(), reinit(), restrict_vectors(), libMesh::MemoryHistoryData::retrieve_vectors(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), libMesh::ContinuationSystem::save_current_solution(), libMesh::TransientRBConstruction::set_error_temporal_data(), setup(), WriteVecAndScalar::setupTests(), libMesh::TwostepTimeSolver::solve(), libMesh::NewtonSolver::solve(), libMesh::PetscDiffSolver::solve(), libMesh::FrequencySystem::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::NonlinearImplicitSystem::solve(), libMesh::RBConstruction::solve_for_matrix_and_rhs(), libMesh::ContinuationSystem::solve_tangent(), libMesh::MemoryHistoryData::store_vectors(), ConstraintOperatorTest::test1DCoarseningOperator(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), SystemsTest::testBoundaryProjectCube(), SystemsTest::testDofCouplingWithVarGroups(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), SystemsTest::testPostInitAddVector(), SystemsTest::testProjectCubeWithMeshFunction(), MeshInputTest::testProjectionRegression(), WriteVecAndScalar::testSolution(), libMesh::RBConstruction::train_reduced_basis_with_POD(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::DirectSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), libMesh::BoundaryVolumeSolutionTransfer::transfer_volume_boundary(), libMesh::TransientRBConstruction::truth_solve(), libMesh::RBConstruction::truth_solve(), update(), update_global_solution(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::TransientRBConstruction::update_residual_terms(), libMesh::RBConstruction::update_residual_terms(), libMesh::ContinuationSystem::update_solution(), libMesh::NewmarkSystem::update_u_v_a(), libMesh::DTKAdapter::update_variable_values(), libMesh::RBEIMEvaluation::write_out_projected_basis_functions(), write_parallel_data(), libMesh::TransientRBConstruction::write_riesz_representors_to_files(), libMesh::RBConstruction::write_riesz_representors_to_files(), and write_serialized_data().

◆ time

Real libMesh::System::time

For time-dependent problems, this is the time t at the beginning of the current timestep.

Note
For DifferentiableSystem users: do not access this time during an assembly! Use the DiffContext::time value instead to get correct results.

Definition at line 1595 of file system.h.

Referenced by libMesh::AdaptiveTimeSolver::adjoint_advance_timestep(), libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::TwostepTimeSolver::adjoint_solve(), libMesh::AdaptiveTimeSolver::advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubProjector::construct_projection(), HeatSystem::element_qoi(), fill_dirichlet_bc(), libMesh::ExactErrorEstimator::find_squared_element_error(), initialize(), libMesh::Euler2Solver::integrate_adjoint_refinement_error_estimate(), libMesh::EulerSolver::integrate_adjoint_refinement_error_estimate(), libMesh::UnsteadySolver::integrate_adjoint_sensitivity(), libMesh::Euler2Solver::integrate_qoi_timestep(), libMesh::EulerSolver::integrate_qoi_timestep(), main(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectVertices::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectEdges::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectSides::operator()(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::ProjectInteriors::operator()(), reinit_constraints(), libMesh::UnsteadySolver::retrieve_timestep(), and libMesh::TwostepTimeSolver::solve().

◆ use_fixed_solution

bool libMesh::System::use_fixed_solution

A boolean to be set to true by systems using elem_fixed_solution, for optional use by e.g.

stabilized methods. False by default.

Note
For FEMSystem users, if this variable is set to true, it must be before init_data() is called.

Definition at line 1543 of file system.h.

Referenced by libMesh::EulerSolver::_general_residual(), libMesh::Euler2Solver::_general_residual(), libMesh::SteadySolver::_general_residual(), libMesh::NewmarkSolver::_general_residual(), libMesh::DifferentiableSystem::clear(), libMesh::DiffContext::DiffContext(), and libMesh::FEMContext::pre_fe_reinit().


The documentation for this class was generated from the following files: