libMesh::ExplicitSystem Class Reference

Used for solving explicit systems of equations. More...

#include <explicit_system.h>

Inheritance diagram for libMesh::ExplicitSystem:

Public Types

typedef ExplicitSystem sys_type
 
typedef System Parent
 
typedef Number(* ValueFunctionPointer) (const Point &p, const Parameters &Parameters, const std::string &sys_name, const std::string &unknown_name)
 
typedef Gradient(* GradientFunctionPointer) (const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name)
 
typedef std::map< std::string, NumericVector< Number > * >::iterator vectors_iterator
 
typedef std::map< std::string, NumericVector< Number > * >::const_iterator const_vectors_iterator
 

Public Member Functions

 ExplicitSystem (EquationSystems &es, const std::string &name, const unsigned int number)
 
sys_typesystem ()
 
virtual void clear () libmesh_override
 
virtual void assemble_qoi (const QoISet &qoi_indices=QoISet()) libmesh_override
 
virtual void assemble_qoi_derivative (const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true) libmesh_override
 
virtual void solve () libmesh_override
 
virtual std::string system_type () const libmesh_override
 
void init ()
 
virtual void reinit ()
 
virtual void reinit_constraints ()
 
bool is_initialized ()
 
virtual void update ()
 
virtual void assemble ()
 
virtual void assemble_residual_derivatives (const ParameterVector &parameters)
 
virtual void restrict_solve_to (const SystemSubset *subset, const SubsetSolveMode subset_solve_mode=SUBSET_ZERO)
 
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
 
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 (ValueFunctionPointer fptr, GradientFunctionPointer gptr, 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 (ValueFunctionPointer fptr, GradientFunctionPointer gptr, const Parameters &parameters, NumericVector< Number > &new_vector, int is_adjoint=-1) const
 
void boundary_project_solution (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, FunctionBase< Number > *f, FunctionBase< Gradient > *g=libmesh_nullptr)
 
void boundary_project_solution (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, ValueFunctionPointer fptr, GradientFunctionPointer gptr, const Parameters &parameters)
 
void boundary_project_vector (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=libmesh_nullptr, int is_adjoint=-1) const
 
void boundary_project_vector (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, ValueFunctionPointer fptr, GradientFunctionPointer gptr, const Parameters &parameters, NumericVector< Number > &new_vector, int is_adjoint=-1) const
 
unsigned int number () const
 
void update_global_solution (std::vector< Number > &global_soln) const
 
void update_global_solution (std::vector< Number > &global_soln, const processor_id_type dest_proc) const
 
const MeshBaseget_mesh () const
 
MeshBaseget_mesh ()
 
const DofMapget_dof_map () const
 
DofMapget_dof_map ()
 
const EquationSystemsget_equation_systems () const
 
EquationSystemsget_equation_systems ()
 
bool active () const
 
void activate ()
 
void deactivate ()
 
void set_basic_system_only ()
 
vectors_iterator vectors_begin ()
 
const_vectors_iterator vectors_begin () const
 
vectors_iterator vectors_end ()
 
const_vectors_iterator vectors_end () const
 
NumericVector< Number > & add_vector (const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
 
void remove_vector (const std::string &vec_name)
 
bool & project_solution_on_reinit (void)
 
bool have_vector (const std::string &vec_name) const
 
const NumericVector< Number > * request_vector (const std::string &vec_name) const
 
NumericVector< Number > * request_vector (const std::string &vec_name)
 
const NumericVector< Number > * request_vector (const unsigned int vec_num) const
 
NumericVector< Number > * request_vector (const unsigned int vec_num)
 
const NumericVector< Number > & get_vector (const std::string &vec_name) const
 
NumericVector< Number > & get_vector (const std::string &vec_name)
 
const NumericVector< Number > & get_vector (const unsigned int vec_num) const
 
NumericVector< Number > & get_vector (const unsigned int vec_num)
 
const std::string & vector_name (const unsigned int vec_num) const
 
const std::string & vector_name (const NumericVector< Number > &vec_reference) const
 
void set_vector_as_adjoint (const std::string &vec_name, int qoi_num)
 
int vector_is_adjoint (const std::string &vec_name) const
 
void set_vector_preservation (const std::string &vec_name, bool preserve)
 
bool vector_preservation (const std::string &vec_name) const
 
NumericVector< Number > & add_adjoint_solution (unsigned int i=0)
 
NumericVector< Number > & get_adjoint_solution (unsigned int i=0)
 
const NumericVector< Number > & get_adjoint_solution (unsigned int i=0) const
 
NumericVector< Number > & add_sensitivity_solution (unsigned int i=0)
 
NumericVector< Number > & get_sensitivity_solution (unsigned int i=0)
 
const NumericVector< Number > & get_sensitivity_solution (unsigned int i=0) const
 
NumericVector< Number > & add_weighted_sensitivity_adjoint_solution (unsigned int i=0)
 
NumericVector< Number > & get_weighted_sensitivity_adjoint_solution (unsigned int i=0)
 
const NumericVector< Number > & get_weighted_sensitivity_adjoint_solution (unsigned int i=0) const
 
NumericVector< Number > & add_weighted_sensitivity_solution ()
 
NumericVector< Number > & get_weighted_sensitivity_solution ()
 
const NumericVector< Number > & get_weighted_sensitivity_solution () const
 
NumericVector< Number > & add_adjoint_rhs (unsigned int i=0)
 
NumericVector< Number > & get_adjoint_rhs (unsigned int i=0)
 
const NumericVector< Number > & get_adjoint_rhs (unsigned int i=0) const
 
NumericVector< Number > & add_sensitivity_rhs (unsigned int i=0)
 
NumericVector< Number > & get_sensitivity_rhs (unsigned int i=0)
 
const NumericVector< Number > & get_sensitivity_rhs (unsigned int i=0) const
 
unsigned int n_vectors () const
 
virtual unsigned int n_matrices () const
 
unsigned int n_vars () const
 
unsigned int n_variable_groups () const
 
unsigned int n_components () const
 
dof_id_type n_dofs () const
 
dof_id_type n_active_dofs () const
 
dof_id_type n_constrained_dofs () const
 
dof_id_type n_local_constrained_dofs () const
 
dof_id_type n_local_dofs () const
 
unsigned int add_variable (const std::string &var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=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 ()
 
void projection_matrix (SparseMatrix< Number > &proj_mat) const
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

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

Public Attributes

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

Protected Types

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

Protected Member Functions

void project_vector (NumericVector< Number > &, int is_adjoint=-1) const
 
void project_vector (const NumericVector< Number > &, NumericVector< Number > &, int is_adjoint=-1) const
 
virtual void init_data ()
 
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

void add_system_rhs ()
 

Detailed Description

Used for solving explicit systems of equations.

The ExplicitSystem provides only "right hand side" storage, which should be sufficient for solving most types of explicit problems.

Note
Additional vectors/matrices can be added via parent class interfaces.
Author
Benjamin S. Kirk
Date
2004

Definition at line 40 of file explicit_system.h.

Member Typedef Documentation

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

Definition at line 735 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.

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

Definition at line 510 of file system.h.

The type of the parent

Definition at line 60 of file explicit_system.h.

The type of system.

Definition at line 55 of file explicit_system.h.

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

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

Definition at line 506 of file system.h.

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

Vector iterator typedefs.

Definition at line 734 of file system.h.

Constructor & Destructor Documentation

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

Constructor. Optionally initializes required data structures.

Definition at line 32 of file explicit_system.C.

References add_system_rhs().

34  :
35  Parent (es, name_in, number_in),
37 
38 {
39  // Add the system RHS.
40  this->add_system_rhs ();
41 }
const class libmesh_nullptr_t libmesh_nullptr
NumericVector< Number > * rhs

Member Function Documentation

void libMesh::System::activate ( )
inlineinherited

Activates the system. Only active systems are solved.

Definition at line 2054 of file system.h.

References libMesh::System::_active.

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

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

Definition at line 2046 of file system.h.

References libMesh::System::_active.

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

2047 {
2048  return _active;
2049 }
NumericVector< Number > & libMesh::System::add_adjoint_rhs ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's adjoint rhs vectors, by default the one corresponding to the first qoi. Creates the vector if it doesn't already exist.

Definition at line 1022 of file system.C.

References libMesh::System::add_vector().

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

1023 {
1024  std::ostringstream adjoint_rhs_name;
1025  adjoint_rhs_name << "adjoint_rhs" << i;
1026 
1027  return this->add_vector(adjoint_rhs_name.str(), false);
1028 }
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Definition: system.C:662
NumericVector< Number > & libMesh::System::add_adjoint_solution ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's adjoint solution vectors, by default the one corresponding to the first qoi. Creates the vector if it doesn't already exist.

Definition at line 958 of file system.C.

References libMesh::System::add_vector(), and libMesh::System::set_vector_as_adjoint().

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

959 {
960  std::ostringstream adjoint_name;
961  adjoint_name << "adjoint_solution" << i;
962 
963  NumericVector<Number> & returnval = this->add_vector(adjoint_name.str());
964  this->set_vector_as_adjoint(adjoint_name.str(), i);
965  return returnval;
966 }
void set_vector_as_adjoint(const std::string &vec_name, int qoi_num)
Definition: system.C:886
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Definition: system.C:662
NumericVector< Number > & libMesh::System::add_sensitivity_rhs ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's sensitivity rhs vectors, by default the one corresponding to the first parameter. Creates the vector if it doesn't already exist.

Definition at line 1052 of file system.C.

References libMesh::System::add_vector().

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

1053 {
1054  std::ostringstream sensitivity_rhs_name;
1055  sensitivity_rhs_name << "sensitivity_rhs" << i;
1056 
1057  return this->add_vector(sensitivity_rhs_name.str(), false);
1058 }
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Definition: system.C:662
NumericVector< Number > & libMesh::System::add_sensitivity_solution ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's solution sensitivity vectors, by default the one corresponding to the first parameter. Creates the vector if it doesn't already exist.

Definition at line 907 of file system.C.

References libMesh::System::add_vector().

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

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

Add the system right-hand-side vector to the _vectors data structure. Useful in initialization.

Definition at line 96 of file explicit_system.C.

References libMesh::System::add_vector(), libmesh_nullptr, libMesh::System::n_vectors(), and rhs.

Referenced by clear(), and ExplicitSystem().

97 {
98  // Possible that we cleared the _vectors but
99  // forgot to NULL-out the rhs?
100  if (this->n_vectors() == 0)
102 
103 
104  // Only need to add the rhs if it isn't there
105  // already!
106  if (rhs == libmesh_nullptr)
107  rhs = &(this->add_vector ("RHS Vector", false));
108 
109  libmesh_assert(rhs);
110 }
const class libmesh_nullptr_t libmesh_nullptr
NumericVector< Number > * rhs
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Definition: system.C:662
unsigned int n_vectors() const
Definition: system.h:2214
unsigned int libMesh::System::add_variable ( const std::string &  var,
const FEType type,
const std::set< subdomain_id_type > *const  active_subdomains = libmesh_nullptr 
)
inherited

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

Returns
The index number for the new variable.

Definition at line 1082 of file system.C.

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

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

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

Adds the variable var to the list of variables for this system. Same as before, but assumes LAGRANGE as default value for FEType.family.

Definition at line 1160 of file system.C.

References libMesh::System::add_variable().

1164 {
1165  return this->add_variable(var,
1166  FEType(order, family),
1167  active_subdomains);
1168 }
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:1082
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 
)
inherited

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

Returns
The index number for the new variable.

Definition at line 1172 of file system.C.

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

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

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

Adds the variable var to the list of variables for this system. Same as before, but assumes LAGRANGE as default value for FEType.family.

Definition at line 1225 of file system.C.

References libMesh::System::add_variables().

1229 {
1230  return this->add_variables(vars,
1231  FEType(order, family),
1232  active_subdomains);
1233 }
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:1172
NumericVector< Number > & libMesh::System::add_vector ( const std::string &  vec_name,
const bool  projections = true,
const ParallelType  type = PARALLEL 
)
inherited

Adds the additional vector vec_name to this system. All the additional vectors are similarly distributed, like the solution, and initialized to zero.

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

Definition at line 662 of file system.C.

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

Referenced by libMesh::System::add_adjoint_rhs(), libMesh::System::add_adjoint_solution(), libMesh::System::add_sensitivity_rhs(), libMesh::System::add_sensitivity_solution(), add_system_rhs(), libMesh::System::add_weighted_sensitivity_adjoint_solution(), libMesh::System::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().

665 {
666  // Return the vector if it is already there.
667  if (this->have_vector(vec_name))
668  return *(_vectors[vec_name]);
669 
670  // Otherwise build the vector
671  NumericVector<Number> * buf = NumericVector<Number>::build(this->comm()).release();
672  _vectors.insert (std::make_pair (vec_name, buf));
673  _vector_projections.insert (std::make_pair (vec_name, projections));
674 
675  _vector_types.insert (std::make_pair (vec_name, type));
676 
677  // Vectors are primal by default
678  _vector_is_adjoint.insert (std::make_pair (vec_name, -1));
679 
680  // Initialize it if necessary
681  if (_is_initialized)
682  {
683  if (type == GHOSTED)
684  {
685 #ifdef LIBMESH_ENABLE_GHOSTED
686  buf->init (this->n_dofs(), this->n_local_dofs(),
687  _dof_map->get_send_list(), false,
688  GHOSTED);
689 #else
690  libmesh_error_msg("Cannot initialize ghosted vectors when they are not enabled.");
691 #endif
692  }
693  else
694  buf->init (this->n_dofs(), this->n_local_dofs(), false, type);
695  }
696 
697  return *buf;
698 }
std::map< std::string, ParallelType > _vector_types
Definition: system.h:1933
bool _is_initialized
Definition: system.h:1952
std::unique_ptr< DofMap > _dof_map
Definition: system.h:1865
bool have_vector(const std::string &vec_name) const
Definition: system.h:2206
std::map< std::string, int > _vector_is_adjoint
Definition: system.h:1928
static std::unique_ptr< NumericVector< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
dof_id_type n_local_dofs() const
Definition: system.C:185
std::map< std::string, NumericVector< Number > * > _vectors
Definition: system.h:1916
const Parallel::Communicator & comm() const
std::map< std::string, bool > _vector_projections
Definition: system.h:1922
dof_id_type n_dofs() const
Definition: system.C:148
NumericVector< Number > & libMesh::System::add_weighted_sensitivity_adjoint_solution ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's weighted sensitivity adjoint solution vectors, by default the one corresponding to the first qoi. Creates the vector if it doesn't already exist.

Definition at line 990 of file system.C.

References libMesh::System::add_vector(), and libMesh::System::set_vector_as_adjoint().

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

991 {
992  std::ostringstream adjoint_name;
993  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
994 
995  NumericVector<Number> & returnval = this->add_vector(adjoint_name.str());
996  this->set_vector_as_adjoint(adjoint_name.str(), i);
997  return returnval;
998 }
void set_vector_as_adjoint(const std::string &vec_name, int qoi_num)
Definition: system.C:886
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Definition: system.C:662
NumericVector< Number > & libMesh::System::add_weighted_sensitivity_solution ( )
inherited
Returns
A reference to the solution of the last weighted sensitivity solve Creates the vector if it doesn't already exist.

Definition at line 937 of file system.C.

References libMesh::System::add_vector().

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

938 {
939  return this->add_vector("weighted_sensitivity_solution");
940 }
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Definition: system.C:662
void libMesh::System::adjoint_qoi_parameter_sensitivity ( const QoISet qoi_indices,
const ParameterVector parameters,
SensitivityData sensitivities 
)
inlinevirtualinherited

Solves for parameter sensitivities using the adjoint method.

This method is only implemented in some derived classes.

Reimplemented in libMesh::ImplicitSystem.

Definition at line 2291 of file system.h.

Referenced by libMesh::System::qoi_parameter_sensitivity(), and libMesh::System::set_adjoint_already_solved().

2294 {
2295  libmesh_not_implemented();
2296 }
std::pair< unsigned int, Real > libMesh::System::adjoint_solve ( const QoISet qoi_indices = QoISet())
inlinevirtualinherited

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

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

2276 {
2277  libmesh_not_implemented();
2278 }
void libMesh::System::assemble ( )
virtualinherited

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

Definition at line 460 of file system.C.

References libMesh::System::user_assembly().

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

461 {
462  // Log how long the user's assembly code takes
463  LOG_SCOPE("assemble()", "System");
464 
465  // Call the user-specified assembly function
466  this->user_assembly();
467 }
virtual void user_assembly()
Definition: system.C:1919
void libMesh::ExplicitSystem::assemble_qoi ( const QoISet qoi_indices = QoISet())
virtual

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

Reimplemented from libMesh::System.

Reimplemented in libMesh::FEMSystem.

Definition at line 56 of file explicit_system.C.

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

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

57 {
58  // The user quantity of interest assembly gets to expect to
59  // accumulate on initially zero values
60  for (std::size_t i=0; i != qoi.size(); ++i)
61  if (qoi_indices.has_index(i))
62  qoi[i] = 0;
63 
64  Parent::assemble_qoi (qoi_indices);
65 }
std::vector< Number > qoi
Definition: system.h:1539
virtual void assemble_qoi(const QoISet &qoi_indices=QoISet())
Definition: system.C:471
void libMesh::ExplicitSystem::assemble_qoi_derivative ( const QoISet qoi_indices = QoISet(),
bool  include_liftfunc = true,
bool  apply_constraints = true 
)
virtual

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

Reimplemented from libMesh::System.

Reimplemented in libMesh::FEMSystem.

Definition at line 69 of file explicit_system.C.

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

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

72 {
73  // The user quantity of interest derivative assembly gets to expect
74  // to accumulate on initially zero vectors
75  for (std::size_t i=0; i != qoi.size(); ++i)
76  if (qoi_indices.has_index(i))
77  this->add_adjoint_rhs(i).zero();
78 
79  Parent::assemble_qoi_derivative (qoi_indices, include_liftfunc,
80  apply_constraints);
81 }
virtual void assemble_qoi_derivative(const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true)
Definition: system.C:482
virtual void zero()=0
std::vector< Number > qoi
Definition: system.h:1539
NumericVector< Number > & add_adjoint_rhs(unsigned int i=0)
Definition: system.C:1022
void libMesh::System::assemble_residual_derivatives ( const ParameterVector parameters)
inlinevirtualinherited

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

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

2251 {
2252  libmesh_not_implemented();
2253 }
void libMesh::System::attach_assemble_function ( void   fptrEquationSystems &es, const std::string &name)
inherited

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

Definition at line 1764 of file system.C.

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

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

1766 {
1767  libmesh_assert(fptr);
1768 
1770  {
1771  libmesh_here();
1772  libMesh::out << "WARNING: Cannot specify both assembly function and object!"
1773  << std::endl;
1774 
1776  }
1777 
1779 }
Assembly * _assemble_system_object
Definition: system.h:1822
const class libmesh_nullptr_t libmesh_nullptr
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1816
OStreamProxy out(std::cout)
void libMesh::System::attach_assemble_object ( System::Assembly assemble_in)
inherited

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

Definition at line 1783 of file system.C.

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

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

1784 {
1786  {
1787  libmesh_here();
1788  libMesh::out << "WARNING: Cannot specify both assembly object and function!"
1789  << std::endl;
1790 
1792  }
1793 
1794  _assemble_system_object = &assemble_in;
1795 }
Assembly * _assemble_system_object
Definition: system.h:1822
const class libmesh_nullptr_t libmesh_nullptr
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1816
OStreamProxy out(std::cout)
void libMesh::System::attach_constraint_function ( void   fptrEquationSystems &es, const std::string &name)
inherited

Register a user function for imposing constraints.

Definition at line 1799 of file system.C.

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

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

1801 {
1802  libmesh_assert(fptr);
1803 
1805  {
1806  libmesh_here();
1807  libMesh::out << "WARNING: Cannot specify both constraint function and object!"
1808  << std::endl;
1809 
1811  }
1812 
1814 }
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1827
Constraint * _constrain_system_object
Definition: system.h:1833
const class libmesh_nullptr_t libmesh_nullptr
OStreamProxy out(std::cout)
void libMesh::System::attach_constraint_object ( System::Constraint constrain)
inherited

Register a user object for imposing constraints.

Definition at line 1818 of file system.C.

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

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

1819 {
1821  {
1822  libmesh_here();
1823  libMesh::out << "WARNING: Cannot specify both constraint object and function!"
1824  << std::endl;
1825 
1827  }
1828 
1829  _constrain_system_object = &constrain;
1830 }
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1827
Constraint * _constrain_system_object
Definition: system.h:1833
const class libmesh_nullptr_t libmesh_nullptr
OStreamProxy out(std::cout)
void libMesh::System::attach_init_function ( void   fptrEquationSystems &es, const std::string &name)
inherited

Register a user function to use in initializing the system.

Definition at line 1729 of file system.C.

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

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

1731 {
1732  libmesh_assert(fptr);
1733 
1735  {
1736  libmesh_here();
1737  libMesh::out << "WARNING: Cannot specify both initialization function and object!"
1738  << std::endl;
1739 
1741  }
1742 
1743  _init_system_function = fptr;
1744 }
const class libmesh_nullptr_t libmesh_nullptr
Initialization * _init_system_object
Definition: system.h:1811
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1805
OStreamProxy out(std::cout)
void libMesh::System::attach_init_object ( System::Initialization init_in)
inherited

Register a user class to use to initialize the system.

Note
This is exclusive with the attach_init_function.

Definition at line 1748 of file system.C.

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

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

1749 {
1751  {
1752  libmesh_here();
1753  libMesh::out << "WARNING: Cannot specify both initialization object and function!"
1754  << std::endl;
1755 
1757  }
1758 
1759  _init_system_object = &init_in;
1760 }
const class libmesh_nullptr_t libmesh_nullptr
Initialization * _init_system_object
Definition: system.h:1811
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1805
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)
inherited

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

Definition at line 1870 of file system.C.

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

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

1872 {
1873  libmesh_assert(fptr);
1874 
1876  {
1877  libmesh_here();
1878  libMesh::out << "WARNING: Cannot specify both QOI derivative function and object!"
1879  << std::endl;
1880 
1882  }
1883 
1885 }
const class libmesh_nullptr_t libmesh_nullptr
QOIDerivative * _qoi_evaluate_derivative_object
Definition: system.h:1859
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:1850
void libMesh::System::attach_QOI_derivative_object ( QOIDerivative qoi_derivative)
inherited

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

Definition at line 1889 of file system.C.

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

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

1890 {
1892  {
1893  libmesh_here();
1894  libMesh::out << "WARNING: Cannot specify both QOI derivative object and function!"
1895  << std::endl;
1896 
1898  }
1899 
1900  _qoi_evaluate_derivative_object = &qoi_derivative;
1901 }
const class libmesh_nullptr_t libmesh_nullptr
QOIDerivative * _qoi_evaluate_derivative_object
Definition: system.h:1859
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:1850
void libMesh::System::attach_QOI_function ( void   fptrEquationSystems &es, const std::string &name, const QoISet &qoi_indices)
inherited

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

Definition at line 1834 of file system.C.

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

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

1837 {
1838  libmesh_assert(fptr);
1839 
1841  {
1842  libmesh_here();
1843  libMesh::out << "WARNING: Cannot specify both QOI function and object!"
1844  << std::endl;
1845 
1847  }
1848 
1849  _qoi_evaluate_function = fptr;
1850 }
const class libmesh_nullptr_t libmesh_nullptr
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Definition: system.h:1838
QOI * _qoi_evaluate_object
Definition: system.h:1845
OStreamProxy out(std::cout)
void libMesh::System::attach_QOI_object ( QOI qoi)
inherited

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

Definition at line 1854 of file system.C.

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

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

1855 {
1857  {
1858  libmesh_here();
1859  libMesh::out << "WARNING: Cannot specify both QOI object and function!"
1860  << std::endl;
1861 
1863  }
1864 
1865  _qoi_evaluate_object = &qoi_in;
1866 }
const class libmesh_nullptr_t libmesh_nullptr
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Definition: system.h:1838
QOI * _qoi_evaluate_object
Definition: system.h:1845
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 
)
inherited

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

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

Definition at line 986 of file system_projection.C.

990 {
991  this->boundary_project_vector(b, variables, *solution, f, g);
992 
993  solution->localize(*current_local_solution);
994 }
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
std::unique_ptr< NumericVector< Number > > solution
Definition: system.h:1509
std::unique_ptr< NumericVector< Number > > current_local_solution
Definition: system.h:1521
void libMesh::System::boundary_project_solution ( const std::set< boundary_id_type > &  b,
const std::vector< unsigned int > &  variables,
ValueFunctionPointer  fptr,
GradientFunctionPointer  gptr,
const Parameters parameters 
)
inherited

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

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

Definition at line 969 of file system_projection.C.

974 {
975  WrappedFunction<Number> f(*this, fptr, &parameters);
976  WrappedFunction<Gradient> g(*this, gptr, &parameters);
977  this->boundary_project_solution(b, variables, &f, &g);
978 }
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 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
inherited

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

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

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

1028 {
1029  LOG_SCOPE ("boundary_project_vector()", "System");
1030 
1032  (ConstElemRange (this->get_mesh().active_local_elements_begin(),
1033  this->get_mesh().active_local_elements_end() ),
1034  BoundaryProjectSolution(b, variables, *this, f, g,
1035  this->get_equation_systems().parameters,
1036  new_vector)
1037  );
1038 
1039  // We don't do SCALAR dofs when just projecting the boundary, so
1040  // we're done here.
1041 
1042  new_vector.close();
1043 
1044 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1045  if (is_adjoint == -1)
1046  this->get_dof_map().enforce_constraints_exactly(*this, &new_vector);
1047  else if (is_adjoint >= 0)
1049  is_adjoint);
1050 #endif
1051 }
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:2014
const DofMap & get_dof_map() const
Definition: system.h:2030
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:698
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,
ValueFunctionPointer  fptr,
GradientFunctionPointer  gptr,
const Parameters parameters,
NumericVector< Number > &  new_vector,
int  is_adjoint = -1 
) const
inherited

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

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

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

Definition at line 1004 of file system_projection.C.

1011 {
1012  WrappedFunction<Number> f(*this, fptr, &parameters);
1013  WrappedFunction<Gradient> g(*this, gptr, &parameters);
1014  this->boundary_project_vector(b, variables, new_vector, &f, &g,
1015  is_adjoint);
1016 }
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
Real libMesh::System::calculate_norm ( const NumericVector< Number > &  v,
unsigned int  var,
FEMNormType  norm_type,
std::set< unsigned int > *  skip_dimensions = libmesh_nullptr 
) const
inherited
Returns
A norm of variable var in the vector v, in the specified norm (e.g. L2, L_INF, H1)

Definition at line 1364 of file system.C.

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

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

1368 {
1369  //short circuit to save time
1370  if (norm_type == DISCRETE_L1 ||
1371  norm_type == DISCRETE_L2 ||
1372  norm_type == DISCRETE_L_INF)
1373  return discrete_var_norm(v,var,norm_type);
1374 
1375  // Not a discrete norm
1376  std::vector<FEMNormType> norms(this->n_vars(), L2);
1377  std::vector<Real> weights(this->n_vars(), 0.0);
1378  norms[var] = norm_type;
1379  weights[var] = 1.0;
1380  Real val = this->calculate_norm(v, SystemNorm(norms, weights), skip_dimensions);
1381  return val;
1382 }
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:1364
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
unsigned int n_vars() const
Definition: system.h:2086
Real discrete_var_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type) const
Definition: system.C:1345
Real libMesh::System::calculate_norm ( const NumericVector< Number > &  v,
const SystemNorm norm,
std::set< unsigned int > *  skip_dimensions = libmesh_nullptr 
) const
inherited
Returns
A norm of the vector v, using component_norm and component_scale to choose and weight the norms of each variable.

Definition at line 1386 of file system.C.

References libMesh::System::_dof_map, libMesh::System::_mesh, std::abs(), libMesh::TypeVector< T >::add_scaled(), libMesh::TypeTensor< T >::add_scaled(), libMesh::FEGenericBase< OutputType >::build(), libMesh::NumericVector< T >::build(), libMesh::ParallelObject::comm(), libMesh::FEType::default_quadrature_rule(), libMesh::DISCRETE_L1, libMesh::DISCRETE_L2, libMesh::DISCRETE_L_INF, libMesh::System::discrete_var_norm(), libMesh::DofMap::dof_indices(), libMesh::MeshBase::elem_dimensions(), libMesh::FEGenericBase< OutputType >::get_d2phi(), libMesh::System::get_dof_map(), libMesh::FEGenericBase< OutputType >::get_dphi(), libMesh::FEAbstract::get_JxW(), libMesh::System::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_nullptr, libMesh::NumericVector< T >::linfty_norm(), libMesh::NumericVector< T >::localize(), std::max(), libMesh::Parallel::Communicator::max(), libMesh::QBase::n_points(), libMesh::System::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().

1389 {
1390  // This function must be run on all processors at once
1391  parallel_object_only();
1392 
1393  LOG_SCOPE ("calculate_norm()", "System");
1394 
1395  // Zero the norm before summation
1396  Real v_norm = 0.;
1397 
1398  if (norm.is_discrete())
1399  {
1400  //Check to see if all weights are 1.0 and all types are equal
1401  FEMNormType norm_type0 = norm.type(0);
1402  unsigned int check_var = 0;
1403  for (; check_var != this->n_vars(); ++check_var)
1404  if ((norm.weight(check_var) != 1.0) || (norm.type(check_var) != norm_type0))
1405  break;
1406 
1407  //All weights were 1.0 so just do the full vector discrete norm
1408  if (check_var == this->n_vars())
1409  {
1410  if (norm_type0 == DISCRETE_L1)
1411  return v.l1_norm();
1412  if (norm_type0 == DISCRETE_L2)
1413  return v.l2_norm();
1414  if (norm_type0 == DISCRETE_L_INF)
1415  return v.linfty_norm();
1416  else
1417  libmesh_error_msg("Invalid norm_type0 = " << norm_type0);
1418  }
1419 
1420  for (unsigned int var=0; var != this->n_vars(); ++var)
1421  {
1422  // Skip any variables we don't need to integrate
1423  if (norm.weight(var) == 0.0)
1424  continue;
1425 
1426  v_norm += norm.weight(var) * discrete_var_norm(v, var, norm.type(var));
1427  }
1428 
1429  return v_norm;
1430  }
1431 
1432  // Localize the potentially parallel vector
1433  std::unique_ptr<NumericVector<Number>> local_v = NumericVector<Number>::build(this->comm());
1434  local_v->init(v.size(), true, SERIAL);
1435  v.localize (*local_v, _dof_map->get_send_list());
1436 
1437  // I'm not sure how best to mix Hilbert norms on some variables (for
1438  // which we'll want to square then sum then square root) with norms
1439  // like L_inf (for which we'll just want to take an absolute value
1440  // and then sum).
1441  bool using_hilbert_norm = true,
1442  using_nonhilbert_norm = true;
1443 
1444  // Loop over all variables
1445  for (unsigned int var=0; var != this->n_vars(); ++var)
1446  {
1447  // Skip any variables we don't need to integrate
1448  Real norm_weight_sq = norm.weight_sq(var);
1449  if (norm_weight_sq == 0.0)
1450  continue;
1451  Real norm_weight = norm.weight(var);
1452 
1453  // Check for unimplemented norms (rather than just returning 0).
1454  FEMNormType norm_type = norm.type(var);
1455  if ((norm_type==H1) ||
1456  (norm_type==H2) ||
1457  (norm_type==L2) ||
1458  (norm_type==H1_SEMINORM) ||
1459  (norm_type==H2_SEMINORM))
1460  {
1461  if (!using_hilbert_norm)
1462  libmesh_not_implemented();
1463  using_nonhilbert_norm = false;
1464  }
1465  else if ((norm_type==L1) ||
1466  (norm_type==L_INF) ||
1467  (norm_type==W1_INF_SEMINORM) ||
1468  (norm_type==W2_INF_SEMINORM))
1469  {
1470  if (!using_nonhilbert_norm)
1471  libmesh_not_implemented();
1472  using_hilbert_norm = false;
1473  }
1474  else
1475  libmesh_not_implemented();
1476 
1477  const FEType & fe_type = this->get_dof_map().variable_type(var);
1478 
1479  // Allow space for dims 0-3, even if we don't use them all
1480  std::vector<std::unique_ptr<FEBase>> fe_ptrs(4);
1481  std::vector<std::unique_ptr<QBase>> q_rules(4);
1482 
1483  const std::set<unsigned char> & elem_dims = _mesh.elem_dimensions();
1484 
1485  // Prepare finite elements for each dimension present in the mesh
1486  for (std::set<unsigned char>::const_iterator d_it = elem_dims.begin();
1487  d_it != elem_dims.end(); ++d_it)
1488  {
1489  if (skip_dimensions && skip_dimensions->find(*d_it) != skip_dimensions->end())
1490  continue;
1491 
1492  // Construct quadrature and finite element objects
1493  q_rules[*d_it] = fe_type.default_quadrature_rule (*d_it);
1494  fe_ptrs[*d_it] = FEBase::build(*d_it, fe_type);
1495 
1496  // Attach quadrature rule to FE object
1497  fe_ptrs[*d_it]->attach_quadrature_rule (q_rules[*d_it].get());
1498  }
1499 
1500  std::vector<dof_id_type> dof_indices;
1501 
1502  // Begin the loop over the elements
1503  for (const auto & elem : this->get_mesh().active_local_element_ptr_range())
1504  {
1505  const unsigned int dim = elem->dim();
1506 
1507 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1508 
1509  // One way for implementing this would be to exchange the fe with the FEInterface- class.
1510  // However, it needs to be discussed whether integral-norms make sense for infinite elements.
1511  // or in which sense they could make sense.
1512  if (elem->infinite() )
1513  libmesh_not_implemented();
1514 
1515 #endif
1516 
1517  if (skip_dimensions && skip_dimensions->find(dim) != skip_dimensions->end())
1518  continue;
1519 
1520  FEBase * fe = fe_ptrs[dim].get();
1521  QBase * qrule = q_rules[dim].get();
1522  libmesh_assert(fe);
1523  libmesh_assert(qrule);
1524 
1525  const std::vector<Real> & JxW = fe->get_JxW();
1526  const std::vector<std::vector<Real>> * phi = libmesh_nullptr;
1527  if (norm_type == H1 ||
1528  norm_type == H2 ||
1529  norm_type == L2 ||
1530  norm_type == L1 ||
1531  norm_type == L_INF)
1532  phi = &(fe->get_phi());
1533 
1534  const std::vector<std::vector<RealGradient>> * dphi = libmesh_nullptr;
1535  if (norm_type == H1 ||
1536  norm_type == H2 ||
1537  norm_type == H1_SEMINORM ||
1538  norm_type == W1_INF_SEMINORM)
1539  dphi = &(fe->get_dphi());
1540 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1541  const std::vector<std::vector<RealTensor>> * d2phi = libmesh_nullptr;
1542  if (norm_type == H2 ||
1543  norm_type == H2_SEMINORM ||
1544  norm_type == W2_INF_SEMINORM)
1545  d2phi = &(fe->get_d2phi());
1546 #endif
1547 
1548  fe->reinit (elem);
1549 
1550  this->get_dof_map().dof_indices (elem, dof_indices, var);
1551 
1552  const unsigned int n_qp = qrule->n_points();
1553 
1554  const unsigned int n_sf = cast_int<unsigned int>
1555  (dof_indices.size());
1556 
1557  // Begin the loop over the Quadrature points.
1558  for (unsigned int qp=0; qp<n_qp; qp++)
1559  {
1560  if (norm_type == L1)
1561  {
1562  Number u_h = 0.;
1563  for (unsigned int i=0; i != n_sf; ++i)
1564  u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
1565  v_norm += norm_weight *
1566  JxW[qp] * std::abs(u_h);
1567  }
1568 
1569  if (norm_type == L_INF)
1570  {
1571  Number u_h = 0.;
1572  for (unsigned int i=0; i != n_sf; ++i)
1573  u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
1574  v_norm = std::max(v_norm, norm_weight * std::abs(u_h));
1575  }
1576 
1577  if (norm_type == H1 ||
1578  norm_type == H2 ||
1579  norm_type == L2)
1580  {
1581  Number u_h = 0.;
1582  for (unsigned int i=0; i != n_sf; ++i)
1583  u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
1584  v_norm += norm_weight_sq *
1585  JxW[qp] * TensorTools::norm_sq(u_h);
1586  }
1587 
1588  if (norm_type == H1 ||
1589  norm_type == H2 ||
1590  norm_type == H1_SEMINORM)
1591  {
1592  Gradient grad_u_h;
1593  for (unsigned int i=0; i != n_sf; ++i)
1594  grad_u_h.add_scaled((*dphi)[i][qp], (*local_v)(dof_indices[i]));
1595  v_norm += norm_weight_sq *
1596  JxW[qp] * grad_u_h.norm_sq();
1597  }
1598 
1599  if (norm_type == W1_INF_SEMINORM)
1600  {
1601  Gradient grad_u_h;
1602  for (unsigned int i=0; i != n_sf; ++i)
1603  grad_u_h.add_scaled((*dphi)[i][qp], (*local_v)(dof_indices[i]));
1604  v_norm = std::max(v_norm, norm_weight * grad_u_h.norm());
1605  }
1606 
1607 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1608  if (norm_type == H2 ||
1609  norm_type == H2_SEMINORM)
1610  {
1611  Tensor hess_u_h;
1612  for (unsigned int i=0; i != n_sf; ++i)
1613  hess_u_h.add_scaled((*d2phi)[i][qp], (*local_v)(dof_indices[i]));
1614  v_norm += norm_weight_sq *
1615  JxW[qp] * hess_u_h.norm_sq();
1616  }
1617 
1618  if (norm_type == W2_INF_SEMINORM)
1619  {
1620  Tensor hess_u_h;
1621  for (unsigned int i=0; i != n_sf; ++i)
1622  hess_u_h.add_scaled((*d2phi)[i][qp], (*local_v)(dof_indices[i]));
1623  v_norm = std::max(v_norm, norm_weight * hess_u_h.norm());
1624  }
1625 #endif
1626  }
1627  }
1628  }
1629 
1630  if (using_hilbert_norm)
1631  {
1632  this->comm().sum(v_norm);
1633  v_norm = std::sqrt(v_norm);
1634  }
1635  else
1636  {
1637  this->comm().max(v_norm);
1638  }
1639 
1640  return v_norm;
1641 }
double abs(double a)
virtual numeric_index_type size() const =0
const FEType & variable_type(const unsigned int c) const
Definition: dof_map.h:1719
void add_scaled(const TypeTensor< T2 > &, const T)
Definition: type_tensor.h:777
void add_scaled(const TypeVector< T2 > &, const T)
Definition: type_vector.h:624
virtual Real l2_norm() const =0
const class libmesh_nullptr_t libmesh_nullptr
std::unique_ptr< DofMap > _dof_map
Definition: system.h:1865
virtual Real l1_norm() const =0
long double max(long double a, double b)
const MeshBase & get_mesh() const
Definition: system.h:2014
const DofMap & get_dof_map() const
Definition: system.h:2030
NumberVectorValue Gradient
static std::unique_ptr< FEGenericBase > build(const unsigned int dim, const FEType &type)
const std::set< unsigned char > & elem_dimensions() const
Definition: mesh_base.h:207
FEGenericBase< Real > FEBase
virtual Real linfty_norm() const =0
static std::unique_ptr< NumericVector< T > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
NumberTensorValue Tensor
const Parallel::Communicator & comm() const
ParallelType type() const
unsigned int n_vars() const
Definition: system.h:2086
MeshBase & _mesh
Definition: system.h:1877
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:1345
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Definition: dof_map.C:1924
void libMesh::ExplicitSystem::clear ( )
virtual
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_jacobian(), libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_petsc_snes_fd_residual(), libMesh::__libmesh_petsc_snes_jacobian(), libMesh::__libmesh_petsc_snes_mffd_residual(), libMesh::__libmesh_petsc_snes_postcheck(), libMesh::__libmesh_petsc_snes_residual(), libMesh::__libmesh_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(), libMesh::System::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(), libMesh::System::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::ExodusII_IO::copy_elemental_solution(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::MeshTools::create_bounding_box(), libMesh::MeshTools::create_nodal_bounding_box(), libMesh::MeshRefinement::create_parent_error_vector(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::MeshTools::create_subdomain_bounding_box(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), DMlibMeshFunction(), DMlibMeshJacobian(), DMlibMeshSetSystem_libMesh(), DMVariableBounds_libMesh(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::EpetraVector< T >::EpetraVector(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::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::TopologyMap::init(), libMesh::TimeSolver::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::libmesh_petsc_snes_residual_helper(), libMesh::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::limit_overrefined_boundary(), libMesh::MeshRefinement::limit_underrefined_boundary(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshCommunication::make_elems_parallel_consistent(), libMesh::MeshRefinement::make_flags_parallel_consistent(), libMesh::MeshCommunication::make_new_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_new_nodes_parallel_consistent(), libMesh::MeshCommunication::make_node_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_unique_ids_parallel_consistent(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::MeshCommunication::make_p_levels_parallel_consistent(), libMesh::MeshRefinement::make_refinement_compatible(), libMesh::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::LinearPartitioner::partition_range(), libMesh::MetisPartitioner::partition_range(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::petsc_auto_fieldsplit(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::SparseMatrix< T >::print(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), 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::MeshRefinement::refine_and_coarsen_elements(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::CheckpointIO::select_split_config(), libMesh::MeshCommunication::send_coarse_ghosts(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Partitioner::set_parent_processor_ids(), libMesh::PetscDiffSolver::setup_petsc_data(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::Parallel::Sort< KeyType, IdxType >::sort(), libMesh::split_mesh(), 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::EigenSparseVector< T >::zero_clone(), libMesh::LaspackVector< 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
virtualinherited
Returns
true when the other system contains identical data, up to the given threshold. Outputs some diagnostic info when verbose is set.

Definition at line 512 of file system.C.

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

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

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

Definition at line 192 of file system.C.

References libMesh::System::_dof_map, and libMesh::System::current_local_solution.

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

193 {
194  // Check the sizes
195  libmesh_assert_less (global_dof_number, _dof_map->n_dofs());
196  libmesh_assert_less (global_dof_number, current_local_solution->size());
197 
198  return (*current_local_solution)(global_dof_number);
199 }
std::unique_ptr< DofMap > _dof_map
Definition: system.h:1865
std::unique_ptr< NumericVector< Number > > current_local_solution
Definition: system.h:1521
void libMesh::System::deactivate ( )
inlineinherited

Deactivates the system. Only active systems are solved.

Definition at line 2062 of file system.h.

References libMesh::System::_active.

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

2063 {
2064  _active = false;
2065 }
void libMesh::System::disable_cache ( )
inlinevirtualinherited

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

References libMesh::System::assemble_before_solve.

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

2256 { assemble_before_solve = true; }
bool assemble_before_solve
Definition: system.h:1463
void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited
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 
)
inlinevirtualinherited

Solves for parameter sensitivities using the forward method.

This method is only implemented in some derived classes.

Reimplemented in libMesh::ImplicitSystem.

Definition at line 2300 of file system.h.

Referenced by libMesh::System::qoi_parameter_sensitivity(), and libMesh::System::set_adjoint_already_solved().

2303 {
2304  libmesh_not_implemented();
2305 }
NumericVector< Number > & libMesh::System::get_adjoint_rhs ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's adjoint rhs vectors, by default the one corresponding to the first qoi. This what the user's QoI derivative code should assemble when setting up an adjoint problem

Definition at line 1032 of file system.C.

References libMesh::System::get_vector().

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

1033 {
1034  std::ostringstream adjoint_rhs_name;
1035  adjoint_rhs_name << "adjoint_rhs" << i;
1036 
1037  return this->get_vector(adjoint_rhs_name.str());
1038 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:775
const NumericVector< Number > & libMesh::System::get_adjoint_rhs ( unsigned int  i = 0) const
inherited
Returns
A reference to one of the system's adjoint rhs vectors, by default the one corresponding to the first qoi.

Definition at line 1042 of file system.C.

References libMesh::System::get_vector().

1043 {
1044  std::ostringstream adjoint_rhs_name;
1045  adjoint_rhs_name << "adjoint_rhs" << i;
1046 
1047  return this->get_vector(adjoint_rhs_name.str());
1048 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:775
NumericVector< Number > & libMesh::System::get_adjoint_solution ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's adjoint solution vectors, by default the one corresponding to the first qoi.

Definition at line 970 of file system.C.

References libMesh::System::get_vector().

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

971 {
972  std::ostringstream adjoint_name;
973  adjoint_name << "adjoint_solution" << i;
974 
975  return this->get_vector(adjoint_name.str());
976 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:775
const NumericVector< Number > & libMesh::System::get_adjoint_solution ( unsigned int  i = 0) const
inherited
Returns
A reference to one of the system's adjoint solution vectors, by default the one corresponding to the first qoi.

Definition at line 980 of file system.C.

References libMesh::System::get_vector().

981 {
982  std::ostringstream adjoint_name;
983  adjoint_name << "adjoint_solution" << i;
984 
985  return this->get_vector(adjoint_name.str());
986 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:775
void libMesh::System::get_all_variable_numbers ( std::vector< unsigned int > &  all_variable_numbers) const
inherited

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

Definition at line 1259 of file system.C.

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

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

1260 {
1261  all_variable_numbers.resize(n_vars());
1262 
1263  // Make sure the variable exists
1264  std::map<std::string, unsigned short int>::const_iterator
1265  it = _variable_numbers.begin();
1266  std::map<std::string, unsigned short int>::const_iterator
1267  it_end = _variable_numbers.end();
1268 
1269  unsigned int count = 0;
1270  for ( ; it != it_end; ++it)
1271  {
1272  all_variable_numbers[count] = it->second;
1273  count++;
1274  }
1275 }
std::map< std::string, unsigned short int > _variable_numbers
Definition: system.h:1903
unsigned int n_vars() const
Definition: system.h:2086
const DofMap & libMesh::System::get_dof_map ( ) const
inlineinherited
Returns
A constant reference to this system's _dof_map.

Definition at line 2030 of file system.h.

References libMesh::System::_dof_map.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_petsc_snes_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(), libMesh::System::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(), libMesh::System::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(), libMesh::System::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::petsc_auto_fieldsplit(), libMesh::ErrorVector::plot_error(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::FEMContext::pre_fe_reinit(), libMesh::System::re_update(), libMesh::SecondOrderUnsteadySolver::reinit(), libMesh::UnsteadySolver::reinit(), libMesh::ImplicitSystem::reinit(), libMesh::EigenSystem::reinit(), libMesh::System::reinit_constraints(), libMesh::EquationSystems::reinit_solutions(), libMesh::UnsteadySolver::retrieve_timestep(), libMesh::HPCoarsenTest::select_refinement(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::NewtonSolver::solve(), libMesh::PetscDiffSolver::solve(), libMesh::PetscNonlinearSolver< T >::solve(), libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve(), libMesh::ImplicitSystem::weighted_sensitivity_solve(), libMesh::EnsightIO::write_scalar_ascii(), and libMesh::EnsightIO::write_vector_ascii().

2031 {
2032  return *_dof_map;
2033 }
std::unique_ptr< DofMap > _dof_map
Definition: system.h:1865
DofMap & libMesh::System::get_dof_map ( )
inlineinherited
Returns
A writable reference to this system's _dof_map.

Definition at line 2038 of file system.h.

References libMesh::System::_dof_map.

2039 {
2040  return *_dof_map;
2041 }
std::unique_ptr< DofMap > _dof_map
Definition: system.h:1865
EquationSystems& libMesh::System::get_equation_systems ( )
inlineinherited
Returns
A reference to this system's parent EquationSystems object.

Definition at line 703 of file system.h.

References libMesh::System::_equation_systems, libMesh::System::activate(), libMesh::System::active(), libMesh::System::deactivate(), and libMesh::System::set_basic_system_only().

703 { return _equation_systems; }
EquationSystems & _equation_systems
Definition: system.h:1871
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
inherited
Returns
A string containing information about the system.

Definition at line 1645 of file system.C.

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

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

1646 {
1647  std::ostringstream oss;
1648 
1649 
1650  const std::string & sys_name = this->name();
1651 
1652  oss << " System #" << this->number() << ", \"" << sys_name << "\"\n"
1653  << " Type \"" << this->system_type() << "\"\n"
1654  << " Variables=";
1655 
1656  for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
1657  {
1658  const VariableGroup & vg_description (this->variable_group(vg));
1659 
1660  if (vg_description.n_variables() > 1) oss << "{ ";
1661  for (unsigned int vn=0; vn<vg_description.n_variables(); vn++)
1662  oss << "\"" << vg_description.name(vn) << "\" ";
1663  if (vg_description.n_variables() > 1) oss << "} ";
1664  }
1665 
1666  oss << '\n';
1667 
1668  oss << " Finite Element Types=";
1669 #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
1670  for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
1671  oss << "\""
1672  << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().family)
1673  << "\" ";
1674 #else
1675  for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
1676  {
1677  oss << "\""
1678  << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().family)
1679  << "\", \""
1680  << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().radial_family)
1681  << "\" ";
1682  }
1683 
1684  oss << '\n' << " Infinite Element Mapping=";
1685  for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
1686  oss << "\""
1687  << Utility::enum_to_string<InfMapType>(this->get_dof_map().variable_group(vg).type().inf_map)
1688  << "\" ";
1689 #endif
1690 
1691  oss << '\n';
1692 
1693  oss << " Approximation Orders=";
1694  for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
1695  {
1696 #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
1697  oss << "\""
1698  << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().order)
1699  << "\" ";
1700 #else
1701  oss << "\""
1702  << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().order)
1703  << "\", \""
1704  << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().radial_order)
1705  << "\" ";
1706 #endif
1707  }
1708 
1709  oss << '\n';
1710 
1711  oss << " n_dofs()=" << this->n_dofs() << '\n';
1712  oss << " n_local_dofs()=" << this->n_local_dofs() << '\n';
1713 #ifdef LIBMESH_ENABLE_CONSTRAINTS
1714  oss << " n_constrained_dofs()=" << this->n_constrained_dofs() << '\n';
1715  oss << " n_local_constrained_dofs()=" << this->n_local_constrained_dofs() << '\n';
1716 #endif
1717 
1718  oss << " " << "n_vectors()=" << this->n_vectors() << '\n';
1719  oss << " " << "n_matrices()=" << this->n_matrices() << '\n';
1720  // oss << " " << "n_additional_matrices()=" << this->n_additional_matrices() << '\n';
1721 
1722  oss << this->get_dof_map().get_info();
1723 
1724  return oss.str();
1725 }
FEFamily family
Definition: fe_type.h:204
dof_id_type n_constrained_dofs() const
Definition: system.C:155
const FEType & type() const
Definition: variable.h:119
std::string get_info() const
Definition: dof_map.C:2642
OrderWrapper radial_order
Definition: fe_type.h:237
OrderWrapper order
Definition: fe_type.h:198
const VariableGroup & variable_group(unsigned int vg) const
Definition: system.h:2124
const VariableGroup & variable_group(const unsigned int c) const
Definition: dof_map.h:1679
const std::string & name() const
Definition: system.h:1998
unsigned int n_variable_groups() const
Definition: system.h:2094
const DofMap & get_dof_map() const
Definition: system.h:2030
InfMapType inf_map
Definition: fe_type.h:258
virtual unsigned int n_matrices() const
Definition: system.h:2220
FEFamily radial_family
Definition: fe_type.h:250
dof_id_type n_local_dofs() const
Definition: system.C:185
virtual std::string system_type() const
Definition: system.h:473
dof_id_type n_local_constrained_dofs() const
Definition: system.C:170
unsigned int number() const
Definition: system.h:2006
dof_id_type n_dofs() const
Definition: system.C:148
unsigned int n_vectors() const
Definition: system.h:2214
const MeshBase & libMesh::System::get_mesh ( ) const
inlineinherited
Returns
A constant reference to this systems's _mesh.

Definition at line 2014 of file system.h.

References libMesh::System::_mesh.

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::HPCoarsenTest::add_projection(), libMesh::FEMSystem::assemble_qoi(), libMesh::FEMSystem::assemble_qoi_derivative(), libMesh::FEMSystem::assembly(), libMesh::System::calculate_norm(), DMCreateDomainDecomposition_libMesh(), DMCreateFieldDecomposition_libMesh(), DMlibMeshSetSystem_libMesh(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::SystemSubsetBySubdomain::init(), libMesh::System::init_data(), libMesh::EigenSystem::init_matrices(), libMesh::ImplicitSystem::init_matrices(), libMesh::System::local_dof_indices(), libMesh::DofMap::max_constraint_error(), libMesh::FEMSystem::mesh_position_get(), libMesh::FEMSystem::mesh_position_set(), libMesh::petsc_auto_fieldsplit(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::FEMSystem::postprocess(), libMesh::ImplicitSystem::reinit(), libMesh::EigenSystem::reinit(), libMesh::HPSingularity::select_refinement(), libMesh::HPCoarsenTest::select_refinement(), and libMesh::System::zero_variable().

2015 {
2016  return _mesh;
2017 }
MeshBase & _mesh
Definition: system.h:1877
MeshBase & libMesh::System::get_mesh ( )
inlineinherited
Returns
A reference to this systems's _mesh.

Definition at line 2022 of file system.h.

References libMesh::System::_mesh.

2023 {
2024  return _mesh;
2025 }
MeshBase & _mesh
Definition: system.h:1877
NumericVector< Number > & libMesh::System::get_sensitivity_rhs ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's sensitivity rhs vectors, by default the one corresponding to the first parameter. By default these vectors are built by the library, using finite differences, when assemble_residual_derivatives() is called.

When assembled, this vector should hold -(partial R / partial p_i)

Definition at line 1062 of file system.C.

References libMesh::System::get_vector().

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

1063 {
1064  std::ostringstream sensitivity_rhs_name;
1065  sensitivity_rhs_name << "sensitivity_rhs" << i;
1066 
1067  return this->get_vector(sensitivity_rhs_name.str());
1068 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:775
const NumericVector< Number > & libMesh::System::get_sensitivity_rhs ( unsigned int  i = 0) const
inherited
Returns
A reference to one of the system's sensitivity rhs vectors, by default the one corresponding to the first parameter.

Definition at line 1072 of file system.C.

References libMesh::System::get_vector().

1073 {
1074  std::ostringstream sensitivity_rhs_name;
1075  sensitivity_rhs_name << "sensitivity_rhs" << i;
1076 
1077  return this->get_vector(sensitivity_rhs_name.str());
1078 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:775
NumericVector< Number > & libMesh::System::get_sensitivity_solution ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's solution sensitivity vectors, by default the one corresponding to the first parameter.

Definition at line 917 of file system.C.

References libMesh::System::get_vector().

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

918 {
919  std::ostringstream sensitivity_name;
920  sensitivity_name << "sensitivity_solution" << i;
921 
922  return this->get_vector(sensitivity_name.str());
923 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:775
const NumericVector< Number > & libMesh::System::get_sensitivity_solution ( unsigned int  i = 0) const
inherited
Returns
A reference to one of the system's solution sensitivity vectors, by default the one corresponding to the first parameter.

Definition at line 927 of file system.C.

References libMesh::System::get_vector().

928 {
929  std::ostringstream sensitivity_name;
930  sensitivity_name << "sensitivity_solution" << i;
931 
932  return this->get_vector(sensitivity_name.str());
933 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:775
const NumericVector< Number > & libMesh::System::get_vector ( const std::string &  vec_name) const
inherited
Returns
A const reference to this system's additional vector named vec_name. Access is only granted when the vector is already properly initialized.

Definition at line 775 of file system.C.

References libMesh::System::_vectors.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::NewmarkSolver::advance_timestep(), libMesh::AdaptiveTimeSolver::advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), libMesh::System::compare(), libMesh::NewmarkSolver::compute_initial_accel(), libMesh::UnsteadySolver::du(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::System::get_adjoint_rhs(), libMesh::System::get_adjoint_solution(), libMesh::System::get_sensitivity_rhs(), libMesh::System::get_sensitivity_solution(), libMesh::System::get_weighted_sensitivity_adjoint_solution(), libMesh::System::get_weighted_sensitivity_solution(), libMesh::NewmarkSystem::initial_conditions(), libMesh::NewmarkSolver::project_initial_accel(), libMesh::SecondOrderUnsteadySolver::project_initial_rate(), libMesh::System::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().

776 {
777  // Make sure the vector exists
778  const_vectors_iterator pos = _vectors.find(vec_name);
779 
780  if (pos == _vectors.end())
781  libmesh_error_msg("ERROR: vector " << vec_name << " does not exist in this system!");
782 
783  return *(pos->second);
784 }
std::map< std::string, NumericVector< Number > * >::const_iterator const_vectors_iterator
Definition: system.h:735
std::map< std::string, NumericVector< Number > * > _vectors
Definition: system.h:1916
NumericVector< Number > & libMesh::System::get_vector ( const std::string &  vec_name)
inherited
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 788 of file system.C.

References libMesh::System::_vectors.

789 {
790  // Make sure the vector exists
791  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 > * >::iterator vectors_iterator
Definition: system.h:734
std::map< std::string, NumericVector< Number > * > _vectors
Definition: system.h:1916
const NumericVector< Number > & libMesh::System::get_vector ( const unsigned int  vec_num) const
inherited
Returns
A const reference to this system's additional vector number vec_num (where the vectors are counted starting with 0).

Definition at line 801 of file system.C.

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

802 {
805  unsigned int num = 0;
806  while ((num<vec_num) && (v!=v_end))
807  {
808  num++;
809  ++v;
810  }
811  libmesh_assert (v != v_end);
812  return *(v->second);
813 }
vectors_iterator vectors_end()
Definition: system.h:2238
std::map< std::string, NumericVector< Number > * >::const_iterator const_vectors_iterator
Definition: system.h:735
vectors_iterator vectors_begin()
Definition: system.h:2226
NumericVector< Number > & libMesh::System::get_vector ( const unsigned int  vec_num)
inherited
Returns
A writable reference to this system's additional vector number vec_num (where the vectors are counted starting with 0).

Definition at line 817 of file system.C.

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

818 {
820  vectors_iterator v_end = vectors_end();
821  unsigned int num = 0;
822  while ((num<vec_num) && (v!=v_end))
823  {
824  num++;
825  ++v;
826  }
827  libmesh_assert (v != v_end);
828  return *(v->second);
829 }
vectors_iterator vectors_end()
Definition: system.h:2238
vectors_iterator vectors_begin()
Definition: system.h:2226
std::map< std::string, NumericVector< Number > * >::iterator vectors_iterator
Definition: system.h:734
NumericVector< Number > & libMesh::System::get_weighted_sensitivity_adjoint_solution ( unsigned int  i = 0)
inherited
Returns
A reference to one of the system's weighted sensitivity adjoint solution vectors, by default the one corresponding to the first qoi.

Definition at line 1002 of file system.C.

References libMesh::System::get_vector().

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

1003 {
1004  std::ostringstream adjoint_name;
1005  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
1006 
1007  return this->get_vector(adjoint_name.str());
1008 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:775
const NumericVector< Number > & libMesh::System::get_weighted_sensitivity_adjoint_solution ( unsigned int  i = 0) const
inherited
Returns
A reference to one of the system's weighted sensitivity adjoint solution vectors, by default the one corresponding to the first qoi.

Definition at line 1012 of file system.C.

References libMesh::System::get_vector().

1013 {
1014  std::ostringstream adjoint_name;
1015  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
1016 
1017  return this->get_vector(adjoint_name.str());
1018 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:775
NumericVector< Number > & libMesh::System::get_weighted_sensitivity_solution ( )
inherited
Returns
A reference to the solution of the last weighted sensitivity solve

Definition at line 944 of file system.C.

References libMesh::System::get_vector().

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

945 {
946  return this->get_vector("weighted_sensitivity_solution");
947 }
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:775
const NumericVector< Number > & libMesh::System::get_weighted_sensitivity_solution ( ) const
inherited
Returns
A reference to the solution of the last weighted sensitivity solve

Definition at line 951 of file system.C.

References libMesh::System::get_vector().

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

Definition at line 1237 of file system.C.

References libMesh::System::_variable_numbers.

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

1238 {
1239  return _variable_numbers.count(var);
1240 }
std::map< std::string, unsigned short int > _variable_numbers
Definition: system.h:1903
bool libMesh::System::have_vector ( const std::string &  vec_name) const
inlineinherited
Returns
true if this System has a vector associated with the given name, false otherwise.

Definition at line 2206 of file system.h.

References libMesh::System::_vectors.

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

2207 {
2208  return (_vectors.count(vec_name));
2209 }
std::map< std::string, NumericVector< Number > * > _vectors
Definition: system.h:1916
bool libMesh::System::identify_variable_groups ( ) const
inlineinherited
Returns
true when VariableGroup structures should be automatically identified, false otherwise.

Definition at line 2182 of file system.h.

References libMesh::System::_identify_variable_groups.

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

2183 {
2185 }
bool _identify_variable_groups
Definition: system.h:1958
void libMesh::System::identify_variable_groups ( const bool  ivg)
inlineinherited

Toggle automatic VariableGroup identification.

Definition at line 2190 of file system.h.

References libMesh::System::_identify_variable_groups.

2191 {
2193 }
bool _identify_variable_groups
Definition: system.h:1958
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 ( )
inherited

Initializes degrees of freedom on the current mesh. Sets the

Definition at line 235 of file system.C.

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

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

236 {
237  // Calling init() twice on the same system currently works evil
238  // magic, whether done directly or via EquationSystems::read()
239  libmesh_assert(!this->is_initialized());
240 
241  // First initialize any required data:
242  // either only the basic System data
243  if (_basic_system_only)
245  // or all the derived class' data too
246  else
247  this->init_data();
248 
249  // If no variables have been added to this system
250  // don't do anything
251  if (!this->n_vars())
252  return;
253 
254  // Then call the user-provided initialization function
255  this->user_initialization();
256 }
bool _basic_system_only
Definition: system.h:1946
virtual void init_data()
Definition: system.C:260
virtual void user_initialization()
Definition: system.C:1905
bool is_initialized()
Definition: system.h:2070
unsigned int n_vars() const
Definition: system.h:2086
void libMesh::System::init_data ( )
protectedvirtualinherited

Initializes the data for the system.

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

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

Definition at line 260 of file system.C.

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

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

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

Definition at line 2070 of file system.h.

References libMesh::System::_is_initialized.

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

2071 {
2072  return _is_initialized;
2073 }
bool _is_initialized
Definition: system.h:1952
void libMesh::System::local_dof_indices ( const unsigned int  var,
std::set< dof_id_type > &  var_indices 
) const
inherited

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

Definition at line 1278 of file system.C.

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

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

1280 {
1281  // Make sure the set is clear
1282  var_indices.clear();
1283 
1284  std::vector<dof_id_type> dof_indices;
1285 
1286  const dof_id_type
1287  first_local = this->get_dof_map().first_dof(),
1288  end_local = this->get_dof_map().end_dof();
1289 
1290  // Begin the loop over the elements
1291  for (const auto & elem : this->get_mesh().active_local_element_ptr_range())
1292  {
1293  this->get_dof_map().dof_indices (elem, dof_indices, var);
1294 
1295  for (std::size_t i=0; i<dof_indices.size(); i++)
1296  {
1297  dof_id_type dof = dof_indices[i];
1298 
1299  //If the dof is owned by the local processor
1300  if (first_local <= dof && dof < end_local)
1301  var_indices.insert(dof_indices[i]);
1302  }
1303  }
1304 }
dof_id_type first_dof(const processor_id_type proc) const
Definition: dof_map.h:544
dof_id_type end_dof(const processor_id_type proc) const
Definition: dof_map.h:586
const MeshBase & get_mesh() const
Definition: system.h:2014
const DofMap & get_dof_map() const
Definition: system.h:2030
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:1924
dof_id_type libMesh::System::n_active_dofs ( ) const
inlineinherited
Returns
The number of active degrees of freedom for this System.

Definition at line 2198 of file system.h.

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

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

2199 {
2200  return this->n_dofs() - this->n_constrained_dofs();
2201 }
dof_id_type n_constrained_dofs() const
Definition: system.C:155
dof_id_type n_dofs() const
Definition: system.C:148
unsigned int libMesh::System::n_components ( ) const
inlineinherited
Returns
The total number of scalar components in the system's variables. This will equal n_vars() in the case of all scalar-valued variables.

Definition at line 2102 of file system.h.

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

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

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

Definition at line 155 of file system.C.

References libMesh::System::_dof_map.

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

156 {
157 #ifdef LIBMESH_ENABLE_CONSTRAINTS
158 
159  return _dof_map->n_constrained_dofs();
160 
161 #else
162 
163  return 0;
164 
165 #endif
166 }
std::unique_ptr< DofMap > _dof_map
Definition: system.h:1865
dof_id_type libMesh::System::n_local_constrained_dofs ( ) const
inherited
Returns
The number of constrained degrees of freedom on this processor.

Definition at line 170 of file system.C.

References libMesh::System::_dof_map.

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

171 {
172 #ifdef LIBMESH_ENABLE_CONSTRAINTS
173 
174  return _dof_map->n_local_constrained_dofs();
175 
176 #else
177 
178  return 0;
179 
180 #endif
181 }
std::unique_ptr< DofMap > _dof_map
Definition: system.h:1865
unsigned int libMesh::System::n_matrices ( ) const
inlinevirtualinherited
Returns
The number of matrices handled by this system.

This will return 0 by default but can be overridden.

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

Definition at line 2220 of file system.h.

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

2221 {
2222  return 0;
2223 }
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(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::SparseMatrix< T >::print(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::XdrIO::read_header(), 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:725
const Parallel::Communicator & _communicator
unsigned int libMesh::System::n_variable_groups ( ) const
inlineinherited
Returns
The number of VariableGroup variable groups in the system

Definition at line 2094 of file system.h.

References libMesh::System::_variable_groups.

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

2095 {
2096  return cast_int<unsigned int>(_variable_groups.size());
2097 }
std::vector< VariableGroup > _variable_groups
Definition: system.h:1897
unsigned int libMesh::System::n_vars ( ) const
inlineinherited
Returns
The number of variables in the system

Definition at line 2086 of file system.h.

References libMesh::System::_variables.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::DiffContext::add_localized_vector(), libMesh::System::add_variable(), libMesh::System::add_variables(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::System::calculate_norm(), libMesh::WrappedFunction< Output >::component(), libMesh::DGFEMContext::DGFEMContext(), libMesh::DiffContext::DiffContext(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::ErrorEstimator::estimate_errors(), libMesh::ExactSolution::ExactSolution(), libMesh::System::get_all_variable_numbers(), libMesh::EquationSystems::get_solution(), libMesh::System::init(), libMesh::FEMSystem::init_context(), libMesh::FEMContext::init_internal_data(), libMesh::DGFEMContext::neighbor_side_fe_reinit(), libMesh::WrappedFunction< Output >::operator()(), libMesh::petsc_auto_fieldsplit(), libMesh::FEMContext::pre_fe_reinit(), libMesh::System::project_solution_on_reinit(), libMesh::System::re_update(), libMesh::HPCoarsenTest::select_refinement(), libMesh::SystemSubsetBySubdomain::set_var_nums(), and libMesh::System::zero_variable().

2087 {
2088  return cast_int<unsigned int>(_variables.size());
2089 }
std::vector< Variable > _variables
Definition: system.h:1892
unsigned int libMesh::System::n_vectors ( ) const
inlineinherited
Returns
The number of vectors (in addition to the solution) handled by this system This is the size of the _vectors map

Definition at line 2214 of file system.h.

References libMesh::System::_vectors.

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

2215 {
2216  return cast_int<unsigned int>(_vectors.size());
2217 }
std::map< std::string, NumericVector< Number > * > _vectors
Definition: system.h:1916
Gradient libMesh::System::point_gradient ( unsigned int  var,
const Point p,
const bool  insist_on_success = true 
) const
inherited
Returns
The gradient of the solution variable var at the physical point p in the mesh, similarly to point_value.

Definition at line 2087 of file system.C.

References libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::PointLocatorBase::enable_out_of_mesh_mode(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::MeshBase::is_serial(), 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 libMesh::System::point_gradient().

2088 {
2089  // This function must be called on every processor; there's no
2090  // telling where in the partition p falls.
2091  parallel_object_only();
2092 
2093  // And every processor had better agree about which point we're
2094  // looking for
2095 #ifndef NDEBUG
2096  libmesh_assert(this->comm().verify(p(0)));
2097 #if LIBMESH_DIM > 1
2098  libmesh_assert(this->comm().verify(p(1)));
2099 #endif
2100 #if LIBMESH_DIM > 2
2101  libmesh_assert(this->comm().verify(p(2)));
2102 #endif
2103 #endif // NDEBUG
2104 
2105  // Get a reference to the mesh object associated with the system object that calls this function
2106  const MeshBase & mesh = this->get_mesh();
2107 
2108  // Use an existing PointLocator or create a new one
2109  std::unique_ptr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2110  PointLocatorBase & locator = *locator_ptr;
2111 
2112  if (!insist_on_success || !mesh.is_serial())
2113  locator.enable_out_of_mesh_mode();
2114 
2115  // Get a pointer to the element that contains P
2116  const Elem * e = locator(p);
2117 
2118  Gradient grad_u;
2119 
2120  if (e && this->get_dof_map().is_evaluable(*e, var))
2121  grad_u = point_gradient(var, p, *e);
2122 
2123  // If I have an element containing p, then let's let everyone know
2124  processor_id_type lowest_owner =
2125  (e && (e->processor_id() == this->processor_id())) ?
2126  this->processor_id() : this->n_processors();
2127  this->comm().min(lowest_owner);
2128 
2129  // Everybody should get their value from a processor that was able
2130  // to compute it.
2131  // If nobody admits owning the point, we may have a problem.
2132  if (lowest_owner != this->n_processors())
2133  this->comm().broadcast(grad_u, lowest_owner);
2134  else
2135  libmesh_assert(!insist_on_success);
2136 
2137  return grad_u;
2138 }
processor_id_type n_processors() const
MeshBase & mesh
uint8_t processor_id_type
Definition: id_types.h:99
const MeshBase & get_mesh() const
Definition: system.h:2014
const DofMap & get_dof_map() const
Definition: system.h:2030
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:2087
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
inherited
Returns
The gradient of the solution variable var at the physical point p in local Elem e in the mesh, similarly to point_value.

Definition at line 2141 of file system.C.

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

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

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

References libMesh::System::point_gradient().

2198 {
2199  libmesh_assert(e);
2200  return this->point_gradient(var, p, *e);
2201 }
Gradient point_gradient(unsigned int var, const Point &p, const bool insist_on_success=true) const
Definition: system.C:2087
Tensor libMesh::System::point_hessian ( unsigned int  var,
const Point p,
const bool  insist_on_success = true 
) const
inherited
Returns
The second derivative tensor of the solution variable var at the physical point p in the mesh, similarly to point_value.

Definition at line 2207 of file system.C.

References libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::PointLocatorBase::enable_out_of_mesh_mode(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::MeshBase::is_serial(), 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 libMesh::System::point_hessian().

2208 {
2209  // This function must be called on every processor; there's no
2210  // telling where in the partition p falls.
2211  parallel_object_only();
2212 
2213  // And every processor had better agree about which point we're
2214  // looking for
2215 #ifndef NDEBUG
2216  libmesh_assert(this->comm().verify(p(0)));
2217 #if LIBMESH_DIM > 1
2218  libmesh_assert(this->comm().verify(p(1)));
2219 #endif
2220 #if LIBMESH_DIM > 2
2221  libmesh_assert(this->comm().verify(p(2)));
2222 #endif
2223 #endif // NDEBUG
2224 
2225  // Get a reference to the mesh object associated with the system object that calls this function
2226  const MeshBase & mesh = this->get_mesh();
2227 
2228  // Use an existing PointLocator or create a new one
2229  std::unique_ptr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2230  PointLocatorBase & locator = *locator_ptr;
2231 
2232  if (!insist_on_success || !mesh.is_serial())
2233  locator.enable_out_of_mesh_mode();
2234 
2235  // Get a pointer to the element that contains P
2236  const Elem * e = locator(p);
2237 
2238  Tensor hess_u;
2239 
2240  if (e && this->get_dof_map().is_evaluable(*e, var))
2241  hess_u = point_hessian(var, p, *e);
2242 
2243  // If I have an element containing p, then let's let everyone know
2244  processor_id_type lowest_owner =
2245  (e && (e->processor_id() == this->processor_id())) ?
2246  this->processor_id() : this->n_processors();
2247  this->comm().min(lowest_owner);
2248 
2249  // Everybody should get their value from a processor that was able
2250  // to compute it.
2251  // If nobody admits owning the point, we may have a problem.
2252  if (lowest_owner != this->n_processors())
2253  this->comm().broadcast(hess_u, lowest_owner);
2254  else
2255  libmesh_assert(!insist_on_success);
2256 
2257  return hess_u;
2258 }
processor_id_type n_processors() const
MeshBase & mesh
uint8_t processor_id_type
Definition: id_types.h:99
const MeshBase & get_mesh() const
Definition: system.h:2014
const DofMap & get_dof_map() const
Definition: system.h:2030
Tensor point_hessian(unsigned int var, const Point &p, const bool insist_on_success=true) const
Definition: system.C:2207
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
inherited
Returns
The second derivative tensor of the solution variable var at the physical point p in local Elem e in the mesh, similarly to point_value.

Definition at line 2260 of file system.C.

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

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

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

References libMesh::System::point_hessian().

2317 {
2318  libmesh_assert(e);
2319  return this->point_hessian(var, p, *e);
2320 }
Tensor point_hessian(unsigned int var, const Point &p, const bool insist_on_success=true) const
Definition: system.C:2207
Number libMesh::System::point_value ( unsigned int  var,
const Point p,
const bool  insist_on_success = true 
) const
inherited
Returns
The value of the solution variable var at the physical point p in the mesh, without knowing a priori which element contains p.
Note
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 1980 of file system.C.

References libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::PointLocatorBase::enable_out_of_mesh_mode(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::MeshBase::is_serial(), 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 libMesh::System::point_value().

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

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

Definition at line 2033 of file system.C.

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

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

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

References libMesh::System::point_value().

2080 {
2081  libmesh_assert(e);
2082  return this->point_value(var, p, *e);
2083 }
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true) const
Definition: system.C:1980
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(), libMesh::System::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(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::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::XdrIO::read(), libMesh::CheckpointIO::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::ExodusII_IO_Helper::read_global_values(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), 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::CheckpointIO::select_split_config(), 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::XdrIO::write(), libMesh::CheckpointIO::write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO::write_global_data(), libMesh::ExodusII_IO_Helper::write_global_values(), 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(), libMesh::ExodusII_IO_Helper::write_timestep(), and libMesh::ExodusII_IO::write_timestep_discontinuous().

100  { return cast_int<processor_id_type>(_communicator.rank()); }
const Parallel::Communicator & _communicator
unsigned int rank() const
Definition: parallel.h:723
void libMesh::System::project_solution ( FunctionBase< Number > *  f,
FunctionBase< Gradient > *  g = libmesh_nullptr 
) const
inherited

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

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

Definition at line 810 of file system_projection.C.

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

812 {
813  this->project_vector(*solution, f, g);
814 
815  solution->localize(*current_local_solution, _dof_map->get_send_list());
816 }
std::unique_ptr< DofMap > _dof_map
Definition: system.h:1865
std::unique_ptr< NumericVector< Number > > solution
Definition: system.h:1509
std::unique_ptr< NumericVector< Number > > current_local_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
inherited

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

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

Definition at line 823 of file system_projection.C.

825 {
826  this->project_vector(*solution, f, g);
827 
828  solution->localize(*current_local_solution, _dof_map->get_send_list());
829 }
std::unique_ptr< DofMap > _dof_map
Definition: system.h:1865
std::unique_ptr< NumericVector< Number > > solution
Definition: system.h:1509
std::unique_ptr< NumericVector< Number > > current_local_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 ( ValueFunctionPointer  fptr,
GradientFunctionPointer  gptr,
const Parameters parameters 
) const
inherited

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

Definition at line 796 of file system_projection.C.

799 {
800  WrappedFunction<Number> f(*this, fptr, &parameters);
801  WrappedFunction<Gradient> g(*this, gptr, &parameters);
802  this->project_solution(&f, &g);
803 }
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=libmesh_nullptr) const
bool& libMesh::System::project_solution_on_reinit ( void  )
inlineinherited

Tells the System whether or not to project the solution vector onto new grids when the system is reinitialized. The solution will be projected unless project_solution_on_reinit() = false is called.

Definition at line 780 of file system.h.

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

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

781  { return _solution_projection; }
bool _solution_projection
Definition: system.h:1940
void libMesh::System::project_vector ( NumericVector< Number > &  new_vector,
FunctionBase< Number > *  f,
FunctionBase< Gradient > *  g = libmesh_nullptr,
int  is_adjoint = -1 
) const
inherited

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

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

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

Definition at line 851 of file system_projection.C.

References libmesh_nullptr.

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

855 {
856  LOG_SCOPE ("project_vector(FunctionBase)", "System");
857 
858  libmesh_assert(f);
859 
860  WrappedFunctor<Number> f_fem(*f);
861 
862  if (g)
863  {
864  WrappedFunctor<Gradient> g_fem(*g);
865 
866  this->project_vector(new_vector, &f_fem, &g_fem, is_adjoint);
867  }
868  else
869  this->project_vector(new_vector, &f_fem, libmesh_nullptr, is_adjoint);
870 }
const class libmesh_nullptr_t libmesh_nullptr
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
inherited

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

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

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

Definition at line 877 of file system_projection.C.

References libMesh::NumericVector< T >::close(), libMesh::FEMFunctionBase< Output >::component(), libmesh_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(), and libMesh::NumericVector< T >::set().

881 {
882  LOG_SCOPE ("project_fem_vector()", "System");
883 
884  libmesh_assert (f);
885 
886  ConstElemRange active_local_range
887  (this->get_mesh().active_local_elements_begin(),
888  this->get_mesh().active_local_elements_end() );
889 
890  VectorSetAction<Number> setter(new_vector);
891 
892  const unsigned int n_variables = this->n_vars();
893 
894  std::vector<unsigned int> vars(n_variables);
895  for (unsigned int i=0; i != n_variables; ++i)
896  vars[i] = i;
897 
898  // Use a typedef to make the calling sequence for parallel_for() a bit more readable
899  typedef
900  GenericProjector<FEMFunctionWrapper<Number>, FEMFunctionWrapper<Gradient>,
901  Number, VectorSetAction<Number>> FEMProjector;
902 
903  FEMFunctionWrapper<Number> fw(*f);
904 
905  if (g)
906  {
907  FEMFunctionWrapper<Gradient> gw(*g);
908 
910  (active_local_range,
911  FEMProjector(*this, fw, &gw, setter, vars));
912  }
913  else
915  (active_local_range,
916  FEMProjector(*this, fw, libmesh_nullptr, setter, vars));
917 
918  // Also, load values into the SCALAR dofs
919  // Note: We assume that all SCALAR dofs are on the
920  // processor with highest ID
921  if (this->processor_id() == (this->n_processors()-1))
922  {
923  // FIXME: Do we want to first check for SCALAR vars before building this? [PB]
924  FEMContext context( *this );
925 
926  const DofMap & dof_map = this->get_dof_map();
927  for (unsigned int var=0; var<this->n_vars(); var++)
928  if (this->variable(var).type().family == SCALAR)
929  {
930  // FIXME: We reinit with an arbitrary element in case the user
931  // doesn't override FEMFunctionBase::component. Is there
932  // any use case we're missing? [PB]
933  Elem * el = const_cast<Elem *>(*(this->get_mesh().active_local_elements_begin()));
934  context.pre_fe_reinit(*this, el);
935 
936  std::vector<dof_id_type> SCALAR_indices;
937  dof_map.SCALAR_dof_indices (SCALAR_indices, var);
938  const unsigned int n_SCALAR_dofs =
939  cast_int<unsigned int>(SCALAR_indices.size());
940 
941  for (unsigned int i=0; i<n_SCALAR_dofs; i++)
942  {
943  const dof_id_type global_index = SCALAR_indices[i];
944  const unsigned int component_index =
945  this->variable_scalar_number(var,i);
946 
947  new_vector.set(global_index, f->component(context, component_index, Point(), this->time));
948  }
949  }
950  }
951 
952  new_vector.close();
953 
954 #ifdef LIBMESH_ENABLE_CONSTRAINTS
955  if (is_adjoint == -1)
956  this->get_dof_map().enforce_constraints_exactly(*this, &new_vector);
957  else if (is_adjoint >= 0)
959  is_adjoint);
960 #endif
961 }
FEFamily family
Definition: fe_type.h:204
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
const MeshBase & get_mesh() const
Definition: system.h:2014
const DofMap & get_dof_map() const
Definition: system.h:2030
const Variable & variable(unsigned int var) const
Definition: system.h:2114
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:2145
unsigned int n_vars() const
Definition: system.h:2086
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 ( ValueFunctionPointer  fptr,
GradientFunctionPointer  gptr,
const Parameters parameters,
NumericVector< Number > &  new_vector,
int  is_adjoint = -1 
) const
inherited

Projects arbitrary functions onto a vector of degree of freedom values for the current system. The function value fptr and its gradient gptr are represented by function pointers. A gradient gptr is only required/used for projecting onto finite element spaces with continuous derivatives.

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

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

Definition at line 836 of file system_projection.C.

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

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 202 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::GHOSTED, libMesh::NumericVector< T >::init(), 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(), libMesh::System::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().

204 {
205  // Create a copy of the vector, which currently
206  // contains the old data.
207  std::unique_ptr<NumericVector<Number>>
208  old_vector (vector.clone());
209 
210  // Project the old vector to the new vector
211  this->project_vector (*old_vector, vector, is_adjoint);
212 }
virtual std::unique_ptr< NumericVector< T > > clone() const =0
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 ( const NumericVector< Number > &  ,
NumericVector< Number > &  ,
int  is_adjoint = -1 
) const
protectedinherited

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

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

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

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

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

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

Definition at line 729 of file system_projection.C.

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

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

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

Prolong vectors after the mesh has refined

Definition at line 378 of file system.C.

References libMesh::System::restrict_vectors().

Referenced by libMesh::System::read_parallel_data(), and libMesh::EquationSystems::reinit_solutions().

379 {
380 #ifdef LIBMESH_ENABLE_AMR
381  // Currently project_vector handles both restriction and prolongation
382  this->restrict_vectors();
383 #endif
384 }
virtual void restrict_vectors()
Definition: system.C:322
void libMesh::System::qoi_parameter_hessian ( const QoISet qoi_indices,
const ParameterVector parameters,
SensitivityData hessian 
)
inlinevirtualinherited

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

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

2312 {
2313  libmesh_not_implemented();
2314 }
void libMesh::System::qoi_parameter_hessian_vector_product ( const QoISet qoi_indices,
const ParameterVector parameters,
const ParameterVector vector,
SensitivityData product 
)
inlinevirtualinherited

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

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

2322 {
2323  libmesh_not_implemented();
2324 }
void libMesh::System::qoi_parameter_sensitivity ( const QoISet qoi_indices,
const ParameterVector parameters,
SensitivityData sensitivities 
)
virtualinherited

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

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

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

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

499 {
500  // Forward sensitivities are more efficient for Nq > Np
501  if (qoi_indices.size(*this) > parameters.size())
502  forward_qoi_parameter_sensitivity(qoi_indices, parameters, sensitivities);
503  // Adjoint sensitivities are more efficient for Np > Nq,
504  // and an adjoint may be more reusable than a forward
505  // solution sensitivity in the Np == Nq case.
506  else
507  adjoint_qoi_parameter_sensitivity(qoi_indices, parameters, sensitivities);
508 }
virtual void forward_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
Definition: system.h:2300
virtual void adjoint_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
Definition: system.h:2291
void libMesh::System::re_update ( )
virtualinherited

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

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

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

428 {
429  parallel_object_only();
430 
431  // If this system is empty... don't do anything!
432  if (!this->n_vars())
433  return;
434 
435  const std::vector<dof_id_type> & send_list = this->get_dof_map().get_send_list ();
436 
437  // Check sizes
438  libmesh_assert_equal_to (current_local_solution->size(), solution->size());
439  // Not true with ghosted vectors
440  // libmesh_assert_equal_to (current_local_solution->local_size(), solution->size());
441  // libmesh_assert (!send_list.empty());
442  libmesh_assert_less_equal (send_list.size(), solution->size());
443 
444  // Create current_local_solution from solution. This will
445  // put a local copy of solution into current_local_solution.
446  solution->localize (*current_local_solution, send_list);
447 }
const DofMap & get_dof_map() const
Definition: system.h:2030
std::unique_ptr< NumericVector< Number > > solution
Definition: system.h:1509
std::unique_ptr< NumericVector< Number > > current_local_solution
Definition: system.h:1521
unsigned int n_vars() const
Definition: system.h:2086
const std::vector< dof_id_type > & get_send_list() const
Definition: dof_map.h:395
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 
)
inherited

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::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 libMesh::System::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 subdomains
136  //
137  // 7.) Combined in an FEType:
138  // - The approximation order(s) of the variable
139  // (Order Enum, cast to int/s)
140  // - The finite element family/ies of the variable
141  // (FEFamily Enum, cast to int/s)
142  //
143  // end variable loop
144  //
145  // 8.) The number of additional vectors (unsigned int),
146  //
147  // for each additional vector in the system object
148  //
149  // 9.) the name of the additional vector (string)
150  //
151  // end system
152  libmesh_assert (io.reading());
153 
154  // Possibly clear data structures and start from scratch.
155  if (read_header_in)
156  this->clear ();
157 
158  // Figure out if we need to read infinite element information.
159  // This will be true if the version string contains " with infinite elements"
160  const bool read_ifem_info =
161  (version.rfind(" with infinite elements") < version.size()) ||
162  libMesh::on_command_line ("--read_ifem_systems");
163 
164 
165  {
166  // 5.)
167  // Read the number of variables in the system
168  unsigned int nv=0;
169  if (this->processor_id() == 0)
170  io.data (nv);
171  this->comm().broadcast(nv);
172 
173  _written_var_indices.clear();
174  _written_var_indices.resize(nv, 0);
175 
176  for (unsigned int var=0; var<nv; var++)
177  {
178  // 6.)
179  // Read the name of the var-th variable
180  std::string var_name;
181  if (this->processor_id() == 0)
182  io.data (var_name);
183  this->comm().broadcast(var_name);
184 
185  // 6.1.)
186  std::set<subdomain_id_type> domains;
187  if (io.version() >= LIBMESH_VERSION_ID(0,7,2))
188  {
189  std::vector<subdomain_id_type> domain_array;
190  if (this->processor_id() == 0)
191  io.data (domain_array);
192  for (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 occurence, but catch it anyway.
228  if (read_legacy_format)
229  if ((type.family == MONOMIAL || type.family == XYZ) &&
230  ((type.order.get_order() > 2 && this->get_mesh().mesh_dimension() == 2) ||
231  (type.order.get_order() > 1 && this->get_mesh().mesh_dimension() == 3)))
232  {
233  libmesh_here();
234  libMesh::out << "*****************************************************************\n"
235  << "* WARNING: reading a potentially incompatible restart file!!! *\n"
236  << "* contact libmesh-users@lists.sourceforge.net for more details *\n"
237  << "*****************************************************************"
238  << std::endl;
239  }
240 
241  // Read additional information for infinite elements
242  int radial_fam=0;
243  int i_map=0;
244  if (read_ifem_info)
245  {
246  if (this->processor_id() == 0)
247  io.data (radial_fam);
248  this->comm().broadcast(radial_fam);
249  if (this->processor_id() == 0)
250  io.data (i_map);
251  this->comm().broadcast(i_map);
252  }
253 
254 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
255 
256  type.radial_order = static_cast<Order>(rad_order);
257  type.radial_family = static_cast<FEFamily>(radial_fam);
258  type.inf_map = static_cast<InfMapType>(i_map);
259 
260 #endif
261 
262  if (read_header_in)
263  {
264  if (domains.empty())
265  _written_var_indices[var] = this->add_variable (var_name, type);
266  else
267  _written_var_indices[var] = this->add_variable (var_name, type, &domains);
268  }
269  else
270  _written_var_indices[var] = this->variable_number(var_name);
271  }
272  }
273 
274  // 8.)
275  // Read the number of additional vectors.
276  unsigned int nvecs=0;
277  if (this->processor_id() == 0)
278  io.data (nvecs);
279  this->comm().broadcast(nvecs);
280 
281  // If nvecs > 0, this means that write_additional_data
282  // was true when this file was written. We will need to
283  // make use of this fact later.
284  this->_additional_data_written = nvecs;
285 
286  for (unsigned int vec=0; vec<nvecs; vec++)
287  {
288  // 9.)
289  // Read the name of the vec-th additional vector
290  std::string vec_name;
291  if (this->processor_id() == 0)
292  io.data (vec_name);
293  this->comm().broadcast(vec_name);
294 
295  if (read_additional_data)
296  {
297  // Systems now can handle adding post-initialization vectors
298  // libmesh_assert(this->_can_add_vectors);
299  // Some systems may have added their own vectors already
300  // libmesh_assert_equal_to (this->_vectors.count(vec_name), 0);
301 
302  this->add_vector(vec_name);
303  }
304  }
305 }
virtual void clear()
Definition: system.C:203
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:1082
unsigned short int variable_number(const std::string &var) const
Definition: system.C:1244
const MeshBase & get_mesh() const
Definition: system.h:2014
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Definition: system.C:662
unsigned int _additional_data_written
Definition: system.h:1965
void broadcast(T &data, const unsigned int root_id=0) const
bool on_command_line(const std::string &arg)
Definition: libmesh.C:920
const Parallel::Communicator & comm() const
unsigned int mesh_dimension() const
Definition: mesh_base.C:150
OStreamProxy out(std::cout)
std::vector< unsigned int > _written_var_indices
Definition: system.h:1977
processor_id_type processor_id() const
void libMesh::System::read_legacy_data ( Xdr io,
const bool  read_additional_data = true 
)
inherited

Reads additional data, namely vectors, for this System.

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

Definition at line 310 of file system_io.C.

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

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

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

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

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

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

for each additional vector in the object

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

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

Definition at line 493 of file system_io.C.

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

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

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

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

Definition at line 729 of file system_io.C.

References libmesh_nullptr, and libMesh::processor_id().

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

731 {
732  // This method implements the input of the vectors
733  // contained in this System object, embedded in the
734  // output of an EquationSystems<T_sys>.
735  //
736  // 10.) The global solution vector, re-ordered to be node-major
737  // (More on this later.)
738  //
739  // for each additional vector in the object
740  //
741  // 11.) The global additional vector, re-ordered to be
742  // node-major (More on this later.)
743  parallel_object_only();
744  std::string comment;
745 
746  // PerfLog pl("IO Performance",false);
747  // pl.push("read_serialized_data");
748  // std::size_t total_read_size = 0;
749 
750  // 10.)
751  // Read the global solution vector
752  {
753  // total_read_size +=
754  this->read_serialized_vector<InValType>(io, this->solution.get());
755 
756  // get the comment
757  if (this->processor_id() == 0)
758  io.comment (comment);
759  }
760 
761  // 11.)
762  // Only read additional vectors if data is available, and only use
763  // that data to fill our vectors if the user requested it.
764  if (this->_additional_data_written)
765  {