libMesh::System Class Reference

#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 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=libmesh_nullptr) const
 
void project_solution (FEMFunctionBase< Number > *f, FEMFunctionBase< Gradient > *g=libmesh_nullptr) const
 
void project_solution (Number fptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), Gradient gptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), const Parameters &parameters) const
 
void project_vector (NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=libmesh_nullptr, int is_adjoint=-1) const
 
void project_vector (NumericVector< Number > &new_vector, FEMFunctionBase< Number > *f, FEMFunctionBase< Gradient > *g=libmesh_nullptr, int is_adjoint=-1) const
 
void project_vector (Number fptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), Gradient gptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), const Parameters &parameters, NumericVector< Number > &new_vector, 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=libmesh_nullptr)
 
void boundary_project_solution (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, Number fptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), Gradient gptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), const Parameters &parameters)
 
void boundary_project_vector (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=libmesh_nullptr, int is_adjoint=-1) const
 
void boundary_project_vector (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, Number fptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), Gradient gptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), const Parameters &parameters, NumericVector< Number > &new_vector, 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=libmesh_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=libmesh_nullptr)
 
unsigned int add_variables (const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=libmesh_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=libmesh_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=libmesh_nullptr) const
 
Real calculate_norm (const NumericVector< Number > &v, const SystemNorm &norm, std::set< unsigned int > *skip_dimensions=libmesh_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
 
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 ()
 
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
 
UniquePtr< NumericVector< Number > > solution
 
UniquePtr< 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
 
UniquePtr< 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

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 EqnSystems<T_sys> object to handle one or more of the children of this class.

Author
Benjamin S. Kirk
Date
2003-2004

Definition at line 76 of file system.h.

Member Typedef Documentation

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

Definition at line 749 of file system.h.

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

Data structure to log the information. The log is identified by the class name.

Definition at line 119 of file reference_counter.h.

The type of system.

Definition at line 219 of file system.h.

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

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

Constructor. Optionally initializes required data structures.

Definition at line 57 of file system.C.

Referenced by hide_output().

59  :
60 
61  ParallelObject (es),
62  assemble_before_solve (true),
63  use_fixed_solution (false),
67  time (0.),
68  qoi (0),
79  _dof_map (new DofMap(number_in, es.get_mesh())),
80  _equation_systems (es),
81  _mesh (es.get_mesh()),
82  _sys_name (name_in),
83  _sys_number (number_in),
84  _active (true),
85  _solution_projection (true),
86  _basic_system_only (false),
87  _is_initialized (false),
90  adjoint_already_solved (false),
91  _hide_output (false)
92 {
93 }
ParallelObject(const Parallel::Communicator &comm_in)
Assembly * _assemble_system_object
Definition: system.h:1820
bool _basic_system_only
Definition: system.h:1944
bool _is_initialized
Definition: system.h:1950
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1825
int extra_quadrature_order
Definition: system.h:1506
const unsigned int _sys_number
Definition: system.h:1885
Constraint * _constrain_system_object
Definition: system.h:1831
UniquePtr< NumericVector< Number > > current_local_solution
Definition: system.h:1533
const class libmesh_nullptr_t libmesh_nullptr
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Definition: system.h:1836
UniquePtr< DofMap > _dof_map
Definition: system.h:1863
bool adjoint_already_solved
Definition: system.h:1982
static UniquePtr< NumericVector< Number > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
QOIDerivative * _qoi_evaluate_derivative_object
Definition: system.h:1857
std::vector< Number > qoi
Definition: system.h:1551
bool use_fixed_solution
Definition: system.h:1491
QOI * _qoi_evaluate_object
Definition: system.h:1843
Initialization * _init_system_object
Definition: system.h:1809
bool _hide_output
Definition: system.h:1988
unsigned int _additional_data_written
Definition: system.h:1963
UniquePtr< NumericVector< Number > > solution
Definition: system.h:1521
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1803
bool _solution_projection
Definition: system.h:1938
EquationSystems & _equation_systems
Definition: system.h:1869
bool _identify_variable_groups
Definition: system.h:1956
const Parallel::Communicator & comm() const
const std::string _sys_name
Definition: system.h:1880
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1814
bool assemble_before_solve
Definition: system.h:1475
MeshBase & _mesh
Definition: system.h:1875
void(* _qoi_evaluate_derivative_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
Definition: system.h:1848
libMesh::System::~System ( )
virtual

Destructor.

Definition at line 116 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(), libMesh::closed(), and libmesh_nullptr.

Referenced by libMesh::System::QOIDerivative::~QOIDerivative().

117 {
118  // Null-out the function pointers. Since this
119  // class is getting destructed it is pointless,
120  // but a good habit.
124 
127 
128  // libmesh_nullptr-out user-provided objects.
134 
135  // Clear data
136  this->clear ();
137 
138  libmesh_exceptionless_assert (!libMesh::closed());
139 }
bool closed()
Definition: libmesh.C:279
virtual void clear()
Definition: system.C:198
Assembly * _assemble_system_object
Definition: system.h:1820
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1825
Constraint * _constrain_system_object
Definition: system.h:1831
const class libmesh_nullptr_t libmesh_nullptr
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Definition: system.h:1836
QOIDerivative * _qoi_evaluate_derivative_object
Definition: system.h:1857
QOI * _qoi_evaluate_object
Definition: system.h:1843
Initialization * _init_system_object
Definition: system.h:1809
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1803
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1814
void(* _qoi_evaluate_derivative_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
Definition: system.h:1848
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 98 of file system.C.

98  :
99  ReferenceCountedObject<System>(),
100  ParallelObject(other),
101  _equation_systems(other._equation_systems),
102  _mesh(other._mesh),
103  _sys_number(other._sys_number)
104 {
105  libmesh_not_implemented();
106 }
ParallelObject(const Parallel::Communicator &comm_in)
const unsigned int _sys_number
Definition: system.h:1885
EquationSystems & _equation_systems
Definition: system.h:1869
MeshBase & _mesh
Definition: system.h:1875

Member Function Documentation

void libMesh::System::activate ( )
inline

Activates the system. Only active systems are solved.

Definition at line 2052 of file system.h.

References _active.

Referenced by get_equation_systems().

2053 {
2054  _active = true;
2055 }
bool libMesh::System::active ( ) const
inline
Returns
true if the system is active, false otherwise. An active system will be solved.

Definition at line 2044 of file system.h.

References _active.

Referenced by get_equation_systems().

2045 {
2046  return _active;
2047 }
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 1035 of file system.C.

References add_vector().

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

1036 {
1037  std::ostringstream adjoint_rhs_name;
1038  adjoint_rhs_name << "adjoint_rhs" << i;
1039 
1040  return this->add_vector(adjoint_rhs_name.str(), false);
1041 }
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Definition: system.C:676
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 971 of file system.C.

References add_vector(), and set_vector_as_adjoint().

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

972 {
973  std::ostringstream adjoint_name;
974  adjoint_name << "adjoint_solution" << i;
975 
976  NumericVector<Number> & returnval = this->add_vector(adjoint_name.str());
977  this->set_vector_as_adjoint(adjoint_name.str(), i);
978  return returnval;
979 }
void set_vector_as_adjoint(const std::string &vec_name, int qoi_num)
Definition: system.C:899
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Definition: system.C:676
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 1065 of file system.C.

References add_vector().

Referenced by libMesh::ImplicitSystem::assemble_residual_derivatives(), and project_solution_on_reinit().

1066 {
1067  std::ostringstream sensitivity_rhs_name;
1068  sensitivity_rhs_name << "sensitivity_rhs" << i;
1069 
1070  return this->add_vector(sensitivity_rhs_name.str(), false);
1071 }
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Definition: system.C:676
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 920 of file system.C.

References add_vector().

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

921 {
922  std::ostringstream sensitivity_name;
923  sensitivity_name << "sensitivity_solution" << i;
924 
925  return this->add_vector(sensitivity_name.str());
926 }
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Definition: system.C:676
unsigned int libMesh::System::add_variable ( const std::string &  var,
const FEType type,
const std::set< subdomain_id_type > *const  active_subdomains = libmesh_nullptr 
)

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

Returns
The index number for the new variable.

Definition at line 1095 of file system.C.

References _variable_groups, _variable_numbers, _variables, add_variables(), libMesh::VariableGroup::append(), identify_variable_groups(), is_initialized(), libMesh::libmesh_assert(), libmesh_nullptr, 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 project_solution_on_reinit().

1098 {
1099  libmesh_assert(!this->is_initialized());
1100 
1101  // Make sure the variable isn't there already
1102  // or if it is, that it's the type we want
1103  for (unsigned int v=0; v<this->n_vars(); v++)
1104  if (this->variable_name(v) == var)
1105  {
1106  if (this->variable_type(v) == type)
1107  return _variables[v].number();
1108 
1109  libmesh_error_msg("ERROR: incompatible variable " << var << " has already been added for this system!");
1110  }
1111 
1112  // Optimize for VariableGroups here - if the user is adding multiple
1113  // variables of the same FEType and subdomain restriction, catch
1114  // that here and add them as members of the same VariableGroup.
1115  //
1116  // start by setting this flag to whatever the user has requested
1117  // and then consider the conditions which should negate it.
1118  bool should_be_in_vg = this->identify_variable_groups();
1119 
1120  // No variable groups, nothing to add to
1121  if (!this->n_variable_groups())
1122  should_be_in_vg = false;
1123 
1124  else
1125  {
1126  VariableGroup & vg(_variable_groups.back());
1127 
1128  // get a pointer to their subdomain restriction, if any.
1129  const std::set<subdomain_id_type> * const
1130  their_active_subdomains (vg.implicitly_active() ?
1131  libmesh_nullptr : &vg.active_subdomains());
1132 
1133  // Different types?
1134  if (vg.type() != type)
1135  should_be_in_vg = false;
1136 
1137  // they are restricted, we aren't?
1138  if (their_active_subdomains && !active_subdomains)
1139  should_be_in_vg = false;
1140 
1141  // they aren't restriced, we are?
1142  if (!their_active_subdomains && active_subdomains)
1143  should_be_in_vg = false;
1144 
1145  if (their_active_subdomains && active_subdomains)
1146  // restricted to different sets?
1147  if (*their_active_subdomains != *active_subdomains)
1148  should_be_in_vg = false;
1149 
1150  // OK, after all that, append the variable to the vg if none of the conditions
1151  // were violated
1152  if (should_be_in_vg)
1153  {
1154  const unsigned short curr_n_vars = cast_int<unsigned short>
1155  (this->n_vars());
1156 
1157  vg.append (var);
1158 
1159  _variables.push_back(vg(vg.n_variables()-1));
1160  _variable_numbers[var] = curr_n_vars;
1161  return curr_n_vars;
1162  }
1163  }
1164 
1165  // otherwise, fall back to adding a single variable group
1166  return this->add_variables (std::vector<std::string>(1, var),
1167  type,
1168  active_subdomains);
1169 }
std::map< std::string, unsigned short int > _variable_numbers
Definition: system.h:1901
const std::string & variable_name(const unsigned int i) const
Definition: system.h:2132
const class libmesh_nullptr_t libmesh_nullptr
std::vector< Variable > _variables
Definition: system.h:1890
const FEType & variable_type(const unsigned int i) const
Definition: system.h:2162
libmesh_assert(j)
unsigned int n_variable_groups() const
Definition: system.h:2092
std::vector< VariableGroup > _variable_groups
Definition: system.h:1895
bool is_initialized()
Definition: system.h:2068
bool identify_variable_groups() const
Definition: system.h:2180
unsigned int number() const
Definition: system.h:2004
unsigned int add_variables(const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=libmesh_nullptr)
Definition: system.C:1185
unsigned int n_vars() const
Definition: system.h:2084
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 = libmesh_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 1173 of file system.C.

References add_variable().

1177 {
1178  return this->add_variable(var,
1179  FEType(order, family),
1180  active_subdomains);
1181 }
unsigned int add_variable(const std::string &var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=libmesh_nullptr)
Definition: system.C:1095
unsigned int libMesh::System::add_variables ( const std::vector< std::string > &  vars,
const FEType type,
const std::set< subdomain_id_type > *const  active_subdomains = libmesh_nullptr 
)

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

Returns
The index number for the new variable.

Definition at line 1185 of file system.C.

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

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

1188 {
1189  libmesh_assert(!this->is_initialized());
1190 
1191  // Make sure the variable isn't there already
1192  // or if it is, that it's the type we want
1193  for (std::size_t ov=0; ov<vars.size(); ov++)
1194  for (unsigned int v=0; v<this->n_vars(); v++)
1195  if (this->variable_name(v) == vars[ov])
1196  {
1197  if (this->variable_type(v) == type)
1198  return _variables[v].number();
1199 
1200  libmesh_error_msg("ERROR: incompatible variable " << vars[ov] << " has already been added for this system!");
1201  }
1202 
1203  const unsigned short curr_n_vars = cast_int<unsigned short>
1204  (this->n_vars());
1205 
1206  const unsigned int next_first_component = this->n_components();
1207 
1208  // Add the variable group to the list
1209  _variable_groups.push_back((active_subdomains == libmesh_nullptr) ?
1210  VariableGroup(this, vars, curr_n_vars,
1211  next_first_component, type) :
1212  VariableGroup(this, vars, curr_n_vars,
1213  next_first_component, type, *active_subdomains));
1214 
1215  const VariableGroup & vg (_variable_groups.back());
1216 
1217  // Add each component of the group individually
1218  for (std::size_t v=0; v<vars.size(); v++)
1219  {
1220  _variables.push_back (vg(v));
1221  _variable_numbers[vars[v]] = cast_int<unsigned short>
1222  (curr_n_vars+v);
1223  }
1224 
1225  libmesh_assert_equal_to ((curr_n_vars+vars.size()), this->n_vars());
1226 
1227  // BSK - Defer this now to System::init_data() so we can detect
1228  // VariableGroups 12/28/2012
1229  // // Add the variable group to the _dof_map
1230  // _dof_map->add_variable_group (vg);
1231 
1232  // Return the number of the new variable
1233  return cast_int<unsigned int>(curr_n_vars+vars.size()-1);
1234 }
std::map< std::string, unsigned short int > _variable_numbers
Definition: system.h:1901
const std::string & variable_name(const unsigned int i) const
Definition: system.h:2132
const class libmesh_nullptr_t libmesh_nullptr
std::vector< Variable > _variables
Definition: system.h:1890
const FEType & variable_type(const unsigned int i) const
Definition: system.h:2162
libmesh_assert(j)
unsigned int n_components() const
Definition: system.h:2100
std::vector< VariableGroup > _variable_groups
Definition: system.h:1895
bool is_initialized()
Definition: system.h:2068
unsigned int number() const
Definition: system.h:2004
unsigned int n_vars() const
Definition: system.h:2084
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 = libmesh_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 1238 of file system.C.

References add_variables().

1242 {
1243  return this->add_variables(vars,
1244  FEType(order, family),
1245  active_subdomains);
1246 }
unsigned int add_variables(const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=libmesh_nullptr)
Definition: system.C:1185
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 inititialized to zero.

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

Definition at line 676 of file system.C.

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

679 {
680  // Return the vector if it is already there.
681  if (this->have_vector(vec_name))
682  return *(_vectors[vec_name]);
683 
684  // Otherwise build the vector
685  NumericVector<Number> * buf = NumericVector<Number>::build(this->comm()).release();
686  _vectors.insert (std::make_pair (vec_name, buf));
687  _vector_projections.insert (std::make_pair (vec_name, projections));
688 
689  _vector_types.insert (std::make_pair (vec_name, type));
690 
691  // Vectors are primal by default
692  _vector_is_adjoint.insert (std::make_pair (vec_name, -1));
693 
694  // Initialize it if necessary
695  if (_is_initialized)
696  {
697  if (type == GHOSTED)
698  {
699 #ifdef LIBMESH_ENABLE_GHOSTED
700  buf->init (this->n_dofs(), this->n_local_dofs(),
701  _dof_map->get_send_list(), false,
702  GHOSTED);
703 #else
704  libmesh_error_msg("Cannot initialize ghosted vectors when they are not enabled.");
705 #endif
706  }
707  else
708  buf->init (this->n_dofs(), this->n_local_dofs(), false, type);
709  }
710 
711  return *buf;
712 }
std::map< std::string, ParallelType > _vector_types
Definition: system.h:1931
bool _is_initialized
Definition: system.h:1950
UniquePtr< DofMap > _dof_map
Definition: system.h:1863
static UniquePtr< NumericVector< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
bool have_vector(const std::string &vec_name) const
Definition: system.h:2204
std::map< std::string, int > _vector_is_adjoint
Definition: system.h:1926
dof_id_type n_local_dofs() const
Definition: system.C:180
std::map< std::string, NumericVector< Number > * > _vectors
Definition: system.h:1914
const Parallel::Communicator & comm() const
std::map< std::string, bool > _vector_projections
Definition: system.h:1920
dof_id_type n_dofs() const
Definition: system.C:143
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 1003 of file system.C.

References add_vector(), and set_vector_as_adjoint().

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

1004 {
1005  std::ostringstream adjoint_name;
1006  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
1007 
1008  NumericVector<Number> & returnval = this->add_vector(adjoint_name.str());
1009  this->set_vector_as_adjoint(adjoint_name.str(), i);
1010  return returnval;
1011 }
void set_vector_as_adjoint(const std::string &vec_name, int qoi_num)
Definition: system.C:899
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Definition: system.C:676
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 950 of file system.C.

References add_vector().

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

951 {
952  return this->add_vector("weighted_sensitivity_solution");
953 }
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Definition: system.C:676
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 2289 of file system.h.

Referenced by qoi_parameter_sensitivity(), and set_adjoint_already_solved().

2292 {
2293  libmesh_not_implemented();
2294 }
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 NULL. 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 2273 of file system.h.

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

2274 {
2275  libmesh_not_implemented();
2276 }
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::FrequencySystem, libMesh::ImplicitSystem, and libMesh::NewmarkSystem.

Definition at line 474 of file system.C.

References user_assembly().

Referenced by libMesh::ImplicitSystem::assemble(), libMesh::EigenSystem::assemble(), libMesh::ExplicitSystem::solve(), system(), and libMesh::System::Assembly::~Assembly().

475 {
476  // Log how long the user's assembly code takes
477  LOG_SCOPE("assemble()", "System");
478 
479  // Call the user-specified assembly function
480  this->user_assembly();
481 }
virtual void user_assembly()
Definition: system.C:1956
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 485 of file system.C.

References user_QOI().

Referenced by libMesh::ExplicitSystem::assemble_qoi(), and system().

486 {
487  // Log how long the user's assembly code takes
488  LOG_SCOPE("assemble_qoi()", "System");
489 
490  // Call the user-specified quantity of interest function
491  this->user_QOI(qoi_indices);
492 }
virtual void user_QOI(const QoISet &qoi_indices)
Definition: system.C:1984
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 496 of file system.C.

References user_QOI_derivative().

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

499 {
500  // Log how long the user's assembly code takes
501  LOG_SCOPE("assemble_qoi_derivative()", "System");
502 
503  // Call the user-specified quantity of interest function
504  this->user_QOI_derivative(qoi_indices, include_liftfunc,
505  apply_constraints);
506 }
virtual void user_QOI_derivative(const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true)
Definition: system.C:1998
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 2248 of file system.h.

Referenced by system().

2249 {
2250  libmesh_not_implemented();
2251 }
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 1801 of file system.C.

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

Referenced by read_parallel_data().

1803 {
1804  libmesh_assert(fptr);
1805 
1807  {
1808  libmesh_here();
1809  libMesh::out << "WARNING: Cannot specify both assembly function and object!"
1810  << std::endl;
1811 
1813  }
1814 
1816 }
Assembly * _assemble_system_object
Definition: system.h:1820
const class libmesh_nullptr_t libmesh_nullptr
libmesh_assert(j)
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1814
OStreamProxy out(std::cout)
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 1820 of file system.C.

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

Referenced by read_parallel_data().

1821 {
1823  {
1824  libmesh_here();
1825  libMesh::out << "WARNING: Cannot specify both assembly object and function!"
1826  << std::endl;
1827 
1829  }
1830 
1831  _assemble_system_object = &assemble_in;
1832 }
Assembly * _assemble_system_object
Definition: system.h:1820
const class libmesh_nullptr_t libmesh_nullptr
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1814
OStreamProxy out(std::cout)
void libMesh::System::attach_constraint_function ( void   fptrEquationSystems &es, const std::string &name)

Register a user function for imposing constraints.

Definition at line 1836 of file system.C.

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

Referenced by read_parallel_data().

1838 {
1839  libmesh_assert(fptr);
1840 
1842  {
1843  libmesh_here();
1844  libMesh::out << "WARNING: Cannot specify both constraint function and object!"
1845  << std::endl;
1846 
1848  }
1849 
1851 }
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1825
Constraint * _constrain_system_object
Definition: system.h:1831
const class libmesh_nullptr_t libmesh_nullptr
libmesh_assert(j)
OStreamProxy out(std::cout)
void libMesh::System::attach_constraint_object ( System::Constraint constrain)

Register a user object for imposing constraints.

Definition at line 1855 of file system.C.

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

Referenced by read_parallel_data().

1856 {
1858  {
1859  libmesh_here();
1860  libMesh::out << "WARNING: Cannot specify both constraint object and function!"
1861  << std::endl;
1862 
1864  }
1865 
1866  _constrain_system_object = &constrain;
1867 }
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1825
Constraint * _constrain_system_object
Definition: system.h:1831
const class libmesh_nullptr_t libmesh_nullptr
OStreamProxy out(std::cout)
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 1766 of file system.C.

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

Referenced by read_parallel_data().

1768 {
1769  libmesh_assert(fptr);
1770 
1772  {
1773  libmesh_here();
1774  libMesh::out << "WARNING: Cannot specify both initialization function and object!"
1775  << std::endl;
1776 
1778  }
1779 
1780  _init_system_function = fptr;
1781 }
const class libmesh_nullptr_t libmesh_nullptr
libmesh_assert(j)
Initialization * _init_system_object
Definition: system.h:1809
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1803
OStreamProxy out(std::cout)
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 1785 of file system.C.

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

Referenced by read_parallel_data().

1786 {
1788  {
1789  libmesh_here();
1790  libMesh::out << "WARNING: Cannot specify both initialization object and function!"
1791  << std::endl;
1792 
1794  }
1795 
1796  _init_system_object = &init_in;
1797 }
const class libmesh_nullptr_t libmesh_nullptr
Initialization * _init_system_object
Definition: system.h:1809
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1803
OStreamProxy out(std::cout)
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 1907 of file system.C.

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

Referenced by read_parallel_data().

1909 {
1910  libmesh_assert(fptr);
1911 
1913  {
1914  libmesh_here();
1915  libMesh::out << "WARNING: Cannot specify both QOI derivative function and object!"
1916  << std::endl;
1917 
1919  }
1920 
1922 }
const class libmesh_nullptr_t libmesh_nullptr
libmesh_assert(j)
QOIDerivative * _qoi_evaluate_derivative_object
Definition: system.h:1857
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:1848
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 1926 of file system.C.

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

Referenced by read_parallel_data().

1927 {
1929  {
1930  libmesh_here();
1931  libMesh::out << "WARNING: Cannot specify both QOI derivative object and function!"
1932  << std::endl;
1933 
1935  }
1936 
1937  _qoi_evaluate_derivative_object = &qoi_derivative;
1938 }
const class libmesh_nullptr_t libmesh_nullptr
QOIDerivative * _qoi_evaluate_derivative_object
Definition: system.h:1857
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:1848
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 1871 of file system.C.

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

Referenced by read_parallel_data().

1874 {
1875  libmesh_assert(fptr);
1876 
1878  {
1879  libmesh_here();
1880  libMesh::out << "WARNING: Cannot specify both QOI function and object!"
1881  << std::endl;
1882 
1884  }
1885 
1886  _qoi_evaluate_function = fptr;
1887 }
const class libmesh_nullptr_t libmesh_nullptr
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Definition: system.h:1836
libmesh_assert(j)
QOI * _qoi_evaluate_object
Definition: system.h:1843
OStreamProxy out(std::cout)
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 1891 of file system.C.

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

Referenced by read_parallel_data().

1892 {
1894  {
1895  libmesh_here();
1896  libMesh::out << "WARNING: Cannot specify both QOI object and function!"
1897  << std::endl;
1898 
1900  }
1901 
1902  _qoi_evaluate_object = &qoi_in;
1903 }
const class libmesh_nullptr_t libmesh_nullptr
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Definition: system.h:1836
QOI * _qoi_evaluate_object
Definition: system.h:1843
OStreamProxy out(std::cout)
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 = libmesh_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 arbitary boundary function onto the solution via L2 projections and nodal interpolations on each element.

Definition at line 999 of file system_projection.C.

References boundary_project_vector().

Referenced by project_vector(), and system_type().

1003 {
1004  this->boundary_project_vector(b, variables, *solution, f, g);
1005 
1006  solution->localize(*current_local_solution);
1007 }
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=libmesh_nullptr, int is_adjoint=-1) const
UniquePtr< NumericVector< Number > > current_local_solution
Definition: system.h:1533
UniquePtr< NumericVector< Number > > solution
Definition: system.h:1521
void libMesh::System::boundary_project_solution ( const std::set< boundary_id_type > &  b,
const std::vector< unsigned int > &  variables,
Number   fptrconst Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name,
Gradient   gptrconst Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name,
const Parameters parameters 
)

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.

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 = libmesh_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 1041 of file system_projection.C.

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

Referenced by boundary_project_solution(), and system_type().

1047 {
1048  LOG_SCOPE ("boundary_project_vector()", "System");
1049 
1051  (ConstElemRange (this->get_mesh().active_local_elements_begin(),
1052  this->get_mesh().active_local_elements_end() ),
1053  BoundaryProjectSolution(b, variables, *this, f, g,
1054  this->get_equation_systems().parameters,
1055  new_vector)
1056  );
1057 
1058  // We don't do SCALAR dofs when just projecting the boundary, so
1059  // we're done here.
1060 
1061  new_vector.close();
1062 
1063 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1064  if (is_adjoint == -1)
1065  this->get_dof_map().enforce_constraints_exactly(*this, &new_vector);
1066  else if (is_adjoint >= 0)
1068  is_adjoint);
1069 #endif
1070 }
void parallel_for(const Range &range, const Body &body)
Definition: threads_none.h:73
StoredRange< MeshBase::const_element_iterator, const Elem * > ConstElemRange
Definition: elem_range.h:34
const MeshBase & get_mesh() const
Definition: system.h:2012
const DofMap & get_dof_map() const
Definition: system.h:2028
void enforce_constraints_exactly(const System &system, NumericVector< Number > *v=libmesh_nullptr, bool homogeneous=false) const
virtual void close()=0
const EquationSystems & get_equation_systems() const
Definition: system.h:712
void enforce_adjoint_constraints_exactly(NumericVector< Number > &v, unsigned int q) const
void libMesh::System::boundary_project_vector ( const std::set< boundary_id_type > &  b,
const std::vector< unsigned int > &  variables,
Number   fptrconst Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name,
Gradient   gptrconst Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name,
const Parameters parameters,
NumericVector< Number > &  new_vector,
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.

Real libMesh::System::calculate_norm ( const NumericVector< Number > &  v,
unsigned int  var,
FEMNormType  norm_type,
std::set< unsigned int > *  skip_dimensions = libmesh_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 1393 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(), libMesh::UnsteadySolver::du(), and project_solution_on_reinit().

1397 {
1398  //short circuit to save time
1399  if (norm_type == DISCRETE_L1 ||
1400  norm_type == DISCRETE_L2 ||
1401  norm_type == DISCRETE_L_INF)
1402  return discrete_var_norm(v,var,norm_type);
1403 
1404  // Not a discrete norm
1405  std::vector<FEMNormType> norms(this->n_vars(), L2);
1406  std::vector<Real> weights(this->n_vars(), 0.0);
1407  norms[var] = norm_type;
1408  weights[var] = 1.0;
1409  Real val = this->calculate_norm(v, SystemNorm(norms, weights), skip_dimensions);
1410  return val;
1411 }
Real calculate_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=libmesh_nullptr) const
Definition: system.C:1393
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
unsigned int n_vars() const
Definition: system.h:2084
Real discrete_var_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type) const
Definition: system.C:1374
Real libMesh::System::calculate_norm ( const NumericVector< Number > &  v,
const SystemNorm norm,
std::set< unsigned int > *  skip_dimensions = libmesh_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 1415 of file system.C.

References _dof_map, _mesh, std::abs(), libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), libMesh::TypeVector< T >::add_scaled(), libMesh::TypeTensor< T >::add_scaled(), libMesh::FEGenericBase< OutputType >::build(), libMesh::NumericVector< T >::build(), libMesh::ParallelObject::comm(), libMesh::FEType::default_quadrature_rule(), libMesh::Elem::dim(), 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::libmesh_assert(), libmesh_nullptr, 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().

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

Clear all the data structures associated with the system.

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

Definition at line 198 of file system.C.

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

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

199 {
200  _variables.clear();
201 
202  _variable_numbers.clear();
203 
204  _dof_map->clear ();
205 
206  solution->clear ();
207 
208  current_local_solution->clear ();
209 
210  // clear any user-added vectors
211  {
212  for (vectors_iterator pos = _vectors.begin(); pos != _vectors.end(); ++pos)
213  {
214  pos->second->clear ();
215  delete pos->second;
216  pos->second = libmesh_nullptr;
217  }
218 
219  _vectors.clear();
220  _vector_projections.clear();
221  _vector_is_adjoint.clear();
222  _vector_types.clear();
223  _is_initialized = false;
224  }
225 
226 }
std::map< std::string, unsigned short int > _variable_numbers
Definition: system.h:1901
std::map< std::string, ParallelType > _vector_types
Definition: system.h:1931
bool _is_initialized
Definition: system.h:1950
UniquePtr< NumericVector< Number > > current_local_solution
Definition: system.h:1533
const class libmesh_nullptr_t libmesh_nullptr
std::vector< Variable > _variables
Definition: system.h:1890
UniquePtr< DofMap > _dof_map
Definition: system.h:1863
UniquePtr< NumericVector< Number > > solution
Definition: system.h:1521
std::map< std::string, int > _vector_is_adjoint
Definition: system.h:1926
std::map< std::string, NumericVector< Number > * >::iterator vectors_iterator
Definition: system.h:748
std::map< std::string, NumericVector< Number > * > _vectors
Definition: system.h:1914
std::map< std::string, bool > _vector_projections
Definition: system.h:1920
const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inlineinherited
Returns
A reference to the Parallel::Communicator object used by this mesh.

Definition at line 87 of file parallel_object.h.

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_petsc_snes_jacobian(), libMesh::__libmesh_petsc_snes_postcheck(), libMesh::__libmesh_petsc_snes_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::ParmetisPartitioner::_do_repartition(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult(), libMesh::SlepcEigenSolver< 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::ImplicitSystem::add_matrix(), add_vector(), libMesh::EigenSparseLinearSolver< T >::adjoint_solve(), libMesh::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assemble_qoi(), libMesh::MeshCommunication::assign_global_indices(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::DofMap::attach_matrix(), libMesh::Parallel::BinSorter< KeyType, IdxType >::binsort(), libMesh::Parallel::Sort< KeyType, IdxType >::binsort(), libMesh::MeshCommunication::broadcast(), libMesh::SparseMatrix< T >::build(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::Parallel::Histogram< KeyType, IdxType >::build_histogram(), libMesh::PetscNonlinearSolver< T >::build_mat_null_space(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::MeshBase::cache_elem_dims(), calculate_norm(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::DistributedVector< T >::clone(), libMesh::EigenSparseVector< T >::clone(), libMesh::LaspackVector< T >::clone(), libMesh::EpetraVector< T >::clone(), libMesh::PetscVector< T >::clone(), libMesh::EpetraVector< T >::close(), libMesh::Parallel::Sort< KeyType, IdxType >::communicate_bins(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::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::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::DofMap::get_info(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::EquationSystems::get_solution(), libMesh::LocationMap< T >::init(), libMesh::PetscDiffSolver::init(), libMesh::TimeSolver::init(), libMesh::TopologyMap::init(), libMesh::TaoOptimizationSolver< T >::init(), libMesh::PetscNonlinearSolver< T >::init(), libMesh::DistributedVector< T >::init(), libMesh::EpetraVector< T >::init(), libMesh::PetscVector< T >::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::EigenSystem::init_data(), libMesh::EigenSystem::init_matrices(), libMesh::ParmetisPartitioner::initialize(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), 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::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::DistributedVector< T >::max(), libMesh::FEMSystem::mesh_position_set(), libMesh::MeshSerializer::MeshSerializer(), libMesh::DistributedVector< T >::min(), 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::Partitioner::partition(), libMesh::MetisPartitioner::partition_range(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::petsc_auto_fieldsplit(), point_gradient(), point_hessian(), point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::SparseMatrix< T >::print(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::MeshCommunication::redistribute(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Partitioner::set_parent_processor_ids(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::Parallel::Sort< KeyType, IdxType >::sort(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), libMesh::Parallel::sync_element_data_by_parent_id(), libMesh::Parallel::sync_node_data_by_element_id(), libMesh::MeshRefinement::test_level_one(), libMesh::MeshRefinement::test_unflagged(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::DistributedVector< T >::zero_clone(), libMesh::LaspackVector< T >::zero_clone(), libMesh::EigenSparseVector< T >::zero_clone(), libMesh::EpetraVector< T >::zero_clone(), and libMesh::PetscVector< T >::zero_clone().

88  { return _communicator; }
const Parallel::Communicator & _communicator
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 526 of file system.C.

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

Referenced by libMesh::EquationSystems::compare(), and set_adjoint_already_solved().

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

188 {
189  // Check the sizes
190  libmesh_assert_less (global_dof_number, _dof_map->n_dofs());
191  libmesh_assert_less (global_dof_number, current_local_solution->size());
192 
193  return (*current_local_solution)(global_dof_number);
194 }
UniquePtr< NumericVector< Number > > current_local_solution
Definition: system.h:1533
UniquePtr< DofMap > _dof_map
Definition: system.h:1863
void libMesh::System::deactivate ( )
inline

Deactivates the system. Only active systems are solved.

Definition at line 2060 of file system.h.

References _active.

Referenced by get_equation_systems().

2061 {
2062  _active = false;
2063 }
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 2254 of file system.h.

References assemble_before_solve.

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

2254 { assemble_before_solve = true; }
bool assemble_before_solve
Definition: system.h:1475
void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited
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 1374 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(), and hide_output().

1377 {
1378  std::set<dof_id_type> var_indices;
1379  local_dof_indices(var, var_indices);
1380 
1381  if (norm_type == DISCRETE_L1)
1382  return v.subset_l1_norm(var_indices);
1383  if (norm_type == DISCRETE_L2)
1384  return v.subset_l2_norm(var_indices);
1385  if (norm_type == DISCRETE_L_INF)
1386  return v.subset_linfty_norm(var_indices);
1387  else
1388  libmesh_error_msg("Invalid norm_type = " << norm_type);
1389 }
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
void local_dof_indices(const unsigned int var, std::set< dof_id_type > &var_indices) const
Definition: system.C:1291
virtual Real subset_l2_norm(const std::set< numeric_index_type > &indices) const
void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

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

Definition at line 101 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

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

102 {
103  _enable_print_counter = true;
104  return;
105 }
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 2298 of file system.h.

Referenced by qoi_parameter_sensitivity(), and set_adjoint_already_solved().

2301 {
2302  libmesh_not_implemented();
2303 }
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 1045 of file system.C.

References get_vector().

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

1046 {
1047  std::ostringstream adjoint_rhs_name;
1048  adjoint_rhs_name << "adjoint_rhs" << i;
1049 
1050  return this->get_vector(adjoint_rhs_name.str());
1051 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:788
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 1055 of file system.C.

References get_vector().

1056 {
1057  std::ostringstream adjoint_rhs_name;
1058  adjoint_rhs_name << "adjoint_rhs" << i;
1059 
1060  return this->get_vector(adjoint_rhs_name.str());
1061 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:788
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 983 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(), project_solution_on_reinit(), libMesh::ImplicitSystem::qoi_parameter_hessian(), libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product(), and libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().

984 {
985  std::ostringstream adjoint_name;
986  adjoint_name << "adjoint_solution" << i;
987 
988  return this->get_vector(adjoint_name.str());
989 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:788
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 993 of file system.C.

References get_vector().

994 {
995  std::ostringstream adjoint_name;
996  adjoint_name << "adjoint_solution" << i;
997 
998  return this->get_vector(adjoint_name.str());
999 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:788
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 1272 of file system.C.

References _variable_numbers, and n_vars().

Referenced by project_solution_on_reinit().

1273 {
1274  all_variable_numbers.resize(n_vars());
1275 
1276  // Make sure the variable exists
1277  std::map<std::string, unsigned short int>::const_iterator
1278  it = _variable_numbers.begin();
1279  std::map<std::string, unsigned short int>::const_iterator
1280  it_end = _variable_numbers.end();
1281 
1282  unsigned int count = 0;
1283  for ( ; it != it_end; ++it)
1284  {
1285  all_variable_numbers[count] = it->second;
1286  count++;
1287  }
1288 }
std::map< std::string, unsigned short int > _variable_numbers
Definition: system.h:1901
unsigned int n_vars() const
Definition: system.h:2084
const DofMap & libMesh::System::get_dof_map ( ) const
inline
Returns
A constant reference to this system's _dof_map.

Definition at line 2028 of file system.h.

References _dof_map.

Referenced by libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_petsc_snes_postcheck(), 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_solution_vector(), 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::EquationSystems::get_solution(), 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(), 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::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::operator()(), libMesh::BuildProjectionList::operator()(), libMesh::BoundaryProjectSolution::operator()(), libMesh::petsc_auto_fieldsplit(), libMesh::ErrorVector::plot_error(), point_gradient(), point_hessian(), point_value(), libMesh::FEMContext::pre_fe_reinit(), re_update(), libMesh::SecondOrderUnsteadySolver::reinit(), libMesh::UnsteadySolver::reinit(), libMesh::ImplicitSystem::reinit(), libMesh::EigenSystem::reinit(), libMesh::EquationSystems::reinit(), reinit_constraints(), libMesh::UnsteadySolver::retrieve_timestep(), libMesh::HPCoarsenTest::select_refinement(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::NewtonSolver::solve(), libMesh::PetscDiffSolver::solve(), libMesh::PetscNonlinearSolver< T >::solve(), system_type(), libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve(), libMesh::ImplicitSystem::weighted_sensitivity_solve(), libMesh::EnsightIO::write_scalar_ascii(), and libMesh::EnsightIO::write_vector_ascii().

2029 {
2030  return *_dof_map;
2031 }
UniquePtr< DofMap > _dof_map
Definition: system.h:1863
DofMap & libMesh::System::get_dof_map ( )
inline
Returns
A writable reference to this system's _dof_map.

Definition at line 2036 of file system.h.

References _dof_map.

2037 {
2038  return *_dof_map;
2039 }
UniquePtr< DofMap > _dof_map
Definition: system.h:1863
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, activate(), active(), deactivate(), and set_basic_system_only().

717 { return _equation_systems; }
EquationSystems & _equation_systems
Definition: system.h:1869
std::string libMesh::ReferenceCounter::get_info ( )
staticinherited

Gets a string containing the reference information.

Definition at line 47 of file reference_counter.C.

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

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

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

Definition at line 1682 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().

Referenced by read_parallel_data().

1683 {
1684  std::ostringstream oss;
1685 
1686 
1687  const std::string & sys_name = this->name();
1688 
1689  oss << " System #" << this->number() << ", \"" << sys_name << "\"\n"
1690  << " Type \"" << this->system_type() << "\"\n"
1691  << " Variables=";
1692 
1693  for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
1694  {
1695  const VariableGroup & vg_description (this->variable_group(vg));
1696 
1697  if (vg_description.n_variables() > 1) oss << "{ ";
1698  for (unsigned int vn=0; vn<vg_description.n_variables(); vn++)
1699  oss << "\"" << vg_description.name(vn) << "\" ";
1700  if (vg_description.n_variables() > 1) oss << "} ";
1701  }
1702 
1703  oss << '\n';
1704 
1705  oss << " Finite Element Types=";
1706 #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
1707  for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
1708  oss << "\""
1709  << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().family)
1710  << "\" ";
1711 #else
1712  for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
1713  {
1714  oss << "\""
1715  << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().family)
1716  << "\", \""
1717  << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().radial_family)
1718  << "\" ";
1719  }
1720 
1721  oss << '\n' << " Infinite Element Mapping=";
1722  for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
1723  oss << "\""
1724  << Utility::enum_to_string<InfMapType>(this->get_dof_map().variable_group(vg).type().inf_map)
1725  << "\" ";
1726 #endif
1727 
1728  oss << '\n';
1729 
1730  oss << " Approximation Orders=";
1731  for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
1732  {
1733 #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
1734  oss << "\""
1735  << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().order)
1736  << "\" ";
1737 #else
1738  oss << "\""
1739  << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().order)
1740  << "\", \""
1741  << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().radial_order)
1742  << "\" ";
1743 #endif
1744  }
1745 
1746  oss << '\n';
1747 
1748  oss << " n_dofs()=" << this->n_dofs() << '\n';
1749  oss << " n_local_dofs()=" << this->n_local_dofs() << '\n';
1750 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1751  oss << " n_constrained_dofs()=" << this->n_constrained_dofs() << '\n';
1752  oss << " n_local_constrained_dofs()=" << this->n_local_constrained_dofs() << '\n';
1753 #endif
1754 
1755  oss << " " << "n_vectors()=" << this->n_vectors() << '\n';
1756  oss << " " << "n_matrices()=" << this->n_matrices() << '\n';
1757  // oss << " " << "n_additional_matrices()=" << this->n_additional_matrices() << '\n';
1758 
1759  oss << this->get_dof_map().get_info();
1760 
1761  return oss.str();
1762 }
FEFamily family
Definition: fe_type.h:203
dof_id_type n_constrained_dofs() const
Definition: system.C:150
const FEType & type() const
Definition: variable.h:119
std::string get_info() const
Definition: dof_map.C:2764
OrderWrapper radial_order
Definition: fe_type.h:236
OrderWrapper order
Definition: fe_type.h:197
const VariableGroup & variable_group(unsigned int vg) const
Definition: system.h:2122
const VariableGroup & variable_group(const unsigned int c) const
Definition: dof_map.h:1636
const std::string & name() const
Definition: system.h:1996
unsigned int n_variable_groups() const
Definition: system.h:2092
const DofMap & get_dof_map() const
Definition: system.h:2028
InfMapType inf_map
Definition: fe_type.h:257
virtual unsigned int n_matrices() const
Definition: system.h:2218
FEFamily radial_family
Definition: fe_type.h:249
dof_id_type n_local_dofs() const
Definition: system.C:180
virtual std::string system_type() const
Definition: system.h:471
dof_id_type n_local_constrained_dofs() const
Definition: system.C:165
unsigned int number() const
Definition: system.h:2004
dof_id_type n_dofs() const
Definition: system.C:143
unsigned int n_vectors() const
Definition: system.h:2212
const MeshBase & libMesh::System::get_mesh ( ) const
inline
MeshBase & libMesh::System::get_mesh ( )
inline
Returns
A reference to this systems's _mesh.

Definition at line 2020 of file system.h.

References _mesh.

2021 {
2022  return _mesh;
2023 }
MeshBase & _mesh
Definition: system.h:1875
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 1075 of file system.C.

References get_vector().

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

1076 {
1077  std::ostringstream sensitivity_rhs_name;
1078  sensitivity_rhs_name << "sensitivity_rhs" << i;
1079 
1080  return this->get_vector(sensitivity_rhs_name.str());
1081 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:788
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 1085 of file system.C.

References get_vector().

1086 {
1087  std::ostringstream sensitivity_rhs_name;
1088  sensitivity_rhs_name << "sensitivity_rhs" << i;
1089 
1090  return this->get_vector(sensitivity_rhs_name.str());
1091 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:788
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 930 of file system.C.

References get_vector().

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

931 {
932  std::ostringstream sensitivity_name;
933  sensitivity_name << "sensitivity_solution" << i;
934 
935  return this->get_vector(sensitivity_name.str());
936 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:788
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 940 of file system.C.

References get_vector().

941 {
942  std::ostringstream sensitivity_name;
943  sensitivity_name << "sensitivity_solution" << i;
944 
945  return this->get_vector(sensitivity_name.str());
946 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:788
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 788 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(), project_solution_on_reinit(), libMesh::SecondOrderUnsteadySolver::reinit(), libMesh::UnsteadySolver::reinit(), libMesh::MemorySolutionHistory::retrieve(), libMesh::UnsteadySolver::retrieve_timestep(), libMesh::TwostepTimeSolver::solve(), libMesh::TaoOptimizationSolver< T >::solve(), libMesh::NloptOptimizationSolver< T >::solve(), libMesh::FrequencySystem::solve(), libMesh::NewmarkSystem::update_rhs(), and libMesh::NewmarkSystem::update_u_v_a().

789 {
790  // Make sure the vector exists
791  const_vectors_iterator pos = _vectors.find(vec_name);
792 
793  if (pos == _vectors.end())
794  libmesh_error_msg("ERROR: vector " << vec_name << " does not exist in this system!");
795 
796  return *(pos->second);
797 }
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:1914
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 801 of file system.C.

References _vectors.

802 {
803  // Make sure the vector exists
804  vectors_iterator pos = _vectors.find(vec_name);
805 
806  if (pos == _vectors.end())
807  libmesh_error_msg("ERROR: vector " << vec_name << " does not exist in this system!");
808 
809  return *(pos->second);
810 }
std::map< std::string, NumericVector< Number > * >::iterator vectors_iterator
Definition: system.h:748
std::map< std::string, NumericVector< Number > * > _vectors
Definition: system.h:1914
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 814 of file system.C.

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

815 {
818  unsigned int num = 0;
819  while ((num<vec_num) && (v!=v_end))
820  {
821  num++;
822  ++v;
823  }
824  libmesh_assert (v != v_end);
825  return *(v->second);
826 }
vectors_iterator vectors_end()
Definition: system.h:2236
std::map< std::string, NumericVector< Number > * >::const_iterator const_vectors_iterator
Definition: system.h:749
vectors_iterator vectors_begin()
Definition: system.h:2224
libmesh_assert(j)
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 830 of file system.C.

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

831 {
833  vectors_iterator v_end = vectors_end();
834  unsigned int num = 0;
835  while ((num<vec_num) && (v!=v_end))
836  {
837  num++;
838  ++v;
839  }
840  libmesh_assert (v != v_end);
841  return *(v->second);
842 }
vectors_iterator vectors_end()
Definition: system.h:2236
vectors_iterator vectors_begin()
Definition: system.h:2224
libmesh_assert(j)
std::map< std::string, NumericVector< Number > * >::iterator vectors_iterator
Definition: system.h:748
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 1015 of file system.C.

References get_vector().

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

1016 {
1017  std::ostringstream adjoint_name;
1018  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
1019 
1020  return this->get_vector(adjoint_name.str());
1021 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:788
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 1025 of file system.C.

References get_vector().

1026 {
1027  std::ostringstream adjoint_name;
1028  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
1029 
1030  return this->get_vector(adjoint_name.str());
1031 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:788
NumericVector< Number > & libMesh::System::get_weighted_sensitivity_solution ( )
Returns
A reference to the solution of the last weighted sensitivity solve

Definition at line 957 of file system.C.

References get_vector().

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

958 {
959  return this->get_vector("weighted_sensitivity_solution");
960 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:788
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 964 of file system.C.

References get_vector().

965 {
966  return this->get_vector("weighted_sensitivity_solution");
967 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:788
bool libMesh::System::has_variable ( const std::string &  var) const
Returns
true if a variable named var exists in this System

Definition at line 1250 of file system.C.

References _variable_numbers.

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

1251 {
1252  return _variable_numbers.count(var);
1253 }
std::map< std::string, unsigned short int > _variable_numbers
Definition: system.h:1901
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 2204 of file system.h.

References _vectors.

Referenced by add_vector(), project_solution_on_reinit(), and remove_vector().

2205 {
2206  return (_vectors.count(vec_name));
2207 }
std::map< std::string, NumericVector< Number > * > _vectors
Definition: system.h:1914
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 1655 of file system.h.

References _hide_output, discrete_var_norm(), end, init_data(), libMesh::invalid_uint, libMesh::ReferenceCounter::n_objects(), operator=(), project_vector(), read_SCALAR_dofs(), read_serialized_blocked_dof_objects(), read_serialized_vector(), libMesh::Real, and System().

1655 { return _hide_output; }
bool _hide_output
Definition: system.h:1988
bool libMesh::System::identify_variable_groups ( ) const
inline
Returns
true when VariableGroup structures should be automatically identified, false otherwise.

Definition at line 2180 of file system.h.

References _identify_variable_groups.

Referenced by add_variable(), and project_solution_on_reinit().

2181 {
2183 }
bool _identify_variable_groups
Definition: system.h:1956
void libMesh::System::identify_variable_groups ( const bool  ivg)
inline

Toggle automatic VariableGroup identification.

Definition at line 2188 of file system.h.

References _identify_variable_groups.

2189 {
2191 }
bool _identify_variable_groups
Definition: system.h:1956
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 185 of file reference_counter.h.

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

Referenced by libMesh::ReferenceCounter::n_objects(), and libMesh::ReferenceCountedObject< RBParametrized >::ReferenceCountedObject().

186 {
187  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
188  std::pair<unsigned int, unsigned int> & p = _counts[name];
189 
190  p.first++;
191 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:39
spin_mutex spin_mtx
Definition: threads.C:29
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 198 of file reference_counter.h.

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

Referenced by libMesh::ReferenceCounter::n_objects(), and libMesh::ReferenceCountedObject< RBParametrized >::~ReferenceCountedObject().

199 {
200  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
201  std::pair<unsigned int, unsigned int> & p = _counts[name];
202 
203  p.second++;
204 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:39
spin_mutex spin_mtx
Definition: threads.C:29
void libMesh::System::init ( )

Initializes degrees of freedom on the current mesh. Sets the

Definition at line 230 of file system.C.

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

Referenced by system().

231 {
232  // Calling init() twice on the same system currently works evil
233  // magic, whether done directly or via EquationSystems::read()
234  libmesh_assert(!this->is_initialized());
235 
236  // First initialize any required data:
237  // either only the basic System data
238  if (_basic_system_only)
240  // or all the derived class' data too
241  else
242  this->init_data();
243 
244  // If no variables have been added to this system
245  // don't do anything
246  if (!this->n_vars())
247  return;
248 
249  // Then call the user-provided intialization function
250  this->user_initialization();
251 }
bool _basic_system_only
Definition: system.h:1944
virtual void init_data()
Definition: system.C:255
virtual void user_initialization()
Definition: system.C:1942
libmesh_assert(j)
bool is_initialized()
Definition: system.h:2068
unsigned int n_vars() const
Definition: system.h:2084
void libMesh::System::init_data ( )
protectedvirtual

Initializes the data for the system.

Note
This is called before any user-supplied intitialization 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::EigenSystem, libMesh::RBConstructionBase< LinearImplicitSystem >, libMesh::RBConstructionBase< CondensedEigenSystem >, libMesh::TransientSystem< RBConstruction >, libMesh::ExplicitSystem, and libMesh::LinearImplicitSystem.

Definition at line 255 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 hide_output(), init(), libMesh::ExplicitSystem::init_data(), and libMesh::EigenSystem::init_data().

256 {
257  MeshBase & mesh = this->get_mesh();
258 
259  // Add all variable groups to our underlying DofMap
260  for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
261  _dof_map->add_variable_group(this->variable_group(vg));
262 
263  // Distribute the degrees of freedom on the mesh
264  _dof_map->distribute_dofs (mesh);
265 
266  // Recreate any user or internal constraints
267  this->reinit_constraints();
268 
269  // And clean up the send_list before we first use it
270  _dof_map->prepare_send_list();
271 
272  // Resize the solution conformal to the current mesh
273  solution->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
274 
275  // Resize the current_local_solution for the current mesh
276 #ifdef LIBMESH_ENABLE_GHOSTED
277  current_local_solution->init (this->n_dofs(), this->n_local_dofs(),
278  _dof_map->get_send_list(), false,
279  GHOSTED);
280 #else
281  current_local_solution->init (this->n_dofs(), false, SERIAL);
282 #endif
283 
284  // from now on, adding additional vectors or variables can't be done
285  // without immediately initializing them
286  _is_initialized = true;
287 
288  // initialize & zero other vectors, if necessary
289  for (vectors_iterator pos = _vectors.begin(); pos != _vectors.end(); ++pos)
290  {
291  ParallelType type = _vector_types[pos->first];
292 
293  if (type == GHOSTED)
294  {
295 #ifdef LIBMESH_ENABLE_GHOSTED
296  pos->second->init (this->n_dofs(), this->n_local_dofs(),
297  _dof_map->get_send_list(), false,
298  GHOSTED);
299 #else
300  libmesh_error_msg("Cannot initialize ghosted vectors when they are not enabled.");
301 #endif
302  }
303  else if (type == SERIAL)
304  {
305  pos->second->init (this->n_dofs(), false, type);
306  }
307  else
308  {
309  libmesh_assert_equal_to(type, PARALLEL);
310  pos->second->init (this->n_dofs(), this->n_local_dofs(), false, type);
311  }
312  }
313 }
std::map< std::string, ParallelType > _vector_types
Definition: system.h:1931
bool _is_initialized
Definition: system.h:1950
MeshBase & mesh
UniquePtr< NumericVector< Number > > current_local_solution
Definition: system.h:1533
UniquePtr< DofMap > _dof_map
Definition: system.h:1863
unsigned int n_variable_groups() const
Definition: system.h:2092
const MeshBase & get_mesh() const
Definition: system.h:2012
UniquePtr< NumericVector< Number > > solution
Definition: system.h:1521
virtual void reinit_constraints()
Definition: system.C:409
std::map< std::string, NumericVector< Number > * >::iterator vectors_iterator
Definition: system.h:748
dof_id_type n_local_dofs() const
Definition: system.C:180
std::map< std::string, NumericVector< Number > * > _vectors
Definition: system.h:1914
dof_id_type n_dofs() const
Definition: system.C:143
bool libMesh::System::is_initialized ( )
inline
Returns
true iff this system has been initialized.

Definition at line 2068 of file system.h.

References _is_initialized.

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

2069 {
2070  return _is_initialized;
2071 }
bool _is_initialized
Definition: system.h:1950
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 1291 of file system.C.

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

Referenced by discrete_var_norm().

1293 {
1294  // Make sure the set is clear
1295  var_indices.clear();
1296 
1297  std::vector<dof_id_type> dof_indices;
1298 
1299  // Begin the loop over the elements
1300  MeshBase::const_element_iterator el =
1302  const MeshBase::const_element_iterator end_el =
1304 
1305  const dof_id_type
1306  first_local = this->get_dof_map().first_dof(),
1307  end_local = this->get_dof_map().end_dof();
1308 
1309  for ( ; el != end_el; ++el)
1310  {
1311  const Elem * elem = *el;
1312  this->get_dof_map().dof_indices (elem, dof_indices, var);
1313 
1314  for (std::size_t i=0; i<dof_indices.size(); i++)
1315  {
1316  dof_id_type dof = dof_indices[i];
1317 
1318  //If the dof is owned by the local processor
1319  if (first_local <= dof && dof < end_local)
1320  var_indices.insert(dof_indices[i]);
1321  }
1322  }
1323 }
dof_id_type first_dof(const processor_id_type proc) const
Definition: dof_map.h:535
dof_id_type end_dof(const processor_id_type proc) const
Definition: dof_map.h:575
const MeshBase & get_mesh() const
Definition: system.h:2012
const DofMap & get_dof_map() const
Definition: system.h:2028
virtual element_iterator active_local_elements_begin()=0
virtual element_iterator active_local_elements_end()=0
uint8_t dof_id_type
Definition: id_types.h:64
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Definition: dof_map.C:2005
dof_id_type libMesh::System::n_active_dofs ( ) const
inline
Returns
The number of active degrees of freedom for this System.

Definition at line 2196 of file system.h.

References n_constrained_dofs(), and n_dofs().

Referenced by project_solution_on_reinit().

2197 {
2198  return this->n_dofs() - this->n_constrained_dofs();
2199 }
dof_id_type n_constrained_dofs() const
Definition: system.C:150
dof_id_type n_dofs() const
Definition: system.C:143
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 2100 of file system.h.

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

Referenced by add_variables(), libMesh::WrappedFunction< Output >::operator()(), and project_solution_on_reinit().

2101 {
2102  if (_variables.empty())
2103  return 0;
2104 
2105  const Variable & last = _variables.back();
2106  return last.first_scalar_number() + last.n_components();
2107 }
std::vector< Variable > _variables
Definition: system.h:1890
dof_id_type libMesh::System::n_constrained_dofs ( ) const
Returns
The total number of constrained degrees of freedom in the system.

Definition at line 150 of file system.C.

References _dof_map.

Referenced by get_info(), n_active_dofs(), and project_solution_on_reinit().

151 {
152 #ifdef LIBMESH_ENABLE_CONSTRAINTS
153 
154  return _dof_map->n_constrained_dofs();
155 
156 #else
157 
158  return 0;
159 
160 #endif
161 }
UniquePtr< DofMap > _dof_map
Definition: system.h:1863
dof_id_type libMesh::System::n_local_constrained_dofs ( ) const
Returns
The number of constrained degrees of freedom on this processor.

Definition at line 165 of file system.C.

References _dof_map.

Referenced by get_info(), and project_solution_on_reinit().

166 {
167 #ifdef LIBMESH_ENABLE_CONSTRAINTS
168 
169  return _dof_map->n_local_constrained_dofs();
170 
171 #else
172 
173  return 0;
174 
175 #endif
176 }
UniquePtr< DofMap > _dof_map
Definition: system.h:1863
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 overriden.

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

Definition at line 2218 of file system.h.

Referenced by get_info(), and project_solution_on_reinit().

2219 {
2220  return 0;
2221 }
static unsigned int libMesh::ReferenceCounter::n_objects ( )
inlinestaticinherited
processor_id_type libMesh::ParallelObject::n_processors ( ) const
inlineinherited
Returns
The number of processors in the group.

Definition at line 93 of file parallel_object.h.

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

Referenced by libMesh::ParmetisPartitioner::_do_repartition(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::DistributedMesh::add_elem(), libMesh::DistributedMesh::add_node(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assembly(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::MeshCommunication::broadcast(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::DistributedMesh::clear(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::MeshTools::correct_node_proc_ids(), 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::DistributedMesh::DistributedMesh(), libMesh::EnsightIO::EnsightIO(), libMesh::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), libMesh::MeshBase::get_info(), libMesh::EquationSystems::get_solution(), libMesh::DistributedVector< T >::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::DistributedMesh::insert_elem(), 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::SparsityPattern::Build::parallel_sync(), libMesh::Partitioner::partition(), libMesh::MeshBase::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::PetscLinearSolver< T >::PetscLinearSolver(), point_gradient(), point_hessian(), point_value(), libMesh::SparseMatrix< T >::print(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::CheckpointIO::read_nodes(), libMesh::MeshCommunication::redistribute(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::Partitioner::repartition(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Parallel::Sort< KeyType, IdxType >::sort(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

94  { return cast_int<processor_id_type>(_communicator.size()); }
unsigned int size() const
Definition: parallel.h:722
const Parallel::Communicator & _communicator
unsigned int libMesh::System::n_variable_groups ( ) const
inline
Returns
The number of VariableGroup variable groups in the system

Definition at line 2092 of file system.h.

References _variable_groups.

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

2093 {
2094  return cast_int<unsigned int>(_variable_groups.size());
2095 }
std::vector< VariableGroup > _variable_groups
Definition: system.h:1895
unsigned int libMesh::System::n_vars ( ) const
inline
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 2212 of file system.h.

References _vectors.

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

2213 {
2214  return cast_int<unsigned int>(_vectors.size());
2215 }
std::map< std::string, NumericVector< Number > * > _vectors
Definition: system.h:1914
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 110 of file system.C.

Referenced by hide_output().

111 {
112  libmesh_not_implemented();
113 }
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 2129 of file system.C.

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

Referenced by point_gradient().

2130 {
2131  // This function must be called on every processor; there's no
2132  // telling where in the partition p falls.
2133  parallel_object_only();
2134 
2135  // And every processor had better agree about which point we're
2136  // looking for
2137 #ifndef NDEBUG
2138  libmesh_assert(this->comm().verify(p(0)));
2139 #if LIBMESH_DIM > 1
2140  libmesh_assert(this->comm().verify(p(1)));
2141 #endif
2142 #if LIBMESH_DIM > 2
2143  libmesh_assert(this->comm().verify(p(2)));
2144 #endif
2145 #endif // NDEBUG
2146 
2147  // Get a reference to the mesh object associated with the system object that calls this function
2148  const MeshBase & mesh = this->get_mesh();
2149 
2150  // Use an existing PointLocator or create a new one
2151  UniquePtr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2152  PointLocatorBase & locator = *locator_ptr;
2153 
2154  if (!insist_on_success || !mesh.is_serial())
2155  locator.enable_out_of_mesh_mode();
2156 
2157  // Get a pointer to the element that contains P
2158  const Elem * e = locator(p);
2159 
2160  Gradient grad_u;
2161 
2162  if (e && this->get_dof_map().is_evaluable(*e, var))
2163  grad_u = point_gradient(var, p, *e);
2164 
2165  // If I have an element containing p, then let's let everyone know
2166  processor_id_type lowest_owner =
2167  (e && (e->processor_id() == this->processor_id())) ?
2168  this->processor_id() : this->n_processors();
2169  this->comm().min(lowest_owner);
2170 
2171  // Everybody should get their value from a processor that was able
2172  // to compute it.
2173  // If nobody admits owning the point, we may have a problem.
2174  if (lowest_owner != this->n_processors())
2175  this->comm().broadcast(grad_u, lowest_owner);
2176  else
2177  libmesh_assert(!insist_on_success);
2178 
2179  return grad_u;
2180 }
processor_id_type n_processors() const
MeshBase & mesh
uint8_t processor_id_type
Definition: id_types.h:99
libmesh_assert(j)
const MeshBase & get_mesh() const
Definition: system.h:2012
const DofMap & get_dof_map() const
Definition: system.h:2028
NumberVectorValue Gradient
void broadcast(T &data, const unsigned int root_id=0) const
Gradient point_gradient(unsigned int var, const Point &p, const bool insist_on_success=true) const
Definition: system.C:2129
bool verify(const T &r, const Communicator &comm=Communicator_World)
const Parallel::Communicator & comm() const
processor_id_type processor_id() const
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 2183 of file system.C.

References libMesh::TypeVector< T >::add_scaled(), libMesh::FEGenericBase< OutputType >::build(), libMesh::Elem::contains_point(), current_solution(), libMesh::Elem::dim(), get_dof_map(), libMesh::FEInterface::inverse_map(), and libMesh::libmesh_assert().

2184 {
2185  // Ensuring that the given point is really in the element is an
2186  // expensive assert, but as long as debugging is turned on we might
2187  // as well try to catch a particularly nasty potential error
2188  libmesh_assert (e.contains_point(p));
2189 
2190  // Get the dof map to get the proper indices for our computation
2191  const DofMap & dof_map = this->get_dof_map();
2192 
2193  // Make sure we can evaluate on this element.
2194  libmesh_assert (dof_map.is_evaluable(e, var));
2195 
2196  // Need dof_indices for phi[i][j]
2197  std::vector<dof_id_type> dof_indices;
2198 
2199  // Fill in the dof_indices for our element
2200  dof_map.dof_indices (&e, dof_indices, var);
2201 
2202  // Get the no of dofs assciated with this point
2203  const unsigned int num_dofs = cast_int<unsigned int>
2204  (dof_indices.size());
2205 
2206  FEType fe_type = dof_map.variable_type(var);
2207 
2208  // Build a FE again so we can calculate u(p)
2209  UniquePtr<FEBase> fe (FEBase::build(e.dim(), fe_type));
2210 
2211  // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h
2212  // Build a vector of point co-ordinates to send to reinit
2213  std::vector<Point> coor(1, FEInterface::inverse_map(e.dim(), fe_type, &e, p));
2214 
2215  // Get the values of the shape function derivatives
2216  const std::vector<std::vector<RealGradient> > & dphi = fe->get_dphi();
2217 
2218  // Reinitialize the element and compute the shape function values at coor
2219  fe->reinit (&e, &coor);
2220 
2221  // Get ready to accumulate a gradient
2222  Gradient grad_u;
2223 
2224  for (unsigned int l=0; l<num_dofs; l++)
2225  {
2226  grad_u.add_scaled (dphi[l][0], this->current_solution (dof_indices[l]));
2227  }
2228 
2229  return grad_u;
2230 }
void add_scaled(const TypeVector< T2 > &, const T)
Definition: type_vector.h:620
libmesh_assert(j)
const DofMap & get_dof_map() const
Definition: system.h:2028
NumberVectorValue Gradient
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:556
Number current_solution(const dof_id_type global_dof_number) const
Definition: system.C:187
static UniquePtr< FEGenericBase > build(const unsigned int dim, const FEType &type)
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 2234 of file system.C.

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

2235 {
2236  libmesh_assert(e);
2237  return this->point_gradient(var, p, *e);
2238 }
libmesh_assert(j)
Gradient point_gradient(unsigned int var, const Point &p, const bool insist_on_success=true) const
Definition: system.C:2129
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 2244 of file system.C.

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

Referenced by point_hessian().

2245 {
2246  // This function must be called on every processor; there's no
2247  // telling where in the partition p falls.
2248  parallel_object_only();
2249 
2250  // And every processor had better agree about which point we're
2251  // looking for
2252 #ifndef NDEBUG
2253  libmesh_assert(this->comm().verify(p(0)));
2254 #if LIBMESH_DIM > 1
2255  libmesh_assert(this->comm().verify(p(1)));
2256 #endif
2257 #if LIBMESH_DIM > 2
2258  libmesh_assert(this->comm().verify(p(2)));
2259 #endif
2260 #endif // NDEBUG
2261 
2262  // Get a reference to the mesh object associated with the system object that calls this function
2263  const MeshBase & mesh = this->get_mesh();
2264 
2265  // Use an existing PointLocator or create a new one
2266  UniquePtr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2267  PointLocatorBase & locator = *locator_ptr;
2268 
2269  if (!insist_on_success || !mesh.is_serial())
2270  locator.enable_out_of_mesh_mode();
2271 
2272  // Get a pointer to the element that contains P
2273  const Elem * e = locator(p);
2274 
2275  Tensor hess_u;
2276 
2277  if (e && this->get_dof_map().is_evaluable(*e, var))
2278  hess_u = point_hessian(var, p, *e);
2279 
2280  // If I have an element containing p, then let's let everyone know
2281  processor_id_type lowest_owner =
2282  (e && (e->processor_id() == this->processor_id())) ?
2283  this->processor_id() : this->n_processors();
2284  this->comm().min(lowest_owner);
2285 
2286  // Everybody should get their value from a processor that was able
2287  // to compute it.
2288  // If nobody admits owning the point, we may have a problem.
2289  if (lowest_owner != this->n_processors())
2290  this->comm().broadcast(hess_u, lowest_owner);
2291  else
2292  libmesh_assert(!insist_on_success);
2293 
2294  return hess_u;
2295 }
processor_id_type n_processors() const
MeshBase & mesh
uint8_t processor_id_type
Definition: id_types.h:99
libmesh_assert(j)
const MeshBase & get_mesh() const
Definition: system.h:2012
const DofMap & get_dof_map() const
Definition: system.h:2028
Tensor point_hessian(unsigned int var, const Point &p, const bool insist_on_success=true) const
Definition: system.C:2244
void broadcast(T &data, const unsigned int root_id=0) const
bool verify(const T &r, const Communicator &comm=Communicator_World)
NumberTensorValue Tensor
const Parallel::Communicator & comm() const
processor_id_type processor_id() const
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 2297 of file system.C.

References libMesh::TypeTensor< T >::add_scaled(), libMesh::FEGenericBase< OutputType >::build(), libMesh::Elem::contains_point(), current_solution(), libMesh::Elem::dim(), get_dof_map(), libMesh::FEInterface::inverse_map(), and libMesh::libmesh_assert().

2298 {
2299  // Ensuring that the given point is really in the element is an
2300  // expensive assert, but as long as debugging is turned on we might
2301  // as well try to catch a particularly nasty potential error
2302  libmesh_assert (e.contains_point(p));
2303 
2304  // Get the dof map to get the proper indices for our computation
2305  const DofMap & dof_map = this->get_dof_map();
2306 
2307  // Make sure we can evaluate on this element.
2308  libmesh_assert (dof_map.is_evaluable(e, var));
2309 
2310  // Need dof_indices for phi[i][j]
2311  std::vector<dof_id_type> dof_indices;
2312 
2313  // Fill in the dof_indices for our element
2314  dof_map.dof_indices (&e, dof_indices, var);
2315 
2316  // Get the no of dofs assciated with this point
2317  const unsigned int num_dofs = cast_int<unsigned int>
2318  (dof_indices.size());
2319 
2320  FEType fe_type = dof_map.variable_type(var);
2321 
2322  // Build a FE again so we can calculate u(p)
2323  UniquePtr<FEBase> fe (FEBase::build(e.dim(), fe_type));
2324 
2325  // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h
2326  // Build a vector of point co-ordinates to send to reinit
2327  std::vector<Point> coor(1, FEInterface::inverse_map(e.dim(), fe_type, &e, p));
2328 
2329  // Get the values of the shape function derivatives
2330  const std::vector<std::vector<RealTensor> > & d2phi = fe->get_d2phi();
2331 
2332  // Reinitialize the element and compute the shape function values at coor
2333  fe->reinit (&e, &coor);
2334 
2335  // Get ready to accumulate a hessian
2336  Tensor hess_u;
2337 
2338  for (unsigned int l=0; l<num_dofs; l++)
2339  {
2340  hess_u.add_scaled (d2phi[l][0], this->current_solution (dof_indices[l]));
2341  }
2342 
2343  return hess_u;
2344 }
void add_scaled(const TypeTensor< T2 > &, const T)
Definition: type_tensor.h:773
libmesh_assert(j)
const DofMap & get_dof_map() const
Definition: system.h:2028
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:556
Number current_solution(const dof_id_type global_dof_number) const
Definition: system.C:187
NumberTensorValue Tensor
static UniquePtr< FEGenericBase > build(const unsigned int dim, const FEType &type)
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 2348 of file system.C.

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

2349 {
2350  libmesh_assert(e);
2351  return this->point_hessian(var, p, *e);
2352 }
libmesh_assert(j)
Tensor point_hessian(unsigned int var, const Point &p, const bool insist_on_success=true) const
Definition: system.C:2244
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 2017 of file system.C.

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

Referenced by point_value().

2018 {
2019  // This function must be called on every processor; there's no
2020  // telling where in the partition p falls.
2021  parallel_object_only();
2022 
2023  // And every processor had better agree about which point we're
2024  // looking for
2025 #ifndef NDEBUG
2026  libmesh_assert(this->comm().verify(p(0)));
2027 #if LIBMESH_DIM > 1
2028  libmesh_assert(this->comm().verify(p(1)));
2029 #endif
2030 #if LIBMESH_DIM > 2
2031  libmesh_assert(this->comm().verify(p(2)));
2032 #endif
2033 #endif // NDEBUG
2034 
2035  // Get a reference to the mesh object associated with the system object that calls this function
2036  const MeshBase & mesh = this->get_mesh();
2037 
2038  // Use an existing PointLocator or create a new one
2039  UniquePtr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2040  PointLocatorBase & locator = *locator_ptr;
2041 
2042  if (!insist_on_success || !mesh.is_serial())
2043  locator.enable_out_of_mesh_mode();
2044 
2045  // Get a pointer to the element that contains P
2046  const Elem * e = locator(p);
2047 
2048  Number u = 0;
2049 
2050  if (e && this->get_dof_map().is_evaluable(*e, var))
2051  u = point_value(var, p, *e);
2052 
2053  // If I have an element containing p, then let's let everyone know
2054  processor_id_type lowest_owner =
2055  (e && (e->processor_id() == this->processor_id())) ?
2056  this->processor_id() : this->n_processors();
2057  this->comm().min(lowest_owner);
2058 
2059  // Everybody should get their value from a processor that was able
2060  // to compute it.
2061  // If nobody admits owning the point, we have a problem.
2062  if (lowest_owner != this->n_processors())
2063  this->comm().broadcast(u, lowest_owner);
2064  else
2065  libmesh_assert(!insist_on_success);
2066 
2067  return u;
2068 }
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true) const
Definition: system.C:2017
processor_id_type n_processors() const
MeshBase & mesh
uint8_t processor_id_type
Definition: id_types.h:99
libmesh_assert(j)
const MeshBase & get_mesh() const
Definition: system.h:2012
const DofMap & get_dof_map() const
Definition: system.h:2028
void broadcast(T &data, const unsigned int root_id=0) const
bool verify(const T &r, const Communicator &comm=Communicator_World)
const Parallel::Communicator & comm() const
processor_id_type processor_id() const
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 2070 of file system.C.

References libMesh::FEGenericBase< OutputType >::build(), libMesh::Elem::contains_point(), current_solution(), libMesh::Elem::dim(), get_dof_map(), libMesh::FEInterface::inverse_map(), and libMesh::libmesh_assert().

2071 {
2072  // Ensuring that the given point is really in the element is an
2073  // expensive assert, but as long as debugging is turned on we might
2074  // as well try to catch a particularly nasty potential error
2075  libmesh_assert (e.contains_point(p));
2076 
2077  // Get the dof map to get the proper indices for our computation
2078  const DofMap & dof_map = this->get_dof_map();
2079 
2080  // Make sure we can evaluate on this element.
2081  libmesh_assert (dof_map.is_evaluable(e, var));
2082 
2083  // Need dof_indices for phi[i][j]
2084  std::vector<dof_id_type> dof_indices;
2085 
2086  // Fill in the dof_indices for our element
2087  dof_map.dof_indices (&e, dof_indices, var);
2088 
2089  // Get the no of dofs assciated with this point
2090  const unsigned int num_dofs = cast_int<unsigned int>
2091  (dof_indices.size());
2092 
2093  FEType fe_type = dof_map.variable_type(var);
2094 
2095  // Build a FE so we can calculate u(p)
2096  UniquePtr<FEBase> fe (FEBase::build(e.dim(), fe_type));
2097 
2098  // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h
2099  // Build a vector of point co-ordinates to send to reinit
2100  std::vector<Point> coor(1, FEInterface::inverse_map(e.dim(), fe_type, &e, p));
2101 
2102  // Get the shape function values
2103  const std::vector<std::vector<Real> > & phi = fe->get_phi();
2104 
2105  // Reinitialize the element and compute the shape function values at coor
2106  fe->reinit (&e, &coor);
2107 
2108  // Get ready to accumulate a value
2109  Number u = 0;
2110 
2111  for (unsigned int l=0; l<num_dofs; l++)
2112  {
2113  u += phi[l][0]*this->current_solution (dof_indices[l]);
2114  }
2115 
2116  return u;
2117 }
libmesh_assert(j)
const DofMap & get_dof_map() const
Definition: system.h:2028
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:556
Number current_solution(const dof_id_type global_dof_number) const
Definition: system.C:187
static UniquePtr< FEGenericBase > build(const unsigned int dim, const FEType &type)
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 2121 of file system.C.

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

2122 {
2123  libmesh_assert(e);
2124  return this->point_value(var, p, *e);
2125 }
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true) const
Definition: system.C:2017
libmesh_assert(j)
void libMesh::ReferenceCounter::print_info ( std::ostream &  out = libMesh::out)
staticinherited

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

Definition at line 88 of file reference_counter.C.

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

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

89 {
91  out_stream << ReferenceCounter::get_info();
92 }
static std::string get_info()
processor_id_type libMesh::ParallelObject::processor_id ( ) const
inlineinherited
Returns
The rank of this processor in the group.

Definition at line 99 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::DistributedMesh::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::MeshRefinement::add_node(), libMesh::MeshTools::Modification::all_tri(), libMesh::FEMSystem::assembly(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::MeshCommunication::broadcast(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::ParmetisPartitioner::build_graph(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::DofMap::build_sparsity(), 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::EnsightIO::EnsightIO(), libMesh::MeshFunction::find_element(), libMesh::MeshFunction::find_elements(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::MeshCommunication::gather(), libMesh::MeshCommunication::gather_neighboring_elements(), 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::EquationSystems::get_solution(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), libMesh::SparsityPattern::Build::handle_vi_vj(), libMesh::DistributedVector< T >::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), 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::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), 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(), n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SparsityPattern::Build::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SparsityPattern::Build::parallel_sync(), libMesh::MetisPartitioner::partition_range(), point_gradient(), point_hessian(), point_value(), libMesh::SparseMatrix< T >::print(), libMesh::NumericVector< T >::print_global(), 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::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::MeshCommunication::redistribute(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::Parallel::Packing< Node * >::unpack(), libMesh::Parallel::Packing< Elem * >::unpack(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::MeshTools::weight(), libMesh::NameBasedIO::write(), libMesh::CheckpointIO::write(), libMesh::XdrIO::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(), 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(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), and libMesh::ExodusII_IO_Helper::write_timestep().

100  { return cast_int<processor_id_type>(_communicator.rank()); }
const Parallel::Communicator & _communicator
unsigned int rank() const
Definition: parallel.h:720
void libMesh::System::project_solution ( FunctionBase< Number > *  f,
FunctionBase< Gradient > *  g = libmesh_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 811 of file system_projection.C.

Referenced by project_vector(), and system_type().

813 {
814  this->project_vector(*solution, f, g);
815 
816  solution->localize(*current_local_solution, _dof_map->get_send_list());
817 }
UniquePtr< NumericVector< Number > > current_local_solution
Definition: system.h:1533
UniquePtr< DofMap > _dof_map
Definition: system.h:1863
UniquePtr< NumericVector< Number > > solution
Definition: system.h:1521
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=libmesh_nullptr, int is_adjoint=-1) const
void libMesh::System::project_solution ( FEMFunctionBase< Number > *  f,
FEMFunctionBase< Gradient > *  g = libmesh_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 824 of file system_projection.C.

References project_vector().

826 {
827  this->project_vector(*solution, f, g);
828 
829  solution->localize(*current_local_solution, _dof_map->get_send_list());
830 }
UniquePtr< NumericVector< Number > > current_local_solution
Definition: system.h:1533
UniquePtr< DofMap > _dof_map
Definition: system.h:1863
UniquePtr< NumericVector< Number > > solution
Definition: system.h:1521
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=libmesh_nullptr, int is_adjoint=-1) const
void libMesh::System::project_solution ( Number   fptrconst Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name,
Gradient   gptrconst Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name,
const Parameters parameters 
) const

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.

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, add_adjoint_rhs(), add_adjoint_solution(), add_sensitivity_rhs(), add_sensitivity_solution(), add_variable(), add_variables(), add_weighted_sensitivity_adjoint_solution(), add_weighted_sensitivity_solution(), calculate_norm(), libMesh::FIRST, get_adjoint_rhs(), get_adjoint_solution(), get_all_variable_numbers(), get_sensitivity_rhs(), get_sensitivity_solution(), get_vector(), get_weighted_sensitivity_adjoint_solution(), get_weighted_sensitivity_solution(), has_variable(), have_vector(), identify_variable_groups(), libMesh::LAGRANGE, libmesh_nullptr, n_active_dofs(), n_components(), n_constrained_dofs(), n_dofs(), n_local_constrained_dofs(), n_local_dofs(), n_matrices(), n_variable_groups(), n_vars(), n_vectors(), read_header(), read_legacy_data(), read_serialized_data(), libMesh::Real, request_vector(), set_vector_as_adjoint(), set_vector_preservation(), variable(), variable_group(), variable_name(), variable_number(), variable_scalar_number(), variable_type(), vector_is_adjoint(), vector_name(), and vector_preservation().

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

795  { return _solution_projection; }
bool _solution_projection
Definition: system.h:1938
void libMesh::System::project_vector ( NumericVector< Number > &  new_vector,
FunctionBase< Number > *  f,
FunctionBase< Gradient > *  g = libmesh_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 858 of file system_projection.C.

References libMesh::libmesh_assert(), and libmesh_nullptr.

Referenced by hide_output(), libMesh::NewmarkSolver::project_initial_accel(), libMesh::SecondOrderUnsteadySolver::project_initial_rate(), project_solution(), project_vector(), restrict_vectors(), and system_type().

862 {
863  LOG_SCOPE ("project_vector(FunctionBase)", "System");
864 
865  libmesh_assert(f);
866 
867  WrappedFunctor<Number> f_fem(*f);
868 
869  if (g)
870  {
871  WrappedFunctor<Gradient> g_fem(*g);
872 
873  this->project_vector(new_vector, &f_fem, &g_fem, is_adjoint);
874  }
875  else
876  this->project_vector(new_vector, &f_fem, libmesh_nullptr, is_adjoint);
877 }
const class libmesh_nullptr_t libmesh_nullptr
libmesh_assert(j)
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=libmesh_nullptr, int is_adjoint=-1) const
void libMesh::System::project_vector ( NumericVector< Number > &  new_vector,
FEMFunctionBase< Number > *  f,
FEMFunctionBase< Gradient > *  g = libmesh_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 884 of file system_projection.C.

References boundary_project_solution(), libMesh::NumericVector< T >::close(), libMesh::FEMFunctionBase< Output >::component(), libMesh::get_dof_map(), libMesh::libmesh_assert(), libmesh_nullptr, libMesh::n_processors(), n_vars, libMesh::Threads::parallel_for(), libMesh::FEMContext::pre_fe_reinit(), libMesh::processor_id(), libMesh::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), libMesh::NumericVector< T >::set(), and libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::variables.

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

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

References libMesh::NumericVector< T >::build(), libMesh::NumericVector< T >::clear(), libMesh::NumericVector< T >::clone(), libMesh::NumericVector< T >::close(), libMesh::NumericVector< T >::get(), libMesh::get_dof_map(), libMesh::GHOSTED, libMesh::NumericVector< T >::init(), libMesh::libmesh_assert(), libmesh_nullptr, libMesh::NumericVector< T >::local_size(), libMesh::NumericVector< T >::localize(), libMesh::n_processors(), n_vars, libMesh::PARALLEL, libMesh::Threads::parallel_for(), libMesh::Threads::parallel_reduce(), libMesh::processor_id(), project_solution(), project_vector(), libMesh::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), libMesh::BuildProjectionList::send_list, libMesh::SERIAL, libMesh::NumericVector< T >::set(), libMesh::NumericVector< T >::size(), libMesh::NumericVector< T >::type(), and libMesh::BuildProjectionList::unique().

578 {
579  // Create a copy of the vector, which currently
580  // contains the old data.
581  UniquePtr<NumericVector<Number> >
582  old_vector (vector.clone());
583 
584  // Project the old vector to the new vector
585  this->project_vector (*old_vector, vector, is_adjoint);
586 }
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=libmesh_nullptr, int is_adjoint=-1) const
virtual UniquePtr< NumericVector< T > > clone() const =0
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.

void libMesh::System::prolong_vectors ( )
virtual

Prolong vectors after the mesh has refined

Definition at line 370 of file system.C.

References restrict_vectors().

Referenced by read_parallel_data(), and libMesh::EquationSystems::reinit().

371 {
372 #ifdef LIBMESH_ENABLE_AMR
373  // Currently project_vector handles both restriction and prolongation
374  this->restrict_vectors();
375 #endif
376 }
virtual void restrict_vectors()
Definition: system.C:317
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 2307 of file system.h.

Referenced by set_adjoint_already_solved().

2310 {
2311  libmesh_not_implemented();
2312 }
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 2316 of file system.h.

Referenced by set_adjoint_already_solved().

2320 {
2321  libmesh_not_implemented();
2322 }
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 510 of file system.C.

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

Referenced by set_adjoint_already_solved().

513 {
514  // Forward sensitivities are more efficient for Nq > Np
515  if (qoi_indices.size(*this) > parameters.size())
516  forward_qoi_parameter_sensitivity(qoi_indices, parameters, sensitivities);
517  // Adjoint sensitivities are more efficient for Np > Nq,
518  // and an adjoint may be more reusable than a forward
519  // solution sensitivity in the Np == Nq case.
520  else
521  adjoint_qoi_parameter_sensitivity(qoi_indices, parameters, sensitivities);
522 }
virtual void forward_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
Definition: system.h:2298
virtual void adjoint_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
Definition: system.h:2289
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 441 of file system.C.

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

Referenced by read_parallel_data().

442 {
443  parallel_object_only();
444 
445  // If this system is empty... don't do anything!
446  if (!this->n_vars())
447  return;
448 
449  const std::vector<dof_id_type> & send_list = this->get_dof_map().get_send_list ();
450 
451  // Check sizes
452  libmesh_assert_equal_to (current_local_solution->size(), solution->size());
453  // Not true with ghosted vectors
454  // libmesh_assert_equal_to (current_local_solution->local_size(), solution->size());
455  // libmesh_assert (!send_list.empty());
456  libmesh_assert_less_equal (send_list.size(), solution->size());
457 
458  // Create current_local_solution from solution. This will
459  // put a local copy of solution into current_local_solution.
460  solution->localize (*current_local_solution, send_list);
461 }
UniquePtr< NumericVector< Number > > current_local_solution
Definition: system.h:1533
const DofMap & get_dof_map() const
Definition: system.h:2028
UniquePtr< NumericVector< Number > > solution
Definition: system.h:1521
unsigned int n_vars() const
Definition: system.h:2084
const std::vector< dof_id_type > & get_send_list() const
Definition: dof_map.h:394
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 libMesh::Xdr::data(), libMesh::FEType::family, libMesh::OrderWrapper::get_order(), libMesh::FEType::inf_map, libMesh::libmesh_assert(), libMesh::MONOMIAL, libMesh::on_command_line(), libMesh::FEType::order, libMesh::out, libMesh::processor_id(), libMesh::FEType::radial_family, libMesh::FEType::radial_order, libMesh::Xdr::reading(), libMesh::Xdr::version(), and libMesh::XYZ.

Referenced by libMesh::EquationSystems::_read_impl(), and project_solution_on_reinit().

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 subdmains
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 (std::vector<subdomain_id_type>::iterator it = domain_array.begin(); it != domain_array.end(); ++it)
193  domains.insert(*it);
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 occurance, 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:198
unsigned int add_variable(const std::string &var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=libmesh_nullptr)
Definition: system.C:1095
libmesh_assert(j)
unsigned short int variable_number(const std::string &var) const
Definition: system.C:1257
const MeshBase & get_mesh() const
Definition: system.h:2012
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Definition: system.C:676
unsigned int _additional_data_written
Definition: system.h:1963
void broadcast(T &data, const unsigned int root_id=0) const
bool on_command_line(const std::string &arg)
Definition: libmesh.C:914
const Parallel::Communicator & comm() const
unsigned int mesh_dimension() const
Definition: mesh_base.C:147
OStreamProxy out(std::cout)
std::vector< unsigned int > _written_var_indices
Definition: system.h:1975
processor_id_type processor_id() const
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 309 of file system_io.C.

References libMesh::Xdr::data(), end, libMesh::libmesh_assert(), n_vars, libMesh::processor_id(), libMesh::Xdr::reading(), libMesh::sys, and libMesh::zero.

Referenced by project_solution_on_reinit().

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

References libMesh::Xdr::data(), libMesh::get_dof_map(), libMesh::Xdr::is_open(), libMesh::libmesh_assert(), libMesh::n_processors(), n_vars, libMesh::processor_id(), libMesh::Xdr::reading(), libMesh::SCALAR, and libMesh::DofMap::SCALAR_dof_indices().

Referenced by read_serialized_vectors().

517 {
537  // PerfLog pl("IO Performance",false);
538  // pl.push("read_parallel_data");
539  dof_id_type total_read_size = 0;
540 
541  libmesh_assert (io.reading());
542