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, NumericVector< Number > * >::iterator vectors_iterator
 Vector iterator typedefs. More...
 
typedef std::map< std::string, NumericVector< Number > * >::const_iterator const_vectors_iterator
 

Public Member Functions

 System (EquationSystems &es, const std::string &name, const unsigned int number)
 Constructor. More...
 
virtual ~System ()
 Destructor. More...
 
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...
 
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 (const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
 Adds the additional vector vec_name to this system. More...
 
void remove_vector (const std::string &vec_name)
 Removes the additional vector vec_name from this system. More...
 
bool & project_solution_on_reinit (void)
 Tells the System whether or not to project the solution vector onto new grids when the system is reinitialized. More...
 
bool have_vector (const std::string &vec_name) const
 
const NumericVector< Number > * request_vector (const std::string &vec_name) const
 
NumericVector< Number > * request_vector (const std::string &vec_name)
 
const NumericVector< Number > * request_vector (const unsigned int vec_num) const
 
NumericVector< Number > * request_vector (const unsigned int vec_num)
 
const NumericVector< Number > & get_vector (const std::string &vec_name) const
 
NumericVector< Number > & get_vector (const std::string &vec_name)
 
const NumericVector< Number > & get_vector (const unsigned int vec_num) const
 
NumericVector< Number > & get_vector (const unsigned int vec_num)
 
const std::string & vector_name (const unsigned int vec_num) const
 
const std::string & vector_name (const NumericVector< Number > &vec_reference) const
 
void set_vector_as_adjoint (const std::string &vec_name, int qoi_num)
 Allows one to set the QoI index controlling whether the vector identified by vec_name represents a solution from the adjoint (qoi_num >= 0) or primal (qoi_num == -1) space. More...
 
int vector_is_adjoint (const std::string &vec_name) const
 
void set_vector_preservation (const std::string &vec_name, bool preserve)
 Allows one to set the boolean controlling whether the vector identified by vec_name should be "preserved": projected to new meshes, saved, etc. More...
 
bool vector_preservation (const std::string &vec_name) const
 
NumericVector< Number > & add_adjoint_solution (unsigned int i=0)
 
NumericVector< Number > & get_adjoint_solution (unsigned int i=0)
 
const NumericVector< Number > & get_adjoint_solution (unsigned int i=0) const
 
NumericVector< Number > & add_sensitivity_solution (unsigned int i=0)
 
NumericVector< Number > & get_sensitivity_solution (unsigned int i=0)
 
const NumericVector< Number > & get_sensitivity_solution (unsigned int i=0) const
 
NumericVector< Number > & add_weighted_sensitivity_adjoint_solution (unsigned int i=0)
 
NumericVector< Number > & get_weighted_sensitivity_adjoint_solution (unsigned int i=0)
 
const NumericVector< Number > & get_weighted_sensitivity_adjoint_solution (unsigned int i=0) const
 
NumericVector< Number > & add_weighted_sensitivity_solution ()
 
NumericVector< Number > & get_weighted_sensitivity_solution ()
 
const NumericVector< Number > & get_weighted_sensitivity_solution () const
 
NumericVector< Number > & add_adjoint_rhs (unsigned int i=0)
 
NumericVector< Number > & get_adjoint_rhs (unsigned int i=0)
 
const NumericVector< Number > & get_adjoint_rhs (unsigned int i=0) const
 
NumericVector< Number > & add_sensitivity_rhs (unsigned int i=0)
 
NumericVector< Number > & get_sensitivity_rhs (unsigned int i=0)
 
const NumericVector< Number > & get_sensitivity_rhs (unsigned int i=0) const
 
unsigned int n_vectors () const
 
virtual 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 (const std::string &var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
 Adds the variable var to the list of variables for this system. More...
 
unsigned int add_variable (const std::string &var, const Order order=FIRST, const FEFamily=LAGRANGE, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
 Adds the variable var to the list of variables for this system. More...
 
unsigned int add_variables (const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
 Adds the variable var to the list of variables for this system. More...
 
unsigned int add_variables (const std::vector< std::string > &vars, const Order order=FIRST, const FEFamily=LAGRANGE, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
 Adds the variable var to the list of variables for this system. More...
 
const 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 (const std::string &var) const
 
const std::string & variable_name (const unsigned int i) const
 
unsigned short int variable_number (const std::string &var) const
 
void get_all_variable_numbers (std::vector< unsigned int > &all_variable_numbers) const
 Fills all_variable_numbers with all the variable numbers for the variables that have been added to this system. More...
 
unsigned int variable_scalar_number (const std::string &var, unsigned int component) const
 
unsigned int variable_scalar_number (unsigned int var_num, unsigned int component) const
 
const FETypevariable_type (const unsigned int i) const
 
const FETypevariable_type (const std::string &var) const
 
bool identify_variable_groups () const
 
void identify_variable_groups (const bool)
 Toggle automatic VariableGroup identification. More...
 
Real calculate_norm (const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=nullptr) const
 
Real calculate_norm (const NumericVector< Number > &v, const SystemNorm &norm, std::set< unsigned int > *skip_dimensions=nullptr) const
 
void read_header (Xdr &io, const std::string &version, const bool read_header=true, const bool read_additional_data=true, const bool read_legacy_format=false)
 Reads the basic data header for this System. More...
 
void read_legacy_data (Xdr &io, const bool read_additional_data=true)
 Reads additional data, namely vectors, for this System. More...
 
template<typename ValType >
void read_serialized_data (Xdr &io, const bool read_additional_data=true)
 Reads additional data, namely vectors, for this System. More...
 
void read_serialized_data (Xdr &io, const bool read_additional_data=true)
 Non-templated version for backward compatibility. More...
 
template<typename InValType >
std::size_t read_serialized_vectors (Xdr &io, const std::vector< NumericVector< Number > * > &vectors) const
 Read a number of identically distributed vectors. More...
 
std::size_t read_serialized_vectors (Xdr &io, const std::vector< NumericVector< Number > * > &vectors) const
 Non-templated version for backward compatibility. More...
 
template<typename InValType >
void read_parallel_data (Xdr &io, const bool read_additional_data)
 Reads additional data, namely vectors, for this System. More...
 
void read_parallel_data (Xdr &io, const bool read_additional_data)
 Non-templated version for backward compatibility. More...
 
void write_header (Xdr &io, const std::string &version, const bool write_additional_data) const
 Writes the basic data header for this System. More...
 
void write_serialized_data (Xdr &io, const bool write_additional_data=true) const
 Writes additional data, namely vectors, for this System. More...
 
std::size_t write_serialized_vectors (Xdr &io, const std::vector< const NumericVector< Number > * > &vectors) const
 Serialize & write a number of identically distributed vectors. More...
 
void write_parallel_data (Xdr &io, const bool write_additional_data) const
 Writes additional data, namely vectors, for this System. More...
 
std::string get_info () const
 
void attach_init_function (void fptr(EquationSystems &es, const std::string &name))
 Register a user function to use in initializing the system. More...
 
void attach_init_object (Initialization &init)
 Register a user class to use to initialize the system. More...
 
void attach_assemble_function (void fptr(EquationSystems &es, const std::string &name))
 Register a user function to use in assembling the system matrix and RHS. More...
 
void attach_assemble_object (Assembly &assemble)
 Register a user object to use in assembling the system matrix and RHS. More...
 
void attach_constraint_function (void fptr(EquationSystems &es, const std::string &name))
 Register a user function for imposing constraints. More...
 
void attach_constraint_object (Constraint &constrain)
 Register a user object for imposing constraints. More...
 
void attach_QOI_function (void fptr(EquationSystems &es, const std::string &name, const QoISet &qoi_indices))
 Register a user function for evaluating the quantities of interest, whose values should be placed in System::qoi. More...
 
void attach_QOI_object (QOI &qoi)
 Register a user object for evaluating the quantities of interest, whose values should be placed in System::qoi. More...
 
void attach_QOI_derivative (void fptr(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints))
 Register a user function for evaluating derivatives of a quantity of interest with respect to test functions, whose values should be placed in System::rhs. More...
 
void attach_QOI_derivative_object (QOIDerivative &qoi_derivative)
 Register a user object for evaluating derivatives of a quantity of interest with respect to test functions, whose values should be placed in System::rhs. More...
 
virtual void user_initialization ()
 Calls user's attached initialization function, or is overridden by the user in derived classes. More...
 
virtual void user_assembly ()
 Calls user's attached assembly function, or is overridden by the user in derived classes. More...
 
virtual void user_constrain ()
 Calls user's attached constraint function, or is overridden by the user in derived classes. More...
 
virtual void user_QOI (const QoISet &qoi_indices)
 Calls user's attached quantity of interest function, or is overridden by the user in derived classes. More...
 
virtual void user_QOI_derivative (const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true)
 Calls user's attached quantity of interest derivative function, or is overridden by the user in derived classes. More...
 
virtual void re_update ()
 Re-update the local values when the mesh has changed. More...
 
virtual void restrict_vectors ()
 Restrict vectors after the mesh has coarsened. More...
 
virtual void prolong_vectors ()
 Prolong vectors after the mesh has refined. More...
 
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...
 
Number point_value (unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
 
Number point_value (unsigned int var, const Point &p, const Elem &e, const NumericVector< Number > *sol=nullptr) const
 
Number point_value (unsigned int var, const Point &p, const Elem *e) const
 Calls the version of point_value() which takes a reference. More...
 
Number point_value (unsigned int var, const Point &p, const NumericVector< Number > *sol) const
 Calls the parallel version of point_value(). More...
 
Gradient point_gradient (unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
 
Gradient point_gradient (unsigned int var, const Point &p, const Elem &e, const NumericVector< Number > *sol=nullptr) const
 
Gradient point_gradient (unsigned int var, const Point &p, const Elem *e) const
 Calls the version of point_gradient() which takes a reference. More...
 
Gradient point_gradient (unsigned int var, const Point &p, const NumericVector< Number > *sol) const
 Calls the parallel version of point_gradient(). More...
 
Tensor point_hessian (unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
 
Tensor point_hessian (unsigned int var, const Point &p, const Elem &e, const NumericVector< Number > *sol=nullptr) const
 
Tensor point_hessian (unsigned int var, const Point &p, const Elem *e) const
 Calls the version of point_hessian() which takes a reference. More...
 
Tensor point_hessian (unsigned int var, const Point &p, const NumericVector< Number > *sol) const
 Calls the parallel version of point_hessian(). More...
 
void local_dof_indices (const unsigned int var, std::set< dof_id_type > &var_indices) const
 Fills the std::set with the degrees of freedom on the local processor corresponding the the variable number passed in. More...
 
void zero_variable (NumericVector< Number > &v, unsigned int var_num) const
 Zeroes all dofs in v that correspond to variable number var_num. More...
 
bool & hide_output ()
 
void projection_matrix (SparseMatrix< Number > &proj_mat) const
 This method creates a projection matrix which corresponds to the operation of project_vector between old and new solution spaces. More...
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static std::string get_info ()
 Gets a string containing the reference information. More...
 
static void print_info (std::ostream &out=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...
 
std::vector< Numberqoi
 Values of the quantities of interest. 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...
 
void project_vector (NumericVector< Number > &, int is_adjoint=-1) const
 Projects the vector defined on the old mesh onto the new mesh. More...
 
void project_vector (const NumericVector< Number > &, NumericVector< Number > &, int is_adjoint=-1) const
 Projects the vector defined on the old mesh onto the new mesh. More...
 
void increment_constructor_count (const std::string &name)
 Increments the construction counter. More...
 
void increment_destructor_count (const std::string &name)
 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

 System (const System &)
 This isn't a copyable object, so let's make sure nobody tries. More...
 
Systemoperator= (const System &)
 This isn't a copyable object, so let's make sure nobody tries. 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

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

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

Member Typedef Documentation

◆ const_vectors_iterator

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

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

◆ GradientFunctionPointer

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

Definition at line 532 of file system.h.

◆ sys_type

The type of system.

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

◆ vectors_iterator

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

Vector iterator typedefs.

Definition at line 756 of file system.h.

Constructor & Destructor Documentation

◆ System() [1/2]

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

Constructor.

Optionally initializes required data structures.

Definition at line 61 of file system.C.

63  :
64 
65  ParallelObject (es),
66  assemble_before_solve (true),
67  use_fixed_solution (false),
71  time (0.),
72  qoi (0),
73  _init_system_function (nullptr),
74  _init_system_object (nullptr),
75  _assemble_system_function (nullptr),
76  _assemble_system_object (nullptr),
78  _constrain_system_object (nullptr),
79  _qoi_evaluate_function (nullptr),
80  _qoi_evaluate_object (nullptr),
83  _dof_map (libmesh_make_unique<DofMap>(number_in, es.get_mesh())),
84  _equation_systems (es),
85  _mesh (es.get_mesh()),
86  _sys_name (name_in),
87  _sys_number (number_in),
88  _active (true),
89  _solution_projection (true),
90  _basic_system_only (false),
91  _is_initialized (false),
94  adjoint_already_solved (false),
95  _hide_output (false)
96 {
97 }

Referenced by HeatSystem::init_context().

◆ ~System()

libMesh::System::~System ( )
virtual

Destructor.

Definition at line 120 of file system.C.

121 {
122  // Null-out the function pointers. Since this
123  // class is getting destructed it is pointless,
124  // but a good habit.
127  _constrain_system_function = nullptr;
128 
129  _qoi_evaluate_function = nullptr;
131 
132  // nullptr-out user-provided objects.
133  _init_system_object = nullptr;
134  _assemble_system_object = nullptr;
135  _constrain_system_object = nullptr;
136  _qoi_evaluate_object = nullptr;
138 
139  // Clear data
140  // Note: although clear() is virtual, C++ only calls
141  // the clear() of the base class in the destructor.
142  // Thus we add System namespace to make it clear.
143  System::clear ();
144 
145  libmesh_exceptionless_assert (!libMesh::closed());
146 }

References _assemble_system_function, _assemble_system_object, _constrain_system_function, _constrain_system_object, _init_system_function, _init_system_object, _qoi_evaluate_derivative_function, _qoi_evaluate_derivative_object, _qoi_evaluate_function, _qoi_evaluate_object, clear(), and libMesh::closed().

◆ System() [2/2]

libMesh::System::System ( const System other)
private

This isn't a copyable object, so let's make sure nobody tries.

We won't even bother implementing this; we'll just make sure that the compiler doesn't implement a default.

Definition at line 102 of file system.C.

102  :
103  ReferenceCountedObject<System>(),
104  ParallelObject(other),
105  _equation_systems(other._equation_systems),
106  _mesh(other._mesh),
107  _sys_number(other._sys_number)
108 {
109  libmesh_not_implemented();
110 }

Member Function Documentation

◆ activate()

void libMesh::System::activate ( )
inline

Activates the system.

Only active systems are solved.

Definition at line 2123 of file system.h.

2124 {
2125  _active = true;
2126 }

References _active.

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

2116 {
2117  return _active;
2118 }

References _active.

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

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

References add_vector().

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

◆ add_adjoint_solution()

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

Definition at line 945 of file system.C.

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

References add_vector(), and set_vector_as_adjoint().

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

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

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

References add_vector().

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

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

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

References add_vector().

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

◆ add_variable() [1/2]

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

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

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

Returns
The index number for the new variable.

Definition at line 1069 of file system.C.

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

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

◆ add_variable() [2/2]

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

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

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

Definition at line 1148 of file system.C.

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

References add_variable().

◆ add_variables() [1/2]

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

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

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

Returns
The index number for the new variable.

Definition at line 1160 of file system.C.

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

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

Referenced by add_variable(), and add_variables().

◆ add_variables() [2/2]

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

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

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

Definition at line 1213 of file system.C.

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

References add_variables().

◆ add_vector()

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

Definition at line 661 of file system.C.

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

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

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(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::SecondOrderUnsteadySolver::init(), libMesh::UnsteadySolver::init(), libMesh::OptimizationSystem::init_data(), libMesh::ContinuationSystem::init_data(), main(), libMesh::NewmarkSystem::NewmarkSystem(), read_header(), libMesh::FrequencySystem::set_frequencies(), libMesh::FrequencySystem::set_frequencies_by_range(), and libMesh::FrequencySystem::set_frequencies_by_steps().

◆ add_weighted_sensitivity_adjoint_solution()

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

Definition at line 977 of file system.C.

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

References add_vector(), and set_vector_as_adjoint().

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

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

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

References add_vector().

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

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

2369 {
2370  libmesh_not_implemented();
2371 }

Referenced by qoi_parameter_sensitivity().

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

2351 {
2352  libmesh_not_implemented();
2353 }

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

◆ 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::EigenSystem, libMesh::ImplicitSystem, libMesh::DifferentiableSystem, libMesh::FrequencySystem, and libMesh::NewmarkSystem.

Definition at line 462 of file system.C.

463 {
464  // Log how long the user's assembly code takes
465  LOG_SCOPE("assemble()", "System");
466 
467  // Call the user-specified assembly function
468  this->user_assembly();
469 }

References user_assembly().

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

◆ 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::ExplicitSystem, and libMesh::FEMSystem.

Definition at line 473 of file system.C.

474 {
475  // Log how long the user's assembly code takes
476  LOG_SCOPE("assemble_qoi()", "System");
477 
478  // Call the user-specified quantity of interest function
479  this->user_QOI(qoi_indices);
480 }

References user_QOI().

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

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

487 {
488  // Log how long the user's assembly code takes
489  LOG_SCOPE("assemble_qoi_derivative()", "System");
490 
491  // Call the user-specified quantity of interest function
492  this->user_QOI_derivative(qoi_indices, include_liftfunc,
493  apply_constraints);
494 }

References user_QOI_derivative().

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

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

2320 {
2321  libmesh_not_implemented();
2322 }

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

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

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

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

◆ attach_assemble_object()

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

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

Definition at line 1774 of file system.C.

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

References _assemble_system_function, _assemble_system_object, and libMesh::out.

Referenced by main().

◆ attach_constraint_function()

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

Register a user function for imposing constraints.

Definition at line 1790 of file system.C.

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

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

◆ attach_constraint_object()

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

Register a user object for imposing constraints.

Definition at line 1809 of file system.C.

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

References _constrain_system_function, _constrain_system_object, and libMesh::out.

Referenced by DofMapTest::testConstraintLoopDetection().

◆ attach_init_function()

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

Register a user function to use in initializing the system.

Definition at line 1720 of file system.C.

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

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

Referenced by main().

◆ attach_init_object()

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

Register a user class to use to initialize the system.

Note
This is exclusive with the attach_init_function.

Definition at line 1739 of file system.C.

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

References _init_system_function, _init_system_object, and libMesh::out.

◆ attach_QOI_derivative()

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

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

Definition at line 1861 of file system.C.

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

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

◆ attach_QOI_derivative_object()

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

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

Definition at line 1880 of file system.C.

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

References _qoi_evaluate_derivative_function, _qoi_evaluate_derivative_object, and libMesh::out.

◆ attach_QOI_function()

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

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

Definition at line 1825 of file system.C.

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

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

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

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

References _qoi_evaluate_function, _qoi_evaluate_object, and libMesh::out.

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

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

Referenced by SystemsTest::testBoundaryProjectCube().

◆ boundary_project_solution() [2/2]

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

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

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

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

Definition at line 1109 of file system_projection.C.

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

References fptr(), and gptr().

◆ boundary_project_vector() [1/2]

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

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

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

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

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

Definition at line 1162 of file system_projection.C.

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

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

◆ boundary_project_vector() [2/2]

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

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

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

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

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

Definition at line 1144 of file system_projection.C.

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

References fptr(), and gptr().

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

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

References _dof_map, _mesh, std::abs(), libMesh::TypeVector< T >::add_scaled(), libMesh::TypeTensor< T >::add_scaled(), libMesh::FEGenericBase< OutputType >::build(), libMesh::NumericVector< T >::build(), libMesh::ParallelObject::comm(), libMesh::FEType::default_quadrature_rule(), dim, libMesh::DISCRETE_L1, libMesh::DISCRETE_L2, libMesh::DISCRETE_L_INF, discrete_var_norm(), libMesh::DofMap::dof_indices(), libMesh::MeshBase::elem_dimensions(), libMesh::ReferenceElem::get(), libMesh::FEGenericBase< OutputType >::get_d2phi(), get_dof_map(), libMesh::FEGenericBase< OutputType >::get_dphi(), libMesh::FEAbstract::get_JxW(), get_mesh(), libMesh::FEGenericBase< OutputType >::get_phi(), libMesh::H1, libMesh::H1_SEMINORM, libMesh::H2, libMesh::H2_SEMINORM, libMesh::L1, libMesh::NumericVector< T >::l1_norm(), libMesh::L2, libMesh::NumericVector< T >::l2_norm(), libMesh::L_INF, libMesh::libmesh_assert(), libMesh::NumericVector< T >::linfty_norm(), libMesh::NumericVector< T >::localize(), libMesh::QBase::n_points(), n_vars(), std::norm(), libMesh::TypeVector< T >::norm(), libMesh::TypeTensor< T >::norm(), libMesh::TensorTools::norm_sq(), libMesh::TypeVector< T >::norm_sq(), libMesh::TypeTensor< T >::norm_sq(), libMesh::Real, libMesh::FEAbstract::reinit(), libMesh::SERIAL, libMesh::NumericVector< T >::size(), std::sqrt(), libMesh::DofMap::variable_type(), libMesh::W1_INF_SEMINORM, libMesh::W2_INF_SEMINORM, and libMesh::SystemNorm::weight().

◆ calculate_norm() [2/2]

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

Definition at line 1356 of file system.C.

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

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

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

◆ clear()

void libMesh::System::clear ( )
virtual

Clear all the data structures associated with the system.

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

Definition at line 205 of file system.C.

206 {
207  _variables.clear();
208 
209  _variable_numbers.clear();
210 
211  _dof_map->clear ();
212 
213  solution->clear ();
214 
215  current_local_solution->clear ();
216 
217  // clear any user-added vectors
218  {
219  for (auto & pr : _vectors)
220  {
221  pr.second->clear ();
222  delete pr.second;
223  pr.second = nullptr;
224  }
225 
226  _vectors.clear();
227  _vector_projections.clear();
228  _vector_is_adjoint.clear();
229  _vector_types.clear();
230  _is_initialized = false;
231  }
232 
233 }

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

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

◆ comm()

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

Definition at line 94 of file parallel_object.h.

95  { return _communicator; }

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_tao_equality_constraints(), libMesh::__libmesh_tao_equality_constraints_jacobian(), libMesh::__libmesh_tao_gradient(), libMesh::__libmesh_tao_hessian(), libMesh::__libmesh_tao_inequality_constraints(), libMesh::__libmesh_tao_inequality_constraints_jacobian(), libMesh::__libmesh_tao_objective(), libMesh::MeshRefinement::_coarsen_elements(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< libMesh::Number >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_mult(), libMesh::SlepcEigenSolver< libMesh::Number >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_mult_add(), libMesh::EquationSystems::_read_impl(), libMesh::MeshRefinement::_refine_elements(), libMesh::MeshRefinement::_smooth_flags(), libMesh::DofMap::add_constraints_to_send_list(), add_cube_convex_hull_to_mesh(), libMesh::PetscDMWrapper::add_dofs_helper(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::TransientRBConstruction::add_IC_to_RB_space(), libMesh::ImplicitSystem::add_matrix(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::DynaIO::add_spline_constraints(), add_vector(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::TransientRBConstruction::allocate_data_structures(), libMesh::RBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::FEMSystem::assemble_qoi(), libMesh::MeshCommunication::assign_global_indices(), libMesh::DofMap::attach_matrix(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::PetscDMWrapper::build_section(), libMesh::PetscDMWrapper::build_sf(), calculate_norm(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_max_error_bound(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), libMesh::RBSCMConstruction::compute_SCM_bounds_on_training_set(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::MeshTools::create_bounding_box(), libMesh::DofMap::create_dof_constraints(), libMesh::MeshTools::create_nodal_bounding_box(), libMesh::MeshRefinement::create_parent_error_vector(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::MeshTools::create_subdomain_bounding_box(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), DMlibMeshFunction(), DMlibMeshJacobian(), DMlibMeshSetSystem_libMesh(), DMVariableBounds_libMesh(), libMesh::DTKSolutionTransfer::DTKSolutionTransfer(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::TransientRBConstruction::enrich_RB_space(), libMesh::RBConstruction::enrich_RB_space(), libMesh::EpetraVector< T >::EpetraVector(), AssembleOptimization::equality_constraints(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::RBEIMConstruction::evaluate_mesh_function(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_error_tolerance(), libMesh::MeshRefinement::flag_elements_by_mean_stddev(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::DofMap::gather_constraints(), libMesh::MeshfreeInterpolation::gather_remote_data(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::DofMap::get_info(), libMesh::ImplicitSystem::get_linear_solver(), AssembleOptimization::inequality_constraints(), AssembleOptimization::inequality_constraints_jacobian(), libMesh::LocationMap< T >::init(), libMesh::TimeSolver::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::EigenSystem::init_matrices(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::RBEIMConstruction::initialize_rb_construction(), integrate_function(), libMesh::MeshTools::libmesh_assert_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_flags(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_p_levels(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshTools::libmesh_assert_valid_unique_ids(), libMesh::libmesh_petsc_preconditioner_apply(), libMesh::libmesh_petsc_snes_fd_residual(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_mffd_residual(), libMesh::libmesh_petsc_snes_postcheck(), libMesh::libmesh_petsc_snes_residual(), libMesh::libmesh_petsc_snes_residual_helper(), libMesh::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::limit_overrefined_boundary(), libMesh::MeshRefinement::limit_underrefined_boundary(), main(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshCommunication::make_elems_parallel_consistent(), libMesh::MeshRefinement::make_flags_parallel_consistent(), libMesh::MeshCommunication::make_new_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_new_nodes_parallel_consistent(), libMesh::MeshCommunication::make_node_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_unique_ids_parallel_consistent(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::MeshCommunication::make_p_levels_parallel_consistent(), libMesh::MeshRefinement::make_refinement_compatible(), libMesh::TransientRBConstruction::mass_matrix_scaled_matvec(), libMesh::FEMSystem::mesh_position_set(), LinearElasticityWithContact::move_mesh(), libMesh::DistributedMesh::n_active_elem(), libMesh::MeshTools::n_active_levels(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::DofMap::n_constrained_dofs(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::CondensedEigenSystem::n_global_non_condensed_dofs(), libMesh::MeshTools::n_levels(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::MeshTools::n_p_levels(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::DistributedMesh::parallel_max_elem_id(), libMesh::DistributedMesh::parallel_max_node_id(), libMesh::ReplicatedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_n_elem(), libMesh::DistributedMesh::parallel_n_nodes(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::MeshTools::paranoid_n_levels(), libMesh::petsc_auto_fieldsplit(), point_gradient(), point_hessian(), point_value(), libMesh::DofMap::print_dof_constraints(), FEMParameters::read(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), read_header(), 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::MeshRefinement::refine_and_coarsen_elements(), libMesh::DistributedMesh::renumber_dof_objects(), LinearElasticityWithContact::residual_and_jacobian(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), libMesh::DofMap::scatter_constraints(), libMesh::CheckpointIO::select_split_config(), libMesh::TransientRBConstruction::set_error_temporal_data(), libMesh::RBEIMConstruction::set_explicit_sys_subvector(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::PetscDiffSolver::setup_petsc_data(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::split_mesh(), libMesh::BoundaryInfo::sync(), libMesh::MeshRefinement::test_level_one(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), libMesh::MeshRefinement::test_unflagged(), SystemsTest::testBlockRestrictedVarNDofs(), PointLocatorTest::testLocator(), BoundaryInfoTest::testMesh(), SystemsTest::testProjectCubeWithMeshFunction(), CheckpointIOTest::testSplitter(), libMesh::MeshTools::total_weight(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::RBEIMConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_RB_system_matrices(), libMesh::RBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_residual_terms(), libMesh::RBConstruction::update_residual_terms(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::VTKIO::write_nodal_data(), libMesh::RBEvaluation::write_out_vectors(), libMesh::TransientRBConstruction::write_riesz_representors_to_files(), libMesh::RBConstruction::write_riesz_representors_to_files(), 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().

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

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

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

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

◆ current_solution()

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

◆ deactivate()

void libMesh::System::deactivate ( )
inline

Deactivates the system.

Only active systems are solved.

Definition at line 2131 of file system.h.

2132 {
2133  _active = false;
2134 }

References _active.

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

2325 { assemble_before_solve = true; }

References assemble_before_solve.

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

◆ disable_print_counter_info()

void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

Definition at line 106 of file reference_counter.C.

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

References libMesh::ReferenceCounter::_enable_print_counter.

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

◆ discrete_var_norm()

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

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

Definition at line 1337 of file system.C.

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

References libMesh::DISCRETE_L1, libMesh::DISCRETE_L2, libMesh::DISCRETE_L_INF, 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().

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

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

References libMesh::ReferenceCounter::_enable_print_counter.

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

2378 {
2379  libmesh_not_implemented();
2380 }

Referenced by qoi_parameter_sensitivity().

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

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

References get_vector().

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

◆ get_adjoint_rhs() [2/2]

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

Definition at line 1029 of file system.C.

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

References get_vector().

◆ get_adjoint_solution() [1/2]

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

Definition at line 957 of file system.C.

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

References get_vector().

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

◆ get_adjoint_solution() [2/2]

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

Definition at line 967 of file system.C.

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

References get_vector().

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

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

References _variable_numbers, and n_vars().

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

◆ get_dof_map() [1/2]

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

Definition at line 2107 of file system.h.

2108 {
2109  return *_dof_map;
2110 }

References _dof_map.

◆ get_dof_map() [2/2]

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

Definition at line 2099 of file system.h.

2100 {
2101  return *_dof_map;
2102 }

References _dof_map.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::DifferentiableSystem::add_dot_var_dirichlet_bcs(), libMesh::HPCoarsenTest::add_projection(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::ImplicitSystem::adjoint_solve(), libMesh::NewmarkSolver::advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), libMesh::EquationSystems::allgather(), libMesh::TransientRBConstruction::allocate_data_structures(), libMesh::RBConstruction::allocate_data_structures(), assemble(), LinearElasticity::assemble(), assemble_1D(), AssembleOptimization::assemble_A_and_F(), assemble_and_solve(), assemble_biharmonic(), assemble_elasticity(), assemble_ellipticdg(), assemble_helmholtz(), assemble_laplace(), assemble_mass(), assemble_matrices(), assemble_matrix_and_rhs(), assemble_poisson(), assemble_SchroedingerEquation(), assemble_shell(), assemble_stokes(), assemble_wave(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::PetscDMWrapper::build_sf(), calculate_norm(), compute_jacobian(), compute_residual(), LinearElasticityWithContact::compute_stresses(), LinearElasticity::compute_stresses(), compute_stresses(), LargeDeformationElasticity::compute_stresses(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), MyConstraint::constrain(), libMesh::ExodusII_IO::copy_scalar_solution(), DMCreateDomainDecomposition_libMesh(), DMCreateFieldDecomposition_libMesh(), DMlibMeshFunction(), DMlibMeshJacobian(), DMlibMeshSetSystem_libMesh(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::RBEIMAssembly::evaluate_basis_function(), get_info(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::SecondOrderUnsteadySolver::init_data(), libMesh::UnsteadySolver::init_data(), HeatSystem::init_data(), SimpleRBConstruction::init_data(), LaplaceSystem::init_dirichlet_bcs(), libMesh::RBEIMConstruction::init_dof_map_between_systems(), libMesh::EigenSystem::init_matrices(), libMesh::ImplicitSystem::init_matrices(), libMesh::CondensedEigenSystem::initialize_condensed_dofs(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::RBEIMAssembly::initialize_fe(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::RBEIMConstruction::initialize_rb_construction(), LaplaceYoung::jacobian(), LargeDeformationElasticity::jacobian(), libMesh::libmesh_petsc_snes_fd_residual(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_mffd_residual(), libMesh::libmesh_petsc_snes_residual(), libMesh::libmesh_petsc_snes_residual_helper(), local_dof_indices(), AssembleOptimization::lower_and_upper_bounds(), main(), libMesh::DofMap::max_constraint_error(), LinearElasticityWithContact::move_mesh(), libMesh::DGFEMContext::neighbor_side_fe_reinit(), libMesh::UnsteadySolver::old_nonlinear_solution(), libMesh::SecondOrderUnsteadySolver::old_solution_accel(), libMesh::SecondOrderUnsteadySolver::old_solution_rate(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::RBSCMConstruction::perform_SCM_greedy(), libMesh::petsc_auto_fieldsplit(), libMesh::ErrorVector::plot_error(), point_gradient(), point_hessian(), point_value(), libMesh::FEMContext::pre_fe_reinit(), libMesh::RBEIMAssembly::RBEIMAssembly(), libMesh::RBEIMConstruction::RBEIMConstruction(), re_update(), read_parallel_data(), read_SCALAR_dofs(), libMesh::SecondOrderUnsteadySolver::reinit(), libMesh::UnsteadySolver::reinit(), libMesh::EigenSystem::reinit(), libMesh::ImplicitSystem::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(), FETest< order, family, elem_type >::setUp(), SolidSystem::side_time_derivative(), libMesh::NewtonSolver::solve(), libMesh::PetscDiffSolver::solve(), libMesh::RBConstruction::solve_for_matrix_and_rhs(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), SystemsTest::testBlockRestrictedVarNDofs(), DofMapTest::testConstraintLoopDetection(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), EquationSystemsTest::testDisableDefaultGhosting(), SystemsTest::testDofCouplingWithVarGroups(), DofMapTest::testDofOwner(), MeshInputTest::testDynaReadPatch(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), SystemsTest::testProjectCubeWithMeshFunction(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), BoundaryInfoTest::testShellFaceConstraints(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), libMesh::RBEIMConstruction::truth_solve(), libMesh::RBEIMConstruction::update_RB_system_matrices(), libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve(), libMesh::ImplicitSystem::weighted_sensitivity_solve(), libMesh::Nemesis_IO_Helper::write_nodal_solution(), write_parallel_data(), libMesh::EnsightIO::write_scalar_ascii(), write_SCALAR_dofs(), libMesh::EnsightIO::write_vector_ascii(), and libMesh::RBConstruction::zero_constrained_dofs_on_vector().

◆ get_equation_systems() [1/2]

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

Definition at line 725 of file system.h.

725 { return _equation_systems; }

References _equation_systems.

◆ get_equation_systems() [2/2]

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

Definition at line 720 of file system.h.

720 { return _equation_systems; }

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

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

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

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

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

◆ get_info() [2/2]

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

Definition at line 1636 of file system.C.

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

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

◆ get_mesh() [1/2]

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

Definition at line 2091 of file system.h.

2092 {
2093  return _mesh;
2094 }

References _mesh.

◆ get_mesh() [2/2]

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

Definition at line 2083 of file system.h.

2084 {
2085  return _mesh;
2086 }

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(), AssemblyF0::boundary_assembly(), AssemblyA1::boundary_assembly(), AssemblyF1::boundary_assembly(), AssemblyF2::boundary_assembly(), AssemblyA2::boundary_assembly(), calculate_norm(), compute_jacobian(), compute_residual(), LinearElasticityWithContact::compute_stresses(), DMCreateDomainDecomposition_libMesh(), DMCreateFieldDecomposition_libMesh(), DMlibMeshSetSystem_libMesh(), SolidSystem::element_time_derivative(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::GenericProjector(), LinearElasticityWithContact::get_least_and_max_gap_function(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), SolidSystem::init_data(), init_data(), libMesh::RBEIMConstruction::init_dof_map_between_systems(), libMesh::EigenSystem::init_matrices(), libMesh::ImplicitSystem::init_matrices(), LinearElasticityWithContact::initialize_contact_load_paths(), libMesh::RBEIMAssembly::initialize_fe(), local_dof_indices(), libMesh::DofMap::max_constraint_error(), libMesh::FEMSystem::mesh_position_get(), libMesh::FEMSystem::mesh_position_set(), LinearElasticityWithContact::move_mesh(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::petsc_auto_fieldsplit(), libMesh::RBEIMConstruction::plot_parametrized_functions_in_training_set(), point_gradient(), point_hessian(), point_value(), libMesh::FEMSystem::postprocess(), read_header(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), read_legacy_data(), read_parallel_data(), read_serialized_vector(), read_serialized_vectors(), libMesh::EigenSystem::reinit(), libMesh::ImplicitSystem::reinit(), LinearElasticityWithContact::residual_and_jacobian(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), SolidSystem::save_initial_mesh(), libMesh::HPSingularity::select_refinement(), libMesh::HPCoarsenTest::select_refinement(), libMesh::PetscDMWrapper::set_point_range_in_section(), SolidSystem::side_time_derivative(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::BoundaryVolumeSolutionTransfer::transfer(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), libMesh::BoundaryVolumeSolutionTransfer::transfer_volume_boundary(), libMesh::TransientRBConstruction::truth_solve(), libMesh::RBEIMConstruction::truth_solve(), libMesh::RBConstruction::truth_solve(), write_header(), libMesh::RBEvaluation::write_out_vectors(), write_parallel_data(), write_serialized_vector(), write_serialized_vectors(), and zero_variable().

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

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

References get_vector().

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

◆ get_sensitivity_rhs() [2/2]

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

Definition at line 1059 of file system.C.

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

References get_vector().

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

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

References get_vector().

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

◆ get_sensitivity_solution() [2/2]

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

Definition at line 914 of file system.C.

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

References get_vector().

◆ get_vector() [1/4]

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

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

References _vectors.

◆ get_vector() [2/4]

const NumericVector< Number > & libMesh::System::get_vector ( const std::string &  vec_name) const

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

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

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

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

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

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

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

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

References get_vector().

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

◆ get_weighted_sensitivity_adjoint_solution() [2/2]

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

Definition at line 999 of file system.C.

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

References get_vector().

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

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

References get_vector().

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

◆ get_weighted_sensitivity_solution() [2/2]

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

Definition at line 938 of file system.C.

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

References get_vector().

◆ has_variable()

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

Definition at line 1225 of file system.C.

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

References _variable_numbers.

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

◆ have_vector()

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

Definition at line 2275 of file system.h.

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

References _vectors.

Referenced by add_vector().

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

1712 { return _hide_output; }

References _hide_output.

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

2252 {
2254 }

References _identify_variable_groups.

Referenced by add_variable().

◆ identify_variable_groups() [2/2]

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

Toggle automatic VariableGroup identification.

Definition at line 2259 of file system.h.

2260 {
2262 }

References _identify_variable_groups.

◆ increment_constructor_count()

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

Increments the construction counter.

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

Definition at line 181 of file reference_counter.h.

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

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

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

◆ increment_destructor_count()

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

Increments the destruction counter.

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

Definition at line 194 of file reference_counter.h.

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

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

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

◆ init()

void libMesh::System::init ( )

Initializes degrees of freedom on the current mesh.

Sets the

Definition at line 237 of file system.C.

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

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

◆ 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::ImplicitSystem, libMesh::DifferentiableSystem, libMesh::ContinuationSystem, libMesh::RBEIMConstruction, libMesh::FEMSystem, libMesh::OptimizationSystem, libMesh::FrequencySystem, libMesh::EigenSystem, SecondOrderScalarSystemSecondOrderTimeSolverBase, FirstOrderScalarSystemBase, libMesh::LinearImplicitSystem, libMesh::RBConstructionBase< LinearImplicitSystem >, libMesh::RBConstructionBase< CondensedEigenSystem >, SimpleRBConstruction, SimpleRBConstruction, SimpleRBConstruction, SimpleRBConstruction, SimpleRBConstruction, HeatSystem, SimpleRBConstruction, ElasticityRBConstruction, CoupledSystem, L2System, ElasticitySystem, LaplaceSystem, CurlCurlSystem, LaplaceSystem, PoissonSystem, LaplaceSystem, LaplaceSystem, CurlCurlSystem, SolidSystem, NavierSystem, and HeatSystem.

Definition at line 262 of file system.C.

263 {
264  MeshBase & mesh = this->get_mesh();
265 
266  // Add all variable groups to our underlying DofMap
267  for (auto vg : IntRange<unsigned int>(0, this->n_variable_groups()))
268  _dof_map->add_variable_group(this->variable_group(vg));
269 
270  // Distribute the degrees of freedom on the mesh
271  _dof_map->distribute_dofs (mesh);
272 
273  // Recreate any user or internal constraints
274  this->reinit_constraints();
275 
276  // And clean up the send_list before we first use it
277  _dof_map->prepare_send_list();
278 
279  // Resize the solution conformal to the current mesh
280  solution->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
281 
282  // Resize the current_local_solution for the current mesh
283 #ifdef LIBMESH_ENABLE_GHOSTED
284  current_local_solution->init (this->n_dofs(), this->n_local_dofs(),
285  _dof_map->get_send_list(), false,
286  GHOSTED);
287 #else
288  current_local_solution->init (this->n_dofs(), false, SERIAL);
289 #endif
290 
291  // from now on, adding additional vectors or variables can't be done
292  // without immediately initializing them
293  _is_initialized = true;
294 
295  // initialize & zero other vectors, if necessary
296  for (auto & pr : _vectors)
297  {
298  ParallelType type = _vector_types[pr.first];
299 
300  if (type == GHOSTED)
301  {
302 #ifdef LIBMESH_ENABLE_GHOSTED
303  pr.second->init (this->n_dofs(), this->n_local_dofs(),
304  _dof_map->get_send_list(), false,
305  GHOSTED);
306 #else
307  libmesh_error_msg("Cannot initialize ghosted vectors when they are not enabled.");
308 #endif
309  }
310  else if (type == SERIAL)
311  {
312  pr.second->init (this->n_dofs(), false, type);
313  }
314  else
315  {
316  libmesh_assert_equal_to(type, PARALLEL);
317  pr.second->init (this->n_dofs(), this->n_local_dofs(), false, type);
318  }
319  }
320 }

References _dof_map, _is_initialized, _vector_types, _vectors, current_local_solution, get_mesh(), libMesh::GHOSTED, mesh, n_dofs(), n_local_dofs(), n_variable_groups(), libMesh::PARALLEL, reinit_constraints(), libMesh::SERIAL, solution, and variable_group().

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

◆ is_adjoint_already_solved()

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

◆ is_initialized()

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

Definition at line 2139 of file system.h.

2140 {
2141  return _is_initialized;
2142 }

References _is_initialized.

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

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

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

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

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

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

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

References n_constrained_dofs(), and n_dofs().

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

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

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

Referenced by add_variables().

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

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

References _dof_map.

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

◆ n_dofs()

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

Definition at line 150 of file system.C.

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

References _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::RBEIMConstruction::enrich_RB_space(), libMesh::TransientRBConstruction::enrich_RB_space(), libMesh::RBConstruction::enrich_RB_space(), libMesh::AdjointRefinementEstimator::estimate_error(), get_info(), libMesh::SecondOrderUnsteadySolver::init_data(), libMesh::UnsteadySolver::init_data(), init_data(), libMesh::RBEIMConstruction::init_dof_map_between_systems(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::RBEIMConstruction::initialize_rb_construction(), main(), libMesh::TransientRBConstruction::mass_matrix_scaled_matvec(), n_active_dofs(), libMesh::CondensedEigenSystem::n_global_non_condensed_dofs(), libMesh::FEMSystem::numerical_jacobian(), libMesh::RBSCMConstruction::perform_SCM_greedy(), libMesh::RBEIMAssembly::RBEIMAssembly(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), 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(), libMesh::RBEIMConstruction::set_explicit_sys_subvector(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), SystemsTest::testProjectCubeWithMeshFunction(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::RBEIMConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_RB_system_matrices(), libMesh::RBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_residual_terms(), and libMesh::RBConstruction::update_residual_terms().

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

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

References _dof_map.

Referenced by get_info().

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

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

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::RBEIMConstruction::enrich_RB_space(), libMesh::TransientRBConstruction::enrich_RB_space(), libMesh::RBConstruction::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(), libMesh::RBEIMConstruction::initialize_rb_construction(), main(), libMesh::TransientRBConstruction::mass_matrix_scaled_matvec(), libMesh::RBEIMAssembly::RBEIMAssembly(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::SecondOrderUnsteadySolver::reinit(), libMesh::UnsteadySolver::reinit(), restrict_vectors(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), libMesh::TransientRBConstruction::set_error_temporal_data(), MeshFunctionTest::test_p_level(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::TransientRBConstruction::update_RB_system_matrices(), libMesh::RBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_residual_terms(), and libMesh::RBConstruction::update_residual_terms().

◆ n_matrices()

unsigned int libMesh::System::n_matrices ( ) const
inlinevirtual
Returns
The number of matrices handled by this system.

This will return 0 by default but can be overridden.

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

Definition at line 2289 of file system.h.

2290 {
2291  return 0;
2292 }

Referenced by get_info().

◆ n_objects()

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

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

Definition at line 83 of file reference_counter.h.

84  { return _n_objects; }

References libMesh::ReferenceCounter::_n_objects.

◆ n_processors()

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

Definition at line 100 of file parallel_object.h.

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

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::DofMap::add_constraints_to_send_list(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::FEMSystem::assembly(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::DistributedMesh::clear(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::EnsightIO::EnsightIO(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::DistributedMesh::insert_elem(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::DofMap::local_variable_indices(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::partition(), 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(), OverlappingFunctorTest::run_partitioner_test(), libMesh::DofMap::scatter_constraints(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), CheckpointIOTest::testSplitter(), WriteVecAndScalar::testWrite(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::VTKIO::write_nodal_data(), 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().

◆ n_qois()

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

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

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

References _variable_groups.

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

◆ n_vars()

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

Definition at line 2155 of file system.h.

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

References _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::FEMContext::attach_quadrature_rules(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::PetscDMWrapper::build_section(), calculate_norm(), LinearElasticityWithContact::compute_stresses(), LinearElasticity::compute_stresses(), compute_stresses(), LargeDeformationElasticity::compute_stresses(), libMesh::DGFEMContext::DGFEMContext(), libMesh::DiffContext::DiffContext(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::ErrorEstimator::estimate_errors(), libMesh::ExactSolution::ExactSolution(), libMesh::FEMContext::find_hardest_fe_type(), libMesh::EquationSystems::find_variable_numbers(), get_all_variable_numbers(), init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::FEMSystem::init_context(), libMesh::RBEIMConstruction::init_context_with_sys(), libMesh::RBEIMConstruction::init_dof_map_between_systems(), libMesh::FEMContext::init_internal_data(), libMesh::DifferentiablePhysics::init_physics(), AssemblyA0::interior_assembly(), AssemblyA1::interior_assembly(), AssemblyA2::interior_assembly(), main(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), output_norms(), libMesh::petsc_auto_fieldsplit(), libMesh::FEMContext::pre_fe_reinit(), re_update(), read_legacy_data(), read_parallel_data(), read_serialized_blocked_dof_objects(), read_serialized_vector(), read_serialized_vectors(), libMesh::HPCoarsenTest::select_refinement(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::SystemSubsetBySubdomain::set_var_nums(), OverlappingTestBase::setup_coupling_matrix(), SystemsTest::testDofCouplingWithVarGroups(), SlitMeshRefinedSystemTest::testRestart(), SlitMeshRefinedSystemTest::testSystem(), libMesh::RBEIMConstruction::truth_solve(), libMesh::RBEIMConstruction::update_RB_system_matrices(), write_header(), write_parallel_data(), write_serialized_blocked_dof_objects(), write_serialized_vector(), write_serialized_vectors(), and zero_variable().

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

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

References _vectors.

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

◆ name()

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

◆ number()

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

◆ operator=()

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

This isn't a copyable object, so let's make sure nobody tries.

We won't even bother implementing this; we'll just make sure that the compiler doesn't implement a default.

Definition at line 114 of file system.C.

115 {
116  libmesh_not_implemented();
117 }

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

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

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

Referenced by line_print(), and point_gradient().

◆ point_gradient() [2/4]

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

Definition at line 2162 of file system.C.

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

References libMesh::FEInterface::compute_data(), libMesh::Elem::contains_point(), 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().

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

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

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

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

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

References point_gradient().

◆ point_hessian() [1/4]

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

Definition at line 2244 of file system.C.

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

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

Referenced by point_hessian().

◆ point_hessian() [2/4]

Tensor libMesh::System::point_hessian ( unsigned int  var,
const Point p,
const Elem e,
const NumericVector< Number > *  sol = nullptr 
) const
Returns
The second derivative tensor of the solution variable var at the physical point p in local Elem e in the mesh, similarly to point_value.

Definition at line 2305 of file system.C.

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

References libMesh::TypeTensor< T >::add_scaled(), libMesh::FEGenericBase< OutputType >::build(), libMesh::Elem::contains_point(), 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().

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

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

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

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

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

References point_hessian().

◆ point_value() [1/4]

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

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

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

Definition at line 1971 of file system.C.

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

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

Referenced by line_print(), main(), point_value(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), MeshInputTest::testExodusCopyElementSolution(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), SystemsTest::testProjectCubeWithMeshFunction(), and EquationSystemsTest::testRepartitionThenReinit().

◆ point_value() [2/4]

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

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

Definition at line 2032 of file system.C.

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

References libMesh::FEInterface::compute_data(), libMesh::Elem::contains_point(), 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().

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

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

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

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

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

References point_value().

◆ print_info()

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

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

Definition at line 87 of file reference_counter.C.

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

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

◆ processor_id()

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

Definition at line 106 of file parallel_object.h.

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

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::EquationSystems::_read_impl(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::FEMSystem::assembly(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::DistributedMesh::clear(), libMesh::ExodusII_IO_Helper::close(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::compute_communication_map_parameters(), libMesh::Nemesis_IO_Helper::compute_internal_and_border_elems_and_internal_nodes(), libMesh::RBConstruction::compute_max_error_bound(), libMesh::Nemesis_IO_Helper::compute_node_communication_maps(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::ExodusII_IO_Helper::create(), libMesh::DistributedMesh::delete_elem(), libMesh::DistributedMesh::delete_node(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DistributedMesh::DistributedMesh(), libMesh::DofMap::end_dof(), libMesh::DofMap::end_old_dof(), libMesh::EnsightIO::EnsightIO(), libMesh::RBEIMConstruction::evaluate_mesh_function(), libMesh::MeshFunction::find_element(), libMesh::MeshFunction::find_elements(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::DofMap::first_dof(), libMesh::DofMap::first_old_dof(), libMesh::Nemesis_IO_Helper::get_cmap_params(), libMesh::Nemesis_IO_Helper::get_eb_info_global(), libMesh::Nemesis_IO_Helper::get_elem_cmap(), libMesh::Nemesis_IO_Helper::get_elem_map(), libMesh::DofMap::get_info(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), libMesh::DofMap::get_local_constraints(), libMesh::Nemesis_IO_Helper::get_node_cmap(), libMesh::Nemesis_IO_Helper::get_node_map(), libMesh::Nemesis_IO_Helper::get_ns_param_global(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), libMesh::SparsityPattern::Build::handle_vi_vj(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), HeatSystem::init_data(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_element_variables(), libMesh::ExodusII_IO_Helper::initialize_global_variables(), libMesh::ExodusII_IO_Helper::initialize_nodal_variables(), libMesh::DistributedMesh::insert_elem(), libMesh::DofMap::is_evaluable(), libMesh::SparsityPattern::Build::join(), libMesh::DofMap::last_dof(), libMesh::TransientRBEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEIMEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEvaluation::legacy_write_offline_data_to_files(), libMesh::RBSCMEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEIMEvaluation::legacy_write_out_interpolation_points_elem(), libMesh::MeshTools::libmesh_assert_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DofMap::local_variable_indices(), main(), libMesh::MeshRefinement::make_coarsening_compatible(), AugmentSparsityOnInterface::mesh_reinit(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::DofMap::n_local_dofs(), n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::SparsityPattern::Build::operator()(), libMesh::DistributedMesh::own_node(), point_gradient(), point_hessian(), point_value(), libMesh::DofMap::print_dof_constraints(), libMesh::Nemesis_IO_Helper::put_cmap_params(), libMesh::Nemesis_IO_Helper::put_elem_cmap(), libMesh::Nemesis_IO_Helper::put_elem_map(), libMesh::Nemesis_IO_Helper::put_loadbal_param(), libMesh::Nemesis_IO_Helper::put_node_cmap(), libMesh::Nemesis_IO_Helper::put_node_map(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::ExodusII_IO_Helper::read_global_values(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), read_header(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), read_legacy_data(), 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::DistributedMesh::renumber_dof_objects(), libMesh::DofMap::scatter_constraints(), libMesh::CheckpointIO::select_split_config(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::LaplaceMeshSmoother::smooth(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), MeshInputTest::testDynaReadElem(), MeshInputTest::testDynaReadPatch(), MeshInputTest::testExodusCopyElementSolution(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), BoundaryInfoTest::testShellFaceConstraints(), CheckpointIOTest::testSplitter(), WriteVecAndScalar::testWrite(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::Parallel::Packing< Node * >::unpack(), libMesh::Parallel::Packing< Elem * >::unpack(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::DTKAdapter::update_variable_values(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::CheckpointIO::write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::ExodusII_IO_Helper::write_element_values_element_major(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO::write_global_data(), libMesh::ExodusII_IO_Helper::write_global_values(), write_header(), libMesh::ExodusII_IO::write_information_records(), libMesh::ExodusII_IO_Helper::write_information_records(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::VTKIO::write_nodal_data(), libMesh::UCDIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::ExodusII_IO_Helper::write_nodal_values(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::RBEvaluation::write_out_vectors(), write_output_solvedata(), 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().

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

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

◆ project_solution() [2/3]

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

Projects arbitrary functions onto the current solution.

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

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

Definition at line 950 of file system_projection.C.

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

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

◆ project_solution() [3/3]

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

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

Definition at line 936 of file system_projection.C.

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

References fptr(), and gptr().

◆ project_solution_on_reinit()

bool& libMesh::System::project_solution_on_reinit ( void  )
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 802 of file system.h.

803  { return _solution_projection; }

References _solution_projection.

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

◆ project_vector() [1/5]

void libMesh::System::project_vector ( const NumericVector< Number > &  old_v,
NumericVector< Number > &  new_v,
int  is_adjoint = -1 
) const
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 270 of file system_projection.C.

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

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

◆ project_vector() [2/5]

void libMesh::System::project_vector ( NumericVector< Number > &  vector,
int  is_adjoint = -1 
) const
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 252 of file system_projection.C.

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

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

◆ project_vector() [3/5]

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

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

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

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

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

Definition at line 1017 of file system_projection.C.

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

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

◆ project_vector() [4/5]

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

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

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

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

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

Definition at line 991 of file system_projection.C.

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

References libMesh::libmesh_assert().

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

◆ project_vector() [5/5]

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

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

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

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

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

Definition at line 976 of file system_projection.C.

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

References fptr(), and gptr().

◆ projection_matrix()

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

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

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

Definition at line 870 of file system_projection.C.

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

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

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

◆ prolong_vectors()

void libMesh::System::prolong_vectors ( )
virtual

Prolong vectors after the mesh has refined.

Definition at line 380 of file system.C.

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

References restrict_vectors().

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

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

2387 {
2388  libmesh_not_implemented();
2389 }

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

2397 {
2398  libmesh_not_implemented();
2399 }

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

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

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

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

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

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

◆ read_header()

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

Reads the basic data header for this System.

Definition at line 114 of file system_io.C.

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

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

◆ read_legacy_data()

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

Reads additional data, namely vectors, for this System.

Definition at line 309 of file system_io.C.

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

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

◆ read_parallel_data() [1/2]

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

Reads additional data, namely vectors, for this System.

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

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

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

for each additional vector in the object

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

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

Definition at line 492 of file system_io.C.

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

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

◆ read_parallel_data() [2/2]

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

1317  { 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 1120 of file system_io.C.

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

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

Referenced by read_serialized_vector(), and read_serialized_vectors().

◆ read_serialized_blocked_dof_objects()

template<typename iterator_type , typename InValType >
std::size_t libMesh::System::read_serialized_blocked_dof_objects ( const dof_id_type  n_objects,
const iterator_type  begin,
const iterator_type  end,
const InValType  dummy,
Xdr io,
const std::vector< NumericVector< Number > * > &  vecs,
const unsigned int  var_to_read = libMesh::invalid_uint 
) const
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 810 of file system_io.C.

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

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

Referenced by read_serialized_vector(), and read_serialized_vectors().

◆ read_serialized_data() [1/2]

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

Reads additional data, namely vectors, for this System.

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

Definition at line 724 of file system_io.C.

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

References _additional_data_written, _vectors, libMesh::Xdr::comment(), 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().

◆ read_serialized_data() [2/2]

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

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

◆ read_serialized_vector() [1/2]

numeric_index_type libMesh::System::read_serialized_vector ( Xdr io,
NumericVector< Number > &  vec 
)
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 1835 of file system.h.

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

◆ read_serialized_vector() [2/2]

template<typename InValType >
numeric_index_type libMesh::System::read_serialized_vector ( Xdr io,
NumericVector< Number > *  vec 
)
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 1167 of file system_io.C.

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

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

◆ read_serialized_vectors() [1/2]

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

Read a number of identically distributed vectors.

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

Definition at line 2199 of file system_io.C.

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

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

◆ read_serialized_vectors() [2/2]

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

1295  { 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::OptimizationSystem, libMesh::NonlinearImplicitSystem, libMesh::LinearImplicitSystem, libMesh::ImplicitSystem, libMesh::EigenSystem, libMesh::DifferentiableSystem, and libMesh::NewmarkSystem.

Definition at line 390 of file system.C.

391 {
392  // project_vector handles vector initialization now
393  libmesh_assert_equal_to (solution->size(), current_local_solution->size());
394 }

References current_local_solution, and solution.

Referenced by libMesh::EigenSystem::reinit(), and libMesh::ImplicitSystem::reinit().

◆ reinit_constraints()

void libMesh::System::reinit_constraints ( )
virtual

◆ remove_vector()

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

Removes the additional vector vec_name from this system.

Definition at line 699 of file system.C.

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

References _vector_is_adjoint, _vector_projections, _vector_types, and _vectors.

◆ request_vector() [1/4]

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

Definition at line 728 of file system.C.

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

References _vectors.

◆ request_vector() [2/4]

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

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

References _vectors.

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

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

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

References vectors_begin(), and vectors_end().

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

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

References vectors_begin(), and vectors_end().

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

455 {
456  if (subset != nullptr)
457  libmesh_not_implemented();
458 }

◆ restrict_vectors()

void libMesh::System::restrict_vectors ( )
virtual

Restrict vectors after the mesh has coarsened.

Definition at line 324 of file system.C.

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

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

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

2336 {
2337  libmesh_not_implemented();
2338 }

◆ set_adjoint_already_solved()

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

Setter for the adjoint_already_solved boolean.

Definition at line 402 of file system.h.

403  { adjoint_already_solved = setting;}

References adjoint_already_solved.

Referenced by main().

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

2148 {
2149  _basic_system_only = true;
2150 }

References _basic_system_only.

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

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

875 {
876  // We reserve -1 for vectors which get primal constraints, -2 for
877  // vectors which get no constraints
878  libmesh_assert_greater_equal(qoi_num, -2);
879  _vector_is_adjoint[vec_name] = qoi_num;
880 }

References _vector_is_adjoint.

Referenced by add_adjoint_solution(), and add_weighted_sensitivity_adjoint_solution().

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

857 {
858  _vector_projections[vec_name] = preserve;
859 }

References _vector_projections.

Referenced by main().

◆ solve()

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

◆ system()

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

Definition at line 248 of file system.h.

248 { 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::OptimizationSystem, libMesh::NonlinearImplicitSystem, libMesh::LinearImplicitSystem, libMesh::RBConstruction, libMesh::FrequencySystem, libMesh::EigenSystem, libMesh::ImplicitSystem, libMesh::ExplicitSystem, libMesh::NewmarkSystem, libMesh::TransientSystem< RBConstruction >, and SolidSystem.

Definition at line 495 of file system.h.

495 { return "Basic"; }

Referenced by get_info().

◆ update()

void libMesh::System::update ( )
virtual

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

Reimplemented in SolidSystem.

Definition at line 408 of file system.C.

409 {
410  libmesh_assert(solution->closed());
411 
412  const std::vector<dof_id_type> & send_list = _dof_map->get_send_list ();
413 
414  // Check sizes
415  libmesh_assert_equal_to (current_local_solution->size(), solution->size());
416  // More processors than elements => empty send_list
417  // libmesh_assert (!send_list.empty());
418  libmesh_assert_less_equal (send_list.size(), solution->size());
419 
420  // Create current_local_solution from solution. This will
421  // put a local copy of solution into current_local_solution.
422  // Only the necessary values (specified by the send_list)
423  // are copied to minimize communication
424  solution->localize (*current_local_solution, send_list);
425 }

References _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(), libMesh::FEMSystem::assemble_qoi(), libMesh::FEMSystem::assemble_qoi_derivative(), libMesh::NonlinearImplicitSystem::assembly(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::NewmarkSolver::compute_initial_accel(), LinearElasticityWithContact::compute_stresses(), LinearElasticity::compute_stresses(), compute_stresses(), LargeDeformationElasticity::compute_stresses(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::GMVIO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), DMlibMeshFunction(), DMlibMeshJacobian(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::TransientRBConstruction::initialize_truth(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_residual_helper(), libMesh::NewtonSolver::line_search(), libMesh::RBEIMConstruction::load_basis_function(), libMesh::RBConstruction::load_basis_function(), libMesh::RBEIMConstruction::load_rb_solution(), libMesh::RBConstruction::load_rb_solution(), libMesh::TransientRBConstruction::load_rb_solution(), libMesh::FEMSystem::mesh_position_get(), HeatSystem::perturb_accumulate_residuals(), libMesh::FEMSystem::postprocess(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::NewtonSolver::solve(), libMesh::ExplicitSystem::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::NonlinearImplicitSystem::solve(), libMesh::OptimizationSystem::solve(), libMesh::RBConstruction::solve_for_matrix_and_rhs(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::DirectSolutionTransfer::transfer(), and libMesh::RBEIMConstruction::truth_solve().

◆ update_global_solution() [1/2]

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

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

Requires communication with all other processors.

Definition at line 642 of file system.C.

643 {
644  global_soln.resize (solution->size());
645 
646  solution->localize (global_soln);
647 }

References solution.

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::ExactErrorEstimator::estimate_error(), and main().

◆ update_global_solution() [2/2]

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

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

Requires communication with all other processors.

Definition at line 651 of file system.C.

653 {
654  global_soln.resize (solution->size());
655 
656  solution->localize_to_one (global_soln, dest_proc);
657 }

References solution.

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

1911 {
1912  // Call the user-provided assembly function,
1913  // if it was provided
1914  if (_assemble_system_function != nullptr)
1916 
1917  // ...or the user-provided assembly object.
1918  else if (_assemble_system_object != nullptr)
1920 }

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

Referenced by assemble().

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

1925 {
1926  // Call the user-provided constraint function,
1927  // if it was provided
1928  if (_constrain_system_function!= nullptr)
1930 
1931  // ...or the user-provided constraint object.
1932  else if (_constrain_system_object != nullptr)
1934 }

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

Referenced by reinit_constraints().

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

1897 {
1898  // Call the user-provided initialization function,
1899  // if it was provided
1900  if (_init_system_function != nullptr)
1901  this->_init_system_function (_equation_systems, this->name());
1902 
1903  // ...or the user-provided initialization object.
1904  else if (_init_system_object != nullptr)
1906 }

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

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

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

1939 {
1940  // Call the user-provided quantity of interest function,
1941  // if it was provided
1942  if (_qoi_evaluate_function != nullptr)
1943  this->_qoi_evaluate_function(_equation_systems, this->name(), qoi_indices);
1944 
1945  // ...or the user-provided QOI function object.
1946  else if (_qoi_evaluate_object != nullptr)
1947  this->_qoi_evaluate_object->qoi(qoi_indices);
1948 }

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

Referenced by assemble_qoi().

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

1955 {
1956  // Call the user-provided quantity of interest derivative,
1957  // if it was provided
1958  if (_qoi_evaluate_derivative_function != nullptr)
1960  (_equation_systems, this->name(), qoi_indices, include_liftfunc,
1961  apply_constraints);
1962 
1963  // ...or the user-provided QOI derivative function object.
1964  else if (_qoi_evaluate_derivative_object != nullptr)
1966  (qoi_indices, include_liftfunc, apply_constraints);
1967 }

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

Referenced by assemble_qoi_derivative().

◆ variable()

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

◆ variable_group()

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

Return a constant reference to VariableGroup vg.

Definition at line 2193 of file system.h.

2194 {
2195  libmesh_assert_less (vg, _variable_groups.size());
2196 
2197  return _variable_groups[vg];
2198 }

References _variable_groups.

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

◆ variable_name()

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

◆ variable_number()

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

Definition at line 1232 of file system.C.

1233 {
1234  auto var_num = libmesh_map_find(_variable_numbers, var);
1235  libmesh_assert_equal_to (_variables[var_num].name(), var);
1236  return var_num;
1237 }

References _variable_numbers, _variables, and name().

Referenced by libMesh::ExactSolution::_compute_error(), LinearElasticity::assemble(), AssembleOptimization::assemble_A_and_F(), assemble_elasticity(), assemble_matrix_and_rhs(), assemble_shell(), assemble_stokes(), LinearElasticityWithContact::compute_stresses(), LinearElasticity::compute_stresses(), compute_stresses(), LargeDeformationElasticity::compute_stresses(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::GMVIO::copy_nodal_solution(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::find_squared_element_error(), LargeDeformationElasticity::jacobian(), line_print(), main(), LinearElasticityWithContact::move_mesh(), 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().

◆ variable_scalar_number() [1/2]

unsigned int libMesh::System::variable_scalar_number ( const std::string &  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 2214 of file system.h.

2216 {
2217  return variable_scalar_number(this->variable_number(var), component);
2218 }

References variable_number().

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::ExodusII_IO::copy_scalar_solution(), and libMesh::ExactErrorEstimator::find_squared_element_error().

◆ variable_scalar_number() [2/2]

unsigned int libMesh::System::variable_scalar_number ( unsigned int  var_num,
unsigned int  component 
) const
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 2224 of file system.h.

2226 {
2227  return _variables[var_num].first_scalar_number() + component;
2228 }

References _variables.

◆ variable_type() [1/2]

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

Definition at line 2243 of file system.h.

2244 {
2245  return _variables[this->variable_number(var)].type();
2246 }

References _variables, and variable_number().

◆ variable_type() [2/2]

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

◆ vector_is_adjoint()

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

885 {
886  libmesh_assert(_vector_is_adjoint.find(vec_name) !=
887  _vector_is_adjoint.end());
888 
889  return _vector_is_adjoint.find(vec_name)->second;
890 }

References _vector_is_adjoint, and libMesh::libmesh_assert().

Referenced by restrict_vectors().

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

835 {
838 
839  for (; v != v_end; ++v)
840  {
841  // Check if the current vector is the one whose name we want
842  if (&vec_reference == v->second)
843  break; // exit loop if it is
844  }
845 
846  // Before returning, make sure we didnt loop till the end and not find any match
847  libmesh_assert (v != v_end);
848 
849  // Return the string associated with the current vector
850  return v->first;
851 }

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

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

821 {
824  unsigned int num = 0;
825  while ((num<vec_num) && (v!=v_end))
826  {
827  num++;
828  ++v;
829  }
830  libmesh_assert (v != v_end);
831  return v->first;
832 }

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

Referenced by main().

◆ vector_preservation()

bool libMesh::System::vector_preservation ( const std::string &  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 863 of file system.C.

864 {
865  if (_vector_projections.find(vec_name) == _vector_projections.end())
866  return false;
867 
868  return _vector_projections.find(vec_name)->second;
869 }

References _vector_projections.

Referenced by libMesh::MemorySolutionHistory::store().

◆ vectors_begin() [1/2]

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

Beginning of vectors container.

Definition at line 2295 of file system.h.

2296 {
2297  return _vectors.begin();
2298 }

References _vectors.

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

◆ vectors_begin() [2/2]

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

Beginning of vectors container.

Definition at line 2301 of file system.h.

2302 {
2303  return _vectors.begin();
2304 }

References _vectors.

◆ vectors_end() [1/2]

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

◆ vectors_end() [2/2]

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

End of vectors container.

Definition at line 2313 of file system.h.

2314 {
2315  return _vectors.end();
2316 }

References _vectors.

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

2360 {
2361  libmesh_not_implemented();
2362 }

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

2344 {
2345  libmesh_not_implemented();
2346 }

◆ write_header()

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

1301 {
1335  libmesh_assert (io.writing());
1336 
1337 
1338  // Only write the header information
1339  // if we are processor 0.
1340  if (this->get_mesh().processor_id() != 0)
1341  return;
1342 
1343  std::string comment;
1344  char buf[80];
1345 
1346  // 5.)
1347  // Write the number of variables in the system
1348 
1349  {
1350  // set up the comment
1351  comment = "# No. of Variables in System \"";
1352  comment += this->name();
1353  comment += "\"";
1354 
1355  unsigned int nv = this->n_vars();
1356  io.data (nv, comment.c_str());
1357  }
1358 
1359 
1360  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
1361  {
1362  // 6.)
1363  // Write the name of the var-th variable
1364  {
1365  // set up the comment
1366  comment = "# Name, Variable No. ";
1367  std::sprintf(buf, "%u", var);
1368  comment += buf;
1369  comment += ", System \"";
1370  comment += this->name();
1371  comment += "\"";
1372 
1373  std::string var_name = this->variable_name(var);
1374  io.data (var_name, comment.c_str());
1375  }
1376 
1377  // 6.1.) Variable subdomains
1378  {
1379  // set up the comment
1380  comment = "# Subdomains, Variable \"";
1381  std::sprintf(buf, "%s", this->variable_name(var).c_str());
1382  comment += buf;
1383  comment += "\", System \"";
1384  comment += this->name();
1385  comment += "\"";
1386 
1387  const std::set<subdomain_id_type> & domains = this->variable(var).active_subdomains();
1388  std::vector<subdomain_id_type> domain_array;
1389  domain_array.assign(domains.begin(), domains.end());
1390  io.data (domain_array, comment.c_str());
1391  }
1392 
1393  // 7.)
1394  // Write the approximation order of the var-th variable
1395  // in this system
1396  {
1397  // set up the comment
1398  comment = "# Approximation Order, Variable \"";
1399  std::sprintf(buf, "%s", this->variable_name(var).c_str());
1400  comment += buf;
1401  comment += "\", System \"";
1402  comment += this->name();
1403  comment += "\"";
1404 
1405  int order = static_cast<int>(this->variable_type(var).order);
1406  io.data (order, comment.c_str());
1407  }
1408 
1409 
1410 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1411 
1412  // do the same for radial_order
1413  {
1414  comment = "# Radial Approximation Order, Variable \"";
1415  std::sprintf(buf, "%s", this->variable_name(var).c_str());
1416  comment += buf;
1417  comment += "\", System \"";
1418  comment += this->name();
1419  comment += "\"";
1420 
1421  int rad_order = static_cast<int>(this->variable_type(var).radial_order);
1422  io.data (rad_order, comment.c_str());
1423  }
1424 
1425 #endif
1426 
1427  // Write the Finite Element type of the var-th variable
1428  // in this System
1429  {
1430  // set up the comment
1431  comment = "# FE Family, Variable \"";
1432  std::sprintf(buf, "%s", this->variable_name(var).c_str());
1433  comment += buf;
1434  comment += "\", System \"";
1435  comment += this->name();
1436  comment += "\"";
1437 
1438  const FEType & type = this->variable_type(var);
1439  int fam = static_cast<int>(type.family);
1440  io.data (fam, comment.c_str());
1441 
1442 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1443 
1444  comment = "# Radial FE Family, Variable \"";
1445  std::sprintf(buf, "%s", this->variable_name(var).c_str());
1446  comment += buf;
1447  comment += "\", System \"";
1448  comment += this->name();
1449  comment += "\"";
1450 
1451  int radial_fam = static_cast<int>(type.radial_family);
1452  io.data (radial_fam, comment.c_str());
1453 
1454  comment = "# Infinite Mapping Type, Variable \"";
1455  std::sprintf(buf, "%s", this->variable_name(var).c_str());
1456  comment += buf;
1457  comment += "\", System \"";
1458  comment += this->name();
1459  comment += "\"";
1460 
1461  int i_map = static_cast<int>(type.inf_map);
1462  io.data (i_map, comment.c_str());
1463 #endif
1464  }
1465  } // end of the variable loop
1466 
1467  // 8.)
1468  // Write the number of additional vectors in the System.
1469  // If write_additional_data==false, then write zero for
1470  // the number of additional vectors.
1471  {
1472  {
1473  // set up the comment
1474  comment = "# No. of Additional Vectors, System \"";
1475  comment += this->name();
1476  comment += "\"";
1477 
1478  unsigned int nvecs = write_additional_data ? this->n_vectors () : 0;
1479  io.data (nvecs, comment.c_str());
1480  }
1481 
1482  if (write_additional_data)
1483  {
1484  unsigned int cnt=0;
1485  for (const auto & pr : _vectors)
1486  {
1487  // 9.)
1488  // write the name of the cnt-th additional vector
1489  comment = "# Name of ";
1490  std::sprintf(buf, "%d", cnt++);
1491  comment += buf;
1492  comment += "th vector";
1493  std::string vec_name = pr.first;
1494 
1495  io.data (vec_name, comment.c_str());
1496  }
1497  }
1498  }
1499 }

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

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

◆ write_parallel_data()

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

Writes additional data, namely vectors, for this System.

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

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

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

for each additional vector in the object

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

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

Definition at line 1503 of file system_io.C.

1505 {
1525  // PerfLog pl("IO Performance",false);
1526  // pl.push("write_parallel_data");
1527  // std::size_t total_written_size = 0;
1528 
1529  std::string comment;
1530 
1531  libmesh_assert (io.writing());
1532 
1533  std::vector<Number> io_buffer; io_buffer.reserve(this->solution->local_size());
1534 
1535  // build the ordered nodes and element maps.
1536  // when writing/reading parallel files we need to iterate
1537  // over our nodes/elements in order of increasing global id().
1538  // however, this is not guaranteed to be ordering we obtain
1539  // by using the node_iterators/element_iterators directly.
1540  // so build a set, sorted by id(), that provides the ordering.
1541  // further, for memory economy build the set but then transfer
1542  // its contents to vectors, which will be sorted.
1543  std::vector<const DofObject *> ordered_nodes, ordered_elements;
1544  {
1545  std::set<const DofObject *, CompareDofObjectsByID>
1546  ordered_nodes_set (this->get_mesh().local_nodes_begin(),
1547  this->get_mesh().local_nodes_end());
1548 
1549  ordered_nodes.insert(ordered_nodes.end(),
1550  ordered_nodes_set.begin(),
1551  ordered_nodes_set.end());
1552  }
1553  {
1554  std::set<const DofObject *, CompareDofObjectsByID>
1555  ordered_elements_set (this->get_mesh().local_elements_begin(),
1556  this->get_mesh().local_elements_end());
1557 
1558  ordered_elements.insert(ordered_elements.end(),
1559  ordered_elements_set.begin(),
1560  ordered_elements_set.end());
1561  }
1562 
1563  const unsigned int sys_num = this->number();
1564  const unsigned int nv = this->n_vars();
1565 
1566  // Loop over each non-SCALAR variable and each node, and write out the value.
1567  for (unsigned int var=0; var<nv; var++)
1568  if (this->variable(var).type().family != SCALAR)
1569  {
1570  // First write the node DOF values
1571  for (const auto & node : ordered_nodes)
1572  for (auto comp : IntRange<unsigned int>(0, node->n_comp(sys_num,var)))
1573  {
1574  libmesh_assert_not_equal_to (node->dof_number(sys_num, var, comp),
1576 
1577  io_buffer.push_back((*this->solution)(node->dof_number(sys_num, var, comp)));
1578  }
1579 
1580  // Then write the element DOF values
1581  for (const auto & elem : ordered_elements)
1582  for (auto comp : IntRange<unsigned int>(0, elem->n_comp(sys_num,var)))
1583  {
1584  libmesh_assert_not_equal_to (elem->dof_number(sys_num, var, comp),
1586 
1587  io_buffer.push_back((*this->solution)(elem->dof_number(sys_num, var, comp)));
1588  }
1589  }
1590 
1591  // Finally, write the SCALAR data on the last processor
1592  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
1593  if (this->variable(var).type().family == SCALAR)
1594  {
1595  if (this->processor_id() == (this->n_processors()-1))
1596  {
1597  const DofMap & dof_map = this->get_dof_map();
1598  std::vector<dof_id_type> SCALAR_dofs;
1599  dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
1600 
1601  for (auto dof : SCALAR_dofs)
1602  io_buffer.push_back((*this->solution)(dof));
1603  }
1604  }
1605 
1606  // 9.)
1607  //
1608  // Actually write the reordered solution vector
1609  // for the ith system to disk
1610 
1611  // set up the comment
1612  {
1613  comment = "# System \"";
1614  comment += this->name();
1615  comment += "\" Solution Vector";
1616  }
1617 
1618  io.data (io_buffer, comment.c_str());
1619 
1620  // total_written_size += io_buffer.size();
1621 
1622  // Only write additional vectors if wanted
1623  if (write_additional_data)
1624  {
1625  for (auto & pr : _vectors)
1626  {
1627  io_buffer.clear();
1628  io_buffer.reserve(pr.second->local_size());
1629 
1630  // Loop over each non-SCALAR variable and each node, and write out the value.
1631  for (unsigned int var=0; var<nv; var++)
1632  if (this->variable(var).type().family != SCALAR)
1633  {
1634  // First write the node DOF values
1635  for (const auto & node : ordered_nodes)
1636  for (auto comp : IntRange<unsigned int>(0, node->n_comp(sys_num,var)))
1637  {
1638  libmesh_assert_not_equal_to (node->dof_number(sys_num, var, comp),
1640 
1641  io_buffer.push_back((*pr.second)(node->dof_number(sys_num, var, comp)));
1642  }
1643 
1644  // Then write the element DOF values
1645  for (const auto & elem : ordered_elements)
1646  for (auto comp : IntRange<unsigned int>(0, elem->n_comp(sys_num,var)))
1647  {
1648  libmesh_assert_not_equal_to (elem->dof_number(sys_num, var, comp),
1650 
1651  io_buffer.push_back((*pr.second)(elem->dof_number(sys_num, var, comp)));
1652  }
1653  }
1654 
1655  // Finally, write the SCALAR data on the last processor
1656  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
1657  if (this->variable(var).type().family == SCALAR)
1658  {
1659  if (this->processor_id() == (this->n_processors()-1))
1660  {
1661  const DofMap & dof_map = this->get_dof_map();
1662  std::vector<dof_id_type> SCALAR_dofs;
1663  dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
1664 
1665  for (auto dof : SCALAR_dofs)
1666  io_buffer.push_back((*pr.second)(dof));
1667  }
1668  }
1669 
1670  // 10.)
1671  //
1672  // Actually write the reordered additional vector
1673  // for this system to disk
1674 
1675  // set up the comment
1676  {
1677  comment = "# System \"";
1678  comment += this->name();
1679  comment += "\" Additional Vector \"";
1680  comment += pr.first;
1681  comment += "\"";
1682  }
1683 
1684  io.data (io_buffer, comment.c_str());
1685 
1686  // total_written_size += io_buffer.size();
1687  }
1688  }
1689 
1690  // const Real
1691  // dt = pl.get_elapsed_time(),
1692  // rate = total_written_size*sizeof(Number)/dt;
1693 
1694  // libMesh::err << "Write " << total_written_size << " \"Number\" values\n"
1695  // << " Elapsed time = " << dt << '\n'
1696  // << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";
1697 
1698  // pl.pop("write_parallel_data");
1699 }

References _vectors, libMesh::Xdr::data(), libMesh::FEType::family, get_dof_map(), get_mesh(), libMesh::DofObject::invalid_id, libMesh::libmesh_assert(), 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().

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

2100 {
2101  unsigned int written_length=0;
2102  std::vector<Number> vals; // The raw values for the local objects in the current block
2103  // Collect the SCALARs for the current variable
2104  if (this->processor_id() == (this->n_processors()-1))
2105  {
2106  const DofMap & dof_map = this->get_dof_map();
2107  std::vector<dof_id_type> SCALAR_dofs;
2108  dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
2109  const unsigned int n_scalar_dofs = cast_int<unsigned int>
2110  (SCALAR_dofs.size());
2111 
2112  for (unsigned int i=0; i<n_scalar_dofs; i++)
2113  {
2114  vals.push_back( vec(SCALAR_dofs[i]) );
2115  }
2116  }
2117 
2118 #ifdef LIBMESH_HAVE_MPI
2119  if (this->n_processors() > 1)
2120  {
2121  const Parallel::MessageTag val_tag(1);
2122 
2123  // Post the receive on processor 0
2124  if (this->processor_id() == 0)
2125  {
2126  this->comm().receive(this->n_processors()-1, vals, val_tag);
2127  }
2128 
2129  // Send the data to processor 0
2130  if (this->processor_id() == (this->n_processors()-1))
2131  {
2132  this->comm().send(0, vals, val_tag);
2133  }
2134  }
2135 #endif
2136 
2137  // -------------------------------------------------------
2138  // Write the output on processor 0.
2139  if (this->processor_id() == 0)
2140  {
2141  const unsigned int vals_size =
2142  cast_int<unsigned int>(vals.size());
2143  io.data_stream (vals.data(), vals_size);
2144  written_length += vals_size;
2145  }
2146 
2147  return written_length;
2148 }

References libMesh::ParallelObject::comm(), libMesh::Xdr::data_stream(), get_dof_map(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), and libMesh::DofMap::SCALAR_dof_indices().

Referenced by write_serialized_vector(), and write_serialized_vectors().

◆ write_serialized_blocked_dof_objects()

template<typename iterator_type >
std::size_t libMesh::System::write_serialized_blocked_dof_objects ( const std::vector< const NumericVector< Number > * > &  vecs,
const dof_id_type  n_objects,
const iterator_type  begin,
const iterator_type  end,
Xdr io,
const unsigned int  var_to_write = libMesh::invalid_uint 
) const
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 1811 of file system_io.C.

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

References libMesh::ParallelObject::comm(), end, libMesh::MeshTools::Generation::Private::idx(), libMesh::invalid_uint, libMesh::libmesh_assert(), libMesh::ParallelObject::n_processors(), n_vars(), number(), and libMesh::ParallelObject::processor_id().

Referenced by write_serialized_vector(), and write_serialized_vectors().

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

1705 {
1719  parallel_object_only();
1720  std::string comment;
1721 
1722  // PerfLog pl("IO Performance",false);
1723  // pl.push("write_serialized_data");
1724  // std::size_t total_written_size = 0;
1725 
1726  // total_written_size +=
1727  this->write_serialized_vector(io, *this->solution);
1728 
1729  // set up the comment
1730  if (this->processor_id() == 0)
1731  {
1732  comment = "# System \"";
1733  comment += this->name();
1734  comment += "\" Solution Vector";
1735 
1736  io.comment (comment);
1737  }
1738 
1739  // Only write additional vectors if wanted
1740  if (write_additional_data)
1741  {
1742  for (auto & pair : this->_vectors)
1743  {
1744  // total_written_size +=
1745  this->write_serialized_vector(io, *pair.second);
1746 
1747  // set up the comment
1748  if (this->processor_id() == 0)
1749  {
1750  comment = "# System \"";
1751  comment += this->name();
1752  comment += "\" Additional Vector \"";
1753  comment += pair.first;
1754  comment += "\"";
1755  io.comment (comment);
1756  }
1757  }
1758  }
1759 
1760  // const Real
1761  // dt = pl.get_elapsed_time(),
1762  // rate = total_written_size*sizeof(Number)/dt;
1763 
1764  // libMesh::out << "Write " << total_written_size << " \"Number\" values\n"
1765  // << " Elapsed time = " << dt << '\n'
1766  // << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";
1767 
1768  // pl.pop("write_serialized_data");
1769 
1770 
1771 
1772 
1773  // // test the new method
1774  // {
1775  // std::vector<std::string> names;
1776  // std::vector<NumericVector<Number> *> vectors_to_write;
1777 
1778  // names.push_back("Solution Vector");
1779  // vectors_to_write.push_back(this->solution.get());
1780 
1781  // // Only write additional vectors if wanted
1782  // if (write_additional_data)
1783  // {
1784  // std::map<std::string, NumericVector<Number> *>::const_iterator
1785  // pos = _vectors.begin();
1786 
1787  // for (; pos != this->_vectors.end(); ++pos)
1788  // {
1789  // names.push_back("Additional Vector " + pos->first);
1790  // vectors_to_write.push_back(pos->second);
1791  // }
1792  // }
1793 
1794  // total_written_size =
1795  // this->write_serialized_vectors (io, names, vectors_to_write);
1796 
1797  // const Real
1798  // dt2 = pl.get_elapsed_time(),
1799  // rate2 = total_written_size*sizeof(Number)/(dt2-dt);
1800 
1801  // libMesh::out << "Write (new) " << total_written_size << " \"Number\" values\n"
1802  // << " Elapsed time = " << (dt2-dt) << '\n'
1803  // << " Rate = " << rate2/1.e6 << "(MB/sec)\n\n";
1804 
1805  // }
1806 }

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

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

2154 {
2155  parallel_object_only();
2156 
2157  libmesh_assert (io.writing());
2158 
2159  dof_id_type vec_length = vec.size();
2160  if (this->processor_id() == 0) io.data (vec_length, "# vector length");
2161 
2162  dof_id_type written_length = 0;
2163 
2164  //---------------------------------
2165  // Collect the values for all nodes
2166  written_length += cast_int<dof_id_type>
2167  (this->write_serialized_blocked_dof_objects (std::vector<const NumericVector<Number> *>(1,&vec),
2168  this->get_mesh().n_nodes(),
2169  this->get_mesh().local_nodes_begin(),
2170  this->get_mesh().local_nodes_end(),
2171  io));
2172 
2173  //------------------------------------
2174  // Collect the values for all elements
2175  written_length += cast_int<dof_id_type>
2176  (this->write_serialized_blocked_dof_objects (std::vector<const NumericVector<Number> *>(1,&vec),
2177  this->get_mesh().n_elem(),
2178  this->get_mesh().local_elements_begin(),
2179  this->get_mesh().local_elements_end(),
2180  io));
2181 
2182  //-------------------------------------------
2183  // Finally loop over all the SCALAR variables
2184  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
2185  if (this->variable(var).type().family == SCALAR)
2186  {
2187  written_length +=
2188  this->write_SCALAR_dofs (vec, var, io);
2189  }
2190 
2191  if (this->processor_id() == 0)
2192  libmesh_assert_equal_to (written_length, vec_length);
2193 
2194  return written_length;
2195 }

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

Referenced by write_serialized_data().

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

2295 {
2296  parallel_object_only();
2297 
2298  libmesh_assert (io.writing());
2299 
2300  // Cache these - they are not free!
2301  const dof_id_type
2302  n_nodes = this->get_mesh().n_nodes(),
2303  n_elem = this->get_mesh().n_elem();
2304 
2305  std::size_t written_length = 0;
2306 
2307  if (this->processor_id() == 0)
2308  {
2309  unsigned int
2310  n_vec = cast_int<unsigned int>(vectors.size());
2311  dof_id_type
2312  vec_size = vectors.empty() ? 0 : vectors[0]->size();
2313  // Set the number of vectors
2314  io.data(n_vec, "# number of vectors");
2315  // Set the buffer size
2316  io.data(vec_size, "# vector length");
2317  }
2318 
2319  //---------------------------------
2320  // Collect the values for all nodes
2321  written_length +=
2322  this->write_serialized_blocked_dof_objects (vectors,
2323  n_nodes,
2324  this->get_mesh().local_nodes_begin(),
2325  this->get_mesh().local_nodes_end(),
2326  io);
2327 
2328  //------------------------------------
2329  // Collect the values for all elements
2330  written_length +=
2331  this->write_serialized_blocked_dof_objects (vectors,
2332  n_elem,
2333  this->get_mesh().local_elements_begin(),
2334  this->get_mesh().local_elements_end(),
2335  io);
2336 
2337  //-------------------------------------------
2338  // Finally loop over all the SCALAR variables
2339  for (const NumericVector<Number> * vec : vectors)
2340  for (auto var : IntRange<unsigned int>(0, this->n_vars()))
2341  if (this->variable(var).type().family == SCALAR)
2342  {
2343  libmesh_assert_not_equal_to (vec, 0);
2344 
2345  written_length +=
2346  this->write_SCALAR_dofs (*vec, var, io);
2347  }
2348 
2349  return written_length;
2350 }

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

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

1302 {
1303  /* Make sure the call makes sense. */
1304  libmesh_assert_less (var_num, this->n_vars());
1305 
1306  /* Get a reference to the mesh. */
1307  const MeshBase & mesh = this->get_mesh();
1308 
1309  /* Check which system we are. */
1310  const unsigned int sys_num = this->number();
1311 
1312  // Loop over nodes.
1313  for (const auto & node : mesh.local_node_ptr_range())
1314  {
1315  unsigned int n_comp = node->n_comp(sys_num,var_num);
1316  for (unsigned int i=0; i<n_comp; i++)
1317  {
1318  const dof_id_type index = node->dof_number(sys_num,var_num,i);
1319  v.set(index,0.0);
1320  }
1321  }
1322 
1323  // Loop over elements.
1324  for (const auto & elem : mesh.active_local_element_ptr_range())
1325  {
1326  unsigned int n_comp = elem->n_comp(sys_num,var_num);
1327  for (unsigned int i=0; i<n_comp; i++)
1328  {
1329  const dof_id_type index = elem->dof_number(sys_num,var_num,i);
1330  v.set(index,0.0);
1331  }
1332  }
1333 }

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

Member Data Documentation

◆ _active

bool libMesh::System::_active
private

Flag stating if the system is active or not.

Definition at line 1977 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 2034 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 1885 of file system.h.

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

◆ _assemble_system_object

Assembly* libMesh::System::_assemble_system_object
private

Object that assembles the system.

Definition at line 1891 of file system.h.

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

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

Referenced by init(), 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 1896 of file system.h.

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

◆ _constrain_system_object

Constraint* libMesh::System::_constrain_system_object
private

Object that constrains the system.

Definition at line 1902 of file system.h.

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

◆ _counts

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

◆ _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 1934 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 141 of file reference_counter.h.

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

◆ _equation_systems

EquationSystems& libMesh::System::_equation_systems
private

Constant reference to the EquationSystems object used for the simulation.

Definition at line 1940 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 2059 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 2027 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 1874 of file system.h.

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

◆ _init_system_object

Initialization* libMesh::System::_init_system_object
private

Object that initializes the system.

Definition at line 1880 of file system.h.

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

◆ _is_initialized

bool libMesh::System::_is_initialized
private

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

Definition at line 2021 of file system.h.

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

◆ _mesh

MeshBase& libMesh::System::_mesh
private

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

Definition at line 1946 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 135 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 130 of file reference_counter.h.

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

◆ _qoi_evaluate_derivative_function

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

Function to evaluate quantity of interest derivative.

Definition at line 1919 of file system.h.

Referenced by attach_QOI_derivative(), attach_QOI_derivative_object(), user_QOI_derivative(), and ~System().

◆ _qoi_evaluate_derivative_object

QOIDerivative* libMesh::System::_qoi_evaluate_derivative_object
private

Object to compute derivatives of quantities of interest.

Definition at line 1928 of file system.h.

Referenced by attach_QOI_derivative(), attach_QOI_derivative_object(), user_QOI_derivative(), and ~System().

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

Referenced by attach_QOI_function(), attach_QOI_object(), user_QOI(), and ~System().

◆ _qoi_evaluate_object

QOI* libMesh::System::_qoi_evaluate_object
private

Object to compute quantities of interest.

Definition at line 1914 of file system.h.

Referenced by attach_QOI_function(), attach_QOI_object(), user_QOI(), and ~System().

◆ _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 2009 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 1951 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 1956 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 1966 of file system.h.

Referenced by add_variable(), add_variables(), n_variable_groups(), and variable_group().

◆ _variable_numbers

std::map<std::string, unsigned short int> libMesh::System::_variable_numbers
private

The variable numbers corresponding to user-specified names, useful for name-based lookups.

Definition at line 1972 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> 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 1997 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> 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 1991 of file system.h.

Referenced by add_vector(), clear(), remove_vector(), restrict_vectors(), set_vector_preservation(), and vector_preservation().

◆ _vector_types

std::map<std::string, ParallelType> libMesh::System::_vector_types
private

Holds the type of a vector.

Definition at line 2002 of file system.h.

Referenced by add_vector(), clear(), init_data(), remove_vector(), and restrict_vectors().

◆ _vectors

std::map<std::string, NumericVector<Number> * > 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 1985 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(), 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 2046 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 2053 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 1493 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::CondensedEigenSystem::solve(), libMesh::EigenSystem::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 1551 of file system.h.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::NonlinearImplicitSystem::assembly(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), 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(), 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(), 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(), FETest< order, family, elem_type >::testGradU(), FETest< order, family, elem_type >::testGradUComp(), FETest< order, family, elem_type >::testU(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::TransientRBConstruction::truth_solve(), update(), 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 1524 of file system.h.

Referenced by libMesh::JumpErrorEstimator::estimate_error(), CurlCurlSystem::init_data(), and set_system_parameters().

◆ qoi

std::vector<Number> libMesh::System::qoi

◆ solution

std::unique_ptr<NumericVector<Number> > libMesh::System::solution

Data structure to hold solution values.

Definition at line 1539 of file system.h.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::TransientRBConstruction::add_IC_to_RB_space(), libMesh::NewmarkSolver::advance_timestep(), libMesh::AdaptiveTimeSolver::advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), libMesh::ContinuationSystem::apply_predictor(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::FEMSystem::assembly(), libMesh::LinearImplicitSystem::assembly(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), clear(), compare(), libMesh::RBEIMConstruction::compute_best_fit_error(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::NewmarkSolver::compute_initial_accel(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), LinearElasticityWithContact::compute_stresses(), LinearElasticity::compute_stresses(), compute_stresses(), LargeDeformationElasticity::compute_stresses(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ContinuationSystem::continuation_solve(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::GMVIO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), DMCreateGlobalVector_libMesh(), DMlibMeshFunction(), DMlibMeshJacobian(), libMesh::UnsteadySolver::du(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::RBConstruction::enrich_RB_space(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::RBSCMConstruction::evaluate_stability_constant(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::EigenSystem::get_eigenpair(), LinearElasticityWithContact::get_least_and_max_gap_function(), init_data(), libMesh::RBEIMConstruction::initialize_parametrized_functions_in_training_set(), libMesh::ContinuationSystem::initialize_tangent(), libMesh::TransientRBConstruction::initialize_truth(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_residual_helper(), libMesh::RBEIMConstruction::load_basis_function(), libMesh::RBConstruction::load_basis_function(), libMesh::RBEIMConstruction::load_rb_solution(), libMesh::RBConstruction::load_rb_solution(), libMesh::TransientRBConstruction::load_rb_solution(), main(), libMesh::DofMap::max_constraint_error(), libMesh::FEMSystem::mesh_position_get(), libMesh::ErrorVector::plot_error(), libMesh::RBEIMConstruction::plot_parametrized_functions_in_training_set(), libMesh::RBConstruction::print_basis_function_orthogonality(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), 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::MemorySolutionHistory::retrieve(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), libMesh::ContinuationSystem::save_current_solution(), libMesh::TransientRBConstruction::set_error_temporal_data(), setup(), libMesh::TwostepTimeSolver::solve(), libMesh::NewtonSolver::solve(), libMesh::PetscDiffSolver::solve(), libMesh::FrequencySystem::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::NonlinearImplicitSystem::solve(), libMesh::RBConstruction::solve_for_matrix_and_rhs(), libMesh::ContinuationSystem::solve_tangent(), libMesh::MemorySolutionHistory::store(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), SystemsTest::testBoundaryProjectCube(), SystemsTest::testDofCouplingWithVarGroups(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), SystemsTest::testProjectCubeWithMeshFunction(), WriteVecAndScalar::testWrite(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::DirectSolutionTransfer::transfer(), libMesh::BoundaryVolumeSolutionTransfer::transfer_boundary_volume(), libMesh::BoundaryVolumeSolutionTransfer::transfer_volume_boundary(), libMesh::TransientRBConstruction::truth_solve(), libMesh::RBEIMConstruction::truth_solve(), libMesh::RBConstruction::truth_solve(), update(), update_global_solution(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::RBEIMConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_residual_terms(), libMesh::RBConstruction::update_residual_terms(), libMesh::ContinuationSystem::update_solution(), libMesh::NewmarkSystem::update_u_v_a(), libMesh::DTKAdapter::update_variable_values(), 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

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

Referenced by libMesh::EulerSolver::_general_residual(), libMesh::Euler2Solver::_general_residual(), libMesh::SteadySolver::_general_residual(), libMesh::NewmarkSolver::_general_residual(), libMesh::DifferentiableSystem::clear(), libMesh::DiffContext::DiffContext(), and libMesh::FEMContext::pre_fe_reinit().


The documentation for this class was generated from the following files:
libMesh::DISCRETE_L_INF
Definition: enum_norm_type.h:54
libMesh::System::write_serialized_vector
dof_id_type write_serialized_vector(Xdr &io, const NumericVector< Number > &vec) const
Writes a vector for this System.
Definition: system_io.C:2152
libMesh::System::_vector_projections
std::map< std::string, bool > _vector_projections
Holds true if a vector by that name should be projected onto a changed grid, false if it should be ze...
Definition: system.h:1991
libMesh::dof_id_type
uint8_t dof_id_type
Definition: id_types.h:67
libMesh::Number
Real Number
Definition: libmesh_common.h:195
libMesh::System::boundary_project_solution
void boundary_project_solution(const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr)
Projects arbitrary boundary functions onto a vector of degree of freedom values for the current syste...
Definition: system_projection.C:1126
libMesh::System::n_vars
unsigned int n_vars() const
Definition: system.h:2155
libMesh::System::have_vector
bool have_vector(const std::string &vec_name) const
Definition: system.h:2275
libMesh::System::get_equation_systems
const EquationSystems & get_equation_systems() const
Definition: system.h:720
libMesh::OrderWrapper::get_order
int get_order() const
Explicitly request the order as an int.
Definition: fe_type.h:77
libMesh::invalid_uint
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value.
Definition: libmesh.h:249
libMesh::System::project_vector
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
Projects arbitrary functions onto a vector of degree of freedom values for the current system.
Definition: system_projection.C:991
libMesh::System::is_initialized
bool is_initialized()
Definition: system.h:2139
libMesh::System::_is_initialized
bool _is_initialized
true when additional vectors and variables do not require immediate initialization,...
Definition: system.h:2021
libMesh::MeshTools::n_elem
dof_id_type n_elem(const MeshBase::const_element_iterator &begin, const MeshBase::const_element_iterator &end)
Count up the number of elements of a specific type (as defined by an iterator range).
Definition: mesh_tools.C:705
libMesh::DofMap::prepare_send_list
void prepare_send_list()
Takes the _send_list vector (which may have duplicate entries) and sorts it.
Definition: dof_map.C:1651
libMesh::System::_variable_groups
std::vector< VariableGroup > _variable_groups
The VariableGroup in this System.
Definition: system.h:1966
libMesh::System::vectors_iterator
std::map< std::string, NumericVector< Number > * >::iterator vectors_iterator
Vector iterator typedefs.
Definition: system.h:756
libMesh::System::_constrain_system_function
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Function to impose constraints.
Definition: system.h:1896
libMesh::FEType::family
FEFamily family
The type of finite element.
Definition: fe_type.h:203
libMesh::System::boundary_project_vector
void boundary_project_vector(const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
Projects arbitrary boundary functions onto a vector of degree of freedom values for the current syste...
Definition: system_projection.C:1162
libMesh::DofMap::dof_indices
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Fills the vector di with the global degree of freedom indices for the element.
Definition: dof_map.C:1967
libMesh::L_INF
Definition: enum_norm_type.h:42
libMesh::PARALLEL
Definition: enum_parallel_type.h:36
libMesh::System::_dof_map
std::unique_ptr< DofMap > _dof_map
Data structure describing the relationship between nodes, variables, etc...
Definition: system.h:1934
libMesh::System::add_variables
unsigned int add_variables(const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system.
Definition: system.C:1160
libMesh::NumericVector::subset_linfty_norm
virtual Real subset_linfty_norm(const std::set< numeric_index_type > &indices) const
Definition: numeric_vector.C:342
libMesh::System::_assemble_system_function
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Function that assembles the system.
Definition: system.h:1885
libMesh::DofMap::get_info
std::string get_info() const
Gets summary info about the sparsity bandwidth and constraints.
Definition: dof_map.C:2843
libMesh::System::_hide_output
bool _hide_output
Are we allowed to write this system to file? If _hide_output is true, then EquationSystems::write wil...
Definition: system.h:2059
libMesh::System::user_assembly
virtual void user_assembly()
Calls user's attached assembly function, or is overridden by the user in derived classes.
Definition: system.C:1910
libMesh::DISCRETE_L2
Definition: enum_norm_type.h:53
libMesh::MeshBase::n_elem
virtual dof_id_type n_elem() const =0
libMesh::System::system_type
virtual std::string system_type() const
Definition: system.h:495
libMesh::System::_vectors
std::map< std::string, NumericVector< Number > * > _vectors
Some systems need an arbitrary number of vectors.
Definition: system.h:1985
libMesh::System::_vector_types
std::map< std::string, ParallelType > _vector_types
Holds the type of a vector.
Definition: system.h:2002
libMesh::System::variable_name
const std::string & variable_name(const unsigned int i) const
Definition: system.h:2203
libMesh::System::read_serialized_blocked_dof_objects
std::size_t read_serialized_blocked_dof_objects(const dof_id_type n_objects, const iterator_type begin, const iterator_type end, const InValType dummy, Xdr &io, const std::vector< NumericVector< Number > * > &vecs, const unsigned int var_to_read=libMesh::invalid_uint) const
Reads an input vector from the stream io and assigns the values to a set of DofObjects.
Definition: system_io.C:810
libMesh::SERIAL
Definition: enum_parallel_type.h:35
libMesh::index_range
IntRange< std::size_t > index_range(const std::vector< T > &vec)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition: int_range.h:106
libMesh::L1
Definition: enum_norm_type.h:41
libMesh::System::n_vectors
unsigned int n_vectors() const
Definition: system.h:2283
libMesh::XYZ
Definition: enum_fe_family.h:46
libMesh::System::restrict_vectors
virtual void restrict_vectors()
Restrict vectors after the mesh has coarsened.
Definition: system.C:324
libMesh::NumericVector::close
virtual void close()=0
Calls the NumericVector's internal assembly routines, ensuring that the values are consistent across ...
libMesh::H1_SEMINORM
Definition: enum_norm_type.h:43
libMesh::System::identify_variable_groups
bool identify_variable_groups() const
Definition: system.h:2251
libMesh::System::_identify_variable_groups
bool _identify_variable_groups
true when VariableGroup structures should be automatically identified, false otherwise.
Definition: system.h:2027
libMesh::NumericVector::init
virtual void init(const numeric_index_type n, const numeric_index_type n_local, const bool fast=false, const ParallelType ptype=AUTOMATIC)=0
Change the dimension of the vector to n.
libMesh::System::extra_quadrature_order
int extra_quadrature_order
A member int that can be employed to indicate increased or reduced quadrature order.
Definition: system.h:1524
end
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end.
Definition: variant_filter_iterator.h:343
libMesh::ReferenceCounter::_counts
static Counts _counts
Actually holds the data.
Definition: reference_counter.h:122
std::sqrt
MetaPhysicL::DualNumber< T, D > sqrt(const MetaPhysicL::DualNumber< T, D > &in)
libMesh::System::_active
bool _active
Flag stating if the system is active or not.
Definition: system.h:1977
libMesh::ParallelObject::comm
const Parallel::Communicator & comm() const
Definition: parallel_object.h:94
libMesh::GHOSTED
Definition: enum_parallel_type.h:37
libMesh::NumericVector::clone
virtual std::unique_ptr< NumericVector< T > > clone() const =0
libMesh::DofMap::process_constraints
void process_constraints(MeshBase &)
Postprocesses any constrained degrees of freedom to be constrained only in terms of unconstrained dof...
Definition: dof_map_constraints.C:3334
libMesh::System::number
unsigned int number() const
Definition: system.h:2075
libMesh::ReferenceCounter::_n_objects
static Threads::atomic< unsigned int > _n_objects
The number of objects.
Definition: reference_counter.h:130
libMesh::Variable::type
const FEType & type() const
Definition: variable.h:119
libMesh::W2_INF_SEMINORM
Definition: enum_norm_type.h:50
libMesh::H2
Definition: enum_norm_type.h:38
libMesh::FEMFunctionBase::component
virtual Output component(const FEMContext &, unsigned int i, const Point &p, Real time=0.)
Definition: fem_function_base.h:132
mesh
MeshBase & mesh
Definition: mesh_communication.C:1257
libMesh::MeshBase::mesh_dimension
unsigned int mesh_dimension() const
Definition: mesh_base.C:135
libMesh::W1_INF_SEMINORM
Definition: enum_norm_type.h:49
libMesh::DofMap::first_dof
dof_id_type first_dof(const processor_id_type proc) const
Definition: dof_map.h:650
libMesh::System::read_SCALAR_dofs
unsigned int read_SCALAR_dofs(const unsigned int var, Xdr &io, NumericVector< Number > *vec) const
Reads the SCALAR dofs from the stream io and assigns the values to the appropriate entries of vec.
Definition: system_io.C:1120
libMesh::System::variable
const Variable & variable(unsigned int var) const
Return a constant reference to Variable var.
Definition: system.h:2183
libMesh::System::use_fixed_solution
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:1509
libMesh::Variable::active_subdomains
const std::set< subdomain_id_type > & active_subdomains() const
Definition: variable.h:150
libMesh::ReferenceCounter::get_info
static std::string get_info()
Gets a string containing the reference information.
Definition: reference_counter.C:47
libMesh::System::local_dof_indices
void local_dof_indices(const unsigned int var, std::set< dof_id_type > &var_indices) const
Fills the std::set with the degrees of freedom on the local processor corresponding the the variable ...
Definition: system.C:1259
libMesh::System::n_matrices
virtual unsigned int n_matrices() const
Definition: system.h:2289
libMesh::System::QOI::qoi
virtual void qoi(const QoISet &qoi_indices)=0
Quantity of interest function.
dim
unsigned int dim
Definition: adaptivity_ex3.C:113
libMesh::NumericVector< Number >::build
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...
Definition: numeric_vector.C:49
libMesh::System::_init_system_function
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Function that initializes the system.
Definition: system.h:1874
libMesh::System::_qoi_evaluate_function
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Function to evaluate quantity of interest.
Definition: system.h:1907
libMesh::NumericVector::size
virtual numeric_index_type size() const =0
libMesh::System::vector_is_adjoint
int vector_is_adjoint(const std::string &vec_name) const
Definition: system.C:884
libMesh::System::QOIDerivative::qoi_derivative
virtual void qoi_derivative(const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)=0
Quantity of interest derivative function.
libMesh::zero
const Number zero
.
Definition: libmesh.h:243
libMesh::DofMap::enforce_adjoint_constraints_exactly
void enforce_adjoint_constraints_exactly(NumericVector< Number > &v, unsigned int q) const
Heterogenously constrains the numeric vector v, which represents an adjoint solution defined on the m...
Definition: dof_map.h:2058
libMesh::System::n_components
unsigned int n_components() const
Definition: system.h:2171
libMesh::System::_basic_system_only
bool _basic_system_only
Holds true if the components of more advanced system types (e.g.
Definition: system.h:2015
libMesh::System::assemble_before_solve
bool assemble_before_solve
Flag which tells the system to whether or not to call the user assembly function during each call to ...
Definition: system.h:1493
libMesh::System::_init_system_object
Initialization * _init_system_object
Object that initializes the system.
Definition: system.h:1880
libMesh::libmesh_assert
libmesh_assert(ctx)
libMesh::FEMNormType
FEMNormType
Definition: enum_norm_type.h:34
libMesh::System::n_variable_groups
unsigned int n_variable_groups() const
Definition: system.h:2163
libMesh::Threads::Thread
NonConcurrentThread Thread
Use the non-concurrent placeholder.
Definition: threads_none.h:43
libMesh::ParallelObject::ParallelObject
ParallelObject(const Parallel::Communicator &comm_in)
Constructor.
Definition: parallel_object.h:63
std::abs
MetaPhysicL::DualNumber< T, D > abs(const MetaPhysicL::DualNumber< T, D > &in)
libMesh::System::reinit_constraints
virtual void reinit_constraints()
Reinitializes the constraints for this system.
Definition: system.C:397
libMesh::Threads::parallel_for
void parallel_for(const Range &range, const Body &body)
Execute the provided function object in parallel on the specified range.
Definition: threads_none.h:73
libMesh::System::vectors_end
vectors_iterator vectors_end()
End of vectors container.
Definition: system.h:2307
libMesh::NumericVector::localize
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.
libMesh::NumericVector::subset_l2_norm
virtual Real subset_l2_norm(const std::set< numeric_index_type > &indices) const
Definition: numeric_vector.C:327
libMesh::System::qoi
std::vector< Number > qoi
Values of the quantities of interest.
Definition: system.h:1574
libMesh::System::vectors_begin
vectors_iterator vectors_begin()
Beginning of vectors container.
Definition: system.h:2295
libMesh::FEMap::inverse_map
static Point inverse_map(const unsigned int dim, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true)
Definition: fe_map.C:1622
libMesh::System::_mesh
MeshBase & _mesh
Constant reference to the mesh data structure used for the simulation.
Definition: system.h:1946
libMesh::System::user_QOI
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.
Definition: system.C:1938
libMesh::System::_variables
std::vector< Variable > _variables
The Variable in this System.
Definition: system.h:1961
libMesh::ParallelObject::n_processors
processor_id_type n_processors() const
Definition: parallel_object.h:100
libMesh::System::n_local_dofs
dof_id_type n_local_dofs() const
Definition: system.C:187
libMesh::System::variable_scalar_number
unsigned int variable_scalar_number(const std::string &var, unsigned int component) const
Definition: system.h:2214
libMesh::System::_qoi_evaluate_derivative_function
void(* _qoi_evaluate_derivative_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
Function to evaluate quantity of interest derivative.
Definition: system.h:1919
libMesh::System::variable_group
const VariableGroup & variable_group(unsigned int vg) const
Return a constant reference to VariableGroup vg.
Definition: system.h:2193
libMesh::FEBase
FEGenericBase< Real > FEBase
Definition: exact_error_estimator.h:39
libMesh::Utility::iota
void iota(ForwardIter first, ForwardIter last, T value)
Utility::iota is a duplication of the SGI STL extension std::iota.
Definition: utility.h:105
libMesh::Threads::spin_mtx
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.
Definition: threads.C:29
libMesh::System::set_vector_as_adjoint
void set_vector_as_adjoint(const std::string &vec_name, int qoi_num)
Allows one to set the QoI index controlling whether the vector identified by vec_name represents a so...
Definition: system.C:873
libMesh::System::get_mesh
const MeshBase & get_mesh() const
Definition: system.h:2083
libMesh::ParallelObject::processor_id
processor_id_type processor_id() const
Definition: parallel_object.h:106
libMesh::System::n_local_constrained_dofs
dof_id_type n_local_constrained_dofs() const
Definition: system.C:172
libMesh::libmesh_ignore
void libmesh_ignore(const Args &...)
Definition: libmesh_common.h:526
libMesh::DofMap::enforce_constraints_exactly
void enforce_constraints_exactly(const System &system, NumericVector< Number > *v=nullptr, bool homogeneous=false) const
Constrains the numeric vector v, which represents a solution defined on the mesh.
Definition: dof_map.h:2054
libMesh::FEGenericBase::build
static std::unique_ptr< FEGenericBase > build(const unsigned int dim, const FEType &type)
Builds a specific finite element type.
libMesh::DofObject::invalid_id
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition: dof_object.h:421
libMesh::System::add_variable
unsigned int add_variable(const std::string &var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system.
Definition: system.C:1069
libMesh::System::current_local_solution
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Definition: system.h:1551
libMesh::System::Constraint::constrain
virtual void constrain()=0
Constraint function.
libMesh::ParallelObject::_communicator
const Parallel::Communicator & _communicator
Definition: parallel_object.h:112
libMesh::ConstElemRange
StoredRange< MeshBase::const_element_iterator, const Elem * > ConstElemRange
Definition: elem_range.h:34
libMesh::processor_id_type
uint8_t processor_id_type
Definition: id_types.h:104
libMesh::TypeVector::add_scaled
void add_scaled(const TypeVector< T2 > &, const T &)
Add a scaled value to this vector without creating a temporary.
Definition: type_vector.h:665
libMesh::MeshBase::elem_dimensions
const std::set< unsigned char > & elem_dimensions() const
Definition: mesh_base.h:225
libMesh::System::write_SCALAR_dofs
unsigned int write_SCALAR_dofs(const NumericVector< Number > &vec, const unsigned int var, Xdr &io) const
Writes the SCALAR dofs associated with var to the stream io.
Definition: system_io.C:2097
libMesh::System::_sys_number
const unsigned int _sys_number
The number associated with this system.
Definition: system.h:1956
libMesh::MeshTools::Generation::Private::idx
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)
A useful inline function which replaces the macros used previously.
Definition: mesh_generation.C:72
libMesh::TypeTensor::add_scaled
void add_scaled(const TypeTensor< T2 > &, const T &)
Add a scaled tensor to this tensor without creating a temporary.
Definition: type_tensor.h:869
libMesh::Threads::parallel_reduce
void parallel_reduce(const Range &range, Body &body)
Execute the provided reduction operation in parallel on the specified range.
Definition: threads_none.h:101
libMesh::NumericVector::local_size
virtual numeric_index_type local_size() const =0
libMesh::System::_written_var_indices
std::vector< unsigned int > _written_var_indices
This vector is used only when reading in a system from file.
Definition: system.h:2046
libMesh::DofMap::variable_type
const FEType & variable_type(const unsigned int c) const
Definition: dof_map.h:1924
n_nodes
const dof_id_type n_nodes
Definition: tecplot_io.C:68
gptr
Gradient gptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:95
libMesh::NumericVector::l1_norm
virtual Real l1_norm() const =0
libMesh::DofMap::get_send_list
const std::vector< dof_id_type > & get_send_list() const
Definition: dof_map.h:496
libMesh::H2_SEMINORM
Definition: enum_norm_type.h:44
libMesh::NumericVector::clear
virtual void clear()
Restores the NumericVector<T> to a pristine state.
Definition: numeric_vector.h:811
libMesh::System::_additional_data_written
unsigned int _additional_data_written
This flag is used only when reading in a system from file.
Definition: system.h:2034
libMesh::System::Assembly::assemble
virtual void assemble()=0
Assembly function.
libMesh::MONOMIAL
Definition: enum_fe_family.h:39
libMesh::System::_assemble_system_object
Assembly * _assemble_system_object
Object that assembles the system.
Definition: system.h:1891
libMesh::DofMap::create_dof_constraints
void create_dof_constraints(const MeshBase &, Real time=0)
Rebuilds the raw degree of freedom and DofObject constraints.
Definition: dof_map_constraints.C:1206
libMesh::System::time
Real time
For time-dependent problems, this is the time t at the beginning of the current timestep.
Definition: system.h:1561
libMesh::NumericVector::linfty_norm
virtual Real linfty_norm() const =0
libMesh::System::variable_type
const FEType & variable_type(const unsigned int i) const
Definition: system.h:2233
libMesh::MeshBase::n_nodes
virtual dof_id_type n_nodes() const =0
libMesh::System::adjoint_already_solved
bool adjoint_already_solved
Has the adjoint problem already been solved? If the user sets adjoint_already_solved to true,...
Definition: system.h:2053
libMesh::System::discrete_var_norm
Real discrete_var_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type) const
Finds the discrete norm for the entries in the vector corresponding to Dofs associated with var.
Definition: system.C:1337
libMesh::System::_constrain_system_object
Constraint * _constrain_system_object
Object that constrains the system.
Definition: system.h:1902
libMesh::Gradient
NumberVectorValue Gradient
Definition: exact_solution.h:58
libMesh::System::solution
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1539
libMesh::ReferenceElem::get
const Elem & get(const ElemType type_in)
Definition: reference_elem.C:237
libMesh::TensorTools::norm_sq
T norm_sq(std::complex< T > a)
Definition: tensor_tools.h:85
libMesh::System::point_value
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:1971
libMesh::FEType::order
OrderWrapper order
The approximation order of the element.
Definition: fe_type.h:197
libMesh::DISCRETE_L1
Definition: enum_norm_type.h:52
libMesh::NumericVector::set
virtual void set(const numeric_index_type i, const T value)=0
Sets v(i) = value.
libMesh::System::_qoi_evaluate_derivative_object
QOIDerivative * _qoi_evaluate_derivative_object
Object to compute derivatives of quantities of interest.
Definition: system.h:1928
libMesh::System::name
const std::string & name() const
Definition: system.h:2067
libMesh::System::init_data
virtual void init_data()
Initializes the data for the system.
Definition: system.C:262
libMesh::System::n_constrained_dofs
dof_id_type n_constrained_dofs() const
Definition: system.C:157
libMesh::L2
Definition: enum_norm_type.h:36
libMesh::System::variable_number
unsigned short int variable_number(const std::string &var) const
Definition: system.C:1232
libMesh::System::write_serialized_blocked_dof_objects
std::size_t write_serialized_blocked_dof_objects(const std::vector< const NumericVector< Number > * > &vecs, const dof_id_type n_objects, const iterator_type begin, const iterator_type end, Xdr &io, const unsigned int var_to_write=libMesh::invalid_uint) const
Writes an output vector to the stream io for a set of DofObjects.
Definition: system_io.C:1811
libMesh::NumericVector::l2_norm
virtual Real l2_norm() const =0
libMesh::on_command_line
bool on_command_line(std::string arg)
Definition: libmesh.C:898
std::norm
MetaPhysicL::DualNumber< T, D > norm(const MetaPhysicL::DualNumber< T, D > &in)
libMesh::System::_equation_systems
EquationSystems & _equation_systems
Constant reference to the EquationSystems object used for the simulation.
Definition: system.h:1940
libMesh::System::calculate_norm
Real calculate_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=nullptr) const
Definition: system.C:1356
libMesh::System::clear
virtual void clear()
Clear all the data structures associated with the system.
Definition: system.C:205
libMesh::System::forward_qoi_parameter_sensitivity
virtual void forward_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
Solves for parameter sensitivities using the forward method.
Definition: system.h:2375
libMesh::System::add_vector
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Adds the additional vector vec_name to this system.
Definition: system.C:661
libMesh::ParallelType
ParallelType
Defines an enum for parallel data structure types.
Definition: enum_parallel_type.h:33
libMesh::NumericVector::get
virtual void get(const std::vector< numeric_index_type > &index, T *values) const
Access multiple components at once.
Definition: numeric_vector.h:821
libMesh::System::get_dof_map
const DofMap & get_dof_map() const
Definition: system.h:2099
libMesh::System::n_dofs
dof_id_type n_dofs() const
Definition: system.C:150
libMesh::System::user_initialization
virtual void user_initialization()
Calls user's attached initialization function, or is overridden by the user in derived classes.
Definition: system.C:1896
libMesh::SparseMatrix::set
virtual void set(const numeric_index_type i, const numeric_index_type j, const T value)=0
Set the element (i,j) to value.
libMesh::System::_qoi_evaluate_object
QOI * _qoi_evaluate_object
Object to compute quantities of interest.
Definition: system.h:1914
libMesh::SCALAR
Definition: enum_fe_family.h:58
libMesh::H1
Definition: enum_norm_type.h:37
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121
libMesh::System::user_constrain
virtual void user_constrain()
Calls user's attached constraint function, or is overridden by the user in derived classes.
Definition: system.C:1924
libMesh::ReferenceCounter::_enable_print_counter
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called.
Definition: reference_counter.h:141
libMesh::System::project_solution
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr) const
Projects arbitrary functions onto the current solution.
Definition: system_projection.C:950
libMesh::Tensor
NumberTensorValue Tensor
Definition: exact_solution.h:56
fptr
Number fptr(const Point &p, const Parameters &, const std::string &libmesh_dbg_var(sys_name), const std::string &unknown_name)
Definition: projection.C:80
libMesh::System::Initialization::initialize
virtual void initialize()=0
Initialization function.
libMesh::out
OStreamProxy out
libMesh::System::user_QOI_derivative
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 deriv...
Definition: system.C:1952
libMesh::NumericVector::subset_l1_norm
virtual Real subset_l1_norm(const std::set< numeric_index_type > &indices) const
Definition: numeric_vector.C:312
libMesh::System::get_vector
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:774
libMesh::System::_variable_numbers
std::map< std::string, unsigned short int > _variable_numbers
The variable numbers corresponding to user-specified names, useful for name-based lookups.
Definition: system.h:1972
libMesh::NumericVector::type
ParallelType type() const
Definition: numeric_vector.h:160
libMesh::System::_solution_projection
bool _solution_projection
Holds true if the solution vector should be projected onto a changed grid, false if it should be zero...
Definition: system.h:2009
libMesh::System::point_gradient
Gradient point_gradient(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:2100
libMesh::Quality::name
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42
libMesh::System::point_hessian
Tensor point_hessian(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
Definition: system.C:2244
libMesh::System::_sys_name
const std::string _sys_name
A name associated with this system.
Definition: system.h:1951
libMesh::System::const_vectors_iterator
std::map< std::string, NumericVector< Number > * >::const_iterator const_vectors_iterator
Definition: system.h:757
libMesh::System::adjoint_qoi_parameter_sensitivity
virtual void adjoint_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
Solves for parameter sensitivities using the adjoint method.
Definition: system.h:2366
libMesh::DofMap::variable_group
const VariableGroup & variable_group(const unsigned int c) const
Definition: dof_map.h:1884
libMesh::closed
bool closed()
Checks that the library has been closed.
Definition: libmesh.C:272
libMesh::DofMap::end_dof
dof_id_type end_dof(const processor_id_type proc) const
Definition: dof_map.h:692
libMesh::FEInterface::compute_data
static void compute_data(const unsigned int dim, const FEType &fe_t, const Elem *elem, FEComputeData &data)
Lets the appropriate child of FEBase compute the requested data for the input specified in data,...
Definition: fe_interface.C:1028
libMesh::System::_vector_is_adjoint
std::map< std::string, int > _vector_is_adjoint
Holds non-negative if a vector by that name should be projected using adjoint constraints/BCs,...
Definition: system.h:1997