libMesh::EigenSystem Class Reference

#include <eigen_system.h>

Inheritance diagram for libMesh::EigenSystem:

Public Types

typedef EigenSystem sys_type
 
typedef System Parent
 
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

 EigenSystem (EquationSystems &es, const std::string &name, const unsigned int number)
 
virtual ~EigenSystem ()
 
sys_typesystem ()
 
virtual void clear ()
 
virtual void reinit ()
 
virtual void solve ()
 
virtual void assemble ()
 
virtual std::pair< Real, Realget_eigenpair (unsigned int i)
 
virtual std::string system_type () const
 
virtual unsigned int n_matrices () const
 
unsigned int get_n_converged () const
 
unsigned int get_n_iterations () const
 
void set_eigenproblem_type (EigenProblemType ept)
 
EigenProblemType get_eigenproblem_type () const
 
bool generalized () const
 
void init ()
 
virtual void update ()
 
virtual void assemble_qoi (const QoISet &qoi_indices=QoISet())
 
virtual void assemble_qoi_derivative (const QoISet &qoi_indices=QoISet())
 
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, Real
sensitivity_solve (const ParameterVector &parameters)
 
virtual std::pair< unsigned
int, Real
weighted_sensitivity_solve (const ParameterVector &parameters, const ParameterVector &weights)
 
virtual std::pair< unsigned
int, Real
adjoint_solve (const QoISet &qoi_indices=QoISet())
 
virtual std::pair< unsigned
int, Real
weighted_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=NULL) const
 
void project_solution (FEMFunctionBase< Number > *f, FEMFunctionBase< Gradient > *g=NULL) const
 
void project_solution (Number fptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), Gradient gptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), const Parameters &parameters) const
 
void project_vector (NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=NULL) const
 
void project_vector (NumericVector< Number > &new_vector, FEMFunctionBase< Number > *f, FEMFunctionBase< Gradient > *g=NULL) const
 
void project_vector (Number fptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), Gradient gptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), const Parameters &parameters, NumericVector< Number > &new_vector) const
 
void boundary_project_solution (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, FunctionBase< Number > *f, FunctionBase< Gradient > *g=NULL)
 
void boundary_project_solution (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, Number fptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), Gradient gptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), const Parameters &parameters)
 
void boundary_project_vector (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=NULL) const
 
void boundary_project_vector (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, Number fptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), Gradient gptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), const Parameters &parameters, NumericVector< Number > &new_vector) 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 unsigned int 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_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
 
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=NULL)
 
unsigned int add_variable (const std::string &var, const Order order=FIRST, const FEFamily=LAGRANGE, const std::set< subdomain_id_type > *const active_subdomains=NULL)
 
unsigned int add_variables (const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=NULL)
 
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=NULL)
 
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=0, FEMNormType norm_type=L2) const
 
Real calculate_norm (const NumericVector< Number > &v, const SystemNorm &norm) 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
 
dof_id_type 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))
 
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)
 
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
 
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
 
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
 
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
 
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

SparseMatrix< Number > * matrix_A
 
SparseMatrix< Number > * matrix_B
 
AutoPtr< EigenSolver< Number > > eigen_solver
 
bool assemble_before_solve
 
bool use_fixed_solution
 
int extra_quadrature_order
 
AutoPtr< NumericVector< Number > > solution
 
AutoPtr< NumericVector< Number > > current_local_solution
 
Real time
 
std::vector< Numberqoi
 

Protected Types

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

Protected Member Functions

virtual void init_data ()
 
virtual void init_matrices ()
 
void set_n_converged (unsigned int nconv)
 
void set_n_iterations (unsigned int its)
 
void project_vector (NumericVector< Number > &) const
 
void project_vector (const NumericVector< Number > &, NumericVector< Number > &) const
 
void increment_constructor_count (const std::string &name)
 
void increment_destructor_count (const std::string &name)
 

Protected Attributes

const Parallel::Communicator_communicator
 

Static Protected Attributes

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

Private Attributes

unsigned int _n_converged_eigenpairs
 
unsigned int _n_iterations
 
bool _is_generalized_eigenproblem
 
EigenProblemType _eigen_problem_type
 

Detailed Description

This class provides a specific system class. It aims at solving eigenvalue problems. Currently, this class is able to handle standard eigenvalue problems A*x=lambda*x and generalited eigenvalue problems A*x=lambda*B*x.

Definition at line 53 of file eigen_system.h.

Member Typedef Documentation

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

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

The type of the parent

Definition at line 78 of file eigen_system.h.

The type of system.

Definition at line 73 of file eigen_system.h.

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

Vector iterator typedefs.

Definition at line 717 of file system.h.

Constructor & Destructor Documentation

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

Constructor. Optionally initializes required data structures.

Definition at line 41 of file eigen_system.C.

44  :
45  Parent (es, name, number),
46  matrix_A (NULL),
47  matrix_B (NULL),
50  _n_iterations (0),
53 {
54 }
libMesh::EigenSystem::~EigenSystem ( )
virtual

Destructor.

Definition at line 58 of file eigen_system.C.

References clear().

59 {
60  // clear data
61  this->clear();
62 }

Member Function Documentation

void libMesh::System::activate ( )
inlineinherited

Activates the system. Only active systems are solved.

Definition at line 1927 of file system.h.

References libMesh::System::_active.

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

Definition at line 1919 of file system.h.

References libMesh::System::_active.

1920 {
1921  return _active;
1922 }
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 1017 of file system.C.

References libMesh::System::add_vector().

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

1018 {
1019  std::ostringstream adjoint_rhs_name;
1020  adjoint_rhs_name << "adjoint_rhs" << i;
1021 
1022  return this->add_vector(adjoint_rhs_name.str(), false);
1023 }
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 957 of file system.C.

References libMesh::System::add_vector().

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

958 {
959  std::ostringstream adjoint_name;
960  adjoint_name << "adjoint_solution" << i;
961 
962  return this->add_vector(adjoint_name.str());
963 }
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 1047 of file system.C.

References libMesh::System::add_vector().

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

1048 {
1049  std::ostringstream sensitivity_rhs_name;
1050  sensitivity_rhs_name << "sensitivity_rhs" << i;
1051 
1052  return this->add_vector(sensitivity_rhs_name.str(), false);
1053 }
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 906 of file system.C.

References libMesh::System::add_vector().

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

907 {
908  std::ostringstream sensitivity_name;
909  sensitivity_name << "sensitivity_solution" << i;
910 
911  return this->add_vector(sensitivity_name.str());
912 }
unsigned int libMesh::System::add_variable ( const std::string &  var,
const FEType type,
const std::set< subdomain_id_type > *const  active_subdomains = NULL 
)
inherited

Adds the variable var to the list of variables for this system. Returns the index number for the new variable.

Definition at line 1077 of file system.C.

References libMesh::System::_variable_groups, libMesh::System::_variable_numbers, libMesh::System::_variables, libMesh::System::add_variables(), libMesh::err, libMesh::System::identify_variable_groups(), libMesh::System::n_variable_groups(), libMesh::System::n_vars(), libMesh::System::number(), libMesh::System::variable_name(), and libMesh::System::variable_type().

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

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

References libMesh::System::add_variable().

1160 {
1161  return this->add_variable(var,
1162  FEType(order, family),
1163  active_subdomains);
1164 }
unsigned int libMesh::System::add_variables ( const std::vector< std::string > &  vars,
const FEType type,
const std::set< subdomain_id_type > *const  active_subdomains = NULL 
)
inherited

Adds the variable var to the list of variables for this system. Returns the index number for the new variable.

Definition at line 1168 of file system.C.

References libMesh::System::_variable_groups, libMesh::System::_variable_numbers, libMesh::System::_variables, libMesh::err, 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(), and libMesh::System::add_variables().

1171 {
1172  // Make sure the variable isn't there already
1173  // or if it is, that it's the type we want
1174  for (unsigned int ov=0; ov<vars.size(); ov++)
1175  for (unsigned int v=0; v<this->n_vars(); v++)
1176  if (this->variable_name(v) == vars[ov])
1177  {
1178  if (this->variable_type(v) == type)
1179  return _variables[v].number();
1180 
1181  libMesh::err << "ERROR: incompatible variable "
1182  << vars[ov]
1183  << " has already been added for this system!"
1184  << std::endl;
1185  libmesh_error();
1186  }
1187 
1188  const unsigned int curr_n_vars = this->n_vars();
1189 
1190  const unsigned int next_first_component = this->n_components();
1191 
1192  // Add the variable group to the list
1193  _variable_groups.push_back((active_subdomains == NULL) ?
1194  VariableGroup(this, vars, curr_n_vars,
1195  next_first_component, type) :
1196  VariableGroup(this, vars, curr_n_vars,
1197  next_first_component, type, *active_subdomains));
1198 
1199  const VariableGroup &vg (_variable_groups.back());
1200 
1201  // Add each component of the group individually
1202  for (unsigned int v=0; v<vars.size(); v++)
1203  {
1204  _variables.push_back (vg(v));
1205  _variable_numbers[vars[v]] = curr_n_vars+v;
1206  }
1207 
1208  libmesh_assert_equal_to ((curr_n_vars+vars.size()), this->n_vars());
1209 
1210  // BSK - Defer this now to System::init_data() so we can detect
1211  // VariableGroups 12/28/2012
1212  // // Add the variable group to the _dof_map
1213  // _dof_map->add_variable_group (vg);
1214 
1215  // Return the number of the new variable
1216  return curr_n_vars+vars.size()-1;
1217 }
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 = NULL 
)
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 1221 of file system.C.

References libMesh::System::add_variables().

1225 {
1226  return this->add_variables(vars,
1227  FEType(order, family),
1228  active_subdomains);
1229 }
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 inititialized to zero.

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

Definition at line 676 of file system.C.

References libMesh::System::_can_add_vectors, libMesh::System::_dof_map, libMesh::System::_vector_projections, libMesh::System::_vector_types, libMesh::System::_vectors, libMesh::NumericVector< T >::build(), libMesh::ParallelObject::comm(), libMesh::err, libMeshEnums::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(), libMesh::ExplicitSystem::add_system_rhs(), libMesh::System::add_weighted_sensitivity_adjoint_solution(), libMesh::System::add_weighted_sensitivity_solution(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::UnsteadySolver::init(), libMesh::ContinuationSystem::init_data(), libMesh::NewmarkSystem::NewmarkSystem(), libMesh::System::read_header(), libMesh::FrequencySystem::set_frequencies(), libMesh::FrequencySystem::set_frequencies_by_range(), and libMesh::FrequencySystem::set_frequencies_by_steps().

679 {
680  // Return the vector if it is already there.
681  if (this->have_vector(vec_name))
682  return *(_vectors[vec_name]);
683 
684  // Otherwise build the vector
685  NumericVector<Number>* buf = NumericVector<Number>::build(this->comm()).release();
686  _vectors.insert (std::make_pair (vec_name, buf));
687  _vector_projections.insert (std::make_pair (vec_name, projections));
688 
689  _vector_types.insert (std::make_pair (vec_name, type));
690 
691  // Initialize it if necessary
692  if (!_can_add_vectors)
693  {
694  if(type == GHOSTED)
695  {
696 #ifdef LIBMESH_ENABLE_GHOSTED
697  buf->init (this->n_dofs(), this->n_local_dofs(),
698  _dof_map->get_send_list(), false,
699  GHOSTED);
700 #else
701  libMesh::err << "Cannot initialize ghosted vectors when they are not enabled." << std::endl;
702  libmesh_error();
703 #endif
704  }
705  else
706  buf->init (this->n_dofs(), this->n_local_dofs(), false, type);
707  }
708 
709  return *buf;
710 }
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 987 of file system.C.

References libMesh::System::add_vector().

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

988 {
989  std::ostringstream adjoint_name;
990  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
991 
992  return this->add_vector(adjoint_name.str());
993 }
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 936 of file system.C.

References libMesh::System::add_vector().

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

937 {
938  return this->add_vector("weighted_sensitivity_solution");
939 }
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 2156 of file system.h.

2159 {
2160  libmesh_not_implemented();
2161 }
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 overloaded 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 2140 of file system.h.

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

2141 {
2142  libmesh_not_implemented();
2143 }
void libMesh::EigenSystem::assemble ( )
virtual

Assembles the system matrix.

Reimplemented from libMesh::System.

Definition at line 251 of file eigen_system.C.

References libMesh::System::assemble().

Referenced by libMesh::CondensedEigenSystem::solve(), and solve().

252 {
253 
254  // Assemble the linear system
255  Parent::assemble ();
256 
257 }
void libMesh::System::assemble_qoi ( const QoISet qoi_indices = QoISet())
virtualinherited

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

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

Definition at line 481 of file system.C.

References libMesh::START_LOG(), libMesh::STOP_LOG(), and libMesh::System::user_QOI().

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

482 {
483  // Log how long the user's assembly code takes
484  START_LOG("assemble_qoi()", "System");
485 
486  // Call the user-specified quantity of interest function
487  this->user_QOI(qoi_indices);
488 
489  // Stop logging the user code
490  STOP_LOG("assemble_qoi()", "System");
491 }
void libMesh::System::assemble_qoi_derivative ( const QoISet qoi_indices = QoISet())
virtualinherited

Calls user qoi derivative function. Can be overloaded in derived classes.

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

Definition at line 495 of file system.C.

References libMesh::START_LOG(), libMesh::STOP_LOG(), and libMesh::System::user_QOI_derivative().

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

496 {
497  // Log how long the user's assembly code takes
498  START_LOG("assemble_qoi_derivative()", "System");
499 
500  // Call the user-specified quantity of interest function
501  this->user_QOI_derivative(qoi_indices);
502 
503  // Stop logging the user code
504  STOP_LOG("assemble_qoi_derivative()", "System");
505 }
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 2115 of file system.h.

2116 {
2117  libmesh_not_implemented();
2118 }
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 1754 of file system.C.

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

1756 {
1757  libmesh_assert(fptr);
1758 
1759  if (_assemble_system_object != NULL)
1760  {
1761  libmesh_here();
1762  libMesh::out << "WARNING: Cannot specify both assembly function and object!"
1763  << std::endl;
1764 
1765  _assemble_system_object = NULL;
1766  }
1767 
1769 }
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 1773 of file system.C.

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

1774 {
1775  if (_assemble_system_function != NULL)
1776  {
1777  libmesh_here();
1778  libMesh::out << "WARNING: Cannot specify both assembly object and function!"
1779  << std::endl;
1780 
1782  }
1783 
1784  _assemble_system_object = &assemble_in;
1785 }
void libMesh::System::attach_constraint_function ( void   fptrEquationSystems &es,const std::string &name)
inherited

Register a user function for imposing constraints.

Definition at line 1789 of file system.C.

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

1791 {
1792  libmesh_assert(fptr);
1793 
1794  if (_constrain_system_object != NULL)
1795  {
1796  libmesh_here();
1797  libMesh::out << "WARNING: Cannot specify both constraint function and object!"
1798  << std::endl;
1799 
1800  _constrain_system_object = NULL;
1801  }
1802 
1804 }
void libMesh::System::attach_constraint_object ( System::Constraint constrain)
inherited

Register a user object for imposing constraints.

Definition at line 1808 of file system.C.

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

1809 {
1810  if (_constrain_system_function != NULL)
1811  {
1812  libmesh_here();
1813  libMesh::out << "WARNING: Cannot specify both constraint object and function!"
1814  << std::endl;
1815 
1817  }
1818 
1819  _constrain_system_object = &constrain;
1820 }
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 1719 of file system.C.

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

1721 {
1722  libmesh_assert(fptr);
1723 
1724  if (_init_system_object != NULL)
1725  {
1726  libmesh_here();
1727  libMesh::out << "WARNING: Cannot specify both initialization function and object!"
1728  << std::endl;
1729 
1730  _init_system_object = NULL;
1731  }
1732 
1733  _init_system_function = fptr;
1734 }
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 1738 of file system.C.

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

1739 {
1740  if (_init_system_function != NULL)
1741  {
1742  libmesh_here();
1743  libMesh::out << "WARNING: Cannot specify both initialization object and function!"
1744  << std::endl;
1745 
1746  _init_system_function = NULL;
1747  }
1748 
1749  _init_system_object = &init_in;
1750 }
void libMesh::System::attach_QOI_derivative ( void   fptrEquationSystems &es,const std::string &name,const QoISet &qoi_indices)
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 1860 of file system.C.

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

1863 {
1864  libmesh_assert(fptr);
1865 
1866  if (_qoi_evaluate_derivative_object != NULL)
1867  {
1868  libmesh_here();
1869  libMesh::out << "WARNING: Cannot specify both QOI derivative function and object!"
1870  << std::endl;
1871 
1873  }
1874 
1876 }
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 1880 of file system.C.

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

1881 {
1883  {
1884  libmesh_here();
1885  libMesh::out << "WARNING: Cannot specify both QOI derivative object and function!"
1886  << std::endl;
1887 
1889  }
1890 
1891  _qoi_evaluate_derivative_object = &qoi_derivative;
1892 }
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 1824 of file system.C.

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

1827 {
1828  libmesh_assert(fptr);
1829 
1830  if (_qoi_evaluate_object != NULL)
1831  {
1832  libmesh_here();
1833  libMesh::out << "WARNING: Cannot specify both QOI function and object!"
1834  << std::endl;
1835 
1836  _qoi_evaluate_object = NULL;
1837  }
1838 
1839  _qoi_evaluate_function = fptr;
1840 }
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 1844 of file system.C.

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

1845 {
1846  if (_qoi_evaluate_function != NULL)
1847  {
1848  libmesh_here();
1849  libMesh::out << "WARNING: Cannot specify both QOI object and function!"
1850  << std::endl;
1851 
1852  _qoi_evaluate_function = NULL;
1853  }
1854 
1855  _qoi_evaluate_object = &qoi_in;
1856 }
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 = NULL 
)
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 arbitary boundary function onto the solution via L2 projections and nodal interpolations on each element.

Definition at line 665 of file system_projection.C.

669 {
670  this->boundary_project_vector(b, variables, *solution, f, g);
671 
672  solution->localize(*current_local_solution);
673 }
void libMesh::System::boundary_project_solution ( const std::set< boundary_id_type > &  b,
const std::vector< unsigned int > &  variables,
Number   fptrconst Point &p,const Parameters &parameters,const std::string &sys_name,const std::string &unknown_name,
Gradient   gptrconst Point &p,const Parameters &parameters,const std::string &sys_name,const std::string &unknown_name,
const Parameters parameters 
)
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 641 of file system_projection.C.

652 {
653  WrappedFunction<Number> f(*this, fptr, &parameters);
654  WrappedFunction<Gradient> g(*this, gptr, &parameters);
655  this->boundary_project_solution(b, variables, &f, &g);
656 }
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 = NULL 
) 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.

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

Definition at line 707 of file system_projection.C.

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

712 {
713  START_LOG ("boundary_project_vector()", "System");
714 
716  (ConstElemRange (this->get_mesh().active_local_elements_begin(),
717  this->get_mesh().active_local_elements_end() ),
718  BoundaryProjectSolution(b, variables, *this, f, g,
719  this->get_equation_systems().parameters,
720  new_vector)
721  );
722 
723  // We don't do SCALAR dofs when just projecting the boundary, so
724  // we're done here.
725 
726  new_vector.close();
727 
728 #ifdef LIBMESH_ENABLE_CONSTRAINTS
729  this->get_dof_map().enforce_constraints_exactly(*this, &new_vector);
730 #endif
731 
732  STOP_LOG("boundary_project_vector()", "System");
733 }
void libMesh::System::boundary_project_vector ( const std::set< boundary_id_type > &  b,
const std::vector< unsigned int > &  variables,
Number   fptrconst Point &p,const Parameters &parameters,const std::string &sys_name,const std::string &unknown_name,
Gradient   gptrconst Point &p,const Parameters &parameters,const std::string &sys_name,const std::string &unknown_name,
const Parameters parameters,
NumericVector< Number > &  new_vector 
) 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.

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

Definition at line 684 of file system_projection.C.

696 {
697  WrappedFunction<Number> f(*this, fptr, &parameters);
698  WrappedFunction<Gradient> g(*this, gptr, &parameters);
699  this->boundary_project_vector(b, variables, new_vector, &f, &g);
700 }
Real libMesh::System::calculate_norm ( const NumericVector< Number > &  v,
unsigned int  var = 0,
FEMNormType  norm_type = L2 
) 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 1380 of file system.C.

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

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

1383 {
1384  //short circuit to save time
1385  if(norm_type == DISCRETE_L1 ||
1386  norm_type == DISCRETE_L2 ||
1387  norm_type == DISCRETE_L_INF)
1388  return discrete_var_norm(v,var,norm_type);
1389 
1390  // Not a discrete norm
1391  std::vector<FEMNormType> norms(this->n_vars(), L2);
1392  std::vector<Real> weights(this->n_vars(), 0.0);
1393  norms[var] = norm_type;
1394  weights[var] = 1.0;
1395  Real val = this->calculate_norm(v, SystemNorm(norms, weights));
1396  return val;
1397 }
Real libMesh::System::calculate_norm ( const NumericVector< Number > &  v,
const SystemNorm norm 
) 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 1401 of file system.C.

References libMesh::System::_dof_map, std::abs(), libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), libMesh::TypeVector< T >::add_scaled(), libMesh::TypeTensor< T >::add_scaled(), libMesh::NumericVector< T >::build(), libMesh::FEGenericBase< T >::build(), libMesh::ParallelObject::comm(), libMesh::FEType::default_quadrature_rule(), libMesh::dim, libMeshEnums::DISCRETE_L1, libMeshEnums::DISCRETE_L2, libMeshEnums::DISCRETE_L_INF, libMesh::System::discrete_var_norm(), libMesh::DofMap::dof_indices(), libMesh::AutoPtr< Tp >::get(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMeshEnums::H1, libMeshEnums::H1_SEMINORM, libMeshEnums::H2, libMeshEnums::H2_SEMINORM, libMesh::SystemNorm::is_discrete(), libMeshEnums::L1, libMesh::NumericVector< T >::l1_norm(), libMeshEnums::L2, libMesh::NumericVector< T >::l2_norm(), libMeshEnums::L_INF, libMesh::NumericVector< T >::linfty_norm(), libMesh::NumericVector< T >::localize(), std::max(), libMesh::Parallel::Communicator::max(), libMesh::MeshBase::mesh_dimension(), libMesh::System::n_vars(), libMesh::TensorTools::norm_sq(), libMesh::Real, libMeshEnums::SERIAL, libMesh::TypeVector< T >::size(), libMesh::TypeTensor< T >::size(), libMesh::NumericVector< T >::size(), libMesh::TypeVector< T >::size_sq(), libMesh::TypeTensor< T >::size_sq(), libMesh::START_LOG(), libMesh::STOP_LOG(), libMesh::Parallel::Communicator::sum(), libMesh::SystemNorm::type(), libMesh::DofMap::variable_type(), libMeshEnums::W1_INF_SEMINORM, libMeshEnums::W2_INF_SEMINORM, libMesh::SystemNorm::weight(), and libMesh::SystemNorm::weight_sq().

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

Clear all the data structures associated with the system.

Reimplemented from libMesh::System.

Reimplemented in libMesh::RBConstructionBase< CondensedEigenSystem >, and libMesh::RBSCMConstruction.

Definition at line 66 of file eigen_system.C.

References libMesh::System::clear(), eigen_solver, matrix_A, and matrix_B.

Referenced by ~EigenSystem().

67 {
68  // Clear the parent data
69  Parent::clear();
70 
71  // delete the matricies
72  delete matrix_A;
73  delete matrix_B;
74 
75  // NULL-out the matricies.
76  matrix_A = NULL;
77  matrix_B = NULL;
78 
79  // clear the solver
80  eigen_solver->clear();
81 
82 }
const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inlineinherited
Returns
a reference to the Parallel::Communicator object used by this mesh.

Definition at line 86 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_jacobian(), libMesh::__libmesh_petsc_snes_residual(), libMesh::MeshRefinement::_coarsen_elements(), libMesh::ExactSolution::_compute_error(), libMesh::MetisPartitioner::_do_partition(), libMesh::ParmetisPartitioner::_do_repartition(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult_add(), libMesh::EquationSystems::_read_impl(), libMesh::MeshRefinement::_refine_elements(), libMesh::ParallelMesh::add_elem(), libMesh::ImplicitSystem::add_matrix(), libMesh::ParallelMesh::add_node(), libMesh::System::add_vector(), libMesh::UnstructuredMesh::all_second_order(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assemble_qoi(), libMesh::MeshCommunication::assign_global_indices(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::DofMap::attach_matrix(), libMesh::MeshTools::bounding_box(), libMesh::System::calculate_norm(), libMesh::MeshRefinement::coarsen_elements(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), DMlibMeshFunction(), DMlibMeshJacobian(), DMLibMeshSetSystem(), DMVariableBounds_libMesh(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::for(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::LocationMap< T >::init(), libMesh::PetscDiffSolver::init(), libMesh::TimeSolver::init(), libMesh::SystemSubsetBySubdomain::init(), init_data(), init_matrices(), libMesh::ParmetisPartitioner::initialize(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::ParallelMesh::libmesh_assert_valid_parallel_flags(), libMesh::MeshTools::libmesh_assert_valid_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshCommunication::make_elems_parallel_consistent(), libMesh::MeshRefinement::make_flags_parallel_consistent(), libMesh::MeshCommunication::make_node_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::MeshRefinement::make_refinement_compatible(), libMesh::FEMSystem::mesh_position_set(), libMesh::MeshSerializer::MeshSerializer(), libMesh::ParallelMesh::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::ParallelMesh::parallel_max_elem_id(), libMesh::ParallelMesh::parallel_max_node_id(), libMesh::ParallelMesh::parallel_n_elem(), libMesh::ParallelMesh::parallel_n_nodes(), libMesh::Partitioner::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::System::project_vector(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::MeshRefinement::refine_elements(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), libMesh::Parallel::sync_element_data_by_parent_id(), libMesh::MeshRefinement::test_level_one(), libMesh::MeshRefinement::test_unflagged(), libMesh::MeshTools::total_weight(), libMesh::CheckpointIO::write(), libMesh::XdrIO::write(), libMesh::UnstructuredMesh::write(), libMesh::LegacyXdrIO::write_mesh(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), and libMesh::DivaIO::write_stream().

87  { return _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 526 of file system.C.

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

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

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

Deactivates the system. Only active systems are solved.

Definition at line 1935 of file system.h.

References libMesh::System::_active.

1936 {
1937  _active = false;
1938 }
void libMesh::System::disable_cache ( )
inlinevirtualinherited

Avoids use of any cached data that might affect any solve result. Should be overloaded in derived systems.

Reimplemented in libMesh::ImplicitSystem.

Definition at line 2121 of file system.h.

References libMesh::System::assemble_before_solve.

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

2121 { assemble_before_solve = true; }
void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

Definition at line 106 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

107 {
108  _enable_print_counter = false;
109  return;
110 }
void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

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

Definition at line 100 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

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

2168 {
2169  libmesh_not_implemented();
2170 }
bool libMesh::EigenSystem::generalized ( ) const
inline
Returns
true if the underlying problem is generalized , false otherwise.

Definition at line 148 of file eigen_system.h.

References _is_generalized_eigenproblem.

Referenced by libMesh::CondensedEigenSystem::solve().

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

References libMesh::System::get_vector().

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

1028 {
1029  std::ostringstream adjoint_rhs_name;
1030  adjoint_rhs_name << "adjoint_rhs" << i;
1031 
1032  return this->get_vector(adjoint_rhs_name.str());
1033 }
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 1037 of file system.C.

References libMesh::System::get_vector().

1038 {
1039  std::ostringstream adjoint_rhs_name;
1040  adjoint_rhs_name << "adjoint_rhs" << i;
1041 
1042  return this->get_vector(adjoint_rhs_name.str());
1043 }
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 967 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(), and libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().

968 {
969  std::ostringstream adjoint_name;
970  adjoint_name << "adjoint_solution" << i;
971 
972  return this->get_vector(adjoint_name.str());
973 }
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 977 of file system.C.

References libMesh::System::get_vector().

978 {
979  std::ostringstream adjoint_name;
980  adjoint_name << "adjoint_solution" << i;
981 
982  return this->get_vector(adjoint_name.str());
983 }
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 1260 of file system.C.

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

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

Definition at line 1903 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_jacobian(), libMesh::__libmesh_petsc_snes_residual(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::HPCoarsenTest::add_projection(), libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::ImplicitSystem::adjoint_solve(), libMesh::UnsteadySolver::advance_timestep(), libMesh::EquationSystems::allgather(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_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::DofMap::enforce_constraints_exactly(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::for(), libMesh::System::get_info(), libMesh::EquationSystems::get_solution(), libMesh::SystemSubsetBySubdomain::init(), libMesh::UnsteadySolver::init_data(), init_matrices(), libMesh::ImplicitSystem::init_matrices(), libMesh::CondensedEigenSystem::initialize_condensed_dofs(), libMesh::System::local_dof_indices(), libMesh::DofMap::max_constraint_error(), libMesh::DGFEMContext::neighbor_side_fe_reinit(), libMesh::UnsteadySolver::old_nonlinear_solution(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::ProjectSolution::operator()(), libMesh::ProjectFEMSolution::operator()(), libMesh::BoundaryProjectSolution::operator()(), libMesh::ErrorVector::plot_error(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::FEMContext::pre_fe_reinit(), libMesh::System::project_vector(), libMesh::System::re_update(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::UnsteadySolver::reinit(), libMesh::ImplicitSystem::reinit(), reinit(), libMesh::EquationSystems::reinit(), libMesh::UnsteadySolver::retrieve_timestep(), libMesh::HPCoarsenTest::select_refinement(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::NewtonSolver::solve(), libMesh::PetscDiffSolver::solve(), libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve(), libMesh::ImplicitSystem::weighted_sensitivity_solve(), libMesh::System::write_parallel_data(), libMesh::EnsightIO::write_scalar_ascii(), libMesh::System::write_SCALAR_dofs(), and libMesh::EnsightIO::write_vector_ascii().

1904 {
1905  return *_dof_map;
1906 }
DofMap & libMesh::System::get_dof_map ( )
inlineinherited
Returns
a writeable reference to this system's _dof_map.

Definition at line 1911 of file system.h.

References libMesh::System::_dof_map.

1912 {
1913  return *_dof_map;
1914 }
std::pair< Real, Real > libMesh::EigenSystem::get_eigenpair ( unsigned int  i)
virtual

Returns real and imaginary part of the ith eigenvalue and copies the respective eigen vector to the solution vector.

Reimplemented in libMesh::CondensedEigenSystem.

Definition at line 260 of file eigen_system.C.

References eigen_solver, and libMesh::System::solution.

Referenced by libMesh::CondensedEigenSystem::get_eigenpair().

261 {
262  // call the eigen_solver get_eigenpair method
263  return eigen_solver->get_eigenpair (i, *solution);
264 }
EigenProblemType libMesh::EigenSystem::get_eigenproblem_type ( ) const
inline
Returns
the eigen problem type.

Definition at line 142 of file eigen_system.h.

References _eigen_problem_type.

142 {return _eigen_problem_type;}
EquationSystems& libMesh::System::get_equation_systems ( )
inlineinherited
Returns
a reference to this system's parent EquationSystems object.

Definition at line 686 of file system.h.

References libMesh::System::_equation_systems.

686 { return _equation_systems; }
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 libMesh::System::get_info ( ) const
inherited
Returns
a string containing information about the system.

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

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

Definition at line 1887 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::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::SystemSubsetBySubdomain::init(), libMesh::System::init_data(), 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::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::ProjectSolution::operator()(), libMesh::BoundaryProjectSolution::operator()(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::FEMSystem::postprocess(), libMesh::System::project_vector(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::System::read_parallel_data(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::ImplicitSystem::reinit(), reinit(), libMesh::HPSingularity::select_refinement(), libMesh::HPCoarsenTest::select_refinement(), libMesh::System::write_header(), libMesh::System::write_parallel_data(), libMesh::System::write_serialized_vector(), libMesh::System::write_serialized_vectors(), and libMesh::System::zero_variable().

1888 {
1889  return _mesh;
1890 }
MeshBase & libMesh::System::get_mesh ( )
inlineinherited
Returns
a reference to this systems's _mesh.

Definition at line 1895 of file system.h.

References libMesh::System::_mesh.

1896 {
1897  return _mesh;
1898 }
unsigned int libMesh::EigenSystem::get_n_converged ( ) const
inline
Returns
the number of converged eigenpairs.

Definition at line 127 of file eigen_system.h.

References _n_converged_eigenpairs.

127 {return _n_converged_eigenpairs;}
unsigned int libMesh::EigenSystem::get_n_iterations ( ) const
inline
Returns
the number of eigen solver iterations.

Definition at line 132 of file eigen_system.h.

References _n_iterations.

132 {return _n_iterations;}
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 1057 of file system.C.

References libMesh::System::get_vector().

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

1058 {
1059  std::ostringstream sensitivity_rhs_name;
1060  sensitivity_rhs_name << "sensitivity_rhs" << i;
1061 
1062  return this->get_vector(sensitivity_rhs_name.str());
1063 }
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 1067 of file system.C.

References libMesh::System::get_vector().

1068 {
1069  std::ostringstream sensitivity_rhs_name;
1070  sensitivity_rhs_name << "sensitivity_rhs" << i;
1071 
1072  return this->get_vector(sensitivity_rhs_name.str());
1073 }
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 916 of file system.C.

References libMesh::System::get_vector().

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

917 {
918  std::ostringstream sensitivity_name;
919  sensitivity_name << "sensitivity_solution" << i;
920 
921  return this->get_vector(sensitivity_name.str());
922 }
const NumericVector< Number > & 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 926 of file system.C.

References libMesh::System::get_vector().

927 {
928  std::ostringstream sensitivity_name;
929  sensitivity_name << "sensitivity_solution" << i;
930 
931  return this->get_vector(sensitivity_name.str());
932 }
const NumericVector< Number > & 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 785 of file system.C.

References libMesh::System::_vectors, and libMesh::err.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::AdaptiveTimeSolver::advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), libMesh::System::compare(), 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::UnsteadySolver::reinit(), libMesh::MemorySolutionHistory::retrieve(), libMesh::UnsteadySolver::retrieve_timestep(), libMesh::TwostepTimeSolver::solve(), libMesh::FrequencySystem::solve(), libMesh::NewmarkSystem::update_rhs(), and libMesh::NewmarkSystem::update_u_v_a().

786 {
787  // Make sure the vector exists
788  const_vectors_iterator pos = _vectors.find(vec_name);
789 
790  if (pos == _vectors.end())
791  {
792  libMesh::err << "ERROR: vector "
793  << vec_name
794  << " does not exist in this system!"
795  << std::endl;
796  libmesh_error();
797  }
798 
799  return *(pos->second);
800 }
NumericVector< Number > & libMesh::System::get_vector ( const std::string &  vec_name)
inherited
Returns
a writeable reference to this system's additional vector named vec_name. Access is only granted when the vector is already properly initialized.

Definition at line 804 of file system.C.

References libMesh::System::_vectors, and libMesh::err.

805 {
806  // Make sure the vector exists
807  vectors_iterator pos = _vectors.find(vec_name);
808 
809  if (pos == _vectors.end())
810  {
811  libMesh::err << "ERROR: vector "
812  << vec_name
813  << " does not exist in this system!"
814  << std::endl;
815  libmesh_error();
816  }
817 
818  return *(pos->second);
819 }
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 823 of file system.C.

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

824 {
827  unsigned int num = 0;
828  while((num<vec_num) && (v!=v_end))
829  {
830  num++;
831  ++v;
832  }
833  libmesh_assert (v != v_end);
834  return *(v->second);
835 }
NumericVector< Number > & libMesh::System::get_vector ( const unsigned int  vec_num)
inherited
Returns
a writeable reference to this system's additional vector number vec_num (where the vectors are counted starting with 0).

Definition at line 839 of file system.C.

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

840 {
842  vectors_iterator v_end = vectors_end();
843  unsigned int num = 0;
844  while((num<vec_num) && (v!=v_end))
845  {
846  num++;
847  ++v;
848  }
849  libmesh_assert (v != v_end);
850  return *(v->second);
851 }
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 997 of file system.C.

References libMesh::System::get_vector().

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

998 {
999  std::ostringstream adjoint_name;
1000  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
1001 
1002  return this->get_vector(adjoint_name.str());
1003 }
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 1007 of file system.C.

References libMesh::System::get_vector().

1008 {
1009  std::ostringstream adjoint_name;
1010  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
1011 
1012  return this->get_vector(adjoint_name.str());
1013 }
NumericVector< Number > & libMesh::System::get_weighted_sensitivity_solution ( )
inherited
Returns
a reference to the solution of the last weighted sensitivity solve

Definition at line 943 of file system.C.

References libMesh::System::get_vector().

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

944 {
945  return this->get_vector("weighted_sensitivity_solution");
946 }
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 950 of file system.C.

References libMesh::System::get_vector().

951 {
952  return this->get_vector("weighted_sensitivity_solution");
953 }
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 1233 of file system.C.

References libMesh::System::_variable_numbers.

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

1234 {
1235  return _variable_numbers.count(var);
1236 }
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 2071 of file system.h.

References libMesh::System::_vectors.

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

2072 {
2073  return (_vectors.count(vec_name));
2074 }
bool libMesh::System::identify_variable_groups ( ) const
inlineinherited
Returns
true when VariableGroup structures should be automatically identified, false otherwise.

Definition at line 2047 of file system.h.

References libMesh::System::_identify_variable_groups.

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

2048 {
2050 }
void libMesh::System::identify_variable_groups ( const bool  ivg)
inlineinherited

Toggle automatic VariableGroup identification.

Definition at line 2055 of file system.h.

References libMesh::System::_identify_variable_groups.

2056 {
2058 }
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 163 of file reference_counter.h.

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

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

164 {
165  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
166  std::pair<unsigned int, unsigned int>& p = _counts[name];
167 
168  p.first++;
169 }
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 176 of file reference_counter.h.

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

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

177 {
178  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
179  std::pair<unsigned int, unsigned int>& p = _counts[name];
180 
181  p.second++;
182 }
void libMesh::System::init ( )
inherited

Initializes degrees of freedom on the current mesh. Sets the

Definition at line 226 of file system.C.

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

227 {
228  // First initialize any required data:
229  // either only the basic System data
230  if (_basic_system_only)
232  // or all the derived class' data too
233  else
234  this->init_data();
235 
236  // If no variables have been added to this system
237  // don't do anything
238  if(!this->n_vars())
239  return;
240 
241  // Then call the user-provided intialization function
242  this->user_initialization();
243 }
void libMesh::EigenSystem::init_data ( )
protectedvirtual

Initializes the member data fields associated with the system, so that, e.g., assemble() may be used.

Reimplemented from libMesh::System.

Reimplemented in libMesh::RBConstructionBase< CondensedEigenSystem >.

Definition at line 117 of file eigen_system.C.

References _eigen_problem_type, _is_generalized_eigenproblem, libMesh::SparseMatrix< T >::build(), libMesh::ParallelObject::comm(), libMeshEnums::GHEP, libMeshEnums::GNHEP, libMesh::System::init_data(), init_matrices(), and matrix_A.

118 {
119  // initialize parent data
121 
122  // define the type of eigenproblem
125 
126  // build the system matrix
127  matrix_A = SparseMatrix<Number>::build(this->comm()).release();
128 
129  this->init_matrices();
130 }
void libMesh::EigenSystem::init_matrices ( )
protectedvirtual

Initializes the matrices associated with the system

Definition at line 134 of file eigen_system.C.

References _is_generalized_eigenproblem, libMesh::DofMap::attach_matrix(), libMesh::SparseMatrix< T >::build(), libMesh::ParallelObject::comm(), libMesh::DofMap::compute_sparsity(), libMesh::dof_map, libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::SparseMatrix< T >::init(), matrix_A, matrix_B, and libMesh::SparseMatrix< T >::zero().

Referenced by init_data().

135 {
136  DofMap& dof_map = this->get_dof_map();
137 
138  dof_map.attach_matrix(*matrix_A);
139 
140  // build matrix_B only in case of a
141  // generalized problem
143  {
144  matrix_B = SparseMatrix<Number>::build(this->comm()).release();
145  dof_map.attach_matrix(*matrix_B);
146  }
147 
148  dof_map.compute_sparsity(this->get_mesh());
149 
150  // initialize and zero system matrix
151  matrix_A->init();
152  matrix_A->zero();
153 
154  // eventually initialize and zero system matrix_B
156  {
157  matrix_B->init();
158  matrix_B->zero();
159  }
160 }
bool libMesh::System::is_adjoint_already_solved ( ) const
inlineinherited

Accessor for the adjoint_already_solved boolean

Definition at line 361 of file system.h.

References libMesh::System::adjoint_already_solved.

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

362  { return adjoint_already_solved;}
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 1279 of file system.C.

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

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

1281 {
1282  // Make sure the set is clear
1283  var_indices.clear();
1284 
1285  std::vector<dof_id_type> dof_indices;
1286 
1287  // Begin the loop over the elements
1288  MeshBase::const_element_iterator el =
1290  const MeshBase::const_element_iterator end_el =
1292 
1293  const dof_id_type
1294  first_local = this->get_dof_map().first_dof(),
1295  end_local = this->get_dof_map().end_dof();
1296 
1297  for ( ; el != end_el; ++el)
1298  {
1299  const Elem* elem = *el;
1300  this->get_dof_map().dof_indices (elem, dof_indices, var);
1301 
1302  for(unsigned int i=0; i<dof_indices.size(); i++)
1303  {
1304  dof_id_type dof = dof_indices[i];
1305 
1306  //If the dof is owned by the local processor
1307  if(first_local <= dof && dof < end_local)
1308  var_indices.insert(dof_indices[i]);
1309  }
1310  }
1311 }
dof_id_type libMesh::System::n_active_dofs ( ) const
inlineinherited

Returns the number of active degrees of freedom for this System.

Definition at line 2063 of file system.h.

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

2064 {
2065  return this->n_dofs() - this->n_constrained_dofs();
2066 }
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 1967 of file system.h.

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

Referenced by libMesh::System::add_variables(), and libMesh::System::project_vector().

1968 {
1969  if (_variables.empty())
1970  return 0;
1971 
1972  const Variable& last = _variables.back();
1973  return last.first_scalar_number() + last.n_components();
1974 }
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 147 of file system.C.

References libMesh::System::_dof_map.

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

148 {
149 #ifdef LIBMESH_ENABLE_CONSTRAINTS
150 
151  return _dof_map->n_constrained_dofs();
152 
153 #else
154 
155  return 0;
156 
157 #endif
158 }
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 162 of file system.C.

References libMesh::System::_dof_map.

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

163 {
164 #ifdef LIBMESH_ENABLE_CONSTRAINTS
165 
166  return _dof_map->n_local_constrained_dofs();
167 
168 #else
169 
170  return 0;
171 
172 #endif
173 }
unsigned int libMesh::EigenSystem::n_matrices ( ) const
inlinevirtual
Returns
the number of matrices handled by this system

Reimplemented from libMesh::System.

Definition at line 227 of file eigen_system.h.

References _is_generalized_eigenproblem.

228 {
230  return 2;
231 
232  return 1;
233 }
static unsigned int libMesh::ReferenceCounter::n_objects ( )
inlinestaticinherited

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

Definition at line 79 of file reference_counter.h.

References libMesh::ReferenceCounter::_n_objects.

80  { return _n_objects; }
processor_id_type libMesh::ParallelObject::n_processors ( ) const
inlineinherited
Returns
the number of processors in the group.

Definition at line 92 of file parallel_object.h.

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

Referenced by libMesh::ParmetisPartitioner::_do_repartition(), libMesh::ParallelMesh::add_elem(), libMesh::ParallelMesh::add_node(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::ParallelMesh::assign_unique_ids(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::ParallelMesh::clear(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::EnsightIO::EnsightIO(), libMesh::MeshBase::get_info(), libMesh::EquationSystems::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshBase::n_active_elem_on_proc(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), 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::MeshTools::processor_bounding_box(), libMesh::System::project_vector(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::UnstructuredMesh::read(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::System::read_serialized_vector(), libMesh::Partitioner::repartition(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::BoundaryInfo::sync(), libMesh::ParallelMesh::update_parallel_id_counts(), libMesh::CheckpointIO::write(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

93  { return libmesh_cast_int<processor_id_type>(_communicator.size()); }
unsigned int libMesh::System::n_variable_groups ( ) const
inlineinherited
Returns
the number of VariableGroup variable groups in the system

Definition at line 1959 of file system.h.

References libMesh::System::_variable_groups.

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

1960 {
1961  return libmesh_cast_int<unsigned int>(_variable_groups.size());
1962 }
unsigned int libMesh::System::n_vars ( ) const
inlineinherited
Returns
the number of variables in the system

Definition at line 1951 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_solution_vector(), libMesh::System::calculate_norm(), libMesh::DGFEMContext::DGFEMContext(), libMesh::DiffContext::DiffContext(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ErrorEstimator::estimate_errors(), libMesh::ExactSolution::ExactSolution(), libMesh::FEMContext::FEMContext(), libMesh::System::get_all_variable_numbers(), libMesh::EquationSystems::get_solution(), libMesh::System::init(), libMesh::FEMSystem::init_context(), libMesh::DGFEMContext::neighbor_side_fe_reinit(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::ProjectSolution::operator()(), libMesh::FEMContext::pre_fe_reinit(), libMesh::System::project_vector(), libMesh::System::re_update(), libMesh::System::read_legacy_data(), libMesh::System::read_parallel_data(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::EquationSystems::reinit(), libMesh::System::reinit(), libMesh::HPCoarsenTest::select_refinement(), libMesh::SystemSubsetBySubdomain::set_var_nums(), libMesh::System::write_header(), libMesh::System::write_parallel_data(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::System::write_serialized_vector(), libMesh::System::write_serialized_vectors(), and libMesh::System::zero_variable().

1952 {
1953  return libmesh_cast_int<unsigned int>(_variables.size());
1954 }
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 2079 of file system.h.

References libMesh::System::_vectors.

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

2080 {
2081  return libmesh_cast_int<unsigned int>(_vectors.size());
2082 }
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 2063 of file system.C.

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

2064 {
2065  // This function must be called on every processor; there's no
2066  // telling where in the partition p falls.
2067  parallel_object_only();
2068 
2069  // And every processor had better agree about which point we're
2070  // looking for
2071 #ifndef NDEBUG
2072  this->comm().verify(p);
2073 #endif // NDEBUG
2074 
2075  // Get a reference to the mesh object associated with the system object that calls this function
2076  const MeshBase &mesh = this->get_mesh();
2077 
2078  // Use an existing PointLocator or create a new one
2079  AutoPtr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2080  PointLocatorBase& locator = *locator_ptr;
2081 
2082  if (!insist_on_success)
2083  locator.enable_out_of_mesh_mode();
2084 
2085  // Get a pointer to the element that contains P
2086  const Elem *e = locator(p);
2087 
2088  Gradient grad_u;
2089 
2090  if (e && e->processor_id() == this->processor_id())
2091  grad_u = point_gradient(var, p, *e);
2092 
2093  // If I have an element containing p, then let's let everyone know
2094  processor_id_type lowest_owner =
2095  (e && (e->processor_id() == this->processor_id())) ?
2096  this->processor_id() : this->n_processors();
2097  this->comm().min(lowest_owner);
2098 
2099  // Everybody should get their value from a processor that was able
2100  // to compute it.
2101  // If nobody admits owning the point, we may have a problem.
2102  if (lowest_owner != this->n_processors())
2103  this->comm().broadcast(grad_u, lowest_owner);
2104  else
2105  libmesh_assert(!insist_on_success);
2106 
2107  return grad_u;
2108 }
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 2111 of file system.C.

References libMesh::TypeVector< T >::add_scaled(), libMesh::FEGenericBase< T >::build(), libMesh::Elem::contains_point(), libMesh::System::current_solution(), libMesh::Elem::dim(), libMesh::dof_map, libMesh::System::get_dof_map(), libMesh::FEInterface::inverse_map(), libMesh::libmesh_assert(), libMesh::ParallelObject::processor_id(), and libMesh::DofObject::processor_id().

2112 {
2113  libmesh_assert_equal_to (e.processor_id(), this->processor_id());
2114 
2115  // Ensuring that the given point is really in the element is an
2116  // expensive assert, but as long as debugging is turned on we might
2117  // as well try to catch a particularly nasty potential error
2118  libmesh_assert (e.contains_point(p));
2119 
2120  // Get the dof map to get the proper indices for our computation
2121  const DofMap& dof_map = this->get_dof_map();
2122 
2123  // Need dof_indices for phi[i][j]
2124  std::vector<dof_id_type> dof_indices;
2125 
2126  // Fill in the dof_indices for our element
2127  dof_map.dof_indices (&e, dof_indices, var);
2128 
2129  // Get the no of dofs assciated with this point
2130  const unsigned int num_dofs = libmesh_cast_int<unsigned int>
2131  (dof_indices.size());
2132 
2133  FEType fe_type = dof_map.variable_type(var);
2134 
2135  // Build a FE again so we can calculate u(p)
2136  AutoPtr<FEBase> fe (FEBase::build(e.dim(), fe_type));
2137 
2138  // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h
2139  // Build a vector of point co-ordinates to send to reinit
2140  std::vector<Point> coor(1, FEInterface::inverse_map(e.dim(), fe_type, &e, p));
2141 
2142  // Get the values of the shape function derivatives
2143  const std::vector<std::vector<RealGradient> >& dphi = fe->get_dphi();
2144 
2145  // Reinitialize the element and compute the shape function values at coor
2146  fe->reinit (&e, &coor);
2147 
2148  // Get ready to accumulate a gradient
2149  Gradient grad_u;
2150 
2151  for (unsigned int l=0; l<num_dofs; l++)
2152  {
2153  grad_u.add_scaled (dphi[l][0], this->current_solution (dof_indices[l]));
2154  }
2155 
2156  return grad_u;
2157 }
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 2162 of file system.C.

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

2163 {
2164  // This function must be called on every processor; there's no
2165  // telling where in the partition p falls.
2166  parallel_object_only();
2167 
2168  // And every processor had better agree about which point we're
2169  // looking for
2170 #ifndef NDEBUG
2171  this->comm().verify(p);
2172 #endif // NDEBUG
2173 
2174  // Get a reference to the mesh object associated with the system object that calls this function
2175  const MeshBase &mesh = this->get_mesh();
2176 
2177  // Use an existing PointLocator or create a new one
2178  AutoPtr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
2179  PointLocatorBase& locator = *locator_ptr;
2180 
2181  if (!insist_on_success)
2182  locator.enable_out_of_mesh_mode();
2183 
2184  // Get a pointer to the element that contains P
2185  const Elem *e = locator(p);
2186 
2187  Tensor hess_u;
2188 
2189  if (e && e->processor_id() == this->processor_id())
2190  hess_u = point_hessian(var, p, *e);
2191 
2192  // If I have an element containing p, then let's let everyone know
2193  processor_id_type lowest_owner =
2194  (e && (e->processor_id() == this->processor_id())) ?
2195  this->processor_id() : this->n_processors();
2196  this->comm().min(lowest_owner);
2197 
2198  // Everybody should get their value from a processor that was able
2199  // to compute it.
2200  // If nobody admits owning the point, we may have a problem.
2201  if (lowest_owner != this->n_processors())
2202  this->comm().broadcast(hess_u, lowest_owner);
2203  else
2204  libmesh_assert(!insist_on_success);
2205 
2206  return hess_u;
2207 }
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 2209 of file system.C.

References libMesh::TypeTensor< T >::add_scaled(), libMesh::FEGenericBase< T >::build(), libMesh::Elem::contains_point(), libMesh::System::current_solution(), libMesh::Elem::dim(), libMesh::dof_map, libMesh::System::get_dof_map(), libMesh::FEInterface::inverse_map(), libMesh::libmesh_assert(), libMesh::ParallelObject::processor_id(), and libMesh::DofObject::processor_id().

2210 {
2211  libmesh_assert_equal_to (e.processor_id(), this->processor_id());
2212 
2213  // Ensuring that the given point is really in the element is an
2214  // expensive assert, but as long as debugging is turned on we might
2215  // as well try to catch a particularly nasty potential error
2216  libmesh_assert (e.contains_point(p));
2217 
2218  // Get the dof map to get the proper indices for our computation
2219  const DofMap& dof_map = this->get_dof_map();
2220 
2221  // Need dof_indices for phi[i][j]
2222  std::vector<dof_id_type> dof_indices;
2223 
2224  // Fill in the dof_indices for our element
2225  dof_map.dof_indices (&e, dof_indices, var);
2226 
2227  // Get the no of dofs assciated with this point
2228  const unsigned int num_dofs = libmesh_cast_int<unsigned int>
2229  (dof_indices.size());
2230 
2231  FEType fe_type = dof_map.variable_type(var);
2232 
2233  // Build a FE again so we can calculate u(p)
2234  AutoPtr<FEBase> fe (FEBase::build(e.dim(), fe_type));
2235 
2236  // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h
2237  // Build a vector of point co-ordinates to send to reinit
2238  std::vector<Point> coor(1, FEInterface::inverse_map(e.dim(), fe_type, &e, p));
2239 
2240  // Get the values of the shape function derivatives
2241  const std::vector<std::vector<RealTensor> >& d2phi = fe->get_d2phi();
2242 
2243  // Reinitialize the element and compute the shape function values at coor
2244  fe->reinit (&e, &coor);
2245 
2246  // Get ready to accumulate a hessian
2247  Tensor hess_u;
2248 
2249  for (unsigned int l=0; l<num_dofs; l++)
2250  {
2251  hess_u.add_scaled (d2phi[l][0], this->current_solution (dof_indices[l]));
2252  }
2253 
2254  return hess_u;
2255 }
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 that 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 . 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 1966 of file system.C.

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

1967 {
1968  // This function must be called on every processor; there's no
1969  // telling where in the partition p falls.
1970  parallel_object_only();
1971 
1972  // And every processor had better agree about which point we're
1973  // looking for
1974 #ifndef NDEBUG
1975  this->comm().verify(p);
1976 #endif // NDEBUG
1977 
1978  // Get a reference to the mesh object associated with the system object that calls this function
1979  const MeshBase &mesh = this->get_mesh();
1980 
1981  // Use an existing PointLocator or create a new one
1982  AutoPtr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
1983  PointLocatorBase& locator = *locator_ptr;
1984 
1985  if (!insist_on_success)
1986  locator.enable_out_of_mesh_mode();
1987 
1988  // Get a pointer to the element that contains P
1989  const Elem *e = locator(p);
1990 
1991  Number u = 0;
1992 
1993  if (e && e->processor_id() == this->processor_id())
1994  u = point_value(var, p, *e);
1995 
1996  // If I have an element containing p, then let's let everyone know
1997  processor_id_type lowest_owner =
1998  (e && (e->processor_id() == this->processor_id())) ?
1999  this->processor_id() : this->n_processors();
2000  this->comm().min(lowest_owner);
2001 
2002  // Everybody should get their value from a processor that was able
2003  // to compute it.
2004  // If nobody admits owning the point, we have a problem.
2005  if (lowest_owner != this->n_processors())
2006  this->comm().broadcast(u, lowest_owner);
2007  else
2008  libmesh_assert(!insist_on_success);
2009 
2010  return u;
2011 }
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.

Definition at line 2013 of file system.C.

References libMesh::FEGenericBase< T >::build(), libMesh::Elem::contains_point(), libMesh::System::current_solution(), libMesh::Elem::dim(), libMesh::dof_map, libMesh::System::get_dof_map(), libMesh::FEInterface::inverse_map(), libMesh::libmesh_assert(), libMesh::ParallelObject::processor_id(), and libMesh::DofObject::processor_id().

2014 {
2015  libmesh_assert_equal_to (e.processor_id(), this->processor_id());
2016 
2017  // Ensuring that the given point is really in the element is an
2018  // expensive assert, but as long as debugging is turned on we might
2019  // as well try to catch a particularly nasty potential error
2020  libmesh_assert (e.contains_point(p));
2021 
2022  // Get the dof map to get the proper indices for our computation
2023  const DofMap& dof_map = this->get_dof_map();
2024 
2025  // Need dof_indices for phi[i][j]
2026  std::vector<dof_id_type> dof_indices;
2027 
2028  // Fill in the dof_indices for our element
2029  dof_map.dof_indices (&e, dof_indices, var);
2030 
2031  // Get the no of dofs assciated with this point
2032  const unsigned int num_dofs = libmesh_cast_int<unsigned int>
2033  (dof_indices.size());
2034 
2035  FEType fe_type = dof_map.variable_type(var);
2036 
2037  // Build a FE so we can calculate u(p)
2038  AutoPtr<FEBase> fe (FEBase::build(e.dim(), fe_type));
2039 
2040  // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h
2041  // Build a vector of point co-ordinates to send to reinit
2042  std::vector<Point> coor(1, FEInterface::inverse_map(e.dim(), fe_type, &e, p));
2043 
2044  // Get the shape function values
2045  const std::vector<std::vector<Real> >& phi = fe->get_phi();
2046 
2047  // Reinitialize the element and compute the shape function values at coor
2048  fe->reinit (&e, &coor);
2049 
2050  // Get ready to accumulate a value
2051  Number u = 0;
2052 
2053  for (unsigned int l=0; l<num_dofs; l++)
2054  {
2055  u += phi[l][0]*this->current_solution (dof_indices[l]);
2056  }
2057 
2058  return u;
2059 }
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().

89 {
91 }
processor_id_type libMesh::ParallelObject::processor_id ( ) const
inlineinherited
Returns
the rank of this processor in the group.

Definition at line 98 of file parallel_object.h.

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

Referenced by libMesh::MetisPartitioner::_do_partition(), libMesh::EquationSystems::_read_impl(), libMesh::SerialMesh::active_local_elements_begin(), libMesh::ParallelMesh::active_local_elements_begin(), libMesh::SerialMesh::active_local_elements_end(), libMesh::ParallelMesh::active_local_elements_end(), libMesh::SerialMesh::active_local_subdomain_elements_begin(), libMesh::ParallelMesh::active_local_subdomain_elements_begin(), libMesh::SerialMesh::active_local_subdomain_elements_end(), libMesh::ParallelMesh::active_local_subdomain_elements_end(), libMesh::SerialMesh::active_not_local_elements_begin(), libMesh::ParallelMesh::active_not_local_elements_begin(), libMesh::SerialMesh::active_not_local_elements_end(), libMesh::ParallelMesh::active_not_local_elements_end(), libMesh::ParallelMesh::add_elem(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::ParallelMesh::add_node(), libMesh::UnstructuredMesh::all_second_order(), libMesh::ParmetisPartitioner::assign_partitioning(), 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::DofMap::build_sparsity(), libMesh::ParallelMesh::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::ExodusII_IO_Helper::create(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DofMap::end_dof(), libMesh::DofMap::end_old_dof(), libMesh::EnsightIO::EnsightIO(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::DofMap::first_dof(), libMesh::DofMap::first_old_dof(), libMesh::Nemesis_IO_Helper::get_cmap_params(), libMesh::Nemesis_IO_Helper::get_eb_info_global(), libMesh::Nemesis_IO_Helper::get_elem_cmap(), libMesh::Nemesis_IO_Helper::get_elem_map(), libMesh::MeshBase::get_info(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), libMesh::Nemesis_IO_Helper::get_node_cmap(), libMesh::Nemesis_IO_Helper::get_node_map(), libMesh::Nemesis_IO_Helper::get_ns_param_global(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), libMesh::MeshFunction::gradient(), libMesh::MeshFunction::hessian(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_discontinuous(), libMesh::ExodusII_IO_Helper::initialize_element_variables(), libMesh::ExodusII_IO_Helper::initialize_global_variables(), libMesh::ExodusII_IO_Helper::initialize_nodal_variables(), libMesh::SparsityPattern::Build::join(), libMesh::DofMap::last_dof(), libMesh::MeshTools::libmesh_assert_valid_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_procids< Node >(), libMesh::SerialMesh::local_elements_begin(), libMesh::ParallelMesh::local_elements_begin(), libMesh::SerialMesh::local_elements_end(), libMesh::ParallelMesh::local_elements_end(), libMesh::SerialMesh::local_level_elements_begin(), libMesh::ParallelMesh::local_level_elements_begin(), libMesh::SerialMesh::local_level_elements_end(), libMesh::ParallelMesh::local_level_elements_end(), libMesh::SerialMesh::local_nodes_begin(), libMesh::ParallelMesh::local_nodes_begin(), libMesh::SerialMesh::local_nodes_end(), libMesh::ParallelMesh::local_nodes_end(), libMesh::SerialMesh::local_not_level_elements_begin(), libMesh::ParallelMesh::local_not_level_elements_begin(), libMesh::SerialMesh::local_not_level_elements_end(), libMesh::ParallelMesh::local_not_level_elements_end(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::DofMap::n_local_dofs(), libMesh::System::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::SerialMesh::not_local_elements_begin(), libMesh::ParallelMesh::not_local_elements_begin(), libMesh::SerialMesh::not_local_elements_end(), libMesh::ParallelMesh::not_local_elements_end(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SparsityPattern::Build::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::MeshFunction::operator()(), libMesh::ParallelMesh::ParallelMesh(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::System::project_vector(), 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::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::UnstructuredMesh::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::System::read_serialized_data(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::MeshData::read_xdr(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::BoundaryInfo::sync(), libMesh::MeshTools::total_weight(), libMesh::ParallelMesh::update_parallel_id_counts(), libMesh::MeshTools::weight(), libMesh::ExodusII_IO::write(), libMesh::CheckpointIO::write(), libMesh::XdrIO::write(), libMesh::UnstructuredMesh::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_Helper::write_elements_discontinuous(), libMesh::ExodusII_IO::write_global_data(), libMesh::ExodusII_IO_Helper::write_global_values(), libMesh::System::write_header(), libMesh::ExodusII_IO::write_information_records(), libMesh::ExodusII_IO_Helper::write_information_records(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates_discontinuous(), 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::ExodusII_IO_Helper::write_nodesets(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::System::write_serialized_data(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::System::write_serialized_vector(), libMesh::System::write_serialized_vectors(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), and libMesh::ExodusII_IO_Helper::write_timestep().

99  { return libmesh_cast_int<processor_id_type>(_communicator.rank()); }
void libMesh::System::project_solution ( FunctionBase< Number > *  f,
FunctionBase< Gradient > *  g = NULL 
) 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 470 of file system_projection.C.

References libMesh::System::_dof_map, libMesh::System::current_local_solution, libMesh::System::project_vector(), and libMesh::System::solution.

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

472 {
473  this->project_vector(*solution, f, g);
474 
475  solution->localize(*current_local_solution, _dof_map->get_send_list());
476 }
void libMesh::System::project_solution ( FEMFunctionBase< Number > *  f,
FEMFunctionBase< Gradient > *  g = NULL 
) 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 483 of file system_projection.C.

References libMesh::System::_dof_map, libMesh::System::current_local_solution, libMesh::System::project_vector(), and libMesh::System::solution.

485 {
486  this->project_vector(*solution, f, g);
487 
488  solution->localize(*current_local_solution, _dof_map->get_send_list());
489 }
void libMesh::System::project_solution ( Number   fptrconst Point &p,const Parameters &parameters,const std::string &sys_name,const std::string &unknown_name,
Gradient   gptrconst Point &p,const Parameters &parameters,const std::string &sys_name,const std::string &unknown_name,
const Parameters parameters 
) const
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.

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

Definition at line 450 of file system_projection.C.

References libMesh::System::project_solution().

459 {
460  WrappedFunction<Number> f(*this, fptr, &parameters);
461  WrappedFunction<Gradient> g(*this, gptr, &parameters);
462  this->project_solution(&f, &g);
463 }
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 763 of file system.h.

References libMesh::System::_solution_projection.

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

764  { return _solution_projection; }
void libMesh::System::project_vector ( NumericVector< Number > &  new_vector,
FunctionBase< Number > *  f,
FunctionBase< Gradient > *  g = NULL 
) 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.

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

Definition at line 516 of file system_projection.C.

References libMesh::NumericVector< T >::close(), libMesh::dof_map, libMesh::DofMap::enforce_constraints_exactly(), libMesh::FEType::family, libMesh::System::get_dof_map(), libMesh::System::get_equation_systems(), libMesh::System::get_mesh(), libMesh::System::n_components(), libMesh::ParallelObject::n_processors(), libMesh::System::n_vars(), libMesh::Threads::parallel_for(), libMesh::ParallelObject::processor_id(), libMeshEnums::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), libMesh::NumericVector< T >::set(), libMesh::START_LOG(), libMesh::STOP_LOG(), libMesh::System::time, libMesh::Variable::type(), libMesh::System::variable(), and libMesh::System::variable_scalar_number().

Referenced by libMesh::System::project_solution(), libMesh::System::project_vector(), and libMesh::System::restrict_vectors().

519 {
520  START_LOG ("project_vector()", "System");
521 
523  (ConstElemRange (this->get_mesh().active_local_elements_begin(),
524  this->get_mesh().active_local_elements_end() ),
525  ProjectSolution(*this, f, g,
526  this->get_equation_systems().parameters,
527  new_vector)
528  );
529 
530  // Also, load values into the SCALAR dofs
531  // Note: We assume that all SCALAR dofs are on the
532  // processor with highest ID
533  if(this->processor_id() == (this->n_processors()-1))
534  {
535  // We get different scalars as different
536  // components from a new-style f functor.
537  DenseVector<Number> fout(this->n_components());
538  bool filled_fout = false;
539 
540  const DofMap& dof_map = this->get_dof_map();
541  for (unsigned int var=0; var<this->n_vars(); var++)
542  if(this->variable(var).type().family == SCALAR)
543  {
544  if (!filled_fout)
545  {
546  (*f) (Point(), this->time, fout);
547  filled_fout = true;
548  }
549 
550  std::vector<dof_id_type> SCALAR_indices;
551  dof_map.SCALAR_dof_indices (SCALAR_indices, var);
552  const unsigned int n_SCALAR_dofs =
553  libmesh_cast_int<unsigned int>(SCALAR_indices.size());
554 
555  for (unsigned int i=0; i<n_SCALAR_dofs; i++)
556  {
557  const dof_id_type global_index = SCALAR_indices[i];
558  const unsigned int component_index =
559  this->variable_scalar_number(var,i);
560  new_vector.set(global_index, fout(component_index));
561  }
562  }
563  }
564 
565  new_vector.close();
566 
567 #ifdef LIBMESH_ENABLE_CONSTRAINTS
568  this->get_dof_map().enforce_constraints_exactly(*this, &new_vector);
569 #endif
570 
571  STOP_LOG("project_vector()", "System");
572 }
void libMesh::System::project_vector ( NumericVector< Number > &  new_vector,
FEMFunctionBase< Number > *  f,
FEMFunctionBase< Gradient > *  g = NULL 
) 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.

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

Definition at line 579 of file system_projection.C.

References libMesh::MeshBase::active_local_elements_begin(), libMesh::NumericVector< T >::close(), libMesh::FEMFunctionBase< Output >::component(), libMesh::dof_map, libMesh::DofMap::enforce_constraints_exactly(), libMesh::FEType::family, libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::ParallelObject::n_processors(), libMesh::System::n_vars(), libMesh::Threads::parallel_for(), libMesh::FEMContext::pre_fe_reinit(), libMesh::ParallelObject::processor_id(), libMeshEnums::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), libMesh::NumericVector< T >::set(), libMesh::START_LOG(), libMesh::STOP_LOG(), libMesh::System::time, libMesh::Variable::type(), libMesh::System::variable(), and libMesh::System::variable_scalar_number().

582 {
583  START_LOG ("project_fem_vector()", "System");
584 
586  (ConstElemRange (this->get_mesh().active_local_elements_begin(),
587  this->get_mesh().active_local_elements_end() ),
588  ProjectFEMSolution(*this, f, g, new_vector)
589  );
590 
591  // Also, load values into the SCALAR dofs
592  // Note: We assume that all SCALAR dofs are on the
593  // processor with highest ID
594  if(this->processor_id() == (this->n_processors()-1))
595  {
596  // FIXME: Do we want to first check for SCALAR vars before building this? [PB]
597  FEMContext context( *this );
598 
599  const DofMap& dof_map = this->get_dof_map();
600  for (unsigned int var=0; var<this->n_vars(); var++)
601  if(this->variable(var).type().family == SCALAR)
602  {
603  // FIXME: We reinit with an arbitrary element in case the user
604  // doesn't override FEMFunctionBase::component. Is there
605  // any use case we're missing? [PB]
606  Elem *el = const_cast<Elem *>(*(this->get_mesh().active_local_elements_begin()));
607  context.pre_fe_reinit( *this, el );
608 
609  std::vector<dof_id_type> SCALAR_indices;
610  dof_map.SCALAR_dof_indices (SCALAR_indices, var);
611  const unsigned int n_SCALAR_dofs =
612  libmesh_cast_int<unsigned int>(SCALAR_indices.size());
613 
614  for (unsigned int i=0; i<n_SCALAR_dofs; i++)
615  {
616  const dof_id_type global_index = SCALAR_indices[i];
617  const unsigned int component_index =
618  this->variable_scalar_number(var,i);
619 
620  new_vector.set(global_index, f->component(context, component_index, Point(), this->time));
621  }
622  }
623  }
624 
625  new_vector.close();
626 
627 #ifdef LIBMESH_ENABLE_CONSTRAINTS
628  this->get_dof_map().enforce_constraints_exactly(*this, &new_vector);
629 #endif
630 
631  STOP_LOG("project_fem_vector()", "System");
632 }
void libMesh::System::project_vector ( Number   fptrconst Point &p,const Parameters &parameters,const std::string &sys_name,const std::string &unknown_name,
Gradient   gptrconst Point &p,const Parameters &parameters,const std::string &sys_name,const std::string &unknown_name,
const Parameters parameters,
NumericVector< Number > &  new_vector 
) 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.

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

Definition at line 496 of file system_projection.C.

References libMesh::System::project_vector().

506 {
507  WrappedFunction<Number> f(*this, fptr, &parameters);
508  WrappedFunction<Gradient> g(*this, gptr, &parameters);
509  this->project_vector(new_vector, &f, &g);
510 }
void libMesh::System::project_vector ( NumericVector< Number > &  vector) const
protectedinherited

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

Definition at line 255 of file system_projection.C.

References libMesh::NumericVector< T >::clone(), and libMesh::System::project_vector().

256 {
257  // Create a copy of the vector, which currently
258  // contains the old data.
259  AutoPtr<NumericVector<Number> >
260  old_vector (vector.clone());
261 
262  // Project the old vector to the new vector
263  this->project_vector (*old_vector, vector);
264 }
void libMesh::System::project_vector ( const NumericVector< Number > &  old_v,
NumericVector< Number > &  new_v 
) 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.

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

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

Definition at line 272 of file system_projection.C.

References libMesh::NumericVector< T >::build(), libMesh::NumericVector< T >::clear(), libMesh::NumericVector< T >::close(), libMesh::ParallelObject::comm(), libMesh::dof_map, libMesh::DofMap::enforce_constraints_exactly(), libMesh::err, libMesh::FEType::family, libMesh::AutoPtr< Tp >::get(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMeshEnums::GHOSTED, libMesh::NumericVector< T >::init(), libMesh::libmesh_assert(), libMesh::NumericVector< T >::local_size(), libMesh::NumericVector< T >::localize(), libMesh::System::n_dofs(), libMesh::System::n_local_dofs(), libMesh::ParallelObject::n_processors(), libMesh::System::n_vars(), libMeshEnums::PARALLEL, libMesh::Threads::parallel_for(), libMesh::Threads::parallel_reduce(), libMesh::ParallelObject::processor_id(), libMeshEnums::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), libMesh::BuildProjectionList::send_list, libMeshEnums::SERIAL, libMesh::NumericVector< T >::set(), libMesh::NumericVector< T >::size(), libMesh::START_LOG(), libMesh::STOP_LOG(), libMesh::Variable::type(), libMesh::NumericVector< T >::type(), libMesh::BuildProjectionList::unique(), and libMesh::System::variable().

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

Prolong vectors after the mesh has refined

Definition at line 371 of file system.C.

References libMesh::System::restrict_vectors().

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

372 {
373 #ifdef LIBMESH_ENABLE_AMR
374  // Currently project_vector handles both restriction and prolongation
375  this->restrict_vectors();
376 #endif
377 }
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 2174 of file system.h.

2177 {
2178  libmesh_not_implemented();
2179 }
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 2183 of file system.h.

2187 {
2188  libmesh_not_implemented();
2189 }
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 that 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 overload an implementation.

Definition at line 510 of file system.C.

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

513 {
514  // Forward sensitivities are more efficient for Nq > Np
515  if (qoi_indices.size(*this) > parameters.size())
516  forward_qoi_parameter_sensitivity(qoi_indices, parameters, sensitivities);
517  // Adjoint sensitivities are more efficient for Np > Nq,
518  // and an adjoint may be more reusable than a forward
519  // solution sensitivity in the Np == Nq case.
520  else
521  adjoint_qoi_parameter_sensitivity(qoi_indices, parameters, sensitivities);
522 }
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 432 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.

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

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

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

119 {
120  // This method implements the input of a
121  // System object, embedded in the output of
122  // an EquationSystems<T_sys>. This warrants some
123  // documentation. The output file essentially
124  // consists of 5 sections:
125  //
126  // for this system
127  //
128  // 5.) The number of variables in the system (unsigned int)
129  //
130  // for each variable in the system
131  //
132  // 6.) The name of the variable (string)
133  //
134  // 6.1.) Variable subdmains
135  //
136  // 7.) Combined in an FEType:
137  // - The approximation order(s) of the variable
138  // (Order Enum, cast to int/s)
139  // - The finite element family/ies of the variable
140  // (FEFamily Enum, cast to int/s)
141  //
142  // end variable loop
143  //
144  // 8.) The number of additional vectors (unsigned int),
145  //
146  // for each additional vector in the system object
147  //
148  // 9.) the name of the additional vector (string)
149  //
150  // end system
151  libmesh_assert (io.reading());
152 
153  // Possibly clear data structures and start from scratch.
154  if (read_header_in)
155  this->clear ();
156 
157  // Figure out if we need to read infinite element information.
158  // This will be true if the version string contains " with infinite elements"
159  const bool read_ifem_info =
160  (version.rfind(" with infinite elements") < version.size()) ||
161  libMesh::on_command_line ("--read_ifem_systems");
162 
163 
164  {
165  // 5.)
166  // Read the number of variables in the system
167  unsigned int nv=0;
168  if (this->processor_id() == 0)
169  io.data (nv);
170  this->comm().broadcast(nv);
171 
172  _written_var_indices.clear();
173  _written_var_indices.resize(nv, 0);
174 
175  for (unsigned int var=0; var<nv; var++)
176  {
177  // 6.)
178  // Read the name of the var-th variable
179  std::string var_name;
180  if (this->processor_id() == 0)
181  io.data (var_name);
182  this->comm().broadcast(var_name);
183 
184  // 6.1.)
185  std::set<subdomain_id_type> domains;
186  if (io.version() >= LIBMESH_VERSION_ID(0,7,2))
187  {
188  std::vector<subdomain_id_type> domain_array;
189  if (this->processor_id() == 0)
190  io.data (domain_array);
191  for (std::vector<subdomain_id_type>::iterator it = domain_array.begin(); it != domain_array.end(); ++it)
192  domains.insert(*it);
193  }
194  this->comm().broadcast(domains);
195 
196  // 7.)
197  // Read the approximation order(s) of the var-th variable
198  int order=0;
199  if (this->processor_id() == 0)
200  io.data (order);
201  this->comm().broadcast(order);
202 
203 
204  // do the same for infinite element radial_order
205  int rad_order=0;
206  if (read_ifem_info)
207  {
208  if (this->processor_id() == 0)
209  io.data(rad_order);
210  this->comm().broadcast(rad_order);
211  }
212 
213 
214  // Read the finite element type of the var-th variable
215  int fam=0;
216  if (this->processor_id() == 0)
217  io.data (fam);
218  this->comm().broadcast(fam);
219  FEType type;
220  type.order = static_cast<Order>(order);
221  type.family = static_cast<FEFamily>(fam);
222 
223  // Check for incompatibilities. The shape function indexing was
224  // changed for the monomial and xyz finite element families to
225  // simplify extension to arbitrary p. The consequence is that
226  // old restart files will not be read correctly. This is expected
227  // to be an unlikely occurance, but catch it anyway.
228  if (read_legacy_format)
229  if ((type.family == MONOMIAL || type.family == XYZ) &&
230  ((type.order > 2 && this->get_mesh().mesh_dimension() == 2) ||
231  (type.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  if (nvecs > 0)
285  this->_additional_data_written = true;
286 
287  for (unsigned int vec=0; vec<nvecs; vec++)
288  {
289  // 9.)
290  // Read the name of the vec-th additional vector
291  std::string vec_name;
292  if (this->processor_id() == 0)
293  io.data (vec_name);
294  this->comm().broadcast(vec_name);
295 
296  if (read_additional_data)
297  {
298  // Systems now can handle adding post-initialization vectors
299 // libmesh_assert(this->_can_add_vectors);
300  // Some systems may have added their own vectors already
301 // libmesh_assert_equal_to (this->_vectors.count(vec_name), 0);
302 
303  this->add_vector(vec_name);
304  }
305  }
306 }
void libMesh::System::read_legacy_data ( Xdr io,
const bool  read_additional_data = true 
)
inherited

Reads additional data, namely vectors, for this System.

Definition at line 310 of file system_io.C.

References libMesh::System::_additional_data_written, libMesh::System::_vectors, libMesh::System::_written_var_indices, libMesh::MeshBase::active_elements_begin(), libMesh::MeshBase::active_elements_end(), libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), end, libMesh::System::get_mesh(), libMesh::DofObject::invalid_id, libMesh::libmesh_assert(), libMesh::System::n_dofs(), libMesh::System::n_vars(), libMesh::MeshBase::nodes_begin(), libMesh::MeshBase::nodes_end(), libMesh::System::number(), libMesh::ParallelObject::processor_id(), libMesh::Xdr::reading(), libMesh::System::solution, and libMesh::zero.

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

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

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

Non-templated version for backward compatibility.

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

Definition at line 1237 of file system.h.

1239  { read_parallel_data<Number>(io, read_additional_data); }
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 710 of file system_io.C.

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

712 {
713  // This method implements the input of the vectors
714  // contained in this System object, embedded in the
715  // output of an EquationSystems<T_sys>.
716  //
717  // 10.) The global solution vector, re-ordered to be node-major
718  // (More on this later.)
719  //
720  // for each additional vector in the object
721  //
722  // 11.) The global additional vector, re-ordered to be
723  // node-major (More on this later.)
724  parallel_object_only();
725  std::string comment;
726 
727  // PerfLog pl("IO Performance",false);
728  // pl.push("read_serialized_data");
729  std::size_t total_read_size = 0;
730 
731  // 10.)
732  // Read the global solution vector
733  {
734  total_read_size +=
735  this->read_serialized_vector<InValType>(io, *this->solution);
736 
737  // get the comment
738  if (this->processor_id() == 0)
739  io.comment (comment);
740  }
741 
742  // 11.)
743  // Only read additional vectors if wanted
744  if (read_additional_data)
745  {
746  std::map<std::string, NumericVector<Number>* >::const_iterator
747  pos = _vectors.begin();
748 
749  for(; pos != this->_vectors.end(); ++pos)
750  {
751  total_read_size +=
752  this->read_serialized_vector<InValType>(io, *pos->second);
753 
754  // get the comment
755  if (this->processor_id() == 0)
756  io.comment (comment);
757 
758  }
759  }
760 
761  // const Real
762  // dt = pl.get_elapsed_time(),
763  // rate = total_read_size*sizeof(Number)/dt;
764 
765  // libMesh::out << "Read " << total_read_size << " \"Number\" values\n"
766  // << " Elapsed time = " << dt << '\n'
767  // << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";
768 
769  // pl.pop("read_serialized_data");
770 }
void libMesh::System::read_serialized_data ( Xdr io,
const bool  read_additional_data = true 
)
inlineinherited

Non-templated version for backward compatibility.

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

Definition at line 1195 of file system.h.

1197  { read_serialized_data<Number>(io, read_additional_data); }
template<typename InValType >
std::size_t libMesh::System::read_serialized_vectors ( Xdr io,
const std::vector< NumericVector< Number > * > &  vectors 
) const
inherited

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

Definition at line 2179 of file system_io.C.

References libMesh::Xdr::data(), libMesh::FEType::family, libMesh::System::get_mesh(), libMesh::libmesh_assert(), libMesh::MeshBase::n_elem(), libMesh::MeshTools::n_elem(), n_nodes, libMesh::MeshBase::n_nodes(), libMesh::System::n_vars(), libMesh::ParallelObject::processor_id(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::Xdr::reading(), libMeshEnums::SCALAR, libMesh::Variable::type(), and libMesh::System::variable().

2181 {
2182  parallel_object_only();
2183 
2184  // Error checking
2185 // #ifndef NDEBUG
2186 // // In parallel we better be reading a parallel vector -- if not
2187 // // we will not set all of its components below!!
2188 // if (this->n_processors() > 1)
2189 // {
2190 // libmesh_assert (vec.type() == PARALLEL ||
2191 // vec.type() == GHOSTED);
2192 // }
2193 // #endif
2194 
2195  libmesh_assert (io.reading());
2196 
2197  // sizes
2198  unsigned int num_vecs=0;
2199  dof_id_type vector_length=0;
2200 
2201  if (this->processor_id() == 0)
2202  {
2203  // Get the number of vectors
2204  io.data(num_vecs);
2205  // Get the buffer size
2206  io.data(vector_length);
2207 
2208  libmesh_assert_equal_to (num_vecs, vectors.size());
2209 
2210  if (num_vecs != 0)
2211  {
2212  libmesh_assert_not_equal_to (vectors[0], 0);
2213  libmesh_assert_equal_to (vectors[0]->size(), vector_length);
2214  }
2215  }
2216 
2217  // no need to actually communicate these.
2218  // this->comm().broadcast(num_vecs);
2219  // this->comm().broadcast(vector_length);
2220 
2221  // Cache these - they are not free!
2222  const dof_id_type
2223  n_nodes = this->get_mesh().n_nodes(),
2224  n_elem = this->get_mesh().n_elem();
2225 
2226  std::size_t read_length = 0.;
2227 
2228  //---------------------------------
2229  // Collect the values for all nodes
2230  read_length +=
2231  this->read_serialized_blocked_dof_objects (n_nodes,
2232  this->get_mesh().local_nodes_begin(),
2233  this->get_mesh().local_nodes_end(),
2234  InValType(),
2235  io,
2236  vectors);
2237 
2238  //------------------------------------
2239  // Collect the values for all elements
2240  read_length +=
2242  this->get_mesh().local_elements_begin(),
2243  this->get_mesh().local_elements_end(),
2244  InValType(),
2245  io,
2246  vectors);
2247 
2248  //-------------------------------------------
2249  // Finally loop over all the SCALAR variables
2250  for (unsigned int vec=0; vec<vectors.size(); vec++)
2251  for (unsigned int var=0; var<this->n_vars(); var++)
2252  if(this->variable(var).type().family == SCALAR)
2253  {
2254  libmesh_assert_not_equal_to (vectors[vec], 0);
2255 
2256  read_length +=
2257  this->read_SCALAR_dofs (var, io, *vectors[vec]);
2258  }
2259 
2260  //---------------------------------------
2261  // last step - must close all the vectors
2262  for (unsigned int vec=0; vec<vectors.size(); vec++)
2263  {
2264  libmesh_assert_not_equal_to (vectors[vec], 0);
2265  vectors[vec]->close();
2266  }
2267 
2268  return read_length;
2269 }
std::size_t libMesh::System::read_serialized_vectors ( Xdr io,
const std::vector< NumericVector< Number > * > &  vectors 
) const
inlineinherited

Non-templated version for backward compatibility.

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

Definition at line 1215 of file system.h.

1217  { return read_serialized_vectors<Number>(io, vectors); }
void libMesh::EigenSystem::reinit ( )
virtual

Reinitializes the member data fields associated with the system, so that, e.g., assemble() may be used.

Reimplemented from libMesh::System.

Definition at line 164 of file eigen_system.C.

References _is_generalized_eigenproblem, libMesh::SparseMatrix< T >::clear(), libMesh::DofMap::clear_sparsity(), libMesh::DofMap::compute_sparsity(), libMesh::dof_map, libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::SparseMatrix< T >::init(), matrix_A, matrix_B, libMesh::System::reinit(), and libMesh::SparseMatrix< T >::zero().

165 {
166  // initialize parent data
167  Parent::reinit();
168 
169  // Clear the matrices
170  matrix_A->clear();
171 
173  matrix_B->clear();
174 
175  DofMap& dof_map = this->get_dof_map();
176 
177  // Clear the sparsity pattern
178  dof_map.clear_sparsity();
179 
180  // Compute the sparsity pattern for the current
181  // mesh and DOF distribution. This also updates
182  // both matrices, \p DofMap now knows them
183  dof_map.compute_sparsity(this->get_mesh());
184 
185  matrix_A->init();
186  matrix_A->zero();
187 
189  {
190  matrix_B->init();
191  matrix_B->zero();
192  }
193 }
void libMesh::System::remove_vector ( const std::string &  vec_name)
inherited

Removes the additional vector vec_name from this system

Definition at line 712 of file system.C.

References libMesh::System::_vector_projections, libMesh::System::_vector_types, libMesh::System::_vectors, and libMesh::System::have_vector().

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

713 {
714  //Return if the vector does not exist
715  if ( !(this->have_vector(vec_name)) )
716  return;
717 
718  _vectors[vec_name]->clear();
719  delete _vectors[vec_name];
720  _vectors[vec_name] = NULL;
721 
722  _vectors.erase(vec_name);
723  _vector_projections.erase(vec_name);
724  _vector_types.erase(vec_name);
725 }
const NumericVector< Number > * libMesh::System::request_vector ( const std::string &  vec_name) const
inherited
Returns
a const pointer to the vector if this System has a vector associated with the given name, NULL otherwise.

Definition at line 727 of file system.C.

References libMesh::System::_vectors.

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

728 {
729  const_vectors_iterator pos = _vectors.find(vec_name);
730 
731  if (pos == _vectors.end())
732  return NULL;
733 
734  return pos->second;
735 }
NumericVector< Number > * libMesh::System::request_vector ( const std::string &  vec_name)
inherited
Returns
a pointer to the vector if this System has a vector associated with the given name, NULL otherwise.

Definition at line 739 of file system.C.

References libMesh::System::_vectors.

740 {
741  vectors_iterator pos = _vectors.find(vec_name);
742 
743  if (pos == _vectors.end())
744  return NULL;
745 
746  return pos->second;
747 }
const NumericVector< Number > * libMesh::System::request_vector ( const unsigned int  vec_num) const
inherited
Returns
a const pointer to this system's additional vector number vec_num (where the vectors are counted starting with 0), or returns NULL if the system has no such vector.

Definition at line 751 of file system.C.

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

752 {
755  unsigned int num = 0;
756  while((num<vec_num) && (v!=v_end))
757  {
758  num++;
759  ++v;
760  }
761  if (v==v_end)
762  return NULL;
763  return v->second;
764 }
NumericVector< Number > * libMesh::System::request_vector ( const unsigned int  vec_num)
inherited
Returns
a writeable pointer to this system's additional vector number vec_num (where the vectors are counted starting with 0), or returns NULL if the system has no such vector.

Definition at line 768 of file system.C.

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

769 {
771  vectors_iterator v_end = vectors_end();
772  unsigned int num = 0;
773  while((num<vec_num) && (v!=v_end))
774  {
775  num++;
776  ++v;
777  }
778  if (v==v_end)
779  return NULL;
780  return v->second;
781 }
void libMesh::System::restrict_solve_to ( const SystemSubset subset,
const SubsetSolveMode  subset_solve_mode = SUBSET_ZERO 
)
virtualinherited

After calling this method, any solve will be restricted to the given subdomain. To disable this mode, call this method with subset being a NULL pointer.

Reimplemented in libMesh::LinearImplicitSystem.

Definition at line 456 of file system.C.

458 {
459  if(subset!=NULL)
460  {
461  libmesh_not_implemented();
462  }
463 }
void libMesh::System::restrict_vectors ( )
virtualinherited

Restrict vectors after the mesh has coarsened

Definition at line 319 of file system.C.

References libMesh::System::_dof_map, libMesh::System::_solution_projection, libMesh::System::_vector_projections, libMesh::System::_vector_types, libMesh::System::_vectors, libMesh::System::current_local_solution, libMesh::err, libMeshEnums::GHOSTED, libMesh::System::n_dofs(), libMesh::System::n_local_dofs(), libMesh::System::project_vector(), and libMesh::System::solution.

Referenced by libMesh::System::prolong_vectors(), and libMesh::EquationSystems::reinit().

320 {
321 #ifdef LIBMESH_ENABLE_AMR
322  // Restrict the _vectors on the coarsened cells
323  for (vectors_iterator pos = _vectors.begin(); pos != _vectors.end(); ++pos)
324  {
325  NumericVector<Number>* v = pos->second;
326 
327  if (_vector_projections[pos->first])
328  this->project_vector (*v);
329  else
330  {
331  ParallelType type = _vector_types[pos->first];
332 
333  if(type == GHOSTED)
334  {
335 #ifdef LIBMESH_ENABLE_GHOSTED
336  pos->second->init (this->n_dofs(), this->n_local_dofs(),
337  _dof_map->get_send_list(), false,
338  GHOSTED);
339 #else
340  libMesh::err << "Cannot initialize ghosted vectors when they are not enabled." << std::endl;
341  libmesh_error();
342 #endif
343  }
344  else
345  pos->second->init (this->n_dofs(), this->n_local_dofs(), false, type);
346  }
347  }
348 
349  const std::vector<dof_id_type>& send_list = _dof_map->get_send_list ();
350 
351  // Restrict the solution on the coarsened cells
353  this->project_vector (*solution);
354 
355 #ifdef LIBMESH_ENABLE_GHOSTED
356  current_local_solution->init(this->n_dofs(),
357  this->n_local_dofs(), send_list,
358  false, GHOSTED);
359 #else
360  current_local_solution->init(this->n_dofs());
361 #endif
362 
364  solution->localize (*current_local_solution, send_list);
365 
366 #endif // LIBMESH_ENABLE_AMR
367 }
std::pair< unsigned int, Real > libMesh::System::sensitivity_solve ( const ParameterVector parameters)
inlinevirtualinherited

Solves the sensitivity system, for the provided parameters. Must be overloaded in derived systems.

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

This method is only implemented in some derived classes.

Reimplemented in libMesh::ImplicitSystem.

Definition at line 2125 of file system.h.

2126 {
2127  libmesh_not_implemented();
2128 }
void libMesh::System::set_adjoint_already_solved ( bool  setting)
inlineinherited

Setter for the adjoint_already_solved boolean

Definition at line 367 of file system.h.

References libMesh::System::adjoint_already_solved.

368  { adjoint_already_solved = setting;}
void libMesh::System::set_basic_system_only ( )
inlineinherited

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

Definition at line 1943 of file system.h.

References libMesh::System::_basic_system_only.

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

1944 {
1945  _basic_system_only = true;
1946 }
void libMesh::EigenSystem::set_eigenproblem_type ( EigenProblemType  ept)

Sets the type of the current eigen problem.

Definition at line 85 of file eigen_system.C.

References _eigen_problem_type, eigen_solver, libMeshEnums::GHEP, libMeshEnums::GNHEP, libMeshEnums::HEP, and libMeshEnums::NHEP.

86 {
87  _eigen_problem_type = ept;
88 
89  eigen_solver->set_eigenproblem_type(ept);
90 
91  // libMesh::out<< "The Problem type is set to be: "<<std::endl;
92 
93  switch (_eigen_problem_type)
94  {
95  case HEP: // libMesh::out<<"Hermitian"<<std::endl;
96  break;
97 
98  case NHEP: // libMesh::out<<"Non-Hermitian"<<std::endl;
99  break;
100 
101  case GHEP: // libMesh::out<<"Gerneralized Hermitian"<<std::endl;
102  break;
103 
104  case GNHEP: // libMesh::out<<"Generalized Non-Hermitian"<<std::endl;
105  break;
106 
107  default: // libMesh::out<<"not properly specified"<<std::endl;
108  libmesh_error();
109  break;
110 
111  }
112 }
void libMesh::EigenSystem::set_n_converged ( unsigned int  nconv)
inlineprotected

Set the _n_converged_eigenpairs member, useful for subclasses of EigenSystem.

Definition at line 185 of file eigen_system.h.

References _n_converged_eigenpairs.

Referenced by libMesh::CondensedEigenSystem::solve().

186  { _n_converged_eigenpairs = nconv; }
void libMesh::EigenSystem::set_n_iterations ( unsigned int  its)
inlineprotected

Set the _n_iterations member, useful for subclasses of EigenSystem.

Definition at line 192 of file eigen_system.h.

References _n_iterations.

Referenced by libMesh::CondensedEigenSystem::solve().

193  { _n_iterations = its;}
void libMesh::System::set_vector_preservation ( const std::string &  vec_name,
bool  preserve 
)
inherited

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

Definition at line 888 of file system.C.

References libMesh::System::_vector_projections.

890 {
891  _vector_projections[vec_name] = preserve;
892 }
void libMesh::EigenSystem::solve ( )
virtual

Assembles & solves the eigen system.

Reimplemented from libMesh::System.

Reimplemented in libMesh::CondensedEigenSystem.

Definition at line 197 of file eigen_system.C.

References _is_generalized_eigenproblem, _n_converged_eigenpairs, _n_iterations, assemble(), libMesh::System::assemble_before_solve, eigen_solver, libMesh::Parameters::get(), libMesh::System::get_equation_systems(), libMesh::Parameters::have_parameter(), libMesh::libmesh_assert(), matrix_A, matrix_B, libMesh::EquationSystems::parameters, and libMesh::Real.

Referenced by libMesh::CondensedEigenSystem::solve().

198 {
199 
200  // A reference to the EquationSystems
201  EquationSystems& es = this->get_equation_systems();
202 
203  // check that necessary parameters have been set
204  libmesh_assert (es.parameters.have_parameter<unsigned int>("eigenpairs"));
205  libmesh_assert (es.parameters.have_parameter<unsigned int>("basis vectors"));
206 
207  if (this->assemble_before_solve)
208  // Assemble the linear system
209  this->assemble ();
210 
211  // Get the tolerance for the solver and the maximum
212  // number of iterations. Here, we simply adopt the linear solver
213  // specific parameters.
214  const Real tol =
215  es.parameters.get<Real>("linear solver tolerance");
216 
217  const unsigned int maxits =
218  es.parameters.get<unsigned int>("linear solver maximum iterations");
219 
220  const unsigned int nev =
221  es.parameters.get<unsigned int>("eigenpairs");
222 
223  const unsigned int ncv =
224  es.parameters.get<unsigned int>("basis vectors");
225 
226  std::pair<unsigned int, unsigned int> solve_data;
227 
228  // call the solver depending on the type of eigenproblem
230  {
231  //in case of a generalized eigenproblem
232  solve_data = eigen_solver->solve_generalized (*matrix_A,*matrix_B, nev, ncv, tol, maxits);
233 
234  }
235 
236  else
237  {
239 
240  //in case of a standard eigenproblem
241  solve_data = eigen_solver->solve_standard (*matrix_A, nev, ncv, tol, maxits);
242 
243  }
244 
245  this->_n_converged_eigenpairs = solve_data.first;
246  this->_n_iterations = solve_data.second;
247 
248 }
sys_type& libMesh::EigenSystem::system ( )
inline
Returns
a clever pointer to the system.

Definition at line 83 of file eigen_system.h.

83 { return *this; }
virtual std::string libMesh::EigenSystem::system_type ( ) const
inlinevirtual
Returns
"Eigen". Helps in identifying the system type in an equation system file.

Reimplemented from libMesh::System.

Definition at line 117 of file eigen_system.h.

117 { return "Eigen"; }
void libMesh::System::update ( )
virtualinherited

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

Definition at line 411 of file system.C.

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

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_petsc_snes_jacobian(), libMesh::__libmesh_petsc_snes_residual(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::FEMSystem::assemble_qoi(), libMesh::FEMSystem::assemble_qoi_derivative(), libMesh::FEMSystem::assembly(), libMesh::NonlinearImplicitSystem::assembly(), libMesh::EquationSystems::build_solution_vector(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::GMVIO::copy_nodal_solution(), DMlibMeshFunction(), DMlibMeshJacobian(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::EquationSystems::get_solution(), libMesh::FEMSystem::mesh_position_get(), libMesh::FEMSystem::postprocess(), libMesh::NewtonSolver::solve(), libMesh::ExplicitSystem::solve(), libMesh::LinearImplicitSystem::solve(), and libMesh::NonlinearImplicitSystem::solve().

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

Fill the input vector global_soln so that it contains the global solution on all processors. Requires communication with all other processors.

Definition at line 657 of file system.C.

References libMesh::System::solution.

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

658 {
659  global_soln.resize (solution->size());
660 
661  solution->localize (global_soln);
662 }
void libMesh::System::update_global_solution ( std::vector< Number > &  global_soln,
const unsigned int  dest_proc 
) const
inherited

Fill the input vector global_soln so that it contains the global solution on processor dest_proc. Requires communication with all other processors.

Definition at line 666 of file system.C.

References libMesh::System::solution.

668 {
669  global_soln.resize (solution->size());
670 
671  solution->localize_to_one (global_soln, dest_proc);
672 }
void libMesh::System::user_assembly ( )
virtualinherited

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

Definition at line 1910 of file system.C.

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

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

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

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

Definition at line 1924 of file system.C.

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

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

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

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

Definition at line 1896 of file system.C.

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

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

1897 {
1898  // Call the user-provided intialization function,
1899  // if it was provided
1900  if (_init_system_function != NULL)
1901  this->_init_system_function (_equation_systems, this->name());
1902 
1903  // ...or the user-provided initialization object.
1904  else if (_init_system_object != NULL)
1906 }
void libMesh::System::user_QOI ( const QoISet qoi_indices)
virtualinherited

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

Definition at line 1938 of file system.C.

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

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

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

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

Definition at line 1952 of file system.C.

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

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

1953 {
1954  // Call the user-provided quantity of interest derivative,
1955  // if it was provided
1957  this->_qoi_evaluate_derivative_function(_equation_systems, this->name(), qoi_indices);
1958 
1959  // ...or the user-provided QOI derivative function object.
1960  else if (_qoi_evaluate_derivative_object != NULL)
1961  this->_qoi_evaluate_derivative_object->qoi_derivative(qoi_indices);
1962 }
const VariableGroup & libMesh::System::variable_group ( unsigned int  vg) const
inlineinherited

Return a constant reference to VariableGroup vg.

Definition at line 1989 of file system.h.

References libMesh::System::_variable_groups.

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

1990 {
1991  libmesh_assert_less (vg, _variable_groups.size());
1992 
1993  return _variable_groups[vg];
1994 }
const std::string & libMesh::System::variable_name ( const unsigned int  i) const
inlineinherited
unsigned short int libMesh::System::variable_number ( const std::string &  var) const
inherited
Returns
the variable number assoicated with the user-specified variable named var.

Definition at line 1240 of file system.C.

References libMesh::System::_variable_numbers, libMesh::System::_variables, and libMesh::err.

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::GMVIO::copy_nodal_solution(), libMesh::ExactErrorEstimator::find_squared_element_error(), libMesh::for(), libMesh::System::read_header(), libMesh::System::variable_scalar_number(), libMesh::System::variable_type(), libMesh::EnsightIO::write_scalar_ascii(), and libMesh::EnsightIO::write_vector_ascii().

1241 {
1242  // Make sure the variable exists
1243  std::map<std::string, unsigned short int>::const_iterator
1244  pos = _variable_numbers.find(var);
1245 
1246  if (pos == _variable_numbers.end())
1247  {
1248  libMesh::err << "ERROR: variable "
1249  << var
1250  << " does not exist in this system!"
1251  << std::endl;
1252  libmesh_error();
1253  }
1254  libmesh_assert_equal_to (_variables[pos->second].name(), var);
1255 
1256  return pos->second;
1257 }
unsigned int libMesh::System::variable_scalar_number ( const std::string &  var,
unsigned int  component 
) const
inlineinherited
Returns
an index, starting from 0 for the first component of the first variable, and incrementing for each component of each (potentially vector-valued) variable in the system in order. For systems with only scalar-valued variables, this will be the same as variable_number(var)

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

Definition at line 2010 of file system.h.

References libMesh::System::variable_number().

Referenced by libMesh::ExactSolution::_compute_error(), libMesh::ExactErrorEstimator::find_squared_element_error(), libMesh::ProjectSolution::operator()(), libMesh::ProjectFEMSolution::operator()(), libMesh::BoundaryProjectSolution::operator()(), and libMesh::System::project_vector().

2012 {
2013  return variable_scalar_number(this->variable_number(var), component);
2014 }
unsigned int libMesh::System::variable_scalar_number ( unsigned int  var_num,
unsigned int  component 
) const
inlineinherited
Returns
an index, starting from 0 for the first component of the first variable, and incrementing for each component of each (potentially vector-valued) variable in the system in order. For systems with only scalar-valued variables, this will be the same as var_num

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

Definition at line 2020 of file system.h.

References libMesh::System::_variables.

2022 {
2023  return _variables[var_num].first_scalar_number() + component;
2024 }
const FEType & libMesh::System::variable_type ( const std::string &  var) const
inlineinherited
Returns
the finite element type for variable var.

Definition at line 2039 of file system.h.

References libMesh::System::_variables, and libMesh::System::variable_number().

2040 {
2041  return _variables[this->variable_number(var)].type();
2042 }
const std::string & libMesh::System::vector_name ( const unsigned int  vec_num) const
inherited
Returns
the name of this system's additional vector number vec_num (where the vectors are counted starting with 0).

Definition at line 855 of file system.C.

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

856 {
859  unsigned int num = 0;
860  while((num<vec_num) && (v!=v_end))
861  {
862  num++;
863  ++v;
864  }
865  libmesh_assert (v != v_end);
866  return v->first;
867 }
const std::string & libMesh::System::vector_name ( const NumericVector< Number > &  vec_reference) const
inherited
Returns
the name of a system vector, given a reference to that vector

Definition at line 869 of file system.C.

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

870 {
873 
874  for(; v != v_end; ++v)
875  {
876  // Check if the current vector is the one whose name we want
877  if(&vec_reference == v->second)
878  break; // exit loop if it is
879  }
880 
881  // Before returning, make sure we didnt loop till the end and not find any match
882  libmesh_assert (v != v_end);
883 
884  // Return the string associated with the current vector
885  return v->first;
886 }
bool libMesh::System::vector_preservation ( const std::string &  vec_name) const
inherited
Returns
the boolean describing whether the vector identified by vec_name should be "preserved": projected to new meshes, saved, etc.

Definition at line 896 of file system.C.

References libMesh::System::_vector_projections.

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

897 {
898  if (_vector_projections.find(vec_name) == _vector_projections.end())
899  return false;
900 
901  return _vector_projections.find(vec_name)->second;
902 }
System::const_vectors_iterator libMesh::System::vectors_begin ( ) const
inlineinherited

Beginning of vectors container

Definition at line 2097 of file system.h.

References libMesh::System::_vectors.

2098 {
2099  return _vectors.begin();
2100 }
System::const_vectors_iterator libMesh::System::vectors_end ( ) const
inlineinherited

End of vectors container

Definition at line 2109 of file system.h.

References libMesh::System::_vectors.

2110 {
2111  return _vectors.end();
2112 }
std::pair< unsigned int, Real > libMesh::System::weighted_sensitivity_adjoint_solve ( const ParameterVector parameters,
const ParameterVector weights,
const QoISet qoi_indices = QoISet() 
)
inlinevirtualinherited

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

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

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

This method is only implemented in some derived classes.

Reimplemented in libMesh::ImplicitSystem.

Definition at line 2147 of file system.h.

2150 {
2151  libmesh_not_implemented();
2152 }
std::pair< unsigned int, Real > libMesh::System::weighted_sensitivity_solve ( const ParameterVector parameters,
const ParameterVector weights 
)
inlinevirtualinherited

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

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

This method is only implemented in some derived classes.

Reimplemented in libMesh::ImplicitSystem.

Definition at line 2132 of file system.h.

2134 {
2135  libmesh_not_implemented();
2136 }
void libMesh::System::write_header ( Xdr io,
const std::string &  version,
const bool  write_additional_data 
) const
inherited

Writes the basic data header for this System.

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

for this system

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

for each variable in the system

6.) The name of the variable (string)

6.1.) subdomain where the variable lives

7.) Combined in an FEType:

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

end variable loop

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

for each additional vector in the system object

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

end system

Definition at line 1254 of file system_io.C.

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

1257 {
1291  libmesh_assert (io.writing());
1292 
1293 
1294  // Only write the header information
1295  // if we are processor 0.
1296  if (this->get_mesh().processor_id() != 0)
1297  return;
1298 
1299  std::string comment;
1300  char buf[80];
1301 
1302  // 5.)
1303  // Write the number of variables in the system
1304 
1305  {
1306  // set up the comment
1307  comment = "# No. of Variables in System \"";
1308  comment += this->name();
1309  comment += "\"";
1310 
1311  unsigned int nv = this->n_vars();
1312  io.data (nv, comment.c_str());
1313  }
1314 
1315 
1316  for (unsigned int var=0; var<this->n_vars(); var++)
1317  {
1318  // 6.)
1319  // Write the name of the var-th variable
1320  {
1321  // set up the comment
1322  comment = "# Name, Variable No. ";
1323  std::sprintf(buf, "%d", var);
1324  comment += buf;
1325  comment += ", System \"";
1326  comment += this->name();
1327  comment += "\"";
1328 
1329  std::string var_name = this->variable_name(var);
1330  io.data (var_name, comment.c_str());
1331  }
1332 
1333  // 6.1.) Variable subdomains
1334  {
1335  // set up the comment
1336  comment = "# Subdomains, Variable \"";
1337  std::sprintf(buf, "%s", this->variable_name(var).c_str());
1338  comment += buf;
1339  comment += "\", System \"";
1340  comment += this->name();
1341  comment += "\"";
1342 
1343  const std::set<subdomain_id_type> & domains = this->variable(var).active_subdomains();
1344  std::vector<subdomain_id_type> domain_array;
1345  domain_array.assign(domains.begin(), domains.end());
1346  io.data (domain_array, comment.c_str());
1347  }
1348 
1349  // 7.)
1350  // Write the approximation order of the var-th variable
1351  // in this system
1352  {
1353  // set up the comment
1354  comment = "# Approximation Order, Variable \"";
1355  std::sprintf(buf, "%s", this->variable_name(var).c_str());
1356  comment += buf;
1357  comment += "\", System \"";
1358  comment += this->name();
1359  comment += "\"";
1360 
1361  int order = static_cast<int>(this->variable_type(var).order);
1362  io.data (order, comment.c_str());
1363  }
1364 
1365 
1366 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1367 
1368  // do the same for radial_order
1369  {
1370  comment = "# Radial Approximation Order, Variable \"";
1371  std::sprintf(buf, "%s", this->variable_name(var).c_str());
1372  comment += buf;
1373  comment += "\", System \"";
1374  comment += this->name();
1375  comment += "\"";
1376 
1377  int rad_order = static_cast<int>(this->variable_type(var).radial_order);
1378  io.data (rad_order, comment.c_str());
1379  }
1380 
1381 #endif
1382 
1383  // Write the Finite Element type of the var-th variable
1384  // in this System
1385  {
1386  // set up the comment
1387  comment = "# FE Family, Variable \"";
1388  std::sprintf(buf, "%s", this->variable_name(var).c_str());
1389  comment += buf;
1390  comment += "\", System \"";
1391  comment += this->name();
1392  comment += "\"";
1393 
1394  const FEType& type = this->variable_type(var);
1395  int fam = static_cast<int>(type.family);
1396  io.data (fam, comment.c_str());
1397 
1398 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1399 
1400  comment = "# Radial FE Family, Variable \"";
1401  std::sprintf(buf, "%s", this->variable_name(var).c_str());
1402  comment += buf;
1403  comment += "\", System \"";
1404  comment += this->name();
1405  comment += "\"";
1406 
1407  int radial_fam = static_cast<int>(type.radial_family);
1408  io.data (radial_fam, comment.c_str());
1409 
1410  comment = "# Infinite Mapping Type, Variable \"";
1411  std::sprintf(buf, "%s", this->variable_name(var).c_str());
1412  comment += buf;
1413  comment += "\", System \"";
1414  comment += this->name();
1415  comment += "\"";
1416 
1417  int i_map = static_cast<int>(type.inf_map);
1418  io.data (i_map, comment.c_str());
1419 #endif
1420  }
1421  } // end of the variable loop
1422 
1423  // 8.)
1424  // Write the number of additional vectors in the System.
1425  // If write_additional_data==false, then write zero for
1426  // the number of additional vectors.
1427  {
1428  {
1429  // set up the comment
1430  comment = "# No. of Additional Vectors, System \"";
1431  comment += this->name();
1432  comment += "\"";
1433 
1434  unsigned int nvecs = write_additional_data ? this->n_vectors () : 0;
1435  io.data (nvecs, comment.c_str());
1436  }
1437 
1438  if (write_additional_data)
1439  {
1440  std::map<std::string, NumericVector<Number>* >::const_iterator
1441  vec_pos = this->_vectors.begin();
1442  unsigned int cnt=0;
1443 
1444  for (; vec_pos != this->_vectors.end(); ++vec_pos)
1445  {
1446  // 9.)
1447  // write the name of the cnt-th additional vector
1448  comment = "# Name of ";
1449  std::sprintf(buf, "%d", cnt++);
1450  comment += buf;
1451  comment += "th vector";
1452  std::string vec_name = vec_pos->first;
1453 
1454  io.data (vec_name, comment.c_str());
1455  }
1456  }
1457  }
1458 }
void libMesh::System::write_parallel_data ( Xdr io,
const bool  write_additional_data 
) const
inherited

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

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

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

for each additional vector in the object

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

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

Definition at line 1462 of file system_io.C.

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

1464 {
1484  // PerfLog pl("IO Performance",false);
1485  // pl.push("write_parallel_data");
1486  std::size_t total_written_size = 0;
1487 
1488  std::string comment;
1489 
1490  libmesh_assert (io.writing());
1491 
1492  std::vector<Number> io_buffer; io_buffer.reserve(this->solution->local_size());
1493 
1494  // build the ordered nodes and element maps.
1495  // when writing/reading parallel files we need to iterate
1496  // over our nodes/elements in order of increasing global id().
1497  // however, this is not guaranteed to be ordering we obtain
1498  // by using the node_iterators/element_iterators directly.
1499  // so build a set, sorted by id(), that provides the ordering.
1500  // further, for memory economy build the set but then transfer
1501  // its contents to vectors, which will be sorted.
1502  std::vector<const DofObject*> ordered_nodes, ordered_elements;
1503  {
1504  std::set<const DofObject*, CompareDofObjectsByID>
1505  ordered_nodes_set (this->get_mesh().local_nodes_begin(),
1506  this->get_mesh().local_nodes_end());
1507 
1508  ordered_nodes.insert(ordered_nodes.end(),
1509  ordered_nodes_set.begin(),
1510  ordered_nodes_set.end());
1511  }
1512  {
1513  std::set<const DofObject*, CompareDofObjectsByID>
1514  ordered_elements_set (this->get_mesh().local_elements_begin(),
1515  this->get_mesh().local_elements_end());
1516 
1517  ordered_elements.insert(ordered_elements.end(),
1518  ordered_elements_set.begin(),
1519  ordered_elements_set.end());
1520  }
1521 
1522  const unsigned int sys_num = this->number();
1523  const unsigned int nv = this->n_vars();
1524 
1525  // Loop over each non-SCALAR variable and each node, and write out the value.
1526  for (unsigned int var=0; var<nv; var++)
1527  if (this->variable(var).type().family != SCALAR)
1528  {
1529  // First write the node DOF values
1530  for (std::vector<const DofObject*>::const_iterator
1531  it = ordered_nodes.begin(); it != ordered_nodes.end(); ++it)
1532  for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++)
1533  {
1534  //libMesh::out << "(*it)->id()=" << (*it)->id() << std::endl;
1535  libmesh_assert_not_equal_to ((*it)->dof_number(sys_num, var, comp),
1537 
1538  io_buffer.push_back((*this->solution)((*it)->dof_number(sys_num, var, comp)));
1539  }
1540 
1541  // Then write the element DOF values
1542  for (std::vector<const DofObject*>::const_iterator
1543  it = ordered_elements.begin(); it != ordered_elements.end(); ++it)
1544  for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++)
1545  {
1546  libmesh_assert_not_equal_to ((*it)->dof_number(sys_num, var, comp),
1548 
1549  io_buffer.push_back((*this->solution)((*it)->dof_number(sys_num, var, comp)));
1550  }
1551  }
1552 
1553  // Finally, write the SCALAR data on the last processor
1554  for (unsigned int var=0; var<this->n_vars(); var++)
1555  if(this->variable(var).type().family == SCALAR)
1556  {
1557  if (this->processor_id() == (this->n_processors()-1))
1558  {
1559  const DofMap& dof_map = this->get_dof_map();
1560  std::vector<dof_id_type> SCALAR_dofs;
1561  dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
1562 
1563  for(unsigned int i=0; i<SCALAR_dofs.size(); i++)
1564  {
1565  io_buffer.push_back( (*this->solution)(SCALAR_dofs[i]) );
1566  }
1567  }
1568  }
1569 
1570  // 9.)
1571  //
1572  // Actually write the reordered solution vector
1573  // for the ith system to disk
1574 
1575  // set up the comment
1576  {
1577  comment = "# System \"";
1578  comment += this->name();
1579  comment += "\" Solution Vector";
1580  }
1581 
1582  io.data (io_buffer, comment.c_str());
1583 
1584  total_written_size += io_buffer.size();
1585 
1586  // Only write additional vectors if wanted
1587  if (write_additional_data)
1588  {
1589  std::map<std::string, NumericVector<Number>* >::const_iterator
1590  pos = _vectors.begin();
1591 
1592  for(; pos != this->_vectors.end(); ++pos)
1593  {
1594  io_buffer.clear(); io_buffer.reserve( pos->second->local_size());
1595 
1596  // Loop over each non-SCALAR variable and each node, and write out the value.
1597  for (unsigned int var=0; var<nv; var++)
1598  if(this->variable(var).type().family != SCALAR)
1599  {
1600  // First write the node DOF values
1601  for (std::vector<const DofObject*>::const_iterator
1602  it = ordered_nodes.begin(); it != ordered_nodes.end(); ++it)
1603  for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++)
1604  {
1605  libmesh_assert_not_equal_to ((*it)->dof_number(sys_num, var, comp),
1607 
1608  io_buffer.push_back((*pos->second)((*it)->dof_number(sys_num, var, comp)));
1609  }
1610 
1611  // Then write the element DOF values
1612  for (std::vector<const DofObject*>::const_iterator
1613  it = ordered_elements.begin(); it != ordered_elements.end(); ++it)
1614  for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++)
1615  {
1616  libmesh_assert_not_equal_to ((*it)->dof_number(sys_num, var, comp),
1618 
1619  io_buffer.push_back((*pos->second)((*it)->dof_number(sys_num, var, comp)));
1620  }
1621  }
1622 
1623  // Finally, write the SCALAR data on the last processor
1624  for (unsigned int var=0; var<this->n_vars(); var++)
1625  if(this->variable(var).