libMesh::System Class Reference

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

#include <system.h>

Inheritance diagram for libMesh::System:

Classes

class  Assembly
 
class  Constraint
 
class  Initialization
 
class  QOI
 
class  QOIDerivative
 

Public Types

typedef System sys_type
 
typedef Number(* ValueFunctionPointer) (const Point &p, const Parameters &Parameters, const std::string &sys_name, const std::string &unknown_name)
 
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
 
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)
 
virtual ~System ()
 
sys_typesystem ()
 
virtual void clear ()
 
void init ()
 
virtual void reinit ()
 
virtual void reinit_constraints ()
 
bool is_initialized ()
 
virtual void update ()
 
virtual void assemble ()
 
virtual void assemble_qoi (const QoISet &qoi_indices=QoISet())
 
virtual void assemble_qoi_derivative (const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true)
 
virtual void assemble_residual_derivatives (const ParameterVector &parameters)
 
virtual void restrict_solve_to (const SystemSubset *subset, const SubsetSolveMode subset_solve_mode=SUBSET_ZERO)
 
virtual void solve ()
 
virtual std::pair< unsigned int, Realsensitivity_solve (const ParameterVector &parameters)
 
virtual std::pair< unsigned int, Realweighted_sensitivity_solve (const ParameterVector &parameters, const ParameterVector &weights)
 
virtual std::pair< unsigned int, Realadjoint_solve (const QoISet &qoi_indices=QoISet())
 
virtual std::pair< unsigned int, Realweighted_sensitivity_adjoint_solve (const ParameterVector &parameters, const ParameterVector &weights, const QoISet &qoi_indices=QoISet())
 
bool is_adjoint_already_solved () const
 
void set_adjoint_already_solved (bool setting)
 
virtual void qoi_parameter_sensitivity (const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
 
virtual void adjoint_qoi_parameter_sensitivity (const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
 
virtual void forward_qoi_parameter_sensitivity (const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
 
virtual void qoi_parameter_hessian (const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &hessian)
 
virtual void qoi_parameter_hessian_vector_product (const QoISet &qoi_indices, const ParameterVector &parameters, const ParameterVector &vector, SensitivityData &product)
 
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
 
void project_solution (FEMFunctionBase< Number > *f, FEMFunctionBase< Gradient > *g=nullptr) const
 
void project_solution (ValueFunctionPointer fptr, GradientFunctionPointer gptr, const Parameters &parameters) const
 
void project_vector (NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
 
void project_vector (NumericVector< Number > &new_vector, FEMFunctionBase< Number > *f, FEMFunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
 
void project_vector (ValueFunctionPointer fptr, GradientFunctionPointer gptr, const Parameters &parameters, NumericVector< Number > &new_vector, int is_adjoint=-1) const
 
void boundary_project_solution (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr)
 
void boundary_project_solution (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, ValueFunctionPointer fptr, GradientFunctionPointer gptr, const Parameters &parameters)
 
void boundary_project_vector (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
 
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
 
unsigned int number () const
 
void update_global_solution (std::vector< Number > &global_soln) const
 
void update_global_solution (std::vector< Number > &global_soln, const processor_id_type dest_proc) const
 
const MeshBaseget_mesh () const
 
MeshBaseget_mesh ()
 
const DofMapget_dof_map () const
 
DofMapget_dof_map ()
 
const EquationSystemsget_equation_systems () const
 
EquationSystemsget_equation_systems ()
 
bool active () const
 
void activate ()
 
void deactivate ()
 
void set_basic_system_only ()
 
vectors_iterator vectors_begin ()
 
const_vectors_iterator vectors_begin () const
 
vectors_iterator vectors_end ()
 
const_vectors_iterator vectors_end () const
 
NumericVector< Number > & add_vector (const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
 
void remove_vector (const std::string &vec_name)
 
bool & project_solution_on_reinit (void)
 
bool have_vector (const std::string &vec_name) const
 
const NumericVector< Number > * request_vector (const std::string &vec_name) const
 
NumericVector< Number > * request_vector (const std::string &vec_name)
 
const NumericVector< Number > * request_vector (const unsigned int vec_num) const
 
NumericVector< Number > * request_vector (const unsigned int vec_num)
 
const NumericVector< Number > & get_vector (const std::string &vec_name) const
 
NumericVector< Number > & get_vector (const std::string &vec_name)
 
const NumericVector< Number > & get_vector (const unsigned int vec_num) const
 
NumericVector< Number > & get_vector (const unsigned int vec_num)
 
const std::string & vector_name (const unsigned int vec_num) const
 
const std::string & vector_name (const NumericVector< Number > &vec_reference) const
 
void set_vector_as_adjoint (const std::string &vec_name, int qoi_num)
 
int vector_is_adjoint (const std::string &vec_name) const
 
void set_vector_preservation (const std::string &vec_name, bool preserve)
 
bool vector_preservation (const std::string &vec_name) const
 
NumericVector< Number > & add_adjoint_solution (unsigned int i=0)
 
NumericVector< Number > & get_adjoint_solution (unsigned int i=0)
 
const NumericVector< Number > & get_adjoint_solution (unsigned int i=0) const
 
NumericVector< Number > & add_sensitivity_solution (unsigned int i=0)
 
NumericVector< Number > & get_sensitivity_solution (unsigned int i=0)
 
const NumericVector< Number > & get_sensitivity_solution (unsigned int i=0) const
 
NumericVector< Number > & add_weighted_sensitivity_adjoint_solution (unsigned int i=0)
 
NumericVector< Number > & get_weighted_sensitivity_adjoint_solution (unsigned int i=0)
 
const NumericVector< Number > & get_weighted_sensitivity_adjoint_solution (unsigned int i=0) const
 
NumericVector< Number > & add_weighted_sensitivity_solution ()
 
NumericVector< Number > & get_weighted_sensitivity_solution ()
 
const NumericVector< Number > & get_weighted_sensitivity_solution () const
 
NumericVector< Number > & add_adjoint_rhs (unsigned int i=0)
 
NumericVector< Number > & get_adjoint_rhs (unsigned int i=0)
 
const NumericVector< Number > & get_adjoint_rhs (unsigned int i=0) const
 
NumericVector< Number > & add_sensitivity_rhs (unsigned int i=0)
 
NumericVector< Number > & get_sensitivity_rhs (unsigned int i=0)
 
const NumericVector< Number > & get_sensitivity_rhs (unsigned int i=0) const
 
unsigned int n_vectors () const
 
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)
 
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)
 
unsigned int add_variables (const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
 
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)
 
const Variablevariable (unsigned int var) const
 
const VariableGroupvariable_group (unsigned int vg) const
 
bool has_variable (const std::string &var) const
 
const std::string & variable_name (const unsigned int i) const
 
unsigned short int variable_number (const std::string &var) const
 
void get_all_variable_numbers (std::vector< unsigned int > &all_variable_numbers) const
 
unsigned int variable_scalar_number (const std::string &var, unsigned int component) const
 
unsigned int variable_scalar_number (unsigned int var_num, unsigned int component) const
 
const FETypevariable_type (const unsigned int i) const
 
const FETypevariable_type (const std::string &var) const
 
bool identify_variable_groups () const
 
void identify_variable_groups (const bool)
 
Real calculate_norm (const NumericVector< Number > &v, unsigned int var, 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)
 
void read_legacy_data (Xdr &io, const bool read_additional_data=true)
 
template<typename ValType >
void read_serialized_data (Xdr &io, const bool read_additional_data=true)
 
void read_serialized_data (Xdr &io, const bool read_additional_data=true)
 
template<typename InValType >
std::size_t read_serialized_vectors (Xdr &io, const std::vector< NumericVector< Number > *> &vectors) const
 
std::size_t read_serialized_vectors (Xdr &io, const std::vector< NumericVector< Number > *> &vectors) const
 
template<typename InValType >
void read_parallel_data (Xdr &io, const bool read_additional_data)
 
void read_parallel_data (Xdr &io, const bool read_additional_data)
 
void write_header (Xdr &io, const std::string &version, const bool write_additional_data) const
 
void write_serialized_data (Xdr &io, const bool write_additional_data=true) const
 
std::size_t write_serialized_vectors (Xdr &io, const std::vector< const NumericVector< Number > *> &vectors) const
 
void write_parallel_data (Xdr &io, const bool write_additional_data) const
 
std::string get_info () const
 
void attach_init_function (void fptr(EquationSystems &es, const std::string &name))
 
void attach_init_object (Initialization &init)
 
void attach_assemble_function (void fptr(EquationSystems &es, const std::string &name))
 
void attach_assemble_object (Assembly &assemble)
 
void attach_constraint_function (void fptr(EquationSystems &es, const std::string &name))
 
void attach_constraint_object (Constraint &constrain)
 
void attach_QOI_function (void fptr(EquationSystems &es, const std::string &name, const QoISet &qoi_indices))
 
void attach_QOI_object (QOI &qoi)
 
void attach_QOI_derivative (void fptr(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints))
 
void attach_QOI_derivative_object (QOIDerivative &qoi_derivative)
 
virtual void user_initialization ()
 
virtual void user_assembly ()
 
virtual void user_constrain ()
 
virtual void user_QOI (const QoISet &qoi_indices)
 
virtual void user_QOI_derivative (const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true)
 
virtual void re_update ()
 
virtual void restrict_vectors ()
 
virtual void prolong_vectors ()
 
virtual void disable_cache ()
 
Number current_solution (const dof_id_type global_dof_number) const
 
unsigned int n_qois () const
 
Number point_value (unsigned int var, const Point &p, const bool insist_on_success=true) const
 
Number point_value (unsigned int var, const Point &p, const Elem &e) const
 
Number point_value (unsigned int var, const Point &p, const Elem *e) const
 
Gradient point_gradient (unsigned int var, const Point &p, const bool insist_on_success=true) const
 
Gradient point_gradient (unsigned int var, const Point &p, const Elem &e) const
 
Gradient point_gradient (unsigned int var, const Point &p, const Elem *e) const
 
Tensor point_hessian (unsigned int var, const Point &p, const bool insist_on_success=true) const
 
Tensor point_hessian (unsigned int var, const Point &p, const Elem &e) const
 
Tensor point_hessian (unsigned int var, const Point &p, const Elem *e) const
 
void local_dof_indices (const unsigned int var, std::set< dof_id_type > &var_indices) const
 
void zero_variable (NumericVector< Number > &v, unsigned int var_num) const
 
bool & hide_output ()
 
void projection_matrix (SparseMatrix< Number > &proj_mat) const
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

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

Public Attributes

bool assemble_before_solve
 
bool use_fixed_solution
 
int extra_quadrature_order
 
std::unique_ptr< NumericVector< Number > > solution
 
std::unique_ptr< NumericVector< Number > > current_local_solution
 
Real time
 
std::vector< Numberqoi
 

Protected Types

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

Protected Member Functions

virtual void init_data ()
 
void project_vector (NumericVector< Number > &, int is_adjoint=-1) const
 
void project_vector (const NumericVector< Number > &, NumericVector< Number > &, int is_adjoint=-1) const
 
void increment_constructor_count (const std::string &name)
 
void increment_destructor_count (const std::string &name)
 

Protected Attributes

const Parallel::Communicator_communicator
 

Static Protected Attributes

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

Private Member Functions

 System (const System &)
 
Systemoperator= (const System &)
 
Real discrete_var_norm (const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type) const
 
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
 
unsigned int read_SCALAR_dofs (const unsigned int var, Xdr &io, NumericVector< Number > *vec) const
 
template<typename InValType >
numeric_index_type read_serialized_vector (Xdr &io, NumericVector< Number > *vec)
 
numeric_index_type read_serialized_vector (Xdr &io, NumericVector< Number > &vec)
 
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
 
unsigned int write_SCALAR_dofs (const NumericVector< Number > &vec, const unsigned int var, Xdr &io) const
 
dof_id_type write_serialized_vector (Xdr &io, const NumericVector< Number > &vec) const
 

Private Attributes

void(* _init_system_function )(EquationSystems &es, const std::string &name)
 
Initialization_init_system_object
 
void(* _assemble_system_function )(EquationSystems &es, const std::string &name)
 
Assembly_assemble_system_object
 
void(* _constrain_system_function )(EquationSystems &es, const std::string &name)
 
Constraint_constrain_system_object
 
void(* _qoi_evaluate_function )(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
 
QOI_qoi_evaluate_object
 
void(* _qoi_evaluate_derivative_function )(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
 
QOIDerivative_qoi_evaluate_derivative_object
 
std::unique_ptr< DofMap_dof_map
 
EquationSystems_equation_systems
 
MeshBase_mesh
 
const std::string _sys_name
 
const unsigned int _sys_number
 
std::vector< Variable_variables
 
std::vector< VariableGroup_variable_groups
 
std::map< std::string, unsigned short int > _variable_numbers
 
bool _active
 
std::map< std::string, NumericVector< Number > *> _vectors
 
std::map< std::string, bool > _vector_projections
 
std::map< std::string, int > _vector_is_adjoint
 
std::map< std::string, ParallelType_vector_types
 
bool _solution_projection
 
bool _basic_system_only
 
bool _is_initialized
 
bool _identify_variable_groups
 
unsigned int _additional_data_written
 
std::vector< unsigned int > _written_var_indices
 
bool adjoint_already_solved
 
bool _hide_output
 

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 92 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 749 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 524 of file system.h.

◆ sys_type

The type of system.

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

◆ vectors_iterator

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

Vector iterator typedefs.

Definition at line 748 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 (new 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 }
ParallelObject(const Parallel::Communicator &comm_in)
Assembly * _assemble_system_object
Definition: system.h:1841
bool _basic_system_only
Definition: system.h:1965
bool _is_initialized
Definition: system.h:1971
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1846
int extra_quadrature_order
Definition: system.h:1508
const unsigned int _sys_number
Definition: system.h:1906
Constraint * _constrain_system_object
Definition: system.h:1852
std::unique_ptr< DofMap > _dof_map
Definition: system.h:1884
const Parallel::Communicator & comm() const
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Definition: system.h:1857
bool adjoint_already_solved
Definition: system.h:2003
QOIDerivative * _qoi_evaluate_derivative_object
Definition: system.h:1878
std::vector< Number > qoi
Definition: system.h:1558
bool use_fixed_solution
Definition: system.h:1493
std::unique_ptr< NumericVector< Number > > solution
Definition: system.h:1523
QOI * _qoi_evaluate_object
Definition: system.h:1864
Initialization * _init_system_object
Definition: system.h:1830
bool _hide_output
Definition: system.h:2009
unsigned int _additional_data_written
Definition: system.h:1984
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1824
static std::unique_ptr< NumericVector< Number > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
bool _solution_projection
Definition: system.h:1959
EquationSystems & _equation_systems
Definition: system.h:1890
bool _identify_variable_groups
Definition: system.h:1977
const std::string _sys_name
Definition: system.h:1901
std::unique_ptr< NumericVector< Number > > current_local_solution
Definition: system.h:1535
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1835
bool assemble_before_solve
Definition: system.h:1477
MeshBase & _mesh
Definition: system.h:1896
void(* _qoi_evaluate_derivative_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
Definition: system.h:1869

◆ ~System()

libMesh::System::~System ( )
virtual

Destructor.

Definition at line 120 of file system.C.

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

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 }
bool closed()
Definition: libmesh.C:265
virtual void clear()
Definition: system.C:205
Assembly * _assemble_system_object
Definition: system.h:1841
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1846
Constraint * _constrain_system_object
Definition: system.h:1852
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Definition: system.h:1857
QOIDerivative * _qoi_evaluate_derivative_object
Definition: system.h:1878
QOI * _qoi_evaluate_object
Definition: system.h:1864
Initialization * _init_system_object
Definition: system.h:1830
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1824
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1835
void(* _qoi_evaluate_derivative_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
Definition: system.h:1869

◆ 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 }
ParallelObject(const Parallel::Communicator &comm_in)
const unsigned int _sys_number
Definition: system.h:1906
EquationSystems & _equation_systems
Definition: system.h:1890
MeshBase & _mesh
Definition: system.h:1896

Member Function Documentation

◆ activate()

void libMesh::System::activate ( )
inline

Activates the system. Only active systems are solved.

Definition at line 2073 of file system.h.

References _active.

2074 {
2075  _active = true;
2076 }

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

References _active.

2066 {
2067  return _active;
2068 }

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

References add_vector().

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

1022 {
1023  std::ostringstream adjoint_rhs_name;
1024  adjoint_rhs_name << "adjoint_rhs" << i;
1025 
1026  return this->add_vector(adjoint_rhs_name.str(), false);
1027 }
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Definition: system.C:661

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

References add_vector(), and set_vector_as_adjoint().

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

958 {
959  std::ostringstream adjoint_name;
960  adjoint_name << "adjoint_solution" << i;
961 
962  NumericVector<Number> & returnval = this->add_vector(adjoint_name.str());
963  this->set_vector_as_adjoint(adjoint_name.str(), i);
964  return returnval;
965 }
void set_vector_as_adjoint(const std::string &vec_name, int qoi_num)
Definition: system.C:885
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Definition: system.C:661

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

References add_vector().

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

1052 {
1053  std::ostringstream sensitivity_rhs_name;
1054  sensitivity_rhs_name << "sensitivity_rhs" << i;
1055 
1056  return this->add_vector(sensitivity_rhs_name.str(), false);
1057 }
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Definition: system.C:661

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

References add_vector().

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

907 {
908  std::ostringstream sensitivity_name;
909  sensitivity_name << "sensitivity_solution" << i;
910 
911  return this->add_vector(sensitivity_name.str());
912 }
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Definition: system.C:661

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

Returns
The index number for the new variable.

Definition at line 1081 of file system.C.

References _variable_groups, _variable_numbers, _variables, add_variables(), libMesh::VariableGroup::append(), identify_variable_groups(), is_initialized(), n_variable_groups(), n_vars(), number(), variable_name(), and variable_type().

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

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

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

Definition at line 1159 of file system.C.

References add_variable().

1163 {
1164  return this->add_variable(var,
1165  FEType(order, family),
1166  active_subdomains);
1167 }
unsigned int add_variable(const std::string &var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Definition: system.C:1081

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

Returns
The index number for the new variable.

Definition at line 1171 of file system.C.

References _variable_groups, _variable_numbers, _variables, is_initialized(), n_components(), n_vars(), number(), variable_name(), and variable_type().

Referenced by add_variable(), and add_variables().

1174 {
1175  libmesh_assert(!this->is_initialized());
1176 
1177  // Make sure the variable isn't there already
1178  // or if it is, that it's the type we want
1179  for (std::size_t ov=0; ov<vars.size(); ov++)
1180  for (unsigned int v=0; v<this->n_vars(); v++)
1181  if (this->variable_name(v) == vars[ov])
1182  {
1183  if (this->variable_type(v) == type)
1184  return _variables[v].number();
1185 
1186  libmesh_error_msg("ERROR: incompatible variable " << vars[ov] << " has already been added for this system!");
1187  }
1188 
1189  const unsigned short curr_n_vars = cast_int<unsigned short>
1190  (this->n_vars());
1191 
1192  const unsigned int next_first_component = this->n_components();
1193 
1194  // Add the variable group to the list
1195  _variable_groups.push_back((active_subdomains == nullptr) ?
1196  VariableGroup(this, vars, curr_n_vars,
1197  next_first_component, type) :
1198  VariableGroup(this, vars, curr_n_vars,
1199  next_first_component, type, *active_subdomains));
1200 
1201  const VariableGroup & vg (_variable_groups.back());
1202 
1203  // Add each component of the group individually
1204  for (auto v : IntRange<unsigned int>(0, vars.size()))
1205  {
1206  _variables.push_back (vg(v));
1207  _variable_numbers[vars[v]] = cast_int<unsigned short>
1208  (curr_n_vars+v);
1209  }
1210 
1211  libmesh_assert_equal_to ((curr_n_vars+vars.size()), this->n_vars());
1212 
1213  // BSK - Defer this now to System::init_data() so we can detect
1214  // VariableGroups 12/28/2012
1215  // // Add the variable group to the _dof_map
1216  // _dof_map->add_variable_group (vg);
1217 
1218  // Return the number of the new variable
1219  return cast_int<unsigned int>(curr_n_vars+vars.size()-1);
1220 }
std::map< std::string, unsigned short int > _variable_numbers
Definition: system.h:1922
unsigned int n_components() const
Definition: system.h:2121
std::vector< Variable > _variables
Definition: system.h:1911
unsigned int number() const
Definition: system.h:2025
std::vector< VariableGroup > _variable_groups
Definition: system.h:1916
bool is_initialized()
Definition: system.h:2089
const std::string & variable_name(const unsigned int i) const
Definition: system.h:2153
const FEType & variable_type(const unsigned int i) const
Definition: system.h:2183
unsigned int n_vars() const
Definition: system.h:2105

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

Definition at line 1224 of file system.C.

References add_variables().

1228 {
1229  return this->add_variables(vars,
1230  FEType(order, family),
1231  active_subdomains);
1232 }
unsigned int add_variables(const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Definition: system.C:1171

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

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(), libMesh::NewmarkSystem::NewmarkSystem(), read_header(), libMesh::FrequencySystem::set_frequencies(), libMesh::FrequencySystem::set_frequencies_by_range(), and libMesh::FrequencySystem::set_frequencies_by_steps().

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 }
std::map< std::string, ParallelType > _vector_types
Definition: system.h:1952
bool _is_initialized
Definition: system.h:1971
std::unique_ptr< DofMap > _dof_map
Definition: system.h:1884
const Parallel::Communicator & comm() const
dof_id_type n_local_dofs() const
Definition: system.C:187
dof_id_type n_dofs() const
Definition: system.C:150
std::map< std::string, int > _vector_is_adjoint
Definition: system.h:1947
bool have_vector(const std::string &vec_name) const
Definition: system.h:2225
static std::unique_ptr< NumericVector< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
std::map< std::string, NumericVector< Number > *> _vectors
Definition: system.h:1935
std::map< std::string, bool > _vector_projections
Definition: system.h:1941

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

References add_vector(), and set_vector_as_adjoint().

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

990 {
991  std::ostringstream adjoint_name;
992  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
993 
994  NumericVector<Number> & returnval = this->add_vector(adjoint_name.str());
995  this->set_vector_as_adjoint(adjoint_name.str(), i);
996  return returnval;
997 }
void set_vector_as_adjoint(const std::string &vec_name, int qoi_num)
Definition: system.C:885
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Definition: system.C:661

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

References add_vector().

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

937 {
938  return this->add_vector("weighted_sensitivity_solution");
939 }
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Definition: system.C:661

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

Referenced by qoi_parameter_sensitivity().

2319 {
2320  libmesh_not_implemented();
2321 }

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

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

2301 {
2302  libmesh_not_implemented();
2303 }

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

Definition at line 462 of file system.C.

References user_assembly().

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

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 }
virtual void user_assembly()
Definition: system.C:1932

◆ assemble_qoi()

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

Calls user qoi function. Can be overridden in derived classes.

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

Definition at line 473 of file system.C.

References user_QOI().

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

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 }
virtual void user_QOI(const QoISet &qoi_indices)
Definition: system.C:1960

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

References user_QOI_derivative().

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

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 }
virtual void user_QOI_derivative(const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true)
Definition: system.C:1974

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

2270 {
2271  libmesh_not_implemented();
2272 }

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

References _assemble_system_function, _assemble_system_object, and libMesh::out.

1779 {
1780  libmesh_assert(fptr);
1781 
1782  if (_assemble_system_object != nullptr)
1783  {
1784  libmesh_here();
1785  libMesh::out << "WARNING: Cannot specify both assembly function and object!"
1786  << std::endl;
1787 
1788  _assemble_system_object = nullptr;
1789  }
1790 
1792 }
Assembly * _assemble_system_object
Definition: system.h:1841
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1835
OStreamProxy out(std::cout)

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

References _assemble_system_function, _assemble_system_object, and libMesh::out.

1797 {
1798  if (_assemble_system_function != nullptr)
1799  {
1800  libmesh_here();
1801  libMesh::out << "WARNING: Cannot specify both assembly object and function!"
1802  << std::endl;
1803 
1804  _assemble_system_function = nullptr;
1805  }
1806 
1807  _assemble_system_object = &assemble_in;
1808 }
Assembly * _assemble_system_object
Definition: system.h:1841
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1835
OStreamProxy out(std::cout)

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

References _constrain_system_function, _constrain_system_object, and libMesh::out.

1814 {
1815  libmesh_assert(fptr);
1816 
1817  if (_constrain_system_object != nullptr)
1818  {
1819  libmesh_here();
1820  libMesh::out << "WARNING: Cannot specify both constraint function and object!"
1821  << std::endl;
1822 
1823  _constrain_system_object = nullptr;
1824  }
1825 
1827 }
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1846
Constraint * _constrain_system_object
Definition: system.h:1852
OStreamProxy out(std::cout)

◆ attach_constraint_object()

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

Register a user object for imposing constraints.

Definition at line 1831 of file system.C.

References _constrain_system_function, _constrain_system_object, and libMesh::out.

1832 {
1833  if (_constrain_system_function != nullptr)
1834  {
1835  libmesh_here();
1836  libMesh::out << "WARNING: Cannot specify both constraint object and function!"
1837  << std::endl;
1838 
1839  _constrain_system_function = nullptr;
1840  }
1841 
1842  _constrain_system_object = &constrain;
1843 }
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1846
Constraint * _constrain_system_object
Definition: system.h:1852
OStreamProxy out(std::cout)

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

References _init_system_function, _init_system_object, and libMesh::out.

1744 {
1745  libmesh_assert(fptr);
1746 
1747  if (_init_system_object != nullptr)
1748  {
1749  libmesh_here();
1750  libMesh::out << "WARNING: Cannot specify both initialization function and object!"
1751  << std::endl;
1752 
1753  _init_system_object = nullptr;
1754  }
1755 
1756  _init_system_function = fptr;
1757 }
Initialization * _init_system_object
Definition: system.h:1830
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1824
OStreamProxy out(std::cout)

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

References _init_system_function, _init_system_object, and libMesh::out.

1762 {
1763  if (_init_system_function != nullptr)
1764  {
1765  libmesh_here();
1766  libMesh::out << "WARNING: Cannot specify both initialization object and function!"
1767  << std::endl;
1768 
1769  _init_system_function = nullptr;
1770  }
1771 
1772  _init_system_object = &init_in;
1773 }
Initialization * _init_system_object
Definition: system.h:1830
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1824
OStreamProxy out(std::cout)

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

References _qoi_evaluate_derivative_function, _qoi_evaluate_derivative_object, and libMesh::out.

1885 {
1886  libmesh_assert(fptr);
1887 
1888  if (_qoi_evaluate_derivative_object != nullptr)
1889  {
1890  libmesh_here();
1891  libMesh::out << "WARNING: Cannot specify both QOI derivative function and object!"
1892  << std::endl;
1893 
1895  }
1896 
1898 }
QOIDerivative * _qoi_evaluate_derivative_object
Definition: system.h:1878
OStreamProxy out(std::cout)
void(* _qoi_evaluate_derivative_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
Definition: system.h:1869

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

References _qoi_evaluate_derivative_function, _qoi_evaluate_derivative_object, and libMesh::out.

1903 {
1904  if (_qoi_evaluate_derivative_function != nullptr)
1905  {
1906  libmesh_here();
1907  libMesh::out << "WARNING: Cannot specify both QOI derivative object and function!"
1908  << std::endl;
1909 
1911  }
1912 
1913  _qoi_evaluate_derivative_object = &qoi_derivative;
1914 }
QOIDerivative * _qoi_evaluate_derivative_object
Definition: system.h:1878
OStreamProxy out(std::cout)
void(* _qoi_evaluate_derivative_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
Definition: system.h:1869

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

References _qoi_evaluate_function, _qoi_evaluate_object, and libMesh::out.

1850 {
1851  libmesh_assert(fptr);
1852 
1853  if (_qoi_evaluate_object != nullptr)
1854  {
1855  libmesh_here();
1856  libMesh::out << "WARNING: Cannot specify both QOI function and object!"
1857  << std::endl;
1858 
1859  _qoi_evaluate_object = nullptr;
1860  }
1861 
1862  _qoi_evaluate_function = fptr;
1863 }
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Definition: system.h:1857
QOI * _qoi_evaluate_object
Definition: system.h:1864
OStreamProxy out(std::cout)

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

References _qoi_evaluate_function, _qoi_evaluate_object, and libMesh::out.

1868 {
1869  if (_qoi_evaluate_function != nullptr)
1870  {
1871  libmesh_here();
1872  libMesh::out << "WARNING: Cannot specify both QOI object and function!"
1873  << std::endl;
1874 
1875  _qoi_evaluate_function = nullptr;
1876  }
1877 
1878  _qoi_evaluate_object = &qoi_in;
1879 }
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Definition: system.h:1857
QOI * _qoi_evaluate_object
Definition: system.h:1864
OStreamProxy out(std::cout)

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

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

Definition at line 985 of file system_projection.C.

989 {
990  this->boundary_project_vector(b, variables, *solution, f, g);
991 
992  solution->localize(*current_local_solution);
993 }
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
std::unique_ptr< NumericVector< Number > > solution
Definition: system.h:1523
std::unique_ptr< NumericVector< Number > > current_local_solution
Definition: system.h:1535

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

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

Definition at line 968 of file system_projection.C.

973 {
974  WrappedFunction<Number> f(*this, fptr, &parameters);
975  WrappedFunction<Gradient> g(*this, gptr, &parameters);
976  this->boundary_project_solution(b, variables, &f, &g);
977 }
void boundary_project_solution(const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr)

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

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

Definition at line 1021 of file system_projection.C.

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

1027 {
1028  LOG_SCOPE ("boundary_project_vector()", "System");
1029 
1031  (ConstElemRange (this->get_mesh().active_local_elements_begin(),
1032  this->get_mesh().active_local_elements_end() ),
1033  BoundaryProjectSolution(b, variables, *this, f, g,
1034  this->get_equation_systems().parameters,
1035  new_vector)
1036  );
1037 
1038  // We don't do SCALAR dofs when just projecting the boundary, so
1039  // we're done here.
1040 
1041  new_vector.close();
1042 
1043 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1044  if (is_adjoint == -1)
1045  this->get_dof_map().enforce_constraints_exactly(*this, &new_vector);
1046  else if (is_adjoint >= 0)
1048  is_adjoint);
1049 #endif
1050 }
void parallel_for(const Range &range, const Body &body)
Definition: threads_none.h:73
const EquationSystems & get_equation_systems() const
Definition: system.h:712
const MeshBase & get_mesh() const
Definition: system.h:2033
StoredRange< MeshBase::const_element_iterator, const Elem * > ConstElemRange
Definition: elem_range.h:34
void enforce_adjoint_constraints_exactly(NumericVector< Number > &v, unsigned int q) const
virtual void close()=0
const DofMap & get_dof_map() const
Definition: system.h:2049
void enforce_constraints_exactly(const System &system, NumericVector< Number > *v=nullptr, bool homogeneous=false) const

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

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

Definition at line 1003 of file system_projection.C.

1010 {
1011  WrappedFunction<Number> f(*this, fptr, &parameters);
1012  WrappedFunction<Gradient> g(*this, gptr, &parameters);
1013  this->boundary_project_vector(b, variables, new_vector, &f, &g,
1014  is_adjoint);
1015 }
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

◆ calculate_norm() [1/2]

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

Definition at line 1378 of file system.C.

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

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

1382 {
1383  //short circuit to save time
1384  if (norm_type == DISCRETE_L1 ||
1385  norm_type == DISCRETE_L2 ||
1386  norm_type == DISCRETE_L_INF)
1387  return discrete_var_norm(v,var,norm_type);
1388 
1389  // Not a discrete norm
1390  std::vector<FEMNormType> norms(this->n_vars(), L2);
1391  std::vector<Real> weights(this->n_vars(), 0.0);
1392  norms[var] = norm_type;
1393  weights[var] = 1.0;
1394  Real val = this->calculate_norm(v, SystemNorm(norms, weights), skip_dimensions);
1395  return val;
1396 }
Real calculate_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=nullptr) const
Definition: system.C:1378
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Real discrete_var_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type) const
Definition: system.C:1359
unsigned int n_vars() const
Definition: system.h:2105

◆ calculate_norm() [2/2]

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

Definition at line 1400 of file system.C.

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(), libMesh::DISCRETE_L1, libMesh::DISCRETE_L2, libMesh::DISCRETE_L_INF, discrete_var_norm(), libMesh::DofMap::dof_indices(), libMesh::MeshBase::elem_dimensions(), 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::SystemNorm::is_discrete(), libMesh::L1, libMesh::NumericVector< T >::l1_norm(), libMesh::L2, libMesh::NumericVector< T >::l2_norm(), libMesh::L_INF, libMesh::NumericVector< T >::linfty_norm(), libMesh::NumericVector< T >::localize(), std::max(), libMesh::Parallel::Communicator::max(), libMesh::QBase::n_points(), n_vars(), 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(), libMesh::Parallel::Communicator::sum(), libMesh::SystemNorm::type(), libMesh::DofMap::variable_type(), libMesh::W1_INF_SEMINORM, libMesh::W2_INF_SEMINORM, libMesh::SystemNorm::weight(), and libMesh::SystemNorm::weight_sq().

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

◆ 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::LinearImplicitSystem, libMesh::EigenSystem, libMesh::TransientSystem< RBConstruction >, libMesh::DifferentiableSystem, libMesh::ContinuationSystem, libMesh::FrequencySystem, libMesh::RBConstructionBase< LinearImplicitSystem >, libMesh::RBConstructionBase< CondensedEigenSystem >, libMesh::RBSCMConstruction, libMesh::RBEIMConstruction, libMesh::ExplicitSystem, libMesh::TransientRBConstruction, and libMesh::NewmarkSystem.

Definition at line 205 of file system.C.

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

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 }
std::map< std::string, unsigned short int > _variable_numbers
Definition: system.h:1922
std::map< std::string, ParallelType > _vector_types
Definition: system.h:1952
bool _is_initialized
Definition: system.h:1971
std::unique_ptr< DofMap > _dof_map
Definition: system.h:1884
std::vector< Variable > _variables
Definition: system.h:1911
std::unique_ptr< NumericVector< Number > > solution
Definition: system.h:1523
std::map< std::string, int > _vector_is_adjoint
Definition: system.h:1947
std::map< std::string, NumericVector< Number > *> _vectors
Definition: system.h:1935
std::map< std::string, bool > _vector_projections
Definition: system.h:1941
std::unique_ptr< NumericVector< Number > > current_local_solution
Definition: system.h:1535

◆ comm()

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

Definition at line 89 of file parallel_object.h.

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_tao_equality_constraints(), libMesh::__libmesh_tao_equality_constraints_jacobian(), libMesh::__libmesh_tao_gradient(), libMesh::__libmesh_tao_hessian(), libMesh::__libmesh_tao_inequality_constraints(), libMesh::__libmesh_tao_inequality_constraints_jacobian(), libMesh::__libmesh_tao_objective(), libMesh::MeshRefinement::_coarsen_elements(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult_add(), libMesh::EquationSystems::_read_impl(), libMesh::MeshRefinement::_refine_elements(), libMesh::MeshRefinement::_smooth_flags(), libMesh::PetscDMWrapper::add_dofs_helper(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::ImplicitSystem::add_matrix(), add_vector(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assemble_qoi(), libMesh::MeshCommunication::assign_global_indices(), libMesh::DofMap::attach_matrix(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::PetscDMWrapper::build_section(), libMesh::PetscDMWrapper::build_sf(), libMesh::MeshBase::cache_elem_dims(), calculate_norm(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::PetscDMWrapper::check_section_n_dofs(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::MeshTools::create_bounding_box(), 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::MeshRefinement::eliminate_unrefined_patches(), libMesh::EpetraVector< T >::EpetraVector(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::DofMap::get_info(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::LocationMap< T >::init(), libMesh::TimeSolver::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::EigenSystem::init_data(), libMesh::EigenSystem::init_matrices(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), 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_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(), 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::FEMSystem::mesh_position_set(), libMesh::DistributedMesh::n_active_elem(), libMesh::MeshTools::n_active_levels(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::CondensedEigenSystem::n_global_non_condensed_dofs(), libMesh::MeshTools::n_levels(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::MeshTools::n_p_levels(), libMesh::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::MeshBase::prepare_for_use(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), read_header(), read_legacy_data(), 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::MeshBase::recalculate_n_partitions(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::CheckpointIO::select_split_config(), 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::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), libMesh::MeshRefinement::test_level_one(), libMesh::MeshRefinement::test_unflagged(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), 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().

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

◆ compare()

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

Definition at line 514 of file system.C.

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

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

517 {
518  // we do not care for matrices, but for vectors
519  libmesh_assert (_is_initialized);
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 }
bool _is_initialized
Definition: system.h:1971
unsigned int n_vectors() const
Definition: system.h:2233
std::unique_ptr< NumericVector< Number > > solution
Definition: system.h:1523
std::map< std::string, NumericVector< Number > *> _vectors
Definition: system.h:1935
const std::string _sys_name
Definition: system.h:1901
OStreamProxy out(std::cout)

◆ current_solution()

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

Definition at line 194 of file system.C.

References _dof_map, and current_local_solution.

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::HPCoarsenTest::add_projection(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), point_gradient(), point_hessian(), point_value(), libMesh::HPCoarsenTest::select_refinement(), libMesh::EnsightIO::write_scalar_ascii(), and libMesh::EnsightIO::write_vector_ascii().

195 {
196  // Check the sizes
197  libmesh_assert_less (global_dof_number, _dof_map->n_dofs());
198  libmesh_assert_less (global_dof_number, current_local_solution->size());
199 
200  return (*current_local_solution)(global_dof_number);
201 }
std::unique_ptr< DofMap > _dof_map
Definition: system.h:1884
std::unique_ptr< NumericVector< Number > > current_local_solution
Definition: system.h:1535

◆ deactivate()

void libMesh::System::deactivate ( )
inline

Deactivates the system. Only active systems are solved.

Definition at line 2081 of file system.h.

References _active.

2082 {
2083  _active = false;
2084 }

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

References assemble_before_solve.

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

2275 { assemble_before_solve = true; }
bool assemble_before_solve
Definition: system.h:1477

◆ disable_print_counter_info()

void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

Definition at line 106 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

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

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

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

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

1362 {
1363  std::set<dof_id_type> var_indices;
1364  local_dof_indices(var, var_indices);
1365 
1366  if (norm_type == DISCRETE_L1)
1367  return v.subset_l1_norm(var_indices);
1368  if (norm_type == DISCRETE_L2)
1369  return v.subset_l2_norm(var_indices);
1370  if (norm_type == DISCRETE_L_INF)
1371  return v.subset_linfty_norm(var_indices);
1372  else
1373  libmesh_error_msg("Invalid norm_type = " << norm_type);
1374 }
void local_dof_indices(const unsigned int var, std::set< dof_id_type > &var_indices) const
Definition: system.C:1277
virtual Real subset_l2_norm(const std::set< numeric_index_type > &indices) const
virtual Real subset_linfty_norm(const std::set< numeric_index_type > &indices) const
virtual Real subset_l1_norm(const std::set< numeric_index_type > &indices) const

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

References libMesh::ReferenceCounter::_enable_print_counter.

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

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

Referenced by qoi_parameter_sensitivity().

2328 {
2329  libmesh_not_implemented();
2330 }

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

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

1032 {
1033  std::ostringstream adjoint_rhs_name;
1034  adjoint_rhs_name << "adjoint_rhs" << i;
1035 
1036  return this->get_vector(adjoint_rhs_name.str());
1037 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:774

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

References get_vector().

1042 {
1043  std::ostringstream adjoint_rhs_name;
1044  adjoint_rhs_name << "adjoint_rhs" << i;
1045 
1046  return this->get_vector(adjoint_rhs_name.str());
1047 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:774

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

References get_vector().

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

970 {
971  std::ostringstream adjoint_name;
972  adjoint_name << "adjoint_solution" << i;
973 
974  return this->get_vector(adjoint_name.str());
975 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:774

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

References get_vector().

980 {
981  std::ostringstream adjoint_name;
982  adjoint_name << "adjoint_solution" << i;
983 
984  return this->get_vector(adjoint_name.str());
985 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:774

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

References _variable_numbers, and n_vars().

1259 {
1260  all_variable_numbers.resize(n_vars());
1261 
1262  // Make sure the variable exists
1263  std::map<std::string, unsigned short int>::const_iterator
1264  it = _variable_numbers.begin();
1265  std::map<std::string, unsigned short int>::const_iterator
1266  it_end = _variable_numbers.end();
1267 
1268  unsigned int count = 0;
1269  for ( ; it != it_end; ++it)
1270  {
1271  all_variable_numbers[count] = it->second;
1272  count++;
1273  }
1274 }
std::map< std::string, unsigned short int > _variable_numbers
Definition: system.h:1922
unsigned int n_vars() const
Definition: system.h:2105

◆ get_dof_map() [1/2]

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

Definition at line 2049 of file system.h.

References _dof_map.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::DifferentiableSystem::add_dot_var_dirichlet_bcs(), libMesh::HPCoarsenTest::add_projection(), libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::ImplicitSystem::adjoint_solve(), libMesh::NewmarkSolver::advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), libMesh::EquationSystems::allgather(), 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(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), DMCreateDomainDecomposition_libMesh(), DMCreateFieldDecomposition_libMesh(), DMlibMeshFunction(), DMlibMeshJacobian(), DMlibMeshSetSystem_libMesh(), libMesh::DofMap::enforce_constraints_exactly(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), get_info(), libMesh::SystemSubsetBySubdomain::init(), libMesh::SecondOrderUnsteadySolver::init_data(), libMesh::UnsteadySolver::init_data(), libMesh::EigenSystem::init_matrices(), libMesh::ImplicitSystem::init_matrices(), libMesh::CondensedEigenSystem::initialize_condensed_dofs(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_postcheck(), libMesh::libmesh_petsc_snes_residual_helper(), local_dof_indices(), libMesh::DofMap::max_constraint_error(), 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::petsc_auto_fieldsplit(), libMesh::ErrorVector::plot_error(), point_gradient(), point_hessian(), point_value(), libMesh::FEMContext::pre_fe_reinit(), 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(), libMesh::UnsteadySolver::retrieve_timestep(), libMesh::HPCoarsenTest::select_refinement(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::NewtonSolver::solve(), libMesh::PetscDiffSolver::solve(), libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve(), libMesh::ImplicitSystem::weighted_sensitivity_solve(), write_parallel_data(), libMesh::EnsightIO::write_scalar_ascii(), write_SCALAR_dofs(), and libMesh::EnsightIO::write_vector_ascii().

2050 {
2051  return *_dof_map;
2052 }
std::unique_ptr< DofMap > _dof_map
Definition: system.h:1884

◆ get_dof_map() [2/2]

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

Definition at line 2057 of file system.h.

References _dof_map.

2058 {
2059  return *_dof_map;
2060 }
std::unique_ptr< DofMap > _dof_map
Definition: system.h:1884

◆ get_equation_systems() [1/2]

◆ get_equation_systems() [2/2]

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

Definition at line 717 of file system.h.

References _equation_systems.

717 { return _equation_systems; }
EquationSystems & _equation_systems
Definition: system.h:1890

◆ get_info() [1/2]

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

Gets a string containing the reference information.

Definition at line 47 of file reference_counter.C.

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

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

48 {
49 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
50 
51  std::ostringstream oss;
52 
53  oss << '\n'
54  << " ---------------------------------------------------------------------------- \n"
55  << "| Reference count information |\n"
56  << " ---------------------------------------------------------------------------- \n";
57 
58  for (const auto & 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 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:42

◆ get_info() [2/2]

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

Definition at line 1658 of file system.C.

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

1659 {
1660  std::ostringstream oss;
1661 
1662 
1663  const std::string & sys_name = this->name();
1664 
1665  oss << " System #" << this->number() << ", \"" << sys_name << "\"\n"
1666  << " Type \"" << this->system_type() << "\"\n"
1667  << " Variables=";
1668 
1669  for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
1670  {
1671  const VariableGroup & vg_description (this->variable_group(vg));
1672 
1673  if (vg_description.n_variables() > 1) oss << "{ ";
1674  for (unsigned int vn=0; vn<vg_description.n_variables(); vn++)
1675  oss << "\"" << vg_description.name(vn) << "\" ";
1676  if (vg_description.n_variables() > 1) oss << "} ";
1677  }
1678 
1679  oss << '\n';
1680 
1681  oss << " Finite Element Types=";
1682 #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
1683  for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
1684  oss << "\""
1685  << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().family)
1686  << "\" ";
1687 #else
1688  for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
1689  {
1690  oss << "\""
1691  << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().family)
1692  << "\", \""
1693  << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().radial_family)
1694  << "\" ";
1695  }
1696 
1697  oss << '\n' << " Infinite Element Mapping=";
1698  for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
1699  oss << "\""
1700  << Utility::enum_to_string<InfMapType>(this->get_dof_map().variable_group(vg).type().inf_map)
1701  << "\" ";
1702 #endif
1703 
1704  oss << '\n';
1705 
1706  oss << " Approximation Orders=";
1707  for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
1708  {
1709 #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
1710  oss << "\""
1711  << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().order)
1712  << "\" ";
1713 #else
1714  oss << "\""
1715  << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().order)
1716  << "\", \""
1717  << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().radial_order)
1718  << "\" ";
1719 #endif
1720  }
1721 
1722  oss << '\n';
1723 
1724  oss << " n_dofs()=" << this->n_dofs() << '\n';
1725  oss << " n_local_dofs()=" << this->n_local_dofs() << '\n';
1726 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1727  oss << " n_constrained_dofs()=" << this->n_constrained_dofs() << '\n';
1728  oss << " n_local_constrained_dofs()=" << this->n_local_constrained_dofs() << '\n';
1729 #endif
1730 
1731  oss << " " << "n_vectors()=" << this->n_vectors() << '\n';
1732  oss << " " << "n_matrices()=" << this->n_matrices() << '\n';
1733  // oss << " " << "n_additional_matrices()=" << this->n_additional_matrices() << '\n';
1734 
1735  oss << this->get_dof_map().get_info();
1736 
1737  return oss.str();
1738 }
FEFamily family
Definition: fe_type.h:204
OrderWrapper radial_order
Definition: fe_type.h:237
unsigned int n_variable_groups() const
Definition: system.h:2113
OrderWrapper order
Definition: fe_type.h:198
dof_id_type n_local_dofs() const
Definition: system.C:187
std::string get_info() const
Definition: dof_map.C:2703
dof_id_type n_dofs() const
Definition: system.C:150
unsigned int number() const
Definition: system.h:2025
unsigned int n_vectors() const
Definition: system.h:2233
const VariableGroup & variable_group(const unsigned int c) const
Definition: dof_map.h:1752
InfMapType inf_map
Definition: fe_type.h:258
virtual unsigned int n_matrices() const
Definition: system.h:2239
FEFamily radial_family
Definition: fe_type.h:250
virtual std::string system_type() const
Definition: system.h:487
dof_id_type n_local_constrained_dofs() const
Definition: system.C:172
const std::string & name() const
Definition: system.h:2017
const DofMap & get_dof_map() const
Definition: system.h:2049
const VariableGroup & variable_group(unsigned int vg) const
Definition: system.h:2143
dof_id_type n_constrained_dofs() const
Definition: system.C:157
const FEType & type() const
Definition: variable.h:119

◆ get_mesh() [1/2]

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

Definition at line 2033 of file system.h.

References _mesh.

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

2034 {
2035  return _mesh;
2036 }
MeshBase & _mesh
Definition: system.h:1896

◆ get_mesh() [2/2]

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

Definition at line 2041 of file system.h.

References _mesh.

2042 {
2043  return _mesh;
2044 }
MeshBase & _mesh
Definition: system.h:1896

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

References get_vector().

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

1062 {
1063  std::ostringstream sensitivity_rhs_name;
1064  sensitivity_rhs_name << "sensitivity_rhs" << i;
1065 
1066  return this->get_vector(sensitivity_rhs_name.str());
1067 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:774

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

References get_vector().

1072 {
1073  std::ostringstream sensitivity_rhs_name;
1074  sensitivity_rhs_name << "sensitivity_rhs" << i;
1075 
1076  return this->get_vector(sensitivity_rhs_name.str());
1077 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:774

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

References get_vector().

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

917 {
918  std::ostringstream sensitivity_name;
919  sensitivity_name << "sensitivity_solution" << i;
920 
921  return this->get_vector(sensitivity_name.str());
922 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:774

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

References get_vector().

927 {
928  std::ostringstream sensitivity_name;
929  sensitivity_name << "sensitivity_solution" << i;
930 
931  return this->get_vector(sensitivity_name.str());
932 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:774

◆ get_vector() [1/4]

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

Definition at line 774 of file system.C.

References _vectors.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::NewmarkSolver::advance_timestep(), libMesh::AdaptiveTimeSolver::advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), compare(), libMesh::NewmarkSolver::compute_initial_accel(), libMesh::UnsteadySolver::du(), libMesh::AdjointRefinementEstimator::estimate_error(), get_adjoint_rhs(), get_adjoint_solution(), get_sensitivity_rhs(), get_sensitivity_solution(), get_weighted_sensitivity_adjoint_solution(), get_weighted_sensitivity_solution(), libMesh::NewmarkSystem::initial_conditions(), libMesh::NewmarkSolver::project_initial_accel(), libMesh::SecondOrderUnsteadySolver::project_initial_rate(), libMesh::SecondOrderUnsteadySolver::reinit(), libMesh::UnsteadySolver::reinit(), libMesh::MemorySolutionHistory::retrieve(), libMesh::UnsteadySolver::retrieve_timestep(), libMesh::TwostepTimeSolver::solve(), libMesh::FrequencySystem::solve(), libMesh::NewmarkSystem::update_rhs(), and libMesh::NewmarkSystem::update_u_v_a().

775 {
776  // Make sure the vector exists
777  const_vectors_iterator pos = _vectors.find(vec_name);
778 
779  if (pos == _vectors.end())
780  libmesh_error_msg("ERROR: vector " << vec_name << " does not exist in this system!");
781 
782  return *(pos->second);
783 }
std::map< std::string, NumericVector< Number > * >::const_iterator const_vectors_iterator
Definition: system.h:749
std::map< std::string, NumericVector< Number > *> _vectors
Definition: system.h:1935

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

References _vectors.

788 {
789  // Make sure the vector exists
790  vectors_iterator pos = _vectors.find(vec_name);
791 
792  if (pos == _vectors.end())
793  libmesh_error_msg("ERROR: vector " << vec_name << " does not exist in this system!");
794 
795  return *(pos->second);
796 }
std::map< std::string, NumericVector< Number > * >::iterator vectors_iterator
Definition: system.h:748
std::map< std::string, NumericVector< Number > *> _vectors
Definition: system.h:1935

◆ get_vector() [3/4]

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

Definition at line 800 of file system.C.

References vectors_begin(), and vectors_end().

801 {
804  unsigned int num = 0;
805  while ((num<vec_num) && (v!=v_end))
806  {
807  num++;
808  ++v;
809  }
810  libmesh_assert (v != v_end);
811  return *(v->second);
812 }
vectors_iterator vectors_end()
Definition: system.h:2257
std::map< std::string, NumericVector< Number > * >::const_iterator const_vectors_iterator
Definition: system.h:749
vectors_iterator vectors_begin()
Definition: system.h:2245

◆ get_vector() [4/4]

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

Definition at line 816 of file system.C.

References vectors_begin(), and vectors_end().

817 {
819  vectors_iterator v_end = vectors_end();
820  unsigned int num = 0;
821  while ((num<vec_num) && (v!=v_end))
822  {
823  num++;
824  ++v;
825  }
826  libmesh_assert (v != v_end);
827  return *(v->second);
828 }
vectors_iterator vectors_end()
Definition: system.h:2257
vectors_iterator vectors_begin()
Definition: system.h:2245
std::map< std::string, NumericVector< Number > * >::iterator vectors_iterator
Definition: system.h:748

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

References get_vector().

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

1002 {
1003  std::ostringstream adjoint_name;
1004  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
1005 
1006  return this->get_vector(adjoint_name.str());
1007 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:774

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

References get_vector().

1012 {
1013  std::ostringstream adjoint_name;
1014  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
1015 
1016  return this->get_vector(adjoint_name.str());
1017 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:774

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

References get_vector().

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

944 {
945  return this->get_vector("weighted_sensitivity_solution");
946 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:774

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

References get_vector().

951 {
952  return this->get_vector("weighted_sensitivity_solution");
953 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:774

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

References _variable_numbers.

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

1237 {
1238  return _variable_numbers.count(var);
1239 }
std::map< std::string, unsigned short int > _variable_numbers
Definition: system.h:1922

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

References _vectors.

Referenced by add_vector().

2226 {
2227  return (_vectors.count(vec_name));
2228 }
std::map< std::string, NumericVector< Number > *> _vectors
Definition: system.h:1935

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

References _hide_output.

1662 { return _hide_output; }
bool _hide_output
Definition: system.h:2009

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

References _identify_variable_groups.

Referenced by add_variable().

2202 {
2204 }
bool _identify_variable_groups
Definition: system.h:1977

◆ identify_variable_groups() [2/2]

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

Toggle automatic VariableGroup identification.

Definition at line 2209 of file system.h.

References _identify_variable_groups.

2210 {
2212 }
bool _identify_variable_groups
Definition: system.h:1977

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

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

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

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 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:42
spin_mutex spin_mtx
Definition: threads.C:29

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

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

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

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 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:42
spin_mutex spin_mtx
Definition: threads.C:29

◆ init()

void libMesh::System::init ( )

Initializes degrees of freedom on the current mesh. Sets the

Definition at line 237 of file system.C.

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

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 }
bool _basic_system_only
Definition: system.h:1965
virtual void init_data()
Definition: system.C:262
virtual void user_initialization()
Definition: system.C:1918
bool is_initialized()
Definition: system.h:2089
unsigned int n_vars() const
Definition: system.h:2105

◆ init_data()

void libMesh::System::init_data ( )
protectedvirtual

Initializes the data for the system.

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

Reimplemented in libMesh::DifferentiableSystem, libMesh::ImplicitSystem, libMesh::ContinuationSystem, libMesh::RBEIMConstruction, libMesh::FEMSystem, libMesh::OptimizationSystem, libMesh::FrequencySystem, libMesh::RBConstructionBase< LinearImplicitSystem >, libMesh::RBConstructionBase< CondensedEigenSystem >, libMesh::EigenSystem, and libMesh::LinearImplicitSystem.

Definition at line 262 of file system.C.

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, and solution.

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

263 {
264  MeshBase & mesh = this->get_mesh();
265 
266  // Add all variable groups to our underlying DofMap
267  for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
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 }
std::map< std::string, ParallelType > _vector_types
Definition: system.h:1952
bool _is_initialized
Definition: system.h:1971
unsigned int n_variable_groups() const
Definition: system.h:2113
MeshBase & mesh
std::unique_ptr< DofMap > _dof_map
Definition: system.h:1884
dof_id_type n_local_dofs() const
Definition: system.C:187
const MeshBase & get_mesh() const
Definition: system.h:2033
dof_id_type n_dofs() const
Definition: system.C:150
std::unique_ptr< NumericVector< Number > > solution
Definition: system.h:1523
virtual void reinit_constraints()
Definition: system.C:397
std::map< std::string, NumericVector< Number > *> _vectors
Definition: system.h:1935
std::unique_ptr< NumericVector< Number > > current_local_solution
Definition: system.h:1535

◆ is_adjoint_already_solved()

◆ is_initialized()

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

Definition at line 2089 of file system.h.

References _is_initialized.

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

2090 {
2091  return _is_initialized;
2092 }
bool _is_initialized
Definition: system.h:1971

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

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

Referenced by discrete_var_norm().

1279 {
1280  // Make sure the set is clear
1281  var_indices.clear();
1282 
1283  std::vector<dof_id_type> dof_indices;
1284 
1285  const dof_id_type
1286  first_local = this->get_dof_map().first_dof(),
1287  end_local = this->get_dof_map().end_dof();
1288 
1289  // Begin the loop over the elements
1290  for (const auto & elem : this->get_mesh().active_local_element_ptr_range())
1291  {
1292  this->get_dof_map().dof_indices (elem, dof_indices, var);
1293 
1294  for (std::size_t i=0; i<dof_indices.size(); i++)
1295  {
1296  dof_id_type dof = dof_indices[i];
1297 
1298  //If the dof is owned by the local processor
1299  if (first_local <= dof && dof < end_local)
1300  var_indices.insert(dof_indices[i]);
1301  }
1302  }
1303 
1304  // we may have missed assigning DOFs to nodes that we own
1305  // but to which we have no connected elements matching our
1306  // variable restriction criterion. this will happen, for example,
1307  // if variable V is restricted to subdomain S. We may not own
1308  // any elements which live in S, but we may own nodes which are
1309  // *connected* to elements which do.
1310  for (const auto & node : this->get_mesh().local_node_ptr_range())
1311  {
1312  libmesh_assert(node);
1313  this->get_dof_map().dof_indices (node, dof_indices, var);
1314  for (auto dof : dof_indices)
1315  if (first_local <= dof && dof < end_local)
1316  var_indices.insert(dof);
1317  }
1318 }
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Definition: dof_map.C:1930
const MeshBase & get_mesh() const
Definition: system.h:2033
dof_id_type first_dof(const processor_id_type proc) const
Definition: dof_map.h:599
dof_id_type end_dof(const processor_id_type proc) const
Definition: dof_map.h:641
const DofMap & get_dof_map() const
Definition: system.h:2049
uint8_t dof_id_type
Definition: id_types.h:64

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

References n_constrained_dofs(), and n_dofs().

2218 {
2219  return this->n_dofs() - this->n_constrained_dofs();
2220 }
dof_id_type n_dofs() const
Definition: system.C:150
dof_id_type n_constrained_dofs() const
Definition: system.C:157

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

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

Referenced by add_variables().

2122 {
2123  if (_variables.empty())
2124  return 0;
2125 
2126  const Variable & last = _variables.back();
2127  return last.first_scalar_number() + last.n_components();
2128 }
std::vector< Variable > _variables
Definition: system.h:1911

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

References _dof_map.

Referenced by get_info(), and n_active_dofs().

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 }
std::unique_ptr< DofMap > _dof_map
Definition: system.h:1884

◆ n_dofs()

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

References _dof_map.

Referenced by get_info().

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 }
std::unique_ptr< DofMap > _dof_map
Definition: system.h:1884

◆ n_local_dofs()

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

Referenced by get_info().

2240 {
2241  return 0;
2242 }

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

References libMesh::ReferenceCounter::_n_objects.

84  { return _n_objects; }
static Threads::atomic< unsigned int > _n_objects

◆ n_processors()

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

Definition at line 95 of file parallel_object.h.

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

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::DistributedMesh::add_node(), libMesh::LaplaceMeshSmoother::allgather_graph(), 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::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::MeshBase::get_info(), 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::n_active_elem_on_proc(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), libMesh::MeshBase::partition(), libMesh::PetscLinearSolver< T >::PetscLinearSolver(), point_gradient(), point_hessian(), point_value(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::XdrIO::read_header(), libMesh::CheckpointIO::read_nodes(), read_parallel_data(), read_SCALAR_dofs(), read_serialized_blocked_dof_objects(), read_serialized_vector(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), 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().

96  { return cast_int<processor_id_type>(_communicator.size()); }
processor_id_type size() const
Definition: communicator.h:175
const Parallel::Communicator & _communicator

◆ n_qois()

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

References _variable_groups.

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

2114 {
2115  return cast_int<unsigned int>(_variable_groups.size());
2116 }
std::vector< VariableGroup > _variable_groups
Definition: system.h:1916

◆ n_vars()

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

Definition at line 2105 of file system.h.

References _variables.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::PetscDMWrapper::add_dofs_helper(), libMesh::DiffContext::add_localized_vector(), add_variable(), add_variables(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::PetscDMWrapper::build_section(), calculate_norm(), libMesh::DGFEMContext::DGFEMContext(), libMesh::DiffContext::DiffContext(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::ErrorEstimator::estimate_errors(), libMesh::ExactSolution::ExactSolution(), get_all_variable_numbers(), init(), libMesh::FEMSystem::init_context(), libMesh::FEMContext::init_internal_data(), libMesh::DGFEMContext::neighbor_side_fe_reinit(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), 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(), write_header(), write_parallel_data(), write_serialized_blocked_dof_objects(), write_serialized_vector(), write_serialized_vectors(), and zero_variable().

2106 {
2107  return cast_int<unsigned int>(_variables.size());
2108 }
std::vector< Variable > _variables
Definition: system.h:1911

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

References _vectors.

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

2234 {
2235  return cast_int<unsigned int>(_vectors.size());
2236 }
std::map< std::string, NumericVector< Number > *> _vectors
Definition: system.h:1935

◆ name()

◆ number()

◆ 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/3]

Gradient libMesh::System::point_gradient ( unsigned int  var,
const Point p,
const bool  insist_on_success = true 
) 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.

References libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::PointLocatorBase::enable_out_of_mesh_mode(), get_dof_map(), get_mesh(), mesh, libMesh::Parallel::Communicator::min(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), and libMesh::DofObject::processor_id().

Referenced by point_gradient().

2101 {
2102  // This function must be called on every processor; there's no
2103  // telling where in the partition p falls.
2104  parallel_object_only();
2105 
2106  // And every processor had better agree about which point we're
2107  // looking for
2108 #ifndef NDEBUG
2109  libmesh_assert(this->comm().verify(p(0)));
2110 #if LIBMESH_DIM > 1
2111  libmesh_assert(this->comm().verify(p(1)));
2112 #endif
2113 #if LIBMESH_DIM > 2
2114  libmesh_assert(this->comm().verify(p(2)));
2115 #endif
2116 #endif // NDEBUG
2117 
2118  // Get a reference to the mesh object associated with the system object that calls this function
2119  const MeshBase & mesh = this->get_mesh();
2120 
2121  // Use an existing PointLocator or create a new one
2122  std::unique_ptr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2123  PointLocatorBase & locator = *locator_ptr;
2124 
2125  if (!insist_on_success || !mesh.is_serial())
2126  locator.enable_out_of_mesh_mode();
2127 
2128  // Get a pointer to the element that contains P
2129  const Elem * e = locator(p);
2130 
2131  Gradient grad_u;
2132 
2133  if (e && this->get_dof_map().is_evaluable(*e, var))
2134  grad_u = point_gradient(var, p, *e);
2135 
2136  // If I have an element containing p, then let's let everyone know
2137  processor_id_type lowest_owner =
2138  (e && (e->processor_id() == this->processor_id())) ?
2139  this->processor_id() : this->n_processors();
2140  this->comm().min(lowest_owner);
2141 
2142  // Everybody should get their value from a processor that was able
2143  // to compute it.
2144  // If nobody admits owning the point, we may have a problem.
2145  if (lowest_owner != this->n_processors())
2146  this->comm().broadcast(grad_u, lowest_owner);
2147  else
2148  libmesh_assert(!insist_on_success);
2149 
2150  return grad_u;
2151 }
Gradient point_gradient(unsigned int var, const Point &p, const bool insist_on_success=true) const
Definition: system.C:2100
MeshBase & mesh
uint8_t processor_id_type
Definition: id_types.h:99
const Parallel::Communicator & comm() const
const MeshBase & get_mesh() const
Definition: system.h:2033
processor_id_type n_processors() const
NumberVectorValue Gradient
processor_id_type processor_id() const
const DofMap & get_dof_map() const
Definition: system.h:2049
void broadcast(T &data, const unsigned int root_id=0) const

◆ point_gradient() [2/3]

Gradient libMesh::System::point_gradient ( unsigned int  var,
const Point p,
const Elem e 
) 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 2154 of file system.C.

References libMesh::TypeVector< T >::add_scaled(), libMesh::FEGenericBase< OutputType >::build(), libMesh::Elem::contains_point(), current_solution(), libMesh::Elem::dim(), libMesh::DofMap::dof_indices(), get_dof_map(), libMesh::Elem::infinite(), libMesh::FEInterface::inverse_map(), libMesh::DofMap::is_evaluable(), and libMesh::DofMap::variable_type().

2155 {
2156  // Ensuring that the given point is really in the element is an
2157  // expensive assert, but as long as debugging is turned on we might
2158  // as well try to catch a particularly nasty potential error
2159  libmesh_assert (e.contains_point(p));
2160 
2161 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
2162  if (e.infinite())
2163  libmesh_not_implemented();
2164 #endif
2165 
2166  // Get the dof map to get the proper indices for our computation
2167  const DofMap & dof_map = this->get_dof_map();
2168 
2169  // Make sure we can evaluate on this element.
2170  libmesh_assert (dof_map.is_evaluable(e, var));
2171 
2172  // Need dof_indices for phi[i][j]
2173  std::vector<dof_id_type> dof_indices;
2174 
2175  // Fill in the dof_indices for our element
2176  dof_map.dof_indices (&e, dof_indices, var);
2177 
2178  // Get the no of dofs associated with this point
2179  const unsigned int num_dofs = cast_int<unsigned int>
2180  (dof_indices.size());
2181 
2182  FEType fe_type = dof_map.variable_type(var);
2183 
2184  // Build a FE again so we can calculate u(p)
2185  std::unique_ptr<FEBase> fe (FEBase::build(e.dim(), fe_type));
2186 
2187  // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h
2188  // Build a vector of point co-ordinates to send to reinit
2189  std::vector<Point> coor(1, FEInterface::inverse_map(e.dim(), fe_type, &e, p));
2190 
2191  // Get the values of the shape function derivatives
2192  const std::vector<std::vector<RealGradient>> & dphi = fe->get_dphi();
2193 
2194  // Reinitialize the element and compute the shape function values at coor
2195  fe->reinit (&e, &coor);
2196 
2197  // Get ready to accumulate a gradient
2198  Gradient grad_u;
2199 
2200  for (unsigned int l=0; l<num_dofs; l++)
2201  {
2202  grad_u.add_scaled (dphi[l][0], this->current_solution (dof_indices[l]));
2203  }
2204 
2205  return grad_u;
2206 }
void add_scaled(const TypeVector< T2 > &, const T)
Definition: type_vector.h:627
Number current_solution(const dof_id_type global_dof_number) const
Definition: system.C:194
NumberVectorValue Gradient
static std::unique_ptr< FEGenericBase > build(const unsigned int dim, const FEType &type)
static Point inverse_map(const unsigned int dim, const FEType &fe_t, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true)
Definition: fe_interface.C:590
const DofMap & get_dof_map() const
Definition: system.h:2049

◆ point_gradient() [3/3]

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

References point_gradient().

2211 {
2212  libmesh_assert(e);
2213  return this->point_gradient(var, p, *e);
2214 }
Gradient point_gradient(unsigned int var, const Point &p, const bool insist_on_success=true) const
Definition: system.C:2100

◆ point_hessian() [1/3]

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

References libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::PointLocatorBase::enable_out_of_mesh_mode(), get_dof_map(), get_mesh(), mesh, libMesh::Parallel::Communicator::min(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), and libMesh::DofObject::processor_id().

Referenced by point_hessian().

2221 {
2222  // This function must be called on every processor; there's no
2223  // telling where in the partition p falls.
2224  parallel_object_only();
2225 
2226  // And every processor had better agree about which point we're
2227  // looking for
2228 #ifndef NDEBUG
2229  libmesh_assert(this->comm().verify(p(0)));
2230 #if LIBMESH_DIM > 1
2231  libmesh_assert(this->comm().verify(p(1)));
2232 #endif
2233 #if LIBMESH_DIM > 2
2234  libmesh_assert(this->comm().verify(p(2)));
2235 #endif
2236 #endif // NDEBUG
2237 
2238  // Get a reference to the mesh object associated with the system object that calls this function
2239  const MeshBase & mesh = this->get_mesh();
2240 
2241  // Use an existing PointLocator or create a new one
2242  std::unique_ptr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2243  PointLocatorBase & locator = *locator_ptr;
2244 
2245  if (!insist_on_success || !mesh.is_serial())
2246  locator.enable_out_of_mesh_mode();
2247 
2248  // Get a pointer to the element that contains P
2249  const Elem * e = locator(p);
2250 
2251  Tensor hess_u;
2252 
2253  if (e && this->get_dof_map().is_evaluable(*e, var))
2254  hess_u = point_hessian(var, p, *e);
2255 
2256  // If I have an element containing p, then let's let everyone know
2257  processor_id_type lowest_owner =
2258  (e && (e->processor_id() == this->processor_id())) ?
2259  this->processor_id() : this->n_processors();
2260  this->comm().min(lowest_owner);
2261 
2262  // Everybody should get their value from a processor that was able
2263  // to compute it.
2264  // If nobody admits owning the point, we may have a problem.
2265  if (lowest_owner != this->n_processors())
2266  this->comm().broadcast(hess_u, lowest_owner);
2267  else
2268  libmesh_assert(!insist_on_success);
2269 
2270  return hess_u;
2271 }
MeshBase & mesh
uint8_t processor_id_type
Definition: id_types.h:99
const Parallel::Communicator & comm() const
const MeshBase & get_mesh() const
Definition: system.h:2033
Tensor point_hessian(unsigned int var, const Point &p, const bool insist_on_success=true) const
Definition: system.C:2220
processor_id_type n_processors() const
NumberTensorValue Tensor
processor_id_type processor_id() const
const DofMap & get_dof_map() const
Definition: system.h:2049
void broadcast(T &data, const unsigned int root_id=0) const

◆ point_hessian() [2/3]

Tensor libMesh::System::point_hessian ( unsigned int  var,
const Point p,
const Elem e 
) 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 2273 of file system.C.

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

2274 {
2275  // Ensuring that the given point is really in the element is an
2276  // expensive assert, but as long as debugging is turned on we might
2277  // as well try to catch a particularly nasty potential error
2278  libmesh_assert (e.contains_point(p));
2279 
2280 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
2281  if (e.infinite())
2282  libmesh_not_implemented();
2283 #endif
2284 
2285  // Get the dof map to get the proper indices for our computation
2286  const DofMap & dof_map = this->get_dof_map();
2287 
2288  // Make sure we can evaluate on this element.
2289  libmesh_assert (dof_map.is_evaluable(e, var));
2290 
2291  // Need dof_indices for phi[i][j]
2292  std::vector<dof_id_type> dof_indices;
2293 
2294  // Fill in the dof_indices for our element
2295  dof_map.dof_indices (&e, dof_indices, var);
2296 
2297  // Get the no of dofs associated with this point
2298  const unsigned int num_dofs = cast_int<unsigned int>
2299  (dof_indices.size());
2300 
2301  FEType fe_type = dof_map.variable_type(var);
2302 
2303  // Build a FE again so we can calculate u(p)
2304  std::unique_ptr<FEBase> fe (FEBase::build(e.dim(), fe_type));
2305 
2306  // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h
2307  // Build a vector of point co-ordinates to send to reinit
2308  std::vector<Point> coor(1, FEInterface::inverse_map(e.dim(), fe_type, &e, p));
2309 
2310  // Get the values of the shape function derivatives
2311  const std::vector<std::vector<RealTensor>> & d2phi = fe->get_d2phi();
2312 
2313  // Reinitialize the element and compute the shape function values at coor
2314  fe->reinit (&e, &coor);
2315 
2316  // Get ready to accumulate a hessian
2317  Tensor hess_u;
2318 
2319  for (unsigned int l=0; l<num_dofs; l++)
2320  {
2321  hess_u.add_scaled (d2phi[l][0], this->current_solution (dof_indices[l]));
2322  }
2323 
2324  return hess_u;
2325 }
void add_scaled(const TypeTensor< T2 > &, const T)
Definition: type_tensor.h:808
Number current_solution(const dof_id_type global_dof_number) const
Definition: system.C:194
static std::unique_ptr< FEGenericBase > build(const unsigned int dim, const FEType &type)
static Point inverse_map(const unsigned int dim, const FEType &fe_t, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true)
Definition: fe_interface.C:590
NumberTensorValue Tensor
const DofMap & get_dof_map() const
Definition: system.h:2049

◆ point_hessian() [3/3]

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

References point_hessian().

2330 {
2331  libmesh_assert(e);
2332  return this->point_hessian(var, p, *e);
2333 }
Tensor point_hessian(unsigned int var, const Point &p, const bool insist_on_success=true) const
Definition: system.C:2220

◆ point_value() [1/3]

Number libMesh::System::point_value ( unsigned int  var,
const Point p,
const bool  insist_on_success = true 
) 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.
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 1993 of file system.C.

References libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::PointLocatorBase::enable_out_of_mesh_mode(), get_dof_map(), get_mesh(), mesh, libMesh::Parallel::Communicator::min(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), and libMesh::DofObject::processor_id().

Referenced by point_value().

1994 {
1995  // This function must be called on every processor; there's no
1996  // telling where in the partition p falls.
1997  parallel_object_only();
1998 
1999  // And every processor had better agree about which point we're
2000  // looking for
2001 #ifndef NDEBUG
2002  libmesh_assert(this->comm().verify(p(0)));
2003 #if LIBMESH_DIM > 1
2004  libmesh_assert(this->comm().verify(p(1)));
2005 #endif
2006 #if LIBMESH_DIM > 2
2007  libmesh_assert(this->comm().verify(p(2)));
2008 #endif
2009 #endif // NDEBUG
2010 
2011  // Get a reference to the mesh object associated with the system object that calls this function
2012  const MeshBase & mesh = this->get_mesh();
2013 
2014  // Use an existing PointLocator or create a new one
2015  std::unique_ptr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2016  PointLocatorBase & locator = *locator_ptr;
2017 
2018  if (!insist_on_success || !mesh.is_serial())
2019  locator.enable_out_of_mesh_mode();
2020 
2021  // Get a pointer to the element that contains P
2022  const Elem * e = locator(p);
2023 
2024  Number u = 0;
2025 
2026  if (e && this->get_dof_map().is_evaluable(*e, var))
2027  u = point_value(var, p, *e);
2028 
2029  // If I have an element containing p, then let's let everyone know
2030  processor_id_type lowest_owner =
2031  (e && (e->processor_id() == this->processor_id())) ?
2032  this->processor_id() : this->n_processors();
2033  this->comm().min(lowest_owner);
2034 
2035  // Everybody should get their value from a processor that was able
2036  // to compute it.
2037  // If nobody admits owning the point, we have a problem.
2038  if (lowest_owner != this->n_processors())
2039  this->comm().broadcast(u, lowest_owner);
2040  else
2041  libmesh_assert(!insist_on_success);
2042 
2043  return u;
2044 }
MeshBase & mesh
uint8_t processor_id_type
Definition: id_types.h:99
const Parallel::Communicator & comm() const
const MeshBase & get_mesh() const
Definition: system.h:2033
processor_id_type n_processors() const
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true) const
Definition: system.C:1993
processor_id_type processor_id() const
const DofMap & get_dof_map() const
Definition: system.h:2049
void broadcast(T &data, const unsigned int root_id=0) const

◆ point_value() [2/3]

Number libMesh::System::point_value ( unsigned int  var,
const Point p,
const Elem e 
) const
Returns
The value of the solution variable var at the physical point p contained in local Elem e

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

Definition at line 2046 of file system.C.

References libMesh::FEInterface::compute_data(), libMesh::Elem::contains_point(), current_solution(), libMesh::Elem::dim(), get_dof_map(), get_equation_systems(), and libMesh::FEInterface::inverse_map().

2047 {
2048  // Ensuring that the given point is really in the element is an
2049  // expensive assert, but as long as debugging is turned on we might
2050  // as well try to catch a particularly nasty potential error
2051  libmesh_assert (e.contains_point(p));
2052 
2053  // Get the dof map to get the proper indices for our computation
2054  const DofMap & dof_map = this->get_dof_map();
2055 
2056  // Make sure we can evaluate on this element.
2057  libmesh_assert (dof_map.is_evaluable(e, var));
2058 
2059  // Need dof_indices for phi[i][j]
2060  std::vector<dof_id_type> dof_indices;
2061 
2062  // Fill in the dof_indices for our element
2063  dof_map.dof_indices (&e, dof_indices, var);
2064 
2065  // Get the no of dofs associated with this point
2066  const unsigned int num_dofs = cast_int<unsigned int>
2067  (dof_indices.size());
2068 
2069  FEType fe_type = dof_map.variable_type(var);
2070 
2071  // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h.
2072  Point coor = FEInterface::inverse_map(e.dim(), fe_type, &e, p);
2073 
2074  // get the shape function value via the FEInterface to also handle the case
2075  // of infinite elements correcly, the shape function is not fe->phi().
2076  FEComputeData fe_data(this->get_equation_systems(), coor);
2077  FEInterface::compute_data(e.dim(), fe_type, &e, fe_data);
2078 
2079  // Get ready to accumulate a value
2080  Number u = 0;
2081 
2082  for (unsigned int l=0; l<num_dofs; l++)
2083  {
2084  u += fe_data.shape[l]*this->current_solution (dof_indices[l]);
2085  }
2086 
2087  return u;
2088 }
const EquationSystems & get_equation_systems() const
Definition: system.h:712
Number current_solution(const dof_id_type global_dof_number) const
Definition: system.C:194
static void compute_data(const unsigned int dim, const FEType &fe_t, const Elem *elem, FEComputeData &data)
Definition: fe_interface.C:837
static Point inverse_map(const unsigned int dim, const FEType &fe_t, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true)
Definition: fe_interface.C:590
const DofMap & get_dof_map() const
Definition: system.h:2049

◆ point_value() [3/3]

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

References point_value().

2093 {
2094  libmesh_assert(e);
2095  return this->point_value(var, p, *e);
2096 }
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true) const
Definition: system.C:1993

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

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

88 {
90  out_stream << ReferenceCounter::get_info();
91 }
static std::string 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 101 of file parallel_object.h.

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

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::FEMSystem::assembly(), libMesh::EquationSystems::build_discontinuous_solution_vector(), 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::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::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::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::MeshBase::get_info(), libMesh::DofMap::get_info(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), libMesh::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::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::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(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::DofMap::n_local_dofs(), 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::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(), read_legacy_data(), libMesh::ExodusII_IO_Helper::read_node_num_map(), read_parallel_data(), 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::CheckpointIO::select_split_config(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::Parallel::Packing< T >::unpack(), libMesh::DistributedMesh::update_parallel_id_counts(), 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_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::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(), write_parallel_data(), 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::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().

102  { return cast_int<processor_id_type>(_communicator.rank()); }
const Parallel::Communicator & _communicator
processor_id_type rank() const
Definition: communicator.h:173

◆ project_solution() [1/3]

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

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

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

Definition at line 810 of file system_projection.C.

812 {
813  this->project_vector(*solution, f, g);
814 
815  solution->localize(*current_local_solution, _dof_map->get_send_list());
816 }
std::unique_ptr< DofMap > _dof_map
Definition: system.h:1884
std::unique_ptr< NumericVector< Number > > solution
Definition: system.h:1523
std::unique_ptr< NumericVector< Number > > current_local_solution
Definition: system.h:1535
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const

◆ project_solution() [2/3]

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

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

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

Definition at line 823 of file system_projection.C.

825 {
826  this->project_vector(*solution, f, g);
827 
828  solution->localize(*current_local_solution, _dof_map->get_send_list());
829 }
std::unique_ptr< DofMap > _dof_map
Definition: system.h:1884
std::unique_ptr< NumericVector< Number > > solution
Definition: system.h:1523
std::unique_ptr< NumericVector< Number > > current_local_solution
Definition: system.h:1535
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const

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

799 {
800  WrappedFunction<Number> f(*this, fptr, &parameters);
801  WrappedFunction<Gradient> g(*this, gptr, &parameters);
802  this->project_solution(&f, &g);
803 }
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr) const

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

References _solution_projection.

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

795  { return _solution_projection; }
bool _solution_projection
Definition: system.h:1959

◆ project_vector() [1/5]

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

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

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

Definition at line 851 of file system_projection.C.

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

855 {
856  LOG_SCOPE ("project_vector(FunctionBase)", "System");
857 
858  libmesh_assert(f);
859 
860  WrappedFunctor<Number> f_fem(*f);
861 
862  if (g)
863  {
864  WrappedFunctor<Gradient> g_fem(*g);
865 
866  this->project_vector(new_vector, &f_fem, &g_fem, is_adjoint);
867  }
868  else
869  this->project_vector(new_vector, &f_fem, nullptr, is_adjoint);
870 }
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const

◆ project_vector() [2/5]

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

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

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

Definition at line 877 of file system_projection.C.

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

881 {
882  LOG_SCOPE ("project_fem_vector()", "System");
883 
884  libmesh_assert (f);
885 
886  ConstElemRange active_local_range
887  (this->get_mesh().active_local_elements_begin(),
888  this->get_mesh().active_local_elements_end() );
889 
890  VectorSetAction<Number> setter(new_vector);
891 
892  const unsigned int n_variables = this->n_vars();
893 
894  std::vector<unsigned int> vars(n_variables);
895  std::iota(vars.begin(), vars.end(), 0);
896 
897  // Use a typedef to make the calling sequence for parallel_for() a bit more readable
898  typedef
899  GenericProjector<FEMFunctionWrapper<Number>, FEMFunctionWrapper<Gradient>,
900  Number, VectorSetAction<Number>> FEMProjector;
901 
902  FEMFunctionWrapper<Number> fw(*f);
903 
904  if (g)
905  {
906  FEMFunctionWrapper<Gradient> gw(*g);
907 
909  (active_local_range,
910  FEMProjector(*this, fw, &gw, setter, vars));
911  }
912  else
914  (active_local_range,
915  FEMProjector(*this, fw, nullptr, setter, vars));
916 
917  // Also, load values into the SCALAR dofs
918  // Note: We assume that all SCALAR dofs are on the
919  // processor with highest ID
920  if (this->processor_id() == (this->n_processors()-1))
921  {
922  // FIXME: Do we want to first check for SCALAR vars before building this? [PB]
923  FEMContext context( *this );
924 
925  const DofMap & dof_map = this->get_dof_map();
926  for (unsigned int var=0; var<this->n_vars(); var++)
927  if (this->variable(var).type().family == SCALAR)
928  {
929  // FIXME: We reinit with an arbitrary element in case the user
930  // doesn't override FEMFunctionBase::component. Is there
931  // any use case we're missing? [PB]
932  Elem * el = const_cast<Elem *>(*(this->get_mesh().active_local_elements_begin()));
933  context.pre_fe_reinit(*this, el);
934 
935  std::vector<dof_id_type> SCALAR_indices;
936  dof_map.SCALAR_dof_indices (SCALAR_indices, var);
937  const unsigned int n_SCALAR_dofs =
938  cast_int<unsigned int>(SCALAR_indices.size());
939 
940  for (unsigned int i=0; i<n_SCALAR_dofs; i++)
941  {
942  const dof_id_type global_index = SCALAR_indices[i];
943  const unsigned int component_index =
944  this->variable_scalar_number(var,i);
945 
946  new_vector.set(global_index, f->component(context, component_index, Point(), this->time));
947  }
948  }
949  }
950 
951  new_vector.close();
952 
953 #ifdef LIBMESH_ENABLE_CONSTRAINTS
954  if (is_adjoint == -1)
955  this->get_dof_map().enforce_constraints_exactly(*this, &new_vector);
956  else if (is_adjoint >= 0)
958  is_adjoint);
959 #endif
960 }
FEFamily family
Definition: fe_type.h:204
unsigned int variable_scalar_number(const std::string &var, unsigned int component) const
Definition: system.h:2164
const Variable & variable(unsigned int var) const
Definition: system.h:2133
void parallel_for(const Range &range, const Body &body)
Definition: threads_none.h:73
const MeshBase & get_mesh() const
Definition: system.h:2033
void iota(ForwardIter first, ForwardIter last, T value)
Definition: utility.h:57
StoredRange< MeshBase::const_element_iterator, const Elem * > ConstElemRange
Definition: elem_range.h:34
void enforce_adjoint_constraints_exactly(NumericVector< Number > &v, unsigned int q) const
processor_id_type n_processors() const
virtual element_iterator active_local_elements_begin()=0
virtual void close()=0
virtual void set(const numeric_index_type i, const T value)=0
unsigned int n_vars() const
Definition: system.h:2105
processor_id_type processor_id() const
const DofMap & get_dof_map() const
Definition: system.h:2049
uint8_t dof_id_type
Definition: id_types.h:64
const FEType & type() const
Definition: variable.h:119
void enforce_constraints_exactly(const System &system, NumericVector< Number > *v=nullptr, bool homogeneous=false) const

◆ project_vector() [3/5]

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

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

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

Definition at line 836 of file system_projection.C.

841 {
842  WrappedFunction<Number> f(*this, fptr, &parameters);
843  WrappedFunction<Gradient> g(*this, gptr, &parameters);
844  this->project_vector(new_vector, &f, &g, is_adjoint);
845 }
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const

◆ project_vector() [4/5]

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

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

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

Definition at line 212 of file system_projection.C.

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

214 {
215  // Create a copy of the vector, which currently
216  // contains the old data.
217  std::unique_ptr<NumericVector<Number>>
218  old_vector (vector.clone());
219 
220  // Project the old vector to the new vector
221  this->project_vector (*old_vector, vector, is_adjoint);
222 }
virtual std::unique_ptr< NumericVector< T > > clone() const =0
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const

◆ project_vector() [5/5]

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

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

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

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

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

Definition at line 730 of file system_projection.C.

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

731 {
732  LOG_SCOPE ("projection_matrix()", "System");
733 
734  const unsigned int n_variables = this->n_vars();
735 
736  if (n_variables)
737  {
738  ConstElemRange active_local_elem_range
739  (this->get_mesh().active_local_elements_begin(),
740  this->get_mesh().active_local_elements_end());
741 
742  std::vector<unsigned int> vars(n_variables);
743  std::iota(vars.begin(), vars.end(), 0);
744 
745  // Use a typedef to make the calling sequence for parallel_for() a bit more readable
746  typedef OldSolutionCoefs<Real, &FEMContext::point_value> OldSolutionValueCoefs;
747  typedef OldSolutionCoefs<RealGradient, &FEMContext::point_gradient> OldSolutionGradientCoefs;
748 
749  typedef
750  GenericProjector<OldSolutionValueCoefs,
751  OldSolutionGradientCoefs,
752  DynamicSparseNumberArray<Real,dof_id_type>,
753  MatrixFillAction<Real, Number> > ProjMatFiller;
754 
755  OldSolutionValueCoefs f(*this);
756  OldSolutionGradientCoefs g(*this);
757  MatrixFillAction<Real, Number> setter(proj_mat);
758 
759  Threads::parallel_for (active_local_elem_range,
760  ProjMatFiller(*this, f, &g, setter, vars));
761 
762  // Set the SCALAR dof transfer entries too.
763  // Note: We assume that all SCALAR dofs are on the
764  // processor with highest ID
765  if (this->processor_id() == (this->n_processors()-1))
766  {
767  const DofMap & dof_map = this->get_dof_map();
768  for (unsigned int var=0; var<this->n_vars(); var++)
769  if (this->variable(var).type().family == SCALAR)
770  {
771  // We can just map SCALAR dofs directly across
772  std::vector<dof_id_type> new_SCALAR_indices, old_SCALAR_indices;
773  dof_map.SCALAR_dof_indices (new_SCALAR_indices, var, false);
774  dof_map.SCALAR_dof_indices (old_SCALAR_indices, var, true);
775  const unsigned int new_n_dofs =
776  cast_int<unsigned int>(new_SCALAR_indices.size());
777 
778  for (unsigned int i=0; i<new_n_dofs; i++)
779  {
780  proj_mat.set( new_SCALAR_indices[i],
781  old_SCALAR_indices[i], 1);
782  }
783  }
784  }
785  }
786 }
FEFamily family
Definition: fe_type.h:204
const Variable & variable(unsigned int var) const
Definition: system.h:2133
void parallel_for(const Range &range, const Body &body)
Definition: threads_none.h:73
const MeshBase & get_mesh() const
Definition: system.h:2033
void iota(ForwardIter first, ForwardIter last, T value)
Definition: utility.h:57
StoredRange< MeshBase::const_element_iterator, const Elem * > ConstElemRange
Definition: elem_range.h:34
virtual void set(const numeric_index_type i, const numeric_index_type j, const T value)=0
processor_id_type n_processors() const
unsigned int n_vars() const
Definition: system.h:2105
processor_id_type processor_id() const
const DofMap & get_dof_map() const
Definition: system.h:2049
const FEType & type() const
Definition: variable.h:119

◆ prolong_vectors()

void libMesh::System::prolong_vectors ( )
virtual

Prolong vectors after the mesh has refined

Definition at line 380 of file system.C.

References restrict_vectors().

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

381 {
382 #ifdef LIBMESH_ENABLE_AMR
383  // Currently project_vector handles both restriction and prolongation
384  this->restrict_vectors();
385 #endif
386 }
virtual void restrict_vectors()
Definition: system.C:324

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

2337 {
2338  libmesh_not_implemented();
2339 }

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

2347 {
2348  libmesh_not_implemented();
2349 }

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

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

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 }
virtual void forward_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
Definition: system.h:2325
virtual void adjoint_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
Definition: system.h:2316

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

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

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 }
std::unique_ptr< NumericVector< Number > > solution
Definition: system.h:1523
std::unique_ptr< NumericVector< Number > > current_local_solution
Definition: system.h:1535
unsigned int n_vars() const
Definition: system.h:2105
const DofMap & get_dof_map() const
Definition: system.h:2049
const std::vector< dof_id_type > & get_send_list() const
Definition: dof_map.h:450

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

References _additional_data_written, _written_var_indices, add_variable(), add_vector(), libMesh::Parallel::Communicator::broadcast(), clear(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::FEType::family, get_mesh(), libMesh::OrderWrapper::get_order(), libMesh::FEType::inf_map, 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().

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

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

Deprecated:
The ability to read XDR data files in the old (aka "legacy") XDR format has been deprecated for many years, this capability may soon disappear altogether.

Definition at line 310 of file system_io.C.

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

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

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

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

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

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

1301  { 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 1121 of file system_io.C.

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

Referenced by read_serialized_vector(), and read_serialized_vectors().

1124 {
1125  unsigned int n_assigned_vals = 0; // the number of values assigned, this will be returned.
1126 
1127  // Processor 0 will read the block from the buffer stream and send it to the last processor
1128  const unsigned int n_SCALAR_dofs = this->variable(var).type().order.get_order();
1129  std::vector<Number> input_buffer(n_SCALAR_dofs);
1130  if (this->processor_id() == 0)
1131  io.data_stream(input_buffer.data(), n_SCALAR_dofs);
1132 
1133 #ifdef LIBMESH_HAVE_MPI
1134  if (this->n_processors() > 1)
1135  {
1136  const Parallel::MessageTag val_tag = this->comm().get_unique_tag(321);
1137 
1138  // Post the receive on the last processor
1139  if (this->processor_id() == (this->n_processors()-1))
1140  this->comm().receive(0, input_buffer, val_tag);
1141 
1142  // Send the data to processor 0
1143  if (this->processor_id() == 0)
1144  this->comm().send(this->n_processors()-1, input_buffer, val_tag);
1145  }
1146 #endif
1147 
1148  // Finally, set the SCALAR values
1149  if (this->processor_id() == (this->n_processors()-1))
1150  {
1151  const DofMap & dof_map = this->get_dof_map();
1152  std::vector<dof_id_type> SCALAR_dofs;
1153  dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
1154 
1155  for (std::size_t i=0; i<SCALAR_dofs.size(); i++)
1156  {
1157  if (vec)
1158  vec->set (SCALAR_dofs[i], input_buffer[i]);
1159  ++n_assigned_vals;
1160  }
1161  }
1162 
1163  return n_assigned_vals;
1164 }
void send(const unsigned int dest_processor_id, const T &buf, const MessageTag &tag=no_tag) const
const Variable & variable(unsigned int var) const
Definition: system.h:2133
const Parallel::Communicator & comm() const
OrderWrapper order
Definition: fe_type.h:198
MessageTag get_unique_tag(int tagvalue) const
Definition: communicator.C:201
processor_id_type n_processors() const
int get_order() const
Definition: fe_type.h:78
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_tag) const
virtual void set(const numeric_index_type i, const T value)=0
processor_id_type processor_id() const
const DofMap & get_dof_map() const
Definition: system.h:2049
const FEType & type() const
Definition: variable.h:119

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

References _written_var_indices, libMesh::Parallel::any_source, libMesh::ParallelObject::comm(), end, libMesh::Parallel::Communicator::get_unique_tag(), libMesh::MeshTools::Generation::Private::idx(), libMesh::invalid_uint, libMesh::Threads::NonConcurrentThread::join(), std::min(), libMesh::ParallelObject::n_processors(), n_vars(), number(), libMesh::ParallelObject::processor_id(), libMesh::Parallel::Communicator::receive(), libMesh::Parallel::Communicator::send(), libMesh::Parallel::Status::source(), libMesh::Parallel::Communicator::sum(), and libMesh::Parallel::wait().

Referenced by read_serialized_vector(), and read_serialized_vectors().

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

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

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

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

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

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

◆ read_serialized_vector() [1/2]

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

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

Returns
The length of the vector read.

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

Definition at line 1168 of file system_io.C.

References _written_var_indices, libMesh::Parallel::Communicator::broadcast(), libMesh::NumericVector< T >::close(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), get_mesh(), libMesh::GHOSTED, 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::Parallel::Communicator::sum(), libMesh::NumericVector< T >::type(), variable(), and libMesh::Xdr::version().

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

◆ read_serialized_vector() [2/2]

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

Non-templated version for backward compatibility.

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

Returns
The length of the vector read.

Definition at line 1785 of file system.h.

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

◆ read_serialized_vectors() [1/2]

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

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

Definition at line 2203 of file system_io.C.

References libMesh::Xdr::data(), libMesh::FEType::family, get_mesh(), 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, libMesh::Variable::type(), and variable().

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

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

1279  { 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.

References current_local_solution, and solution.

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

391 {
392  // project_vector handles vector initialization now
393  libmesh_assert_equal_to (solution->size(), current_local_solution->size());
394 }
std::unique_ptr< NumericVector< Number > > solution
Definition: system.h:1523
std::unique_ptr< NumericVector< Number > > current_local_solution
Definition: system.h:1535

◆ reinit_constraints()

void libMesh::System::reinit_constraints ( )
virtual

Reinitializes the constraints for this system.

Definition at line 397 of file system.C.

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

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

398 {
399 #ifdef LIBMESH_ENABLE_CONSTRAINTS
401  user_constrain();
403 #endif
405 }
void process_constraints(MeshBase &)
void create_dof_constraints(const MeshBase &, Real time=0)
void prepare_send_list()
Definition: dof_map.C:1639
virtual void user_constrain()
Definition: system.C:1946
const DofMap & get_dof_map() const
Definition: system.h:2049
MeshBase & _mesh
Definition: system.h:1896

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

References _vector_is_adjoint, _vector_projections, _vector_types, and _vectors.

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 }
std::map< std::string, ParallelType > _vector_types
Definition: system.h:1952
std::map< std::string, int > _vector_is_adjoint
Definition: system.h:1947
std::map< std::string, NumericVector< Number > * >::iterator vectors_iterator
Definition: system.h:748
std::map< std::string, NumericVector< Number > *> _vectors
Definition: system.h:1935
std::map< std::string, bool > _vector_projections
Definition: system.h:1941

◆ request_vector() [1/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.

References _vectors.

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

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 }
std::map< std::string, NumericVector< Number > * >::const_iterator const_vectors_iterator
Definition: system.h:749
std::map< std::string, NumericVector< Number > *> _vectors
Definition: system.h:1935

◆ request_vector() [2/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.

References _vectors.

729 {
730  vectors_iterator pos = _vectors.find(vec_name);
731 
732  if (pos == _vectors.end())
733  return nullptr;
734 
735  return pos->second;
736 }
std::map< std::string, NumericVector< Number > * >::iterator vectors_iterator
Definition: system.h:748
std::map< std::string, NumericVector< Number > *> _vectors
Definition: system.h:1935

◆ request_vector() [3/4]

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

Definition at line 740 of file system.C.

References vectors_begin(), and vectors_end().

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 }
vectors_iterator vectors_end()
Definition: system.h:2257
std::map< std::string, NumericVector< Number > * >::const_iterator const_vectors_iterator
Definition: system.h:749
vectors_iterator vectors_begin()
Definition: system.h:2245

◆ request_vector() [4/4]

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

Definition at line 757 of file system.C.

References vectors_begin(), and vectors_end().

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 }
vectors_iterator vectors_end()
Definition: system.h:2257
vectors_iterator vectors_begin()
Definition: system.h:2245
std::map< std::string, NumericVector< Number > * >::iterator vectors_iterator
Definition: system.h:748

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

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

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 }
std::map< std::string, ParallelType > _vector_types
Definition: system.h:1952
int vector_is_adjoint(const std::string &vec_name) const
Definition: system.C:896
std::unique_ptr< DofMap > _dof_map
Definition: system.h:1884
dof_id_type n_local_dofs() const
Definition: system.C:187
dof_id_type n_dofs() const
Definition: system.C:150
std::unique_ptr< NumericVector< Number > > solution
Definition: system.h:1523
bool _solution_projection
Definition: system.h:1959
std::map< std::string, NumericVector< Number > *> _vectors
Definition: system.h:1935
std::map< std::string, bool > _vector_projections
Definition: system.h:1941
std::unique_ptr< NumericVector< Number > > current_local_solution
Definition: system.h:1535
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const

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

2286 {
2287  libmesh_not_implemented();
2288 }

◆ set_adjoint_already_solved()

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

Setter for the adjoint_already_solved boolean

Definition at line 394 of file system.h.

References adjoint_already_solved.

395  { adjoint_already_solved = setting;}
bool adjoint_already_solved
Definition: system.h:2003

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

References _basic_system_only.

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

2098 {
2099  _basic_system_only = true;
2100 }
bool _basic_system_only
Definition: system.h:1965

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

References _vector_is_adjoint.

Referenced by add_adjoint_solution(), and add_weighted_sensitivity_adjoint_solution().

887 {
888  // We reserve -1 for vectors which get primal constraints, -2 for
889  // vectors which get no constraints
890  libmesh_assert_greater_equal(qoi_num, -2);
891  _vector_is_adjoint[vec_name] = qoi_num;
892 }
std::map< std::string, int > _vector_is_adjoint
Definition: system.h:1947

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

References _vector_projections.

869 {
870  _vector_projections[vec_name] = preserve;
871 }
std::map< std::string, bool > _vector_projections
Definition: system.h:1941

◆ solve()

◆ system()

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

Definition at line 240 of file system.h.

240 { 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, and libMesh::TransientSystem< RBConstruction >.

Definition at line 487 of file system.h.

Referenced by get_info().

487 { return "Basic"; }

◆ update()

void libMesh::System::update ( )
virtual

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

Definition at line 408 of file system.C.

References _dof_map, current_local_solution, 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(), 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(), DMlibMeshFunction(), DMlibMeshJacobian(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_residual_helper(), libMesh::NewtonSolver::line_search(), libMesh::FEMSystem::mesh_position_get(), libMesh::FEMSystem::postprocess(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::NewtonSolver::solve(), libMesh::ExplicitSystem::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::NonlinearImplicitSystem::solve(), and libMesh::OptimizationSystem::solve().

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 }
std::unique_ptr< DofMap > _dof_map
Definition: system.h:1884
std::unique_ptr< NumericVector< Number > > solution
Definition: system.h:1523
std::unique_ptr< NumericVector< Number > > current_local_solution
Definition: system.h:1535

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

References solution.

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

643 {
644  global_soln.resize (solution->size());
645 
646  solution->localize (global_soln);
647 }
std::unique_ptr< NumericVector< Number > > solution
Definition: system.h:1523

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

References solution.

653 {
654  global_soln.resize (solution->size());
655 
656  solution->localize_to_one (global_soln, dest_proc);
657 }
std::unique_ptr< NumericVector< Number > > solution
Definition: system.h:1523

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

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

Referenced by assemble().

1933 {
1934  // Call the user-provided assembly function,
1935  // if it was provided
1936  if (_assemble_system_function != nullptr)
1938 
1939  // ...or the user-provided assembly object.
1940  else if (_assemble_system_object != nullptr)
1942 }
Assembly * _assemble_system_object
Definition: system.h:1841
virtual void assemble()=0
EquationSystems & _equation_systems
Definition: system.h:1890
const std::string & name() const
Definition: system.h:2017
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1835

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

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

Referenced by reinit_constraints().

1947 {
1948  // Call the user-provided constraint function,
1949  // if it was provided
1950  if (_constrain_system_function!= nullptr)
1952 
1953  // ...or the user-provided constraint object.
1954  else if (_constrain_system_object != nullptr)
1956 }
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1846
Constraint * _constrain_system_object
Definition: system.h:1852
EquationSystems & _equation_systems
Definition: system.h:1890
virtual void constrain()=0
const std::string & name() const
Definition: system.h:2017

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

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

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

1919 {
1920  // Call the user-provided initialization function,
1921  // if it was provided
1922  if (_init_system_function != nullptr)
1923  this->_init_system_function (_equation_systems, this->name());
1924 
1925  // ...or the user-provided initialization object.
1926  else if (_init_system_object != nullptr)
1928 }
Initialization * _init_system_object
Definition: system.h:1830
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1824
EquationSystems & _equation_systems
Definition: system.h:1890
const std::string & name() const
Definition: system.h:2017

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

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

Referenced by assemble_qoi().

1961 {
1962  // Call the user-provided quantity of interest function,
1963  // if it was provided
1964  if (_qoi_evaluate_function != nullptr)
1965  this->_qoi_evaluate_function(_equation_systems, this->name(), qoi_indices);
1966 
1967  // ...or the user-provided QOI function object.
1968  else if (_qoi_evaluate_object != nullptr)
1969  this->_qoi_evaluate_object->qoi(qoi_indices);
1970 }
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Definition: system.h:1857
virtual void qoi(const QoISet &qoi_indices)=0
QOI * _qoi_evaluate_object
Definition: system.h:1864
EquationSystems & _equation_systems
Definition: system.h:1890
const std::string & name() const
Definition: system.h:2017

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

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

Referenced by assemble_qoi_derivative().

1977 {
1978  // Call the user-provided quantity of interest derivative,
1979  // if it was provided
1980  if (_qoi_evaluate_derivative_function != nullptr)
1982  (_equation_systems, this->name(), qoi_indices, include_liftfunc,
1983  apply_constraints);
1984 
1985  // ...or the user-provided QOI derivative function object.
1986  else if (_qoi_evaluate_derivative_object != nullptr)
1988  (qoi_indices, include_liftfunc, apply_constraints);
1989 }
QOIDerivative * _qoi_evaluate_derivative_object
Definition: system.h:1878
virtual void qoi_derivative(const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)=0
EquationSystems & _equation_systems
Definition: system.h:1890
const std::string & name() const
Definition: system.h:2017
void(* _qoi_evaluate_derivative_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
Definition: system.h:1869

◆ variable()

◆ variable_group()

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

Return a constant reference to VariableGroup vg.

Definition at line 2143 of file system.h.

References _variable_groups.

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

2144 {
2145  libmesh_assert_less (vg, _variable_groups.size());
2146 
2147  return _variable_groups[vg];
2148 }
std::vector< VariableGroup > _variable_groups
Definition: system.h:1916

◆ variable_name()

const std::string & libMesh::System::variable_name ( const unsigned int  i) const
inline
Returns
The name of variable i.

Definition at line 2153 of file system.h.

References _variables.

Referenced by add_variable(), add_variables(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::PetscDMWrapper::build_section(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::ExactSolution::ExactSolution(), libMesh::petsc_auto_fieldsplit(), and write_header().

2154 {
2155  libmesh_assert_less (i, _variables.size());
2156 
2157  return _variables[i].name();
2158 }
std::vector< Variable > _variables
Definition: system.h:1911

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

References _variable_numbers, and _variables.

Referenced by libMesh::ExactSolution::_compute_error(), 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(), read_header(), variable_scalar_number(), variable_type(), libMesh::EnsightIO::write_scalar_ascii(), and libMesh::EnsightIO::write_vector_ascii().

1244 {
1245  // Make sure the variable exists
1246  std::map<std::string, unsigned short int>::const_iterator
1247  pos = _variable_numbers.find(var);
1248 
1249  if (pos == _variable_numbers.end())
1250  libmesh_error_msg("ERROR: variable " << var << " does not exist in this system!");
1251 
1252  libmesh_assert_equal_to (_variables[pos->second].name(), var);
1253 
1254  return pos->second;
1255 }
std::map< std::string, unsigned short int > _variable_numbers
Definition: system.h:1922
std::vector< Variable > _variables
Definition: system.h:1911

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

References variable_number().

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

2166 {
2167  return variable_scalar_number(this->variable_number(var), component);
2168 }
unsigned int variable_scalar_number(const std::string &var, unsigned int component) const
Definition: system.h:2164
unsigned short int variable_number(const std::string &var) const
Definition: system.C:1243

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

References _variables.

2176 {
2177  return _variables[var_num].first_scalar_number() + component;
2178 }
std::vector< Variable > _variables
Definition: system.h:1911

◆ variable_type() [1/2]

◆ variable_type() [2/2]

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

Definition at line 2193 of file system.h.

References _variables, and variable_number().

2194 {
2195  return _variables[this->variable_number(var)].type();
2196 }
std::vector< Variable > _variables
Definition: system.h:1911
unsigned short int variable_number(const std::string &var) const
Definition: system.C:1243

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

References _vector_is_adjoint.

Referenced by restrict_vectors().

897 {
898  libmesh_assert(_vector_is_adjoint.find(vec_name) !=
899  _vector_is_adjoint.end());
900 
901  return _vector_is_adjoint.find(vec_name)->second;
902 }
std::map< std::string, int > _vector_is_adjoint
Definition: system.h:1947

◆ vector_name() [1/2]

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

Definition at line 832 of file system.C.

References vectors_begin(), and vectors_end().

833 {
836  unsigned int num = 0;
837  while ((num<vec_num) && (v!=v_end))
838  {
839  num++;
840  ++v;
841  }
842  libmesh_assert (v != v_end);
843  return v->first;
844 }
vectors_iterator vectors_end()
Definition: system.h:2257
std::map< std::string, NumericVector< Number > * >::const_iterator const_vectors_iterator
Definition: system.h:749
vectors_iterator vectors_begin()
Definition: system.h:2245

◆ vector_name() [2/2]

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

Definition at line 846 of file system.C.

References vectors_begin(), and vectors_end().

847 {
850 
851  for (; v != v_end; ++v)
852  {
853  // Check if the current vector is the one whose name we want
854  if (&vec_reference == v->second)
855  break; // exit loop if it is
856  }
857 
858  // Before returning, make sure we didnt loop till the end and not find any match
859  libmesh_assert (v != v_end);
860 
861  // Return the string associated with the current vector
862  return v->first;
863 }
vectors_iterator vectors_end()
Definition: system.h:2257
std::map< std::string, NumericVector< Number > * >::const_iterator const_vectors_iterator
Definition: system.h:749
vectors_iterator vectors_begin()
Definition: system.h:2245

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

References _vector_projections.

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

876 {
877  if (_vector_projections.find(vec_name) == _vector_projections.end())
878  return false;
879 
880  return _vector_projections.find(vec_name)->second;
881 }
std::map< std::string, bool > _vector_projections
Definition: system.h:1941

◆ vectors_begin() [1/2]

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

Beginning of vectors container

Definition at line 2245 of file system.h.

References _vectors.

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

2246 {
2247  return _vectors.begin();
2248 }
std::map< std::string, NumericVector< Number > *> _vectors
Definition: system.h:1935

◆ vectors_begin() [2/2]

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

Beginning of vectors container

Definition at line 2251 of file system.h.

References _vectors.

2252 {
2253  return _vectors.begin();
2254 }
std::map< std::string, NumericVector< Number > *> _vectors
Definition: system.h:1935

◆ vectors_end() [1/2]

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

End of vectors container

Definition at line 2257 of file system.h.

References _vectors.

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

2258 {
2259  return _vectors.end();
2260 }
std::map< std::string, NumericVector< Number > *> _vectors
Definition: system.h:1935

◆ vectors_end() [2/2]

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

End of vectors container

Definition at line 2263 of file system.h.

References _vectors.

2264 {
2265  return _vectors.end();
2266 }
std::map< std::string, NumericVector< Number > *> _vectors
Definition: system.h:1935

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

2310 {
2311  libmesh_not_implemented();
2312 }

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

2294 {
2295  libmesh_not_implemented();
2296 }

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

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

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

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

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

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

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

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

Referenced by write_serialized_vector(), and write_serialized_vectors().

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

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

References libMesh::Parallel::any_source, libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), end, libMesh::Parallel::Communicator::get_unique_tag(), libMesh::MeshTools::Generation::Private::idx(), libMesh::invalid_uint, std::min(), libMesh::ParallelObject::n_processors(), n_vars(), number(), libMesh::ParallelObject::processor_id(), libMesh::Parallel::Communicator::receive(), libMesh::Parallel::Communicator::send(), libMesh::Parallel::Status::source(), and libMesh::Parallel::wait().

Referenced by write_serialized_vector(), and write_serialized_vectors().

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

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

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

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

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

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

Referenced by write_serialized_data().

2158 {
2159  parallel_object_only();
2160 
2161  libmesh_assert (io.writing());
2162 
2163  dof_id_type vec_length = vec.size();
2164  if (this->processor_id() == 0) io.data (vec_length, "# vector length");
2165 
2166  dof_id_type written_length = 0;
2167 
2168  //---------------------------------
2169  // Collect the values for all nodes
2170  written_length += cast_int<dof_id_type>
2171  (this->write_serialized_blocked_dof_objects (std::vector<const NumericVector<Number> *>(1,&vec),
2172  this->get_mesh().n_nodes(),
2173  this->get_mesh().local_nodes_begin(),
2174  this->get_mesh().local_nodes_end(),
2175  io));
2176 
2177  //------------------------------------
2178  // Collect the values for all elements
2179  written_length += cast_int<dof_id_type>
2180  (this->write_serialized_blocked_dof_objects (std::vector<const NumericVector<Number> *>(1,&vec),
2181  this->get_mesh().n_elem(),
2182  this->get_mesh().local_elements_begin(),
2183  this->get_mesh().local_elements_end(),
2184  io));
2185 
2186  //-------------------------------------------
2187  // Finally loop over all the SCALAR variables
2188  for (unsigned int var=0; var<this->n_vars(); var++)
2189  if (this->variable(var).type().family == SCALAR)
2190  {
2191  written_length +=
2192  this->write_SCALAR_dofs (vec, var, io);
2193  }
2194 
2195  if (this->processor_id() == 0)
2196  libmesh_assert_equal_to (written_length, vec_length);
2197 
2198  return written_length;
2199 }
FEFamily family
Definition: fe_type.h:204
const Variable & variable(unsigned int var) const
Definition: system.h:2133
dof_id_type n_elem(const MeshBase::const_element_iterator &begin, const MeshBase::const_element_iterator &end)
Definition: mesh_tools.C:702
virtual numeric_index_type size() const =0
unsigned int write_SCALAR_dofs(const NumericVector< Number > &vec, const unsigned int var, Xdr &io) const
Definition: system_io.C:2101
const MeshBase & get_mesh() const
Definition: system.h:2033
const dof_id_type n_nodes
Definition: tecplot_io.C:68
unsigned int n_vars() const
Definition: system.h:2105
processor_id_type processor_id() const
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
Definition: system_io.C:1815
uint8_t dof_id_type
Definition: id_types.h:64
const FEType & type() const
Definition: variable.h:119

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

References libMesh::Xdr::data(), libMesh::FEType::family, get_mesh(), libMesh::MeshBase::n_elem(), libMesh::MeshTools::n_elem(), n_nodes, libMesh::MeshBase::n_nodes(), n_vars(), libMesh::ParallelObject::processor_id(), libMesh::SCALAR, libMesh::Variable::type(), variable(), write_SCALAR_dofs(), write_serialized_blocked_dof_objects(), and libMesh::Xdr::writing().

2299 {
2300  parallel_object_only();
2301 
2302  libmesh_assert (io.writing());
2303 
2304  // Cache these - they are not free!
2305  const dof_id_type
2306  n_nodes = this->get_mesh().n_nodes(),
2307  n_elem = this->get_mesh().n_elem();
2308 
2309  std::size_t written_length = 0;
2310 
2311  if (this->processor_id() == 0)
2312  {
2313  unsigned int
2314  n_vec = cast_int<unsigned int>(vectors.size());
2315  dof_id_type
2316  vec_size = vectors.empty() ? 0 : vectors[0]->size();
2317  // Set the number of vectors
2318  io.data(n_vec, "# number of vectors");
2319  // Set the buffer size
2320  io.data(vec_size, "# vector length");
2321  }
2322 
2323  //---------------------------------
2324  // Collect the values for all nodes
2325  written_length +=
2326  this->write_serialized_blocked_dof_objects (vectors,
2327  n_nodes,
2328  this->get_mesh().local_nodes_begin(),
2329  this->get_mesh().local_nodes_end(),
2330  io);
2331 
2332  //------------------------------------
2333  // Collect the values for all elements
2334  written_length +=
2335  this->write_serialized_blocked_dof_objects (vectors,
2336  n_elem,
2337  this->get_mesh().local_elements_begin(),
2338  this->get_mesh().local_elements_end(),
2339  io);
2340 
2341  //-------------------------------------------
2342  // Finally loop over all the SCALAR variables
2343  for (std::size_t vec=0; vec<vectors.size(); vec++)
2344  for (unsigned int var=0; var<this->n_vars(); var++)
2345  if (this->variable(var).type().family == SCALAR)
2346  {
2347  libmesh_assert_not_equal_to (vectors[vec], 0);
2348 
2349  written_length +=
2350  this->write_SCALAR_dofs (*vectors[vec], var, io);
2351  }
2352 
2353  return written_length;
2354 }
FEFamily family
Definition: fe_type.h:204
const Variable & variable(unsigned int var) const
Definition: system.h:2133
dof_id_type n_elem(const MeshBase::const_element_iterator &begin, const MeshBase::const_element_iterator &end)
Definition: mesh_tools.C:702
unsigned int write_SCALAR_dofs(const NumericVector< Number > &vec, const unsigned int var, Xdr &io) const
Definition: system_io.C:2101
const MeshBase & get_mesh() const
Definition: system.h:2033
const dof_id_type n_nodes
Definition: tecplot_io.C:68
unsigned int n_vars() const
Definition: system.h:2105
virtual dof_id_type n_elem() const =0
processor_id_type processor_id() const
virtual dof_id_type n_nodes() const =0
std::size_t write_serialized_blocked_dof_objects(const std::vector< const NumericVector< Number > *> &vecs, const dof_id_type n_objects, const iterator_type begin, const iterator_type end, Xdr &io, const unsigned int var_to_write=libMesh::invalid_uint) const
Definition: system_io.C:1815
uint8_t dof_id_type
Definition: id_types.h:64
const FEType & type() const
Definition: variable.h:119

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

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

1324 {
1325  /* Make sure the call makes sense. */
1326  libmesh_assert_less (var_num, this->n_vars());
1327 
1328  /* Get a reference to the mesh. */
1329  const MeshBase & mesh = this->get_mesh();
1330 
1331  /* Check which system we are. */
1332  const unsigned int sys_num = this->number();
1333 
1334  // Loop over nodes.
1335  for (const auto & node : mesh.local_node_ptr_range())
1336  {
1337  unsigned int n_comp = node->n_comp(sys_num,var_num);
1338  for (unsigned int i=0; i<n_comp; i++)
1339  {
1340  const dof_id_type index = node->dof_number(sys_num,var_num,i);
1341  v.set(index,0.0);
1342  }
1343  }
1344 
1345  // Loop over elements.
1346  for (const auto & elem : mesh.active_local_element_ptr_range())
1347  {
1348  unsigned int n_comp = elem->n_comp(sys_num,var_num);
1349  for (unsigned int i=0; i<n_comp; i++)
1350  {
1351  const dof_id_type index = elem->dof_number(sys_num,var_num,i);
1352  v.set(index,0.0);
1353  }
1354  }
1355 }
MeshBase & mesh
const MeshBase & get_mesh() const
Definition: system.h:2033
unsigned int number() const
Definition: system.h:2025
virtual void set(const numeric_index_type i, const T value)=0
unsigned int n_vars() const
Definition: system.h:2105
uint8_t dof_id_type
Definition: id_types.h:64

Member Data Documentation

◆ _active

bool libMesh::System::_active
private

Flag stating if the system is active or not.

Definition at line 1927 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 1984 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 1835 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 1841 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 1965 of file system.h.

Referenced by init(), and set_basic_system_only().

◆ _communicator

◆ _constrain_system_function

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

Function to impose constraints.

Definition at line 1846 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 1852 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 1884 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 1890 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 2009 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 1977 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 1824 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 1830 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 1971 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 1896 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 1869 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 1878 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 1857 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 1864 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 1959 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 1901 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 1906 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 1916 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 1922 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 1947 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 1941 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 1952 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 1935 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 1996 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 2003 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 1477 of file system.h.

Referenced by libMesh::ImplicitSystem::adjoint_solve(), libMesh::ImplicitSystem::disable_cache(), disable_cache(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::CondensedEigenSystem::solve(), libMesh::EigenSystem::solve(), and libMesh::LinearImplicitSystem::solve().

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

◆ 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 1523 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::NewmarkSolver::advance_timestep(), libMesh::AdaptiveTimeSolver::advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), libMesh::ContinuationSystem::apply_predictor(), libMesh::FEMSystem::assembly(), libMesh::LinearImplicitSystem::assembly(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), clear(), compare(), libMesh::NewmarkSolver::compute_initial_accel(), 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(), DMCreateGlobalVector_libMesh(), DMlibMeshFunction(), DMlibMeshJacobian(), libMesh::UnsteadySolver::du(), libMesh::DofMap::enforce_constraints_exactly(), 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::CondensedEigenSystem::get_eigenpair(), libMesh::EigenSystem::get_eigenpair(), init_data(), libMesh::ContinuationSystem::initialize_tangent(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_postcheck(), libMesh::libmesh_petsc_snes_residual_helper(), libMesh::DofMap::max_constraint_error(), libMesh::FEMSystem::mesh_position_get(), libMesh::ErrorVector::plot_error(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), re_update(), read_legacy_data(), read_parallel_data(), read_serialized_data(), reinit(), restrict_vectors(), libMesh::MemorySolutionHistory::retrieve(), libMesh::ContinuationSystem::save_current_solution(), libMesh::TwostepTimeSolver::solve(), libMesh::NewtonSolver::solve(), libMesh::PetscDiffSolver::solve(), libMesh::FrequencySystem::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::NonlinearImplicitSystem::solve(), libMesh::ContinuationSystem::solve_tangent(), libMesh::MemorySolutionHistory::store(), update(), update_global_solution(), libMesh::ContinuationSystem::update_solution(), libMesh::NewmarkSystem::update_u_v_a(), write_parallel_data(), and write_serialized_data().

◆ 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 1493 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: