$extrastylesheet
libMesh::System Class Reference

#include <system.h>

Inheritance diagram for libMesh::System:

List of all members.

Classes

class  Assembly
class  Constraint
class  Initialization
class  QOI
class  QOIDerivative

Public Types

typedef System sys_type
typedef std::map< std::string,
NumericVector< Number >
* >::iterator 
vectors_iterator
typedef std::map< std::string,
NumericVector< Number >
* >::const_iterator 
const_vectors_iterator

Public Member Functions

 System (EquationSystems &es, const std::string &name, const unsigned int number)
virtual ~System ()
sys_typesystem ()
virtual void clear ()
void init ()
virtual void reinit ()
virtual void reinit_constraints ()
bool is_initialized ()
virtual void update ()
virtual void assemble ()
virtual void assemble_qoi (const QoISet &qoi_indices=QoISet())
virtual void assemble_qoi_derivative (const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true)
virtual void assemble_residual_derivatives (const ParameterVector &parameters)
virtual void restrict_solve_to (const SystemSubset *subset, const SubsetSolveMode subset_solve_mode=SUBSET_ZERO)
virtual void solve ()
virtual std::pair< unsigned
int, 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
virtual std::string system_type () 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, int is_adjoint=-1) const
void project_vector (NumericVector< Number > &new_vector, FEMFunctionBase< Number > *f, FEMFunctionBase< Gradient > *g=NULL, int is_adjoint=-1) const
void project_vector (Number fptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), Gradient gptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), const Parameters &parameters, NumericVector< Number > &new_vector, int is_adjoint=-1) const
void boundary_project_solution (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, FunctionBase< Number > *f, FunctionBase< Gradient > *g=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, int is_adjoint=-1) const
void boundary_project_vector (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, Number fptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), Gradient gptr(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name), const Parameters &parameters, NumericVector< Number > &new_vector, int is_adjoint=-1) const
unsigned int number () const
void update_global_solution (std::vector< Number > &global_soln) const
void update_global_solution (std::vector< Number > &global_soln, const processor_id_type dest_proc) const
const MeshBaseget_mesh () const
MeshBaseget_mesh ()
const DofMapget_dof_map () const
DofMapget_dof_map ()
const EquationSystemsget_equation_systems () const
EquationSystemsget_equation_systems ()
bool active () const
void activate ()
void deactivate ()
void set_basic_system_only ()
vectors_iterator vectors_begin ()
const_vectors_iterator vectors_begin () const
vectors_iterator vectors_end ()
const_vectors_iterator vectors_end () const
NumericVector< Number > & add_vector (const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
void remove_vector (const std::string &vec_name)
bool & project_solution_on_reinit (void)
bool have_vector (const std::string &vec_name) const
const NumericVector< Number > * request_vector (const std::string &vec_name) const
NumericVector< Number > * request_vector (const std::string &vec_name)
const NumericVector< Number > * request_vector (const unsigned int vec_num) const
NumericVector< Number > * request_vector (const unsigned int vec_num)
const NumericVector< Number > & get_vector (const std::string &vec_name) const
NumericVector< Number > & get_vector (const std::string &vec_name)
const NumericVector< Number > & get_vector (const unsigned int vec_num) const
NumericVector< Number > & get_vector (const unsigned int vec_num)
const std::string & vector_name (const unsigned int vec_num) const
const std::string & vector_name (const NumericVector< Number > &vec_reference) const
void set_vector_as_adjoint (const std::string &vec_name, int qoi_num)
int vector_is_adjoint (const std::string &vec_name) const
void set_vector_preservation (const std::string &vec_name, bool preserve)
bool vector_preservation (const std::string &vec_name) const
NumericVector< Number > & add_adjoint_solution (unsigned int i=0)
NumericVector< Number > & get_adjoint_solution (unsigned int i=0)
const NumericVector< Number > & get_adjoint_solution (unsigned int i=0) const
NumericVector< Number > & add_sensitivity_solution (unsigned int i=0)
NumericVector< Number > & get_sensitivity_solution (unsigned int i=0)
const NumericVector< Number > & get_sensitivity_solution (unsigned int i=0) const
NumericVector< Number > & add_weighted_sensitivity_adjoint_solution (unsigned int i=0)
NumericVector< Number > & get_weighted_sensitivity_adjoint_solution (unsigned int i=0)
const NumericVector< Number > & get_weighted_sensitivity_adjoint_solution (unsigned int i=0) const
NumericVector< Number > & add_weighted_sensitivity_solution ()
NumericVector< Number > & get_weighted_sensitivity_solution ()
const NumericVector< Number > & get_weighted_sensitivity_solution () const
NumericVector< Number > & add_adjoint_rhs (unsigned int i=0)
NumericVector< Number > & get_adjoint_rhs (unsigned int i=0)
const NumericVector< Number > & get_adjoint_rhs (unsigned int i=0) const
NumericVector< Number > & add_sensitivity_rhs (unsigned int i=0)
NumericVector< Number > & get_sensitivity_rhs (unsigned int i=0)
const NumericVector< Number > & get_sensitivity_rhs (unsigned int i=0) const
unsigned int n_vectors () const
virtual unsigned int n_matrices () const
unsigned int n_vars () const
unsigned int n_variable_groups () const
unsigned int n_components () const
dof_id_type n_dofs () const
dof_id_type n_active_dofs () const
dof_id_type n_constrained_dofs () const
dof_id_type n_local_constrained_dofs () const
dof_id_type n_local_dofs () const
unsigned int add_variable (const std::string &var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=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, FEMNormType norm_type) 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
std::size_t write_serialized_vectors (Xdr &io, const std::vector< const NumericVector< Number > * > &vectors) const
void write_parallel_data (Xdr &io, const bool write_additional_data) const
std::string get_info () const
void attach_init_function (void fptr(EquationSystems &es, const std::string &name))
void attach_init_object (Initialization &init)
void attach_assemble_function (void fptr(EquationSystems &es, const std::string &name))
void attach_assemble_object (Assembly &assemble)
void attach_constraint_function (void fptr(EquationSystems &es, const std::string &name))
void attach_constraint_object (Constraint &constrain)
void attach_QOI_function (void fptr(EquationSystems &es, const std::string &name, const QoISet &qoi_indices))
void attach_QOI_object (QOI &qoi)
void attach_QOI_derivative (void fptr(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints))
void attach_QOI_derivative_object (QOIDerivative &qoi_derivative)
virtual void user_initialization ()
virtual void user_assembly ()
virtual void user_constrain ()
virtual void user_QOI (const QoISet &qoi_indices)
virtual void user_QOI_derivative (const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true)
virtual void re_update ()
virtual void restrict_vectors ()
virtual void prolong_vectors ()
virtual void disable_cache ()
Number current_solution (const dof_id_type global_dof_number) const
Number point_value (unsigned int var, const Point &p, const bool insist_on_success=true) const
Number point_value (unsigned int var, const Point &p, const Elem &e) const
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

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

Protected Types

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

Protected Member Functions

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

Protected Attributes

const Parallel::Communicator_communicator

Static Protected Attributes

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

Private Member Functions

 System (const System &)
Systemoperator= (const System &)
Real discrete_var_norm (const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type) const
template<typename iterator_type , typename InValType >
std::size_t read_serialized_blocked_dof_objects (const dof_id_type n_objects, const iterator_type begin, const iterator_type end, const InValType dummy, Xdr &io, const std::vector< NumericVector< Number > * > &vecs, const unsigned int var_to_read=libMesh::invalid_uint) const
unsigned int read_SCALAR_dofs (const unsigned int var, Xdr &io, NumericVector< Number > &vec) const
template<typename InValType >
numeric_index_type read_serialized_vector (Xdr &io, NumericVector< Number > &vec)
numeric_index_type read_serialized_vector (Xdr &io, NumericVector< Number > &vec)
template<typename iterator_type >
std::size_t write_serialized_blocked_dof_objects (const std::vector< const NumericVector< Number > * > &vecs, const dof_id_type n_objects, const iterator_type begin, const iterator_type end, Xdr &io, const unsigned int var_to_write=libMesh::invalid_uint) const
unsigned int write_SCALAR_dofs (const NumericVector< Number > &vec, const unsigned int var, Xdr &io) const
dof_id_type write_serialized_vector (Xdr &io, const NumericVector< Number > &vec) const

Private Attributes

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

Detailed Description

This is the base class for classes which contain information related to any physical process that might be simulated. Such information may range from the actual solution values to algorithmic flags that may be used to control the numerical methods employed. In general, use an EqnSystems<T_sys> object to handle one or more of the children of this class. Note that templating EqnSystems relaxes the use of virtual members.

Author:
Benjamin S. Kirk, 2003-2004.

Definition at line 79 of file system.h.


Member Typedef Documentation

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

Definition at line 752 of file system.h.

typedef std::map<std::string, std::pair<unsigned int, unsigned int> > libMesh::ReferenceCounter::Counts [protected, inherited]

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

Definition at line 113 of file reference_counter.h.

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

Vector iterator typedefs.

Definition at line 751 of file system.h.


Constructor & Destructor Documentation

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

Constructor. Optionally initializes required data structures.

Definition at line 55 of file system.C.

libMesh::System::~System ( ) [virtual]

Destructor.

Definition at line 113 of file system.C.

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

{
  // Null-out the function pointers.  Since this
  // class is getting destructed it is pointless,
  // but a good habit.
  _init_system_function =
    _assemble_system_function =
    _constrain_system_function =  NULL;

  _qoi_evaluate_function = NULL;
  _qoi_evaluate_derivative_function =  NULL;

  // NULL-out user-provided objects.
  _init_system_object             = NULL;
  _assemble_system_object         = NULL;
  _constrain_system_object        = NULL;
  _qoi_evaluate_object            = NULL;
  _qoi_evaluate_derivative_object = NULL;

  // Clear data
  this->clear ();

  libmesh_exceptionless_assert (!libMesh::closed());
}
libMesh::System::System ( const System other) [private]

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

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

Definition at line 95 of file system.C.

                                   :
  ReferenceCountedObject<System>(),
  ParallelObject(other),
  _equation_systems(other._equation_systems),
  _mesh(other._mesh),
  _sys_number(other._sys_number)
{
  libmesh_not_implemented();
}

Member Function Documentation

void libMesh::System::activate ( ) [inline]

Activates the system. Only active systems are solved.

Definition at line 2001 of file system.h.

References _active.

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

Definition at line 1993 of file system.h.

References _active.

{
  return _active;
}
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 1048 of file system.C.

References add_vector().

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

{
  std::ostringstream adjoint_rhs_name;
  adjoint_rhs_name << "adjoint_rhs" << i;

  return this->add_vector(adjoint_rhs_name.str(), false);
}
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 984 of file system.C.

References add_vector(), and set_vector_as_adjoint().

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

{
  std::ostringstream adjoint_name;
  adjoint_name << "adjoint_solution" << i;

  NumericVector<Number> &returnval = this->add_vector(adjoint_name.str());
  this->set_vector_as_adjoint(adjoint_name.str(), i);
  return returnval;
}
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 1078 of file system.C.

References add_vector().

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

{
  std::ostringstream sensitivity_rhs_name;
  sensitivity_rhs_name << "sensitivity_rhs" << i;

  return this->add_vector(sensitivity_rhs_name.str(), false);
}
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 933 of file system.C.

References add_vector().

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

{
  std::ostringstream sensitivity_name;
  sensitivity_name << "sensitivity_solution" << i;

  return this->add_vector(sensitivity_name.str());
}
unsigned int libMesh::System::add_variable ( const std::string &  var,
const FEType type,
const std::set< subdomain_id_type > *const  active_subdomains = NULL 
)

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

Definition at line 1108 of file system.C.

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

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

{
  libmesh_assert(!this->is_initialized());

  // Make sure the variable isn't there already
  // or if it is, that it's the type we want
  for (unsigned int v=0; v<this->n_vars(); v++)
    if (this->variable_name(v) == var)
      {
        if (this->variable_type(v) == type)
          return _variables[v].number();

        libmesh_error_msg("ERROR: incompatible variable " << var << " has already been added for this system!");
      }

  // Optimize for VariableGroups here - if the user is adding multiple
  // variables of the same FEType and subdomain restriction, catch
  // that here and add them as members of the same VariableGroup.
  //
  // start by setting this flag to whatever the user has requested
  // and then consider the conditions which should negate it.
  bool should_be_in_vg = this->identify_variable_groups();

  // No variable groups, nothing to add to
  if (!this->n_variable_groups())
    should_be_in_vg = false;

  else
    {
      VariableGroup &vg(_variable_groups.back());

      // get a pointer to their subdomain restriction, if any.
      const std::set<subdomain_id_type> * const
        their_active_subdomains (vg.implicitly_active() ?
                                 NULL : &vg.active_subdomains());

      // Different types?
      if (vg.type() != type)
        should_be_in_vg = false;

      // they are restricted, we aren't?
      if (their_active_subdomains && !active_subdomains)
        should_be_in_vg = false;

      // they aren't restriced, we are?
      if (!their_active_subdomains && active_subdomains)
        should_be_in_vg = false;

      if (their_active_subdomains && active_subdomains)
        // restricted to different sets?
        if (*their_active_subdomains != *active_subdomains)
          should_be_in_vg = false;

      // OK, after all that, append the variable to the vg if none of the conditions
      // were violated
      if (should_be_in_vg)
        {
          const unsigned short curr_n_vars = cast_int<unsigned short>
            (this->n_vars());

          vg.append (var);

          _variables.push_back(vg(vg.n_variables()-1));
          _variable_numbers[var] = curr_n_vars;
          return curr_n_vars;
        }
    }

  // otherwise, fall back to adding a single variable group
  return this->add_variables (std::vector<std::string>(1, var),
                              type,
                              active_subdomains);
}
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 
)

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

References add_variable().

{
  return this->add_variable(var,
                            FEType(order, family),
                            active_subdomains);
}
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 
)

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

Definition at line 1198 of file system.C.

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

Referenced by add_variable(), and add_variables().

{
  libmesh_assert(!this->is_initialized());

  // Make sure the variable isn't there already
  // or if it is, that it's the type we want
  for (unsigned int ov=0; ov<vars.size(); ov++)
    for (unsigned int v=0; v<this->n_vars(); v++)
      if (this->variable_name(v) == vars[ov])
        {
          if (this->variable_type(v) == type)
            return _variables[v].number();

          libmesh_error_msg("ERROR: incompatible variable " << vars[ov] << " has already been added for this system!");
        }

  const unsigned short curr_n_vars = cast_int<unsigned short>
    (this->n_vars());

  const unsigned int next_first_component = this->n_components();

  // Add the variable group to the list
  _variable_groups.push_back((active_subdomains == NULL) ?
                             VariableGroup(this, vars, curr_n_vars,
                                           next_first_component, type) :
                             VariableGroup(this, vars, curr_n_vars,
                                           next_first_component, type, *active_subdomains));

  const VariableGroup &vg (_variable_groups.back());

  // Add each component of the group individually
  for (unsigned short v=0; v<vars.size(); v++)
    {
      _variables.push_back (vg(v));
      _variable_numbers[vars[v]] = cast_int<unsigned short>
        (curr_n_vars+v);
    }

  libmesh_assert_equal_to ((curr_n_vars+vars.size()), this->n_vars());

  // BSK - Defer this now to System::init_data() so we can detect
  // VariableGroups 12/28/2012
  // // Add the variable group to the _dof_map
  // _dof_map->add_variable_group (vg);

  // Return the number of the new variable
  return cast_int<unsigned int>(curr_n_vars+vars.size()-1);
}
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 
)

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

References add_variables().

{
  return this->add_variables(vars,
                             FEType(order, family),
                             active_subdomains);
}
NumericVector< Number > & libMesh::System::add_vector ( const std::string &  vec_name,
const bool  projections = true,
const ParallelType  type = PARALLEL 
)

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

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

Definition at line 689 of file system.C.

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

Referenced by add_adjoint_rhs(), add_adjoint_solution(), add_sensitivity_rhs(), add_sensitivity_solution(), libMesh::ExplicitSystem::add_system_rhs(), add_weighted_sensitivity_adjoint_solution(), add_weighted_sensitivity_solution(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::UnsteadySolver::init(), libMesh::ContinuationSystem::init_data(), libMesh::NewmarkSystem::NewmarkSystem(), read_header(), libMesh::FrequencySystem::set_frequencies(), libMesh::FrequencySystem::set_frequencies_by_range(), and libMesh::FrequencySystem::set_frequencies_by_steps().

{
  // Return the vector if it is already there.
  if (this->have_vector(vec_name))
    return *(_vectors[vec_name]);

  // Otherwise build the vector
  NumericVector<Number>* buf = NumericVector<Number>::build(this->comm()).release();
  _vectors.insert (std::make_pair (vec_name, buf));
  _vector_projections.insert (std::make_pair (vec_name, projections));

  _vector_types.insert (std::make_pair (vec_name, type));

  // Vectors are primal by default
  _vector_is_adjoint.insert (std::make_pair (vec_name, -1));

  // Initialize it if necessary
  if (_is_initialized)
    {
      if(type == GHOSTED)
        {
#ifdef LIBMESH_ENABLE_GHOSTED
          buf->init (this->n_dofs(), this->n_local_dofs(),
                     _dof_map->get_send_list(), false,
                     GHOSTED);
#else
          libmesh_error_msg("Cannot initialize ghosted vectors when they are not enabled.");
#endif
        }
      else
        buf->init (this->n_dofs(), this->n_local_dofs(), false, type);
    }

  return *buf;
}
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 1016 of file system.C.

References add_vector(), and set_vector_as_adjoint().

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

{
  std::ostringstream adjoint_name;
  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;

  NumericVector<Number> &returnval = this->add_vector(adjoint_name.str());
  this->set_vector_as_adjoint(adjoint_name.str(), i);
  return returnval;
}
Returns:
a reference to the solution of the last weighted sensitivity solve Creates the vector if it doesn't already exist.

Definition at line 963 of file system.C.

References add_vector().

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

{
  return this->add_vector("weighted_sensitivity_solution");
}
void libMesh::System::adjoint_qoi_parameter_sensitivity ( const QoISet qoi_indices,
const ParameterVector parameters,
SensitivityData sensitivities 
) [inline, virtual]

Solves for parameter sensitivities using the adjoint method.

This method is only implemented in some derived classes.

Reimplemented in libMesh::ImplicitSystem.

Definition at line 2238 of file system.h.

{
  libmesh_not_implemented();
}
std::pair< unsigned int, Real > libMesh::System::adjoint_solve ( const QoISet qoi_indices = QoISet()) [inline, virtual]

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

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

{
  libmesh_not_implemented();
}
void libMesh::System::assemble ( ) [virtual]

Prepares matrix and _dof_map for matrix assembly. Does not actually assemble anything. For matrix assembly, use the assemble() in derived classes. Should be overloaded in derived classes.

Reimplemented in libMesh::EigenSystem, libMesh::FrequencySystem, libMesh::LinearImplicitSystem, libMesh::DifferentiableSystem, libMesh::ImplicitSystem, and libMesh::NewmarkSystem.

Definition at line 477 of file system.C.

References libMesh::START_LOG(), and user_assembly().

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

{
  // Log how long the user's assembly code takes
  START_LOG("assemble()", "System");

  // Call the user-specified assembly function
  this->user_assembly();

  // Stop logging the user code
  STOP_LOG("assemble()", "System");
}
void libMesh::System::assemble_qoi ( const QoISet qoi_indices = QoISet()) [virtual]

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

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

Definition at line 491 of file system.C.

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

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

{
  // Log how long the user's assembly code takes
  START_LOG("assemble_qoi()", "System");

  // Call the user-specified quantity of interest function
  this->user_QOI(qoi_indices);

  // Stop logging the user code
  STOP_LOG("assemble_qoi()", "System");
}
void libMesh::System::assemble_qoi_derivative ( const QoISet qoi_indices = QoISet(),
bool  include_liftfunc = true,
bool  apply_constraints = true 
) [virtual]

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

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

Definition at line 505 of file system.C.

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

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

{
  // Log how long the user's assembly code takes
  START_LOG("assemble_qoi_derivative()", "System");

  // Call the user-specified quantity of interest function
  this->user_QOI_derivative(qoi_indices, include_liftfunc,
                            apply_constraints);

  // Stop logging the user code
  STOP_LOG("assemble_qoi_derivative()", "System");
}
void libMesh::System::assemble_residual_derivatives ( const ParameterVector parameters) [inline, virtual]

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

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

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

Definition at line 1779 of file system.C.

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

{
  libmesh_assert(fptr);

  if (_assemble_system_object != NULL)
    {
      libmesh_here();
      libMesh::out << "WARNING:  Cannot specify both assembly function and object!"
                   << std::endl;

      _assemble_system_object = NULL;
    }

  _assemble_system_function = fptr;
}

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

Definition at line 1798 of file system.C.

References _assemble_system_function, _assemble_system_object, and libMesh::out.

{
  if (_assemble_system_function != NULL)
    {
      libmesh_here();
      libMesh::out << "WARNING:  Cannot specify both assembly object and function!"
                   << std::endl;

      _assemble_system_function = NULL;
    }

  _assemble_system_object = &assemble_in;
}
void libMesh::System::attach_constraint_function ( void   fptrEquationSystems &es,const std::string &name)

Register a user function for imposing constraints.

Definition at line 1814 of file system.C.

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

{
  libmesh_assert(fptr);

  if (_constrain_system_object != NULL)
    {
      libmesh_here();
      libMesh::out << "WARNING:  Cannot specify both constraint function and object!"
                   << std::endl;

      _constrain_system_object = NULL;
    }

  _constrain_system_function = fptr;
}

Register a user object for imposing constraints.

Definition at line 1833 of file system.C.

References _constrain_system_function, _constrain_system_object, and libMesh::out.

{
  if (_constrain_system_function != NULL)
    {
      libmesh_here();
      libMesh::out << "WARNING:  Cannot specify both constraint object and function!"
                   << std::endl;

      _constrain_system_function = NULL;
    }

  _constrain_system_object = &constrain;
}
void libMesh::System::attach_init_function ( void   fptrEquationSystems &es,const std::string &name)

Register a user function to use in initializing the system.

Definition at line 1744 of file system.C.

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

{
  libmesh_assert(fptr);

  if (_init_system_object != NULL)
    {
      libmesh_here();
      libMesh::out << "WARNING:  Cannot specify both initialization function and object!"
                   << std::endl;

      _init_system_object = NULL;
    }

  _init_system_function = fptr;
}

Register a user class to use to initialize the system. Note this is exclusive with the attach_init_function.

Definition at line 1763 of file system.C.

References _init_system_function, _init_system_object, and libMesh::out.

{
  if (_init_system_function != NULL)
    {
      libmesh_here();
      libMesh::out << "WARNING:  Cannot specify both initialization object and function!"
                   << std::endl;

      _init_system_function = NULL;
    }

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

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

Definition at line 1885 of file system.C.

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

{
  libmesh_assert(fptr);

  if (_qoi_evaluate_derivative_object != NULL)
    {
      libmesh_here();
      libMesh::out << "WARNING:  Cannot specify both QOI derivative function and object!"
                   << std::endl;

      _qoi_evaluate_derivative_object = NULL;
    }

  _qoi_evaluate_derivative_function = fptr;
}

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

References _qoi_evaluate_derivative_function, _qoi_evaluate_derivative_object, and libMesh::out.

{
  if (_qoi_evaluate_derivative_function != NULL)
    {
      libmesh_here();
      libMesh::out << "WARNING:  Cannot specify both QOI derivative object and function!"
                   << std::endl;

      _qoi_evaluate_derivative_function = NULL;
    }

  _qoi_evaluate_derivative_object = &qoi_derivative;
}
void libMesh::System::attach_QOI_function ( void   fptrEquationSystems &es,const std::string &name,const QoISet &qoi_indices)

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

Definition at line 1849 of file system.C.

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

{
  libmesh_assert(fptr);

  if (_qoi_evaluate_object != NULL)
    {
      libmesh_here();
      libMesh::out << "WARNING:  Cannot specify both QOI function and object!"
                   << std::endl;

      _qoi_evaluate_object = NULL;
    }

  _qoi_evaluate_function = fptr;
}

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

Definition at line 1869 of file system.C.

References _qoi_evaluate_function, _qoi_evaluate_object, and libMesh::out.

{
  if (_qoi_evaluate_function != NULL)
    {
      libmesh_here();
      libMesh::out << "WARNING:  Cannot specify both QOI object and function!"
                   << std::endl;

      _qoi_evaluate_function = NULL;
    }

  _qoi_evaluate_object = &qoi_in;
}
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 
)

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

{
  this->boundary_project_vector(b, variables, *solution, f, g);

  solution->localize(*current_local_solution);
}
void libMesh::System::boundary_project_solution ( const std::set< boundary_id_type > &  b,
const std::vector< unsigned int > &  variables,
Number   fptrconst Point &p,const Parameters &parameters,const std::string &sys_name,const std::string &unknown_name,
Gradient   gptrconst Point &p,const Parameters &parameters,const std::string &sys_name,const std::string &unknown_name,
const Parameters parameters 
)

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

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

Definition at line 654 of file system_projection.C.

{
  WrappedFunction<Number> f(*this, fptr, &parameters);
  WrappedFunction<Gradient> g(*this, gptr, &parameters);
  this->boundary_project_solution(b, variables, &f, &g);
}
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,
int  is_adjoint = -1 
) const

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

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

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

Definition at line 722 of file system_projection.C.

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

{
  START_LOG ("boundary_project_vector()", "System");

  Threads::parallel_for
    (ConstElemRange (this->get_mesh().active_local_elements_begin(),
                     this->get_mesh().active_local_elements_end() ),
     BoundaryProjectSolution(b, variables, *this, f, g,
                             this->get_equation_systems().parameters,
                             new_vector)
     );

  // We don't do SCALAR dofs when just projecting the boundary, so
  // we're done here.

  new_vector.close();

#ifdef LIBMESH_ENABLE_CONSTRAINTS
  if (is_adjoint == -1)
    this->get_dof_map().enforce_constraints_exactly(*this, &new_vector);
  else if (is_adjoint >= 0)
    this->get_dof_map().enforce_adjoint_constraints_exactly(new_vector,
                                                            is_adjoint);
#endif

  STOP_LOG("boundary_project_vector()", "System");
}
void libMesh::System::boundary_project_vector ( const std::set< boundary_id_type > &  b,
const std::vector< unsigned int > &  variables,
Number   fptrconst Point &p,const Parameters &parameters,const std::string &sys_name,const std::string &unknown_name,
Gradient   gptrconst Point &p,const Parameters &parameters,const std::string &sys_name,const std::string &unknown_name,
const Parameters parameters,
NumericVector< Number > &  new_vector,
int  is_adjoint = -1 
) const

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

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

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

Definition at line 697 of file system_projection.C.

{
  WrappedFunction<Number> f(*this, fptr, &parameters);
  WrappedFunction<Gradient> g(*this, gptr, &parameters);
  this->boundary_project_vector(b, variables, new_vector, &f, &g,
                                is_adjoint);
}
Real libMesh::System::calculate_norm ( const NumericVector< Number > &  v,
unsigned int  var,
FEMNormType  norm_type 
) const
Returns:
a norm of variable var in the vector v, in the specified norm (e.g. L2, L_INF, H1)

Definition at line 1405 of file system.C.

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

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

{
  //short circuit to save time
  if(norm_type == DISCRETE_L1 ||
     norm_type == DISCRETE_L2 ||
     norm_type == DISCRETE_L_INF)
    return discrete_var_norm(v,var,norm_type);

  // Not a discrete norm
  std::vector<FEMNormType> norms(this->n_vars(), L2);
  std::vector<Real> weights(this->n_vars(), 0.0);
  norms[var] = norm_type;
  weights[var] = 1.0;
  Real val = this->calculate_norm(v, SystemNorm(norms, weights));
  return val;
}
Real libMesh::System::calculate_norm ( const NumericVector< Number > &  v,
const SystemNorm norm 
) const
Returns:
a norm of the vector v, using component_norm and component_scale to choose and weight the norms of each variable.

Definition at line 1426 of file system.C.

References _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::FEGenericBase< OutputType >::build(), libMesh::ParallelObject::comm(), libMesh::FEType::default_quadrature_rule(), libMesh::DISCRETE_L1, libMesh::DISCRETE_L2, libMesh::DISCRETE_L_INF, discrete_var_norm(), libMesh::DofMap::dof_indices(), get_dof_map(), get_mesh(), libMesh::H1, libMesh::H1_SEMINORM, libMesh::H2, libMesh::H2_SEMINORM, libMesh::SystemNorm::is_discrete(), libMesh::L1, libMesh::NumericVector< T >::l1_norm(), libMesh::L2, libMesh::NumericVector< T >::l2_norm(), libMesh::L_INF, libMesh::NumericVector< T >::linfty_norm(), libMesh::NumericVector< T >::localize(), std::max(), libMesh::Parallel::Communicator::max(), libMesh::MeshBase::mesh_dimension(), n_vars(), libMesh::TensorTools::norm_sq(), libMesh::Real, libMesh::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::Parallel::Communicator::sum(), libMesh::SystemNorm::type(), libMesh::DofMap::variable_type(), libMesh::W1_INF_SEMINORM, libMesh::W2_INF_SEMINORM, libMesh::SystemNorm::weight(), and libMesh::SystemNorm::weight_sq().

{
  // This function must be run on all processors at once
  parallel_object_only();

  START_LOG ("calculate_norm()", "System");

  // Zero the norm before summation
  Real v_norm = 0.;

  if (norm.is_discrete())
    {
      STOP_LOG ("calculate_norm()", "System");
      //Check to see if all weights are 1.0 and all types are equal
      FEMNormType norm_type0 = norm.type(0);
      unsigned int check_var = 0;
      for (; check_var != this->n_vars(); ++check_var)
        if((norm.weight(check_var) != 1.0) || (norm.type(check_var) != norm_type0))
          break;

      //All weights were 1.0 so just do the full vector discrete norm
      if(check_var == this->n_vars())
        {
          if(norm_type0 == DISCRETE_L1)
            return v.l1_norm();
          if(norm_type0 == DISCRETE_L2)
            return v.l2_norm();
          if(norm_type0 == DISCRETE_L_INF)
            return v.linfty_norm();
          else
            libmesh_error_msg("Invalid norm_type0 = " << norm_type0);
        }

      for (unsigned int var=0; var != this->n_vars(); ++var)
        {
          // Skip any variables we don't need to integrate
          if (norm.weight(var) == 0.0)
            continue;

          v_norm += norm.weight(var) * discrete_var_norm(v, var, norm.type(var));
        }

      return v_norm;
    }

  // Localize the potentially parallel vector
  UniquePtr<NumericVector<Number> > local_v = NumericVector<Number>::build(this->comm());
  local_v->init(v.size(), true, SERIAL);
  v.localize (*local_v, _dof_map->get_send_list());

  unsigned int dim = this->get_mesh().mesh_dimension();

  // I'm not sure how best to mix Hilbert norms on some variables (for
  // which we'll want to square then sum then square root) with norms
  // like L_inf (for which we'll just want to take an absolute value
  // and then sum).
  bool using_hilbert_norm = true,
    using_nonhilbert_norm = true;

  // Loop over all variables
  for (unsigned int var=0; var != this->n_vars(); ++var)
    {
      // Skip any variables we don't need to integrate
      Real norm_weight_sq = norm.weight_sq(var);
      if (norm_weight_sq == 0.0)
        continue;
      Real norm_weight = norm.weight(var);

      // Check for unimplemented norms (rather than just returning 0).
      FEMNormType norm_type = norm.type(var);
      if((norm_type==H1) ||
         (norm_type==H2) ||
         (norm_type==L2) ||
         (norm_type==H1_SEMINORM) ||
         (norm_type==H2_SEMINORM))
        {
          if (!using_hilbert_norm)
            libmesh_not_implemented();
          using_nonhilbert_norm = false;
        }
      else if ((norm_type==L1) ||
               (norm_type==L_INF) ||
               (norm_type==W1_INF_SEMINORM) ||
               (norm_type==W2_INF_SEMINORM))
        {
          if (!using_nonhilbert_norm)
            libmesh_not_implemented();
          using_hilbert_norm = false;
        }
      else
        libmesh_not_implemented();

      const FEType& fe_type = this->get_dof_map().variable_type(var);
      UniquePtr<QBase> qrule =
        fe_type.default_quadrature_rule (dim);
      UniquePtr<FEBase> fe
        (FEBase::build(dim, fe_type));
      fe->attach_quadrature_rule (qrule.get());

      const std::vector<Real>&               JxW = fe->get_JxW();
      const std::vector<std::vector<Real> >* phi = NULL;
      if (norm_type == H1 ||
          norm_type == H2 ||
          norm_type == L2 ||
          norm_type == L1 ||
          norm_type == L_INF)
        phi = &(fe->get_phi());

      const std::vector<std::vector<RealGradient> >* dphi = NULL;
      if (norm_type == H1 ||
          norm_type == H2 ||
          norm_type == H1_SEMINORM ||
          norm_type == W1_INF_SEMINORM)
        dphi = &(fe->get_dphi());
#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
      const std::vector<std::vector<RealTensor> >*   d2phi = NULL;
      if (norm_type == H2 ||
          norm_type == H2_SEMINORM ||
          norm_type == W2_INF_SEMINORM)
        d2phi = &(fe->get_d2phi());
#endif

      std::vector<dof_id_type> dof_indices;

      // Begin the loop over the elements
      MeshBase::const_element_iterator       el     =
        this->get_mesh().active_local_elements_begin();
      const MeshBase::const_element_iterator end_el =
        this->get_mesh().active_local_elements_end();

      for ( ; el != end_el; ++el)
        {
          const Elem* elem = *el;

          fe->reinit (elem);

          this->get_dof_map().dof_indices (elem, dof_indices, var);

          const unsigned int n_qp = qrule->n_points();

          const unsigned int n_sf = cast_int<unsigned int>
            (dof_indices.size());

          // Begin the loop over the Quadrature points.
          for (unsigned int qp=0; qp<n_qp; qp++)
            {
              if (norm_type == L1)
                {
                  Number u_h = 0.;
                  for (unsigned int i=0; i != n_sf; ++i)
                    u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
                  v_norm += norm_weight *
                    JxW[qp] * std::abs(u_h);
                }

              if (norm_type == L_INF)
                {
                  Number u_h = 0.;
                  for (unsigned int i=0; i != n_sf; ++i)
                    u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
                  v_norm = std::max(v_norm, norm_weight * std::abs(u_h));
                }

              if (norm_type == H1 ||
                  norm_type == H2 ||
                  norm_type == L2)
                {
                  Number u_h = 0.;
                  for (unsigned int i=0; i != n_sf; ++i)
                    u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
                  v_norm += norm_weight_sq *
                    JxW[qp] * TensorTools::norm_sq(u_h);
                }

              if (norm_type == H1 ||
                  norm_type == H2 ||
                  norm_type == H1_SEMINORM)
                {
                  Gradient grad_u_h;
                  for (unsigned int i=0; i != n_sf; ++i)
                    grad_u_h.add_scaled((*dphi)[i][qp], (*local_v)(dof_indices[i]));
                  v_norm += norm_weight_sq *
                    JxW[qp] * grad_u_h.size_sq();
                }

              if (norm_type == W1_INF_SEMINORM)
                {
                  Gradient grad_u_h;
                  for (unsigned int i=0; i != n_sf; ++i)
                    grad_u_h.add_scaled((*dphi)[i][qp], (*local_v)(dof_indices[i]));
                  v_norm = std::max(v_norm, norm_weight * grad_u_h.size());
                }

#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
              if (norm_type == H2 ||
                  norm_type == H2_SEMINORM)
                {
                  Tensor hess_u_h;
                  for (unsigned int i=0; i != n_sf; ++i)
                    hess_u_h.add_scaled((*d2phi)[i][qp], (*local_v)(dof_indices[i]));
                  v_norm += norm_weight_sq *
                    JxW[qp] * hess_u_h.size_sq();
                }

              if (norm_type == W2_INF_SEMINORM)
                {
                  Tensor hess_u_h;
                  for (unsigned int i=0; i != n_sf; ++i)
                    hess_u_h.add_scaled((*d2phi)[i][qp], (*local_v)(dof_indices[i]));
                  v_norm = std::max(v_norm, norm_weight * hess_u_h.size());
                }
#endif
            }
        }
    }

  if (using_hilbert_norm)
    {
      this->comm().sum(v_norm);
      v_norm = std::sqrt(v_norm);
    }
  else
    {
      this->comm().max(v_norm);
    }

  STOP_LOG ("calculate_norm()", "System");

  return v_norm;
}
const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const [inline, inherited]
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_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), 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::ImplicitSystem::add_matrix(), 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::MeshBase::cache_elem_dims(), 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(), DMlibMeshSetSystem_libMesh(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::LocationMap< T >::init(), libMesh::TimeSolver::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::EigenSystem::init_data(), libMesh::EigenSystem::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::petsc_auto_fieldsplit(), point_gradient(), point_hessian(), point_value(), libMesh::MeshBase::prepare_for_use(), project_vector(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), read_header(), read_legacy_data(), read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs(), read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), read_serialized_vector(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::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::Parallel::sync_node_data_by_element_id(), libMesh::MeshRefinement::test_level_one(), libMesh::MeshRefinement::test_unflagged(), libMesh::MeshTools::total_weight(), libMesh::NameBasedIO::write(), libMesh::CheckpointIO::write(), libMesh::XdrIO::write(), libMesh::LegacyXdrIO::write_mesh(), write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs(), 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().

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

Definition at line 539 of file system.C.

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

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

{
  // we do not care for matrices, but for vectors
  libmesh_assert (_is_initialized);
  libmesh_assert (other_system._is_initialized);

  if (verbose)
    {
      libMesh::out << "  Systems \"" << _sys_name << "\"" << std::endl;
      libMesh::out << "   comparing matrices not supported." << std::endl;
      libMesh::out << "   comparing names...";
    }

  // compare the name: 0 means identical
  const int name_result = _sys_name.compare(other_system.name());
  if (verbose)
    {
      if (name_result == 0)
        libMesh::out << " identical." << std::endl;
      else
        libMesh::out << "  names not identical." << std::endl;
      libMesh::out << "   comparing solution vector...";
    }


  // compare the solution: -1 means identical
  const int solu_result = solution->compare (*other_system.solution.get(),
                                             threshold);

  if (verbose)
    {
      if (solu_result == -1)
        libMesh::out << " identical up to threshold." << std::endl;
      else
        libMesh::out << "  first difference occured at index = "
                     << solu_result << "." << std::endl;
    }


  // safety check, whether we handle at least the same number
  // of vectors
  std::vector<int> ov_result;

  if (this->n_vectors() != other_system.n_vectors())
    {
      if (verbose)
        {
          libMesh::out << "   Fatal difference. This system handles "
                       << this->n_vectors() << " add'l vectors," << std::endl
                       << "   while the other system handles "
                       << other_system.n_vectors()
                       << " add'l vectors." << std::endl
                       << "   Aborting comparison." << std::endl;
        }
      return false;
    }
  else if (this->n_vectors() == 0)
    {
      // there are no additional vectors...
      ov_result.clear ();
    }
  else
    {
      // compare other vectors
      for (const_vectors_iterator pos = _vectors.begin();
           pos != _vectors.end(); ++pos)
        {
          if (verbose)
            libMesh::out << "   comparing vector \""
                         << pos->first << "\" ...";

          // assume they have the same name
          const NumericVector<Number>& other_system_vector =
            other_system.get_vector(pos->first);

          ov_result.push_back(pos->second->compare (other_system_vector,
                                                    threshold));

          if (verbose)
            {
              if (ov_result[ov_result.size()-1] == -1)
                libMesh::out << " identical up to threshold." << std::endl;
              else
                libMesh::out << " first difference occured at" << std::endl
                             << "   index = " << ov_result[ov_result.size()-1] << "." << std::endl;
            }

        }

    } // finished comparing additional vectors


  bool overall_result;

  // sum up the results
  if ((name_result==0) && (solu_result==-1))
    {
      if (ov_result.size()==0)
        overall_result = true;
      else
        {
          bool ov_identical;
          unsigned int n    = 0;
          do
            {
              ov_identical = (ov_result[n]==-1);
              n++;
            }
          while (ov_identical && n<ov_result.size());
          overall_result = ov_identical;
        }
    }
  else
    overall_result = false;

  if (verbose)
    {
      libMesh::out << "   finished comparisons, ";
      if (overall_result)
        libMesh::out << "found no differences." << std::endl << std::endl;
      else
        libMesh::out << "found differences." << std::endl << std::endl;
    }

  return overall_result;
}
void libMesh::System::deactivate ( ) [inline]

Deactivates the system. Only active systems are solved.

Definition at line 2009 of file system.h.

References _active.

{
  _active = false;
}
void libMesh::System::disable_cache ( ) [inline, virtual]

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

References assemble_before_solve.

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

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

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

Definition at line 1386 of file system.C.

References libMesh::DISCRETE_L1, libMesh::DISCRETE_L2, libMesh::DISCRETE_L_INF, local_dof_indices(), libMesh::NumericVector< T >::subset_l1_norm(), libMesh::NumericVector< T >::subset_l2_norm(), and libMesh::NumericVector< T >::subset_linfty_norm().

Referenced by calculate_norm().

{
  std::set<dof_id_type> var_indices;
  local_dof_indices(var, var_indices);

  if(norm_type == DISCRETE_L1)
    return v.subset_l1_norm(var_indices);
  if(norm_type == DISCRETE_L2)
    return v.subset_l2_norm(var_indices);
  if(norm_type == DISCRETE_L_INF)
    return v.subset_linfty_norm(var_indices);
  else
    libmesh_error_msg("Invalid norm_type = " << norm_type);
}

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.

{
  _enable_print_counter = true;
  return;
}
void libMesh::System::forward_qoi_parameter_sensitivity ( const QoISet qoi_indices,
const ParameterVector parameters,
SensitivityData sensitivities 
) [inline, virtual]

Solves for parameter sensitivities using the forward method.

This method is only implemented in some derived classes.

Reimplemented in libMesh::ImplicitSystem.

Definition at line 2247 of file system.h.

{
  libmesh_not_implemented();
}
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 1058 of file system.C.

References get_vector().

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

{
  std::ostringstream adjoint_rhs_name;
  adjoint_rhs_name << "adjoint_rhs" << i;

  return this->get_vector(adjoint_rhs_name.str());
}
const NumericVector< Number > & libMesh::System::get_adjoint_rhs ( unsigned int  i = 0) const
Returns:
a reference to one of the system's adjoint rhs vectors, by default the one corresponding to the first qoi.

Definition at line 1068 of file system.C.

References get_vector().

{
  std::ostringstream adjoint_rhs_name;
  adjoint_rhs_name << "adjoint_rhs" << i;

  return this->get_vector(adjoint_rhs_name.str());
}
Returns:
a reference to one of the system's adjoint solution vectors, by default the one corresponding to the first qoi.

Definition at line 996 of file system.C.

References get_vector().

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

{
  std::ostringstream adjoint_name;
  adjoint_name << "adjoint_solution" << i;

  return this->get_vector(adjoint_name.str());
}
const NumericVector< Number > & libMesh::System::get_adjoint_solution ( unsigned int  i = 0) const
Returns:
a reference to one of the system's adjoint solution vectors, by default the one corresponding to the first qoi.

Definition at line 1006 of file system.C.

References get_vector().

{
  std::ostringstream adjoint_name;
  adjoint_name << "adjoint_solution" << i;

  return this->get_vector(adjoint_name.str());
}
void libMesh::System::get_all_variable_numbers ( std::vector< unsigned int > &  all_variable_numbers) const

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

Definition at line 1285 of file system.C.

References _variable_numbers, and n_vars().

{
  all_variable_numbers.resize(n_vars());

  // Make sure the variable exists
  std::map<std::string, unsigned short int>::const_iterator
    it = _variable_numbers.begin();
  std::map<std::string, unsigned short int>::const_iterator
    it_end = _variable_numbers.end();

  unsigned int count = 0;
  for( ; it != it_end; ++it)
    {
      all_variable_numbers[count] = it->second;
      count++;
    }
}
const DofMap & libMesh::System::get_dof_map ( ) const [inline]
Returns:
a constant reference to this system's _dof_map.

Definition at line 1977 of file system.h.

References _dof_map.

Referenced by libMesh::__libmesh_petsc_diff_solver_residual(), 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(), calculate_norm(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), DMCreateDomainDecomposition_libMesh(), DMCreateFieldDecomposition_libMesh(), DMlibMeshFunction(), DMlibMeshSetSystem_libMesh(), libMesh::DofMap::enforce_constraints_exactly(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), get_info(), libMesh::EquationSystems::get_solution(), libMesh::SystemSubsetBySubdomain::init(), libMesh::UnsteadySolver::init_data(), libMesh::EigenSystem::init_matrices(), libMesh::ImplicitSystem::init_matrices(), libMesh::CondensedEigenSystem::initialize_condensed_dofs(), 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::petsc_auto_fieldsplit(), libMesh::ErrorVector::plot_error(), point_gradient(), point_hessian(), point_value(), libMesh::FEMContext::pre_fe_reinit(), project_vector(), re_update(), read_parallel_data(), read_SCALAR_dofs(), libMesh::UnsteadySolver::reinit(), libMesh::ImplicitSystem::reinit(), libMesh::EigenSystem::reinit(), libMesh::EquationSystems::reinit(), reinit_constraints(), libMesh::UnsteadySolver::retrieve_timestep(), libMesh::HPCoarsenTest::select_refinement(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::NewtonSolver::solve(), libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve(), libMesh::ImplicitSystem::weighted_sensitivity_solve(), write_parallel_data(), libMesh::EnsightIO::write_scalar_ascii(), write_SCALAR_dofs(), and libMesh::EnsightIO::write_vector_ascii().

{
  return *_dof_map;
}
Returns:
a writeable reference to this system's _dof_map.

Definition at line 1985 of file system.h.

References _dof_map.

{
  return *_dof_map;
}
Returns:
a reference to this system's parent EquationSystems object.

Definition at line 720 of file system.h.

References _equation_systems.

{ return _equation_systems; }
std::string libMesh::ReferenceCounter::get_info ( ) [static, inherited]

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

{
#if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)

  std::ostringstream oss;

  oss << '\n'
      << " ---------------------------------------------------------------------------- \n"
      << "| Reference count information                                                |\n"
      << " ---------------------------------------------------------------------------- \n";

  for (Counts::iterator it = _counts.begin();
       it != _counts.end(); ++it)
    {
      const std::string name(it->first);
      const unsigned int creations    = it->second.first;
      const unsigned int destructions = it->second.second;

      oss << "| " << name << " reference count information:\n"
          << "|  Creations:    " << creations    << '\n'
          << "|  Destructions: " << destructions << '\n';
    }

  oss << " ---------------------------------------------------------------------------- \n";

  return oss.str();

#else

  return "";

#endif
}
std::string libMesh::System::get_info ( ) const
Returns:
a string containing information about the system.

Definition at line 1660 of file system.C.

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

{
  std::ostringstream oss;


  const std::string& sys_name = this->name();

  oss << "   System #"  << this->number() << ", \"" << sys_name << "\"\n"
      << "    Type \""  << this->system_type() << "\"\n"
      << "    Variables=";

  for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
    {
      const VariableGroup &vg_description (this->variable_group(vg));

      if (vg_description.n_variables() > 1) oss << "{ ";
      for (unsigned int vn=0; vn<vg_description.n_variables(); vn++)
        oss << "\"" << vg_description.name(vn) << "\" ";
      if (vg_description.n_variables() > 1) oss << "} ";
    }

  oss << '\n';

  oss << "    Finite Element Types=";
#ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
  for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
    oss << "\""
        << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().family)
        << "\" ";
#else
  for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
    {
      oss << "\""
          << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().family)
          << "\", \""
          << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().radial_family)
          << "\" ";
    }

  oss << '\n' << "    Infinite Element Mapping=";
  for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
    oss << "\""
        << Utility::enum_to_string<InfMapType>(this->get_dof_map().variable_group(vg).type().inf_map)
        << "\" ";
#endif

  oss << '\n';

  oss << "    Approximation Orders=";
  for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
    {
#ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
      oss << "\""
          << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().order)
          << "\" ";
#else
      oss << "\""
          << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().order)
          << "\", \""
          << Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().radial_order)
          << "\" ";
#endif
    }

  oss << '\n';

  oss << "    n_dofs()="             << this->n_dofs()             << '\n';
  oss << "    n_local_dofs()="       << this->n_local_dofs()       << '\n';
#ifdef LIBMESH_ENABLE_CONSTRAINTS
  oss << "    n_constrained_dofs()=" << this->n_constrained_dofs() << '\n';
  oss << "    n_local_constrained_dofs()=" << this->n_local_constrained_dofs() << '\n';
#endif

  oss << "    " << "n_vectors()="  << this->n_vectors()  << '\n';
  oss << "    " << "n_matrices()="  << this->n_matrices()  << '\n';
  //   oss << "    " << "n_additional_matrices()=" << this->n_additional_matrices() << '\n';

  oss << this->get_dof_map().get_info();

  return oss.str();
}
const MeshBase & libMesh::System::get_mesh ( ) const [inline]
Returns:
a constant reference to this systems's _mesh.

Definition at line 1961 of file system.h.

References _mesh.

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

{
  return _mesh;
}
Returns:
a reference to this systems's _mesh.

Definition at line 1969 of file system.h.

References _mesh.

{
  return _mesh;
}
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 1088 of file system.C.

References get_vector().

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

{
  std::ostringstream sensitivity_rhs_name;
  sensitivity_rhs_name << "sensitivity_rhs" << i;

  return this->get_vector(sensitivity_rhs_name.str());
}
const NumericVector< Number > & libMesh::System::get_sensitivity_rhs ( unsigned int  i = 0) const
Returns:
a reference to one of the system's sensitivity rhs vectors, by default the one corresponding to the first parameter.

Definition at line 1098 of file system.C.

References get_vector().

{
  std::ostringstream sensitivity_rhs_name;
  sensitivity_rhs_name << "sensitivity_rhs" << i;

  return this->get_vector(sensitivity_rhs_name.str());
}
Returns:
a reference to one of the system's solution sensitivity vectors, by default the one corresponding to the first parameter.

Definition at line 943 of file system.C.

References get_vector().

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

{
  std::ostringstream sensitivity_name;
  sensitivity_name << "sensitivity_solution" << i;

  return this->get_vector(sensitivity_name.str());
}
const NumericVector< Number > & libMesh::System::get_sensitivity_solution ( unsigned int  i = 0) const
Returns:
a reference to one of the system's solution sensitivity vectors, by default the one corresponding to the first parameter.

Definition at line 953 of file system.C.

References get_vector().

{
  std::ostringstream sensitivity_name;
  sensitivity_name << "sensitivity_solution" << i;

  return this->get_vector(sensitivity_name.str());
}
NumericVector< Number > & libMesh::System::get_vector ( const std::string &  vec_name)
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 814 of file system.C.

References _vectors.

{
  // Make sure the vector exists
  vectors_iterator pos = _vectors.find(vec_name);

  if (pos == _vectors.end())
    libmesh_error_msg("ERROR: vector " << vec_name << " does not exist in this system!");

  return *(pos->second);
}
const NumericVector< Number > & libMesh::System::get_vector ( const unsigned int  vec_num) const
Returns:
a const reference to this system's additional vector number vec_num (where the vectors are counted starting with 0).

Definition at line 827 of file system.C.

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

{
  const_vectors_iterator v = vectors_begin();
  const_vectors_iterator v_end = vectors_end();
  unsigned int num = 0;
  while((num<vec_num) && (v!=v_end))
    {
      num++;
      ++v;
    }
  libmesh_assert (v != v_end);
  return *(v->second);
}
NumericVector< Number > & libMesh::System::get_vector ( const unsigned int  vec_num)
Returns:
a writeable reference to this system's additional vector number vec_num (where the vectors are counted starting with 0).

Definition at line 843 of file system.C.

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

{
  vectors_iterator v = vectors_begin();
  vectors_iterator v_end = vectors_end();
  unsigned int num = 0;
  while((num<vec_num) && (v!=v_end))
    {
      num++;
      ++v;
    }
  libmesh_assert (v != v_end);
  return *(v->second);
}
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 1028 of file system.C.

References get_vector().

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

{
  std::ostringstream adjoint_name;
  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;

  return this->get_vector(adjoint_name.str());
}
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 1038 of file system.C.

References get_vector().

{
  std::ostringstream adjoint_name;
  adjoint_name << "weighted_sensitivity_adjoint_solution" << i;

  return this->get_vector(adjoint_name.str());
}
Returns:
a reference to the solution of the last weighted sensitivity solve

Definition at line 970 of file system.C.

References get_vector().

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

{
  return this->get_vector("weighted_sensitivity_solution");
}
Returns:
a reference to the solution of the last weighted sensitivity solve

Definition at line 977 of file system.C.

References get_vector().

{
  return this->get_vector("weighted_sensitivity_solution");
}
bool libMesh::System::has_variable ( const std::string &  var) const
Returns:
true if a variable named var exists in this System

Definition at line 1263 of file system.C.

References _variable_numbers.

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

{
  return _variable_numbers.count(var);
}
bool libMesh::System::have_vector ( const std::string &  vec_name) const [inline]
Returns:
true if this System has a vector associated with the given name, false otherwise.

Definition at line 2153 of file system.h.

References _vectors.

Referenced by add_vector(), and remove_vector().

{
  return (_vectors.count(vec_name));
}
Returns:
true when VariableGroup structures should be automatically identified, false otherwise.

Definition at line 2129 of file system.h.

References _identify_variable_groups.

Referenced by add_variable().

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

Toggle automatic VariableGroup identification.

Definition at line 2137 of file system.h.

References _identify_variable_groups.

void libMesh::ReferenceCounter::increment_constructor_count ( const std::string &  name) [inline, protected, inherited]

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

{
  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
  std::pair<unsigned int, unsigned int>& p = _counts[name];

  p.first++;
}
void libMesh::ReferenceCounter::increment_destructor_count ( const std::string &  name) [inline, protected, inherited]

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

{
  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
  std::pair<unsigned int, unsigned int>& p = _counts[name];

  p.second++;
}

Initializes degrees of freedom on the current mesh. Sets the

Definition at line 227 of file system.C.

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

{
  // First initialize any required data:
  // either only the basic System data
  if (_basic_system_only)
    System::init_data();
  // or all the derived class' data too
  else
    this->init_data();

  // If no variables have been added to this system
  // don't do anything
  if(!this->n_vars())
    return;

  // Then call the user-provided intialization function
  this->user_initialization();
}
void libMesh::System::init_data ( ) [protected, virtual]

Initializes the data for the system. Note that this is called before any user-supplied intitialization function so that all required storage will be available.

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

Definition at line 248 of file system.C.

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

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

{
  MeshBase &mesh = this->get_mesh();

  // Add all variable groups to our underlying DofMap
  for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
    _dof_map->add_variable_group(this->variable_group(vg));

  // Distribute the degrees of freedom on the mesh
  _dof_map->distribute_dofs (mesh);

#ifdef LIBMESH_ENABLE_CONSTRAINTS

  // Recreate any hanging node constraints
  _dof_map->create_dof_constraints(mesh);

  // Apply any user-defined constraints
  this->user_constrain();

  // Expand any recursive constraints
  _dof_map->process_constraints(mesh);

#endif

  // And clean up the send_list before we first use it
  _dof_map->prepare_send_list();

  // Resize the solution conformal to the current mesh
  solution->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);

  // Resize the current_local_solution for the current mesh
#ifdef LIBMESH_ENABLE_GHOSTED
  current_local_solution->init (this->n_dofs(), this->n_local_dofs(),
                                _dof_map->get_send_list(), false,
                                GHOSTED);
#else
  current_local_solution->init (this->n_dofs(), false, SERIAL);
#endif

  // from now on, adding additional vectors or variables can't be done
  // without immediately initializing them
  _is_initialized = true;

  // initialize & zero other vectors, if necessary
  for (vectors_iterator pos = _vectors.begin(); pos != _vectors.end(); ++pos)
    {
      ParallelType type = _vector_types[pos->first];

      if (type == GHOSTED)
        {
#ifdef LIBMESH_ENABLE_GHOSTED
          pos->second->init (this->n_dofs(), this->n_local_dofs(),
                             _dof_map->get_send_list(), false,
                             GHOSTED);
#else
          libmesh_error_msg("Cannot initialize ghosted vectors when they are not enabled.");
#endif
        }
      else if (type == SERIAL)
        {
          pos->second->init (this->n_dofs(), false, type);
        }
      else
        {
          libmesh_assert_equal_to(type, PARALLEL);
          pos->second->init (this->n_dofs(), this->n_local_dofs(), false, type);
        }
    }
}

Accessor for the adjoint_already_solved boolean

Definition at line 375 of file system.h.

References adjoint_already_solved.

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

Returns true iff this system has been initialized.

Definition at line 2017 of file system.h.

References _is_initialized.

Referenced by add_variable(), and add_variables().

{
  return _is_initialized;
}
void libMesh::System::local_dof_indices ( const unsigned int  var,
std::set< dof_id_type > &  var_indices 
) const

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

Definition at line 1304 of file system.C.

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

Referenced by discrete_var_norm().

{
  // Make sure the set is clear
  var_indices.clear();

  std::vector<dof_id_type> dof_indices;

  // Begin the loop over the elements
  MeshBase::const_element_iterator       el     =
    this->get_mesh().active_local_elements_begin();
  const MeshBase::const_element_iterator end_el =
    this->get_mesh().active_local_elements_end();

  const dof_id_type
    first_local = this->get_dof_map().first_dof(),
    end_local   = this->get_dof_map().end_dof();

  for ( ; el != end_el; ++el)
    {
      const Elem* elem = *el;
      this->get_dof_map().dof_indices (elem, dof_indices, var);

      for(unsigned int i=0; i<dof_indices.size(); i++)
        {
          dof_id_type dof = dof_indices[i];

          //If the dof is owned by the local processor
          if(first_local <= dof && dof < end_local)
            var_indices.insert(dof_indices[i]);
        }
    }
}

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

Definition at line 2145 of file system.h.

References n_constrained_dofs(), and n_dofs().

{
  return this->n_dofs() - this->n_constrained_dofs();
}
unsigned int libMesh::System::n_components ( ) const [inline]
Returns:
the total number of scalar components in the system's variables. This will equal n_vars() in the case of all scalar-valued variables.

Definition at line 2049 of file system.h.

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

Referenced by add_variables(), and project_vector().

{
  if (_variables.empty())
    return 0;

  const Variable& last = _variables.back();
  return last.first_scalar_number() + last.n_components();
}
Returns:
the total number of constrained degrees of freedom in the system.

Definition at line 147 of file system.C.

References _dof_map.

Referenced by get_info(), and n_active_dofs().

{
#ifdef LIBMESH_ENABLE_CONSTRAINTS

  return _dof_map->n_constrained_dofs();

#else

  return 0;

#endif
}
Returns:
the number of constrained degrees of freedom on this processor.

Definition at line 162 of file system.C.

References _dof_map.

Referenced by get_info().

{
#ifdef LIBMESH_ENABLE_CONSTRAINTS

  return _dof_map->n_local_constrained_dofs();

#else

  return 0;

#endif
}
unsigned int libMesh::System::n_matrices ( ) const [inline, virtual]
Returns:
the number of matrices handled by this system.

This will return 0 by default but can be overriden.

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

Definition at line 2167 of file system.h.

Referenced by get_info().

{
  return 0;
}
static unsigned int libMesh::ReferenceCounter::n_objects ( ) [inline, static, inherited]

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.

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

  { return _n_objects; }
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::FEMSystem::assembly(), 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::DofMap::local_variable_indices(), 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(), point_gradient(), point_hessian(), point_value(), libMesh::MeshTools::processor_bounding_box(), project_vector(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::XdrIO::read(), read_parallel_data(), read_SCALAR_dofs(), read_serialized_blocked_dof_objects(), 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(), write_parallel_data(), write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs(), write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

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

Definition at line 2041 of file system.h.

References _variable_groups.

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

{
  return cast_int<unsigned int>(_variable_groups.size());
}
unsigned int libMesh::System::n_vars ( ) const [inline]
Returns:
the number of variables in the system

Definition at line 2033 of file system.h.

References _variables.

Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::DiffContext::add_localized_vector(), add_variable(), add_variables(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_solution_vector(), calculate_norm(), libMesh::DGFEMContext::DGFEMContext(), libMesh::DiffContext::DiffContext(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::ErrorEstimator::estimate_errors(), libMesh::ExactSolution::ExactSolution(), libMesh::FEMContext::FEMContext(), get_all_variable_numbers(), libMesh::EquationSystems::get_solution(), init(), libMesh::FEMSystem::init_context(), libMesh::DGFEMContext::neighbor_side_fe_reinit(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::ProjectSolution::operator()(), libMesh::petsc_auto_fieldsplit(), libMesh::FEMContext::pre_fe_reinit(), project_vector(), re_update(), read_legacy_data(), read_parallel_data(), read_serialized_blocked_dof_objects(), read_serialized_vector(), read_serialized_vectors(), reinit(), libMesh::HPCoarsenTest::select_refinement(), libMesh::SystemSubsetBySubdomain::set_var_nums(), write_header(), write_parallel_data(), write_serialized_blocked_dof_objects(), write_serialized_vector(), write_serialized_vectors(), and zero_variable().

{
  return cast_int<unsigned int>(_variables.size());
}
unsigned int libMesh::System::n_vectors ( ) const [inline]
Returns:
the number of vectors (in addition to the solution) handled by this system This is the size of the _vectors map

Definition at line 2161 of file system.h.

References _vectors.

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

{
  return cast_int<unsigned int>(_vectors.size());
}
System & libMesh::System::operator= ( const System ) [private]

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

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

Definition at line 107 of file system.C.

{
  libmesh_not_implemented();
}
Gradient libMesh::System::point_gradient ( unsigned int  var,
const Point p,
const bool  insist_on_success = true 
) const

Returns the gradient of the solution variable var at the physical point p in the mesh, similarly to point_value.

Definition at line 2092 of file system.C.

References libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::PointLocatorBase::enable_out_of_mesh_mode(), 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().

{
  // This function must be called on every processor; there's no
  // telling where in the partition p falls.
  parallel_object_only();

  // And every processor had better agree about which point we're
  // looking for
#ifndef NDEBUG
  this->comm().verify(p);
#endif // NDEBUG

  // Get a reference to the mesh object associated with the system object that calls this function
  const MeshBase &mesh = this->get_mesh();

  // Use an existing PointLocator or create a new one
  UniquePtr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
  PointLocatorBase& locator = *locator_ptr;

  if (!insist_on_success)
    locator.enable_out_of_mesh_mode();

  // Get a pointer to the element that contains P
  const Elem *e = locator(p);

  Gradient grad_u;

  if (e && e->processor_id() == this->processor_id())
    grad_u = point_gradient(var, p, *e);

  // If I have an element containing p, then let's let everyone know
  processor_id_type lowest_owner =
    (e && (e->processor_id() == this->processor_id())) ?
    this->processor_id() : this->n_processors();
  this->comm().min(lowest_owner);

  // Everybody should get their value from a processor that was able
  // to compute it.
  // If nobody admits owning the point, we may have a problem.
  if (lowest_owner != this->n_processors())
    this->comm().broadcast(grad_u, lowest_owner);
  else
    libmesh_assert(!insist_on_success);

  return grad_u;
}
Gradient libMesh::System::point_gradient ( unsigned int  var,
const Point p,
const Elem e 
) const

Returns the gradient of the solution variable var at the physical point p in local Elem e in the mesh, similarly to point_value.

Definition at line 2140 of file system.C.

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

{
  libmesh_assert_equal_to (e.processor_id(), this->processor_id());

  // Ensuring that the given point is really in the element is an
  // expensive assert, but as long as debugging is turned on we might
  // as well try to catch a particularly nasty potential error
  libmesh_assert (e.contains_point(p));

  // Get the dof map to get the proper indices for our computation
  const DofMap& dof_map = this->get_dof_map();

  // Need dof_indices for phi[i][j]
  std::vector<dof_id_type> dof_indices;

  // Fill in the dof_indices for our element
  dof_map.dof_indices (&e, dof_indices, var);

  // Get the no of dofs assciated with this point
  const unsigned int num_dofs = cast_int<unsigned int>
    (dof_indices.size());

  FEType fe_type = dof_map.variable_type(var);

  // Build a FE again so we can calculate u(p)
  UniquePtr<FEBase> fe (FEBase::build(e.dim(), fe_type));

  // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h
  // Build a vector of point co-ordinates to send to reinit
  std::vector<Point> coor(1, FEInterface::inverse_map(e.dim(), fe_type, &e, p));

  // Get the values of the shape function derivatives
  const std::vector<std::vector<RealGradient> >&  dphi = fe->get_dphi();

  // Reinitialize the element and compute the shape function values at coor
  fe->reinit (&e, &coor);

  // Get ready to accumulate a gradient
  Gradient grad_u;

  for (unsigned int l=0; l<num_dofs; l++)
    {
      grad_u.add_scaled (dphi[l][0], this->current_solution (dof_indices[l]));
    }

  return grad_u;
}
Tensor libMesh::System::point_hessian ( unsigned int  var,
const Point p,
const bool  insist_on_success = true 
) const

Returns the second derivative tensor of the solution variable var at the physical point p in the mesh, similarly to point_value.

Definition at line 2191 of file system.C.

References libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::PointLocatorBase::enable_out_of_mesh_mode(), 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().

{
  // This function must be called on every processor; there's no
  // telling where in the partition p falls.
  parallel_object_only();

  // And every processor had better agree about which point we're
  // looking for
#ifndef NDEBUG
  this->comm().verify(p);
#endif // NDEBUG

  // Get a reference to the mesh object associated with the system object that calls this function
  const MeshBase &mesh = this->get_mesh();

  // Use an existing PointLocator or create a new one
  UniquePtr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
  PointLocatorBase& locator = *locator_ptr;

  if (!insist_on_success)
    locator.enable_out_of_mesh_mode();

  // Get a pointer to the element that contains P
  const Elem *e = locator(p);

  Tensor hess_u;

  if (e && e->processor_id() == this->processor_id())
    hess_u = point_hessian(var, p, *e);

  // If I have an element containing p, then let's let everyone know
  processor_id_type lowest_owner =
    (e && (e->processor_id() == this->processor_id())) ?
    this->processor_id() : this->n_processors();
  this->comm().min(lowest_owner);

  // Everybody should get their value from a processor that was able
  // to compute it.
  // If nobody admits owning the point, we may have a problem.
  if (lowest_owner != this->n_processors())
    this->comm().broadcast(hess_u, lowest_owner);
  else
    libmesh_assert(!insist_on_success);

  return hess_u;
}
Tensor libMesh::System::point_hessian ( unsigned int  var,
const Point p,
const Elem e 
) const

Returns the second derivative tensor of the solution variable var at the physical point p in local Elem e in the mesh, similarly to point_value.

Definition at line 2238 of file system.C.

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

{
  libmesh_assert_equal_to (e.processor_id(), this->processor_id());

  // Ensuring that the given point is really in the element is an
  // expensive assert, but as long as debugging is turned on we might
  // as well try to catch a particularly nasty potential error
  libmesh_assert (e.contains_point(p));

  // Get the dof map to get the proper indices for our computation
  const DofMap& dof_map = this->get_dof_map();

  // Need dof_indices for phi[i][j]
  std::vector<dof_id_type> dof_indices;

  // Fill in the dof_indices for our element
  dof_map.dof_indices (&e, dof_indices, var);

  // Get the no of dofs assciated with this point
  const unsigned int num_dofs = cast_int<unsigned int>
    (dof_indices.size());

  FEType fe_type = dof_map.variable_type(var);

  // Build a FE again so we can calculate u(p)
  UniquePtr<FEBase> fe (FEBase::build(e.dim(), fe_type));

  // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h
  // Build a vector of point co-ordinates to send to reinit
  std::vector<Point> coor(1, FEInterface::inverse_map(e.dim(), fe_type, &e, p));

  // Get the values of the shape function derivatives
  const std::vector<std::vector<RealTensor> >&  d2phi = fe->get_d2phi();

  // Reinitialize the element and compute the shape function values at coor
  fe->reinit (&e, &coor);

  // Get ready to accumulate a hessian
  Tensor hess_u;

  for (unsigned int l=0; l<num_dofs; l++)
    {
      hess_u.add_scaled (d2phi[l][0], this->current_solution (dof_indices[l]));
    }

  return hess_u;
}
Number libMesh::System::point_value ( unsigned int  var,
const Point p,
const bool  insist_on_success = true 
) const

Returns the value of the solution variable var at the physical point p in the mesh, without knowing a priori which element contains p.

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

References libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::PointLocatorBase::enable_out_of_mesh_mode(), 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().

{
  // This function must be called on every processor; there's no
  // telling where in the partition p falls.
  parallel_object_only();

  // And every processor had better agree about which point we're
  // looking for
#ifndef NDEBUG
  this->comm().verify(p);
#endif // NDEBUG

  // Get a reference to the mesh object associated with the system object that calls this function
  const MeshBase &mesh = this->get_mesh();

  // Use an existing PointLocator or create a new one
  UniquePtr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
  PointLocatorBase& locator = *locator_ptr;

  if (!insist_on_success)
    locator.enable_out_of_mesh_mode();

  // Get a pointer to the element that contains P
  const Elem *e = locator(p);

  Number u = 0;

  if (e && e->processor_id() == this->processor_id())
    u = point_value(var, p, *e);

  // If I have an element containing p, then let's let everyone know
  processor_id_type lowest_owner =
    (e && (e->processor_id() == this->processor_id())) ?
    this->processor_id() : this->n_processors();
  this->comm().min(lowest_owner);

  // Everybody should get their value from a processor that was able
  // to compute it.
  // If nobody admits owning the point, we have a problem.
  if (lowest_owner != this->n_processors())
    this->comm().broadcast(u, lowest_owner);
  else
    libmesh_assert(!insist_on_success);

  return u;
}
Number libMesh::System::point_value ( unsigned int  var,
const Point p,
const Elem e 
) const

Returns the value of the solution variable var at the physical point p contained in local Elem e

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

Definition at line 2042 of file system.C.

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

{
  libmesh_assert_equal_to (e.processor_id(), this->processor_id());

  // Ensuring that the given point is really in the element is an
  // expensive assert, but as long as debugging is turned on we might
  // as well try to catch a particularly nasty potential error
  libmesh_assert (e.contains_point(p));

  // Get the dof map to get the proper indices for our computation
  const DofMap& dof_map = this->get_dof_map();

  // Need dof_indices for phi[i][j]
  std::vector<dof_id_type> dof_indices;

  // Fill in the dof_indices for our element
  dof_map.dof_indices (&e, dof_indices, var);

  // Get the no of dofs assciated with this point
  const unsigned int num_dofs = cast_int<unsigned int>
    (dof_indices.size());

  FEType fe_type = dof_map.variable_type(var);

  // Build a FE so we can calculate u(p)
  UniquePtr<FEBase> fe (FEBase::build(e.dim(), fe_type));

  // Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h
  // Build a vector of point co-ordinates to send to reinit
  std::vector<Point> coor(1, FEInterface::inverse_map(e.dim(), fe_type, &e, p));

  // Get the shape function values
  const std::vector<std::vector<Real> >& phi = fe->get_phi();

  // Reinitialize the element and compute the shape function values at coor
  fe->reinit (&e, &coor);

  // Get ready to accumulate a value
  Number u = 0;

  for (unsigned int l=0; l<num_dofs; l++)
    {
      u += phi[l][0]*this->current_solution (dof_indices[l]);
    }

  return u;
}
void libMesh::ReferenceCounter::print_info ( std::ostream &  out = libMesh::out) [static, inherited]

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

Definition at line 88 of file reference_counter.C.

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

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

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::FEMSystem::assembly(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::ParallelMesh::assign_unique_ids(), 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::ParallelMesh::delete_elem(), libMesh::ParallelMesh::delete_node(), 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::SerialMesh::facelocal_elements_begin(), libMesh::ParallelMesh::facelocal_elements_begin(), libMesh::SerialMesh::facelocal_elements_end(), libMesh::ParallelMesh::facelocal_elements_end(), libMesh::MeshFunction::find_element(), 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::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_element_variables(), libMesh::ExodusII_IO_Helper::initialize_global_variables(), libMesh::ExodusII_IO_Helper::initialize_nodal_variables(), libMesh::ParallelMesh::insert_elem(), 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::DofMap::local_variable_indices(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::DofMap::n_local_dofs(), n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::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::ParallelMesh::ParallelMesh(), point_gradient(), point_hessian(), point_value(), 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::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), read_header(), read_legacy_data(), libMesh::ExodusII_IO_Helper::read_node_num_map(), read_parallel_data(), read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs(), read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), read_serialized_data(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), read_serialized_vector(), read_serialized_vectors(), libMesh::MeshData::read_xdr(), libMesh::SerialMesh::semilocal_elements_begin(), libMesh::ParallelMesh::semilocal_elements_begin(), libMesh::SerialMesh::semilocal_elements_end(), libMesh::ParallelMesh::semilocal_elements_end(), 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::NameBasedIO::write(), libMesh::ExodusII_IO::write(), libMesh::CheckpointIO::write(), libMesh::XdrIO::write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO::write_global_data(), libMesh::ExodusII_IO_Helper::write_global_values(), write_header(), libMesh::ExodusII_IO::write_information_records(), libMesh::ExodusII_IO_Helper::write_information_records(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::UCDIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::ExodusII_IO_Helper::write_nodal_values(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::Nemesis_IO_Helper::write_nodesets(), write_parallel_data(), write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs(), write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), write_serialized_data(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), write_serialized_vector(), write_serialized_vectors(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), and libMesh::ExodusII_IO_Helper::write_timestep().

  { return cast_int<processor_id_type>(_communicator.rank()); }
void libMesh::System::project_solution ( FunctionBase< Number > *  f,
FunctionBase< Gradient > *  g = NULL 
) const

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

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

Definition at line 472 of file system_projection.C.

References _dof_map, current_local_solution, project_vector(), and solution.

Referenced by project_solution().

{
  this->project_vector(*solution, f, g);

  solution->localize(*current_local_solution, _dof_map->get_send_list());
}

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

References _dof_map, current_local_solution, project_vector(), and solution.

{
  this->project_vector(*solution, f, g);

  solution->localize(*current_local_solution, _dof_map->get_send_list());
}
void libMesh::System::project_solution ( Number   fptrconst Point &p,const Parameters &parameters,const std::string &sys_name,const std::string &unknown_name,
Gradient   gptrconst Point &p,const Parameters &parameters,const std::string &sys_name,const std::string &unknown_name,
const Parameters parameters 
) const

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

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

Definition at line 452 of file system_projection.C.

References project_solution().

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

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

References _solution_projection.

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

  { return _solution_projection; }
void libMesh::System::project_vector ( NumericVector< Number > &  new_vector,
FunctionBase< Number > *  f,
FunctionBase< Gradient > *  g = NULL,
int  is_adjoint = -1 
) const

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

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

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

Definition at line 519 of file system_projection.C.

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

Referenced by project_solution(), project_vector(), and restrict_vectors().

{
  START_LOG ("project_vector()", "System");

  Threads::parallel_for
    (ConstElemRange (this->get_mesh().active_local_elements_begin(),
                     this->get_mesh().active_local_elements_end() ),
     ProjectSolution(*this, f, g,
                     this->get_equation_systems().parameters,
                     new_vector)
     );

  // Also, load values into the SCALAR dofs
  // Note: We assume that all SCALAR dofs are on the
  // processor with highest ID
  if(this->processor_id() == (this->n_processors()-1))
    {
      // We get different scalars as different
      // components from a new-style f functor.
      DenseVector<Number> fout(this->n_components());
      bool filled_fout = false;

      const DofMap& dof_map = this->get_dof_map();
      for (unsigned int var=0; var<this->n_vars(); var++)
        if(this->variable(var).type().family == SCALAR)
          {
            if (!filled_fout)
              {
                (*f) (Point(), this->time, fout);
                filled_fout = true;
              }

            std::vector<dof_id_type> SCALAR_indices;
            dof_map.SCALAR_dof_indices (SCALAR_indices, var);
            const unsigned int n_SCALAR_dofs =
              cast_int<unsigned int>(SCALAR_indices.size());

            for (unsigned int i=0; i<n_SCALAR_dofs; i++)
              {
                const dof_id_type global_index = SCALAR_indices[i];
                const unsigned int component_index =
                  this->variable_scalar_number(var,i);
                new_vector.set(global_index, fout(component_index));
              }
          }
    }

  new_vector.close();

#ifdef LIBMESH_ENABLE_CONSTRAINTS
  if (is_adjoint == -1)
    this->get_dof_map().enforce_constraints_exactly(*this, &new_vector);
  else if (is_adjoint >= 0)
    this->get_dof_map().enforce_adjoint_constraints_exactly(new_vector,
                                                            is_adjoint);
#endif

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

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

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

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

Definition at line 587 of file system_projection.C.

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

{
  START_LOG ("project_fem_vector()", "System");

  Threads::parallel_for
    (ConstElemRange (this->get_mesh().active_local_elements_begin(),
                     this->get_mesh().active_local_elements_end() ),
     ProjectFEMSolution(*this, f, g, new_vector)
     );

  // Also, load values into the SCALAR dofs
  // Note: We assume that all SCALAR dofs are on the
  // processor with highest ID
  if(this->processor_id() == (this->n_processors()-1))
    {
      // FIXME: Do we want to first check for SCALAR vars before building this? [PB]
      FEMContext context( *this );

      const DofMap& dof_map = this->get_dof_map();
      for (unsigned int var=0; var<this->n_vars(); var++)
        if(this->variable(var).type().family == SCALAR)
          {
            // FIXME: We reinit with an arbitrary element in case the user
            //        doesn't override FEMFunctionBase::component. Is there
            //        any use case we're missing? [PB]
            Elem *el = const_cast<Elem *>(*(this->get_mesh().active_local_elements_begin()));
            context.pre_fe_reinit( *this, el );

            std::vector<dof_id_type> SCALAR_indices;
            dof_map.SCALAR_dof_indices (SCALAR_indices, var);
            const unsigned int n_SCALAR_dofs =
              cast_int<unsigned int>(SCALAR_indices.size());

            for (unsigned int i=0; i<n_SCALAR_dofs; i++)
              {
                const dof_id_type global_index = SCALAR_indices[i];
                const unsigned int component_index =
                  this->variable_scalar_number(var,i);

                new_vector.set(global_index, f->component(context, component_index, Point(), this->time));
              }
          }
    }

  new_vector.close();

#ifdef LIBMESH_ENABLE_CONSTRAINTS
  if (is_adjoint == -1)
    this->get_dof_map().enforce_constraints_exactly(*this, &new_vector);
  else if (is_adjoint >= 0)
    this->get_dof_map().enforce_adjoint_constraints_exactly(new_vector,
                                                            is_adjoint);
#endif

  STOP_LOG("project_fem_vector()", "System");
}
void libMesh::System::project_vector ( Number   fptrconst Point &p,const Parameters &parameters,const std::string &sys_name,const std::string &unknown_name,
Gradient   gptrconst Point &p,const Parameters &parameters,const std::string &sys_name,const std::string &unknown_name,
const Parameters parameters,
NumericVector< Number > &  new_vector,
int  is_adjoint = -1 
) const

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

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

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

Definition at line 498 of file system_projection.C.

References project_vector().

{
  WrappedFunction<Number> f(*this, fptr, &parameters);
  WrappedFunction<Gradient> g(*this, gptr, &parameters);
  this->project_vector(new_vector, &f, &g, is_adjoint);
}
void libMesh::System::project_vector ( NumericVector< Number > &  vector,
int  is_adjoint = -1 
) const [protected]

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

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

Definition at line 255 of file system_projection.C.

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

{
  // Create a copy of the vector, which currently
  // contains the old data.
  UniquePtr<NumericVector<Number> >
    old_vector (vector.clone());

  // Project the old vector to the new vector
  this->project_vector (*old_vector, vector, is_adjoint);
}
void libMesh::System::project_vector ( const NumericVector< Number > &  old_v,
NumericVector< Number > &  new_v,
int  is_adjoint = -1 
) const [protected]

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

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

This method projects 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 273 of file system_projection.C.

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

{
  START_LOG ("project_vector()", "System");

  new_v.clear();

#ifdef LIBMESH_ENABLE_AMR

  // Resize the new vector and get a serial version.
  NumericVector<Number> *new_vector_ptr = NULL;
  UniquePtr<NumericVector<Number> > new_vector_built;
  NumericVector<Number> *local_old_vector;
  UniquePtr<NumericVector<Number> > local_old_vector_built;
  const NumericVector<Number> *old_vector_ptr = NULL;

  ConstElemRange active_local_elem_range
    (this->get_mesh().active_local_elements_begin(),
     this->get_mesh().active_local_elements_end());

  // If the old vector was uniprocessor, make the new
  // vector uniprocessor
  if (old_v.type() == SERIAL)
    {
      new_v.init (this->n_dofs(), false, SERIAL);
      new_vector_ptr = &new_v;
      old_vector_ptr = &old_v;
    }

  // Otherwise it is a parallel, distributed vector, which
  // we need to localize.
  else if (old_v.type() == PARALLEL)
    {
      // Build a send list for efficient localization
      BuildProjectionList projection_list(*this);
      Threads::parallel_reduce (active_local_elem_range,
                                projection_list);

      // Create a sorted, unique send_list
      projection_list.unique();

      new_v.init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
      new_vector_built = NumericVector<Number>::build(this->comm());
      local_old_vector_built = NumericVector<Number>::build(this->comm());
      new_vector_ptr = new_vector_built.get();
      local_old_vector = local_old_vector_built.get();
      new_vector_ptr->init(this->n_dofs(), false, SERIAL);
      local_old_vector->init(old_v.size(), false, SERIAL);
      old_v.localize(*local_old_vector, projection_list.send_list);
      local_old_vector->close();
      old_vector_ptr = local_old_vector;
    }
  else if (old_v.type() == GHOSTED)
    {
      // Build a send list for efficient localization
      BuildProjectionList projection_list(*this);
      Threads::parallel_reduce (active_local_elem_range,
                                projection_list);

      // Create a sorted, unique send_list
      projection_list.unique();

      new_v.init (this->n_dofs(), this->n_local_dofs(),
                  this->get_dof_map().get_send_list(), false, GHOSTED);

      local_old_vector_built = NumericVector<Number>::build(this->comm());
      new_vector_ptr = &new_v;
      local_old_vector = local_old_vector_built.get();
      local_old_vector->init(old_v.size(), old_v.local_size(),
                             projection_list.send_list, false, GHOSTED);
      old_v.localize(*local_old_vector, projection_list.send_list);
      local_old_vector->close();
      old_vector_ptr = local_old_vector;
    }
  else // unknown old_v.type()
    libmesh_error_msg("ERROR: Unknown old_v.type() == " << old_v.type());

  // Note that the above will have zeroed the new_vector.
  // Just to be sure, assert that new_vector_ptr and old_vector_ptr
  // were successfully set before trying to deref them.
  libmesh_assert(new_vector_ptr);
  libmesh_assert(old_vector_ptr);

  NumericVector<Number> &new_vector = *new_vector_ptr;
  const NumericVector<Number> &old_vector = *old_vector_ptr;

  Threads::parallel_for (active_local_elem_range,
                         ProjectVector(*this,
                                       old_vector,
                                       new_vector)
                         );

  // Copy the SCALAR dofs from old_vector to new_vector
  // Note: We assume that all SCALAR dofs are on the
  // processor with highest ID
  if(this->processor_id() == (this->n_processors()-1))
    {
      const DofMap& dof_map = this->get_dof_map();
      for (unsigned int var=0; var<this->n_vars(); var++)
        if(this->variable(var).type().family == SCALAR)
          {
            // We can just map SCALAR dofs directly across
            std::vector<dof_id_type> new_SCALAR_indices, old_SCALAR_indices;
            dof_map.SCALAR_dof_indices (new_SCALAR_indices, var, false);
            dof_map.SCALAR_dof_indices (old_SCALAR_indices, var, true);
            const unsigned int new_n_dofs =
              cast_int<unsigned int>(new_SCALAR_indices.size());

            for (unsigned int i=0; i<new_n_dofs; i++)
              {
                new_vector.set( new_SCALAR_indices[i], old_vector(old_SCALAR_indices[i]) );
              }
          }
    }

  new_vector.close();

  // If the old vector was serial, we probably need to send our values
  // to other processors
  //
  // FIXME: I'm not sure how to make a NumericVector do that without
  // creating a temporary parallel vector to use localize! - RHS
  if (old_v.type() == SERIAL)
    {
      UniquePtr<NumericVector<Number> > dist_v = NumericVector<Number>::build(this->comm());
      dist_v->init(this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
      dist_v->close();

      for (dof_id_type i=0; i!=dist_v->size(); i++)
        if (new_vector(i) != 0.0)
          dist_v->set(i, new_vector(i));

      dist_v->close();

      dist_v->localize (new_v, this->get_dof_map().get_send_list());
      new_v.close();
    }
  // If the old vector was parallel, we need to update it
  // and free the localized copies
  else if (old_v.type() == PARALLEL)
    {
      // We may have to set dof values that this processor doesn't
      // own in certain special cases, like LAGRANGE FIRST or
      // HERMITE THIRD elements on second-order meshes
      for (dof_id_type i=0; i!=new_v.size(); i++)
        if (new_vector(i) != 0.0)
          new_v.set(i, new_vector(i));
      new_v.close();
    }

  if (is_adjoint == -1)
    this->get_dof_map().enforce_constraints_exactly(*this, &new_v);
  else if (is_adjoint >= 0)
    this->get_dof_map().enforce_adjoint_constraints_exactly(new_v,
                                                            is_adjoint);

#else

  // AMR is disabled: simply copy the vector
  new_v = old_v;

#endif // #ifdef LIBMESH_ENABLE_AMR

  STOP_LOG("project_vector()", "System");
}

Prolong vectors after the mesh has refined

Definition at line 373 of file system.C.

References restrict_vectors().

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

{
#ifdef LIBMESH_ENABLE_AMR
  // Currently project_vector handles both restriction and prolongation
  this->restrict_vectors();
#endif
}
void libMesh::System::qoi_parameter_hessian ( const QoISet qoi_indices,
const ParameterVector parameters,
SensitivityData hessian 
) [inline, virtual]

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

{
  libmesh_not_implemented();
}
void libMesh::System::qoi_parameter_hessian_vector_product ( const QoISet qoi_indices,
const ParameterVector parameters,
const ParameterVector vector,
SensitivityData product 
) [inline, virtual]

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

{
  libmesh_not_implemented();
}
void libMesh::System::qoi_parameter_sensitivity ( const QoISet qoi_indices,
const ParameterVector parameters,
SensitivityData sensitivities 
) [virtual]

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

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

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

{
  // Forward sensitivities are more efficient for Nq > Np
  if (qoi_indices.size(*this) > parameters.size())
    forward_qoi_parameter_sensitivity(qoi_indices, parameters, sensitivities);
  // Adjoint sensitivities are more efficient for Np > Nq,
  // and an adjoint may be more reusable than a forward
  // solution sensitivity in the Np == Nq case.
  else
    adjoint_qoi_parameter_sensitivity(qoi_indices, parameters, sensitivities);
}
void libMesh::System::re_update ( ) [virtual]

Re-update the local values when the mesh has changed. This method takes the data updated by update() and makes it up-to-date on the current mesh.

Reimplemented in libMesh::TransientSystem< RBConstruction >.

Definition at line 442 of file system.C.

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

{
  parallel_object_only();

  // If this system is empty... don't do anything!
  if(!this->n_vars())
    return;

  const std::vector<dof_id_type>& send_list = this->get_dof_map().get_send_list ();

  // Check sizes
  libmesh_assert_equal_to (current_local_solution->size(), solution->size());
  // Not true with ghosted vectors
  // libmesh_assert_equal_to (current_local_solution->local_size(), solution->size());
  // libmesh_assert (!send_list.empty());
  libmesh_assert_less_equal (send_list.size(), solution->size());

  // Create current_local_solution from solution.  This will
  // put a local copy of solution into current_local_solution.
  solution->localize (*current_local_solution, send_list);
}
void libMesh::System::read_header ( Xdr io,
const std::string &  version,
const bool  read_header = true,
const bool  read_additional_data = true,
const bool  read_legacy_format = false 
)

Reads the basic data header for this System.

Definition at line 115 of file system_io.C.

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

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

{
  // This method implements the input of a
  // System object, embedded in the output of
  // an EquationSystems<T_sys>.  This warrants some
  // documentation.  The output file essentially
  // 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.) Variable subdmains
  //
  //     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
  libmesh_assert (io.reading());

  // Possibly clear data structures and start from scratch.
  if (read_header_in)
    this->clear ();

  // Figure out if we need to read infinite element information.
  // This will be true if the version string contains " with infinite elements"
  const bool read_ifem_info =
    (version.rfind(" with infinite elements") < version.size()) ||
    libMesh::on_command_line ("--read_ifem_systems");


  {
    // 5.)
    // Read the number of variables in the system
    unsigned int nv=0;
    if (this->processor_id() == 0)
      io.data (nv);
    this->comm().broadcast(nv);

    _written_var_indices.clear();
    _written_var_indices.resize(nv, 0);

    for (unsigned int var=0; var<nv; var++)
      {
        // 6.)
        // Read the name of the var-th variable
        std::string var_name;
        if (this->processor_id() == 0)
          io.data (var_name);
        this->comm().broadcast(var_name);

        // 6.1.)
        std::set<subdomain_id_type> domains;
        if (io.version() >= LIBMESH_VERSION_ID(0,7,2))
          {
            std::vector<subdomain_id_type> domain_array;
            if (this->processor_id() == 0)
              io.data (domain_array);
            for (std::vector<subdomain_id_type>::iterator it = domain_array.begin(); it != domain_array.end(); ++it)
              domains.insert(*it);
          }
        this->comm().broadcast(domains);

        // 7.)
        // Read the approximation order(s) of the var-th variable
        int order=0;
        if (this->processor_id() == 0)
          io.data (order);
        this->comm().broadcast(order);


        // do the same for infinite element radial_order
        int rad_order=0;
        if (read_ifem_info)
          {
            if (this->processor_id() == 0)
              io.data(rad_order);
            this->comm().broadcast(rad_order);
          }

        // Read the finite element type of the var-th variable
        int fam=0;
        if (this->processor_id() == 0)
          io.data (fam);
        this->comm().broadcast(fam);
        FEType type;
        type.order  = static_cast<Order>(order);
        type.family = static_cast<FEFamily>(fam);

        // Check for incompatibilities.  The shape function indexing was
        // changed for the monomial and xyz finite element families to
        // simplify extension to arbitrary p.  The consequence is that
        // old restart files will not be read correctly.  This is expected
        // to be an unlikely occurance, but catch it anyway.
        if (read_legacy_format)
          if ((type.family == MONOMIAL || type.family == XYZ) &&
              ((type.order > 2 && this->get_mesh().mesh_dimension() == 2) ||
               (type.order > 1 && this->get_mesh().mesh_dimension() == 3)))
            {
              libmesh_here();
              libMesh::out << "*****************************************************************\n"
                           << "* WARNING: reading a potentially incompatible restart file!!!   *\n"
                           << "*  contact libmesh-users@lists.sourceforge.net for more details *\n"
                           << "*****************************************************************"
                           << std::endl;
            }

        // Read additional information for infinite elements
        int radial_fam=0;
        int i_map=0;
        if (read_ifem_info)
          {
            if (this->processor_id() == 0)
              io.data (radial_fam);
            this->comm().broadcast(radial_fam);
            if (this->processor_id() == 0)
              io.data (i_map);
            this->comm().broadcast(i_map);
          }

#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS

        type.radial_order  = static_cast<Order>(rad_order);
        type.radial_family = static_cast<FEFamily>(radial_fam);
        type.inf_map       = static_cast<InfMapType>(i_map);

#endif

        if (read_header_in)
          {
            if (domains.empty())
              _written_var_indices[var] = this->add_variable (var_name, type);
            else
              _written_var_indices[var] = this->add_variable (var_name, type, &domains);
          }
        else
          _written_var_indices[var] = this->variable_number(var_name);
      }
  }

  // 8.)
  // Read the number of additional vectors.
  unsigned int nvecs=0;
  if (this->processor_id() == 0)
    io.data (nvecs);
  this->comm().broadcast(nvecs);

  // If nvecs > 0, this means that write_additional_data
  // was true when this file was written.  We will need to
  // make use of this fact later.
  if (nvecs > 0)
    this->_additional_data_written = true;

  for (unsigned int vec=0; vec<nvecs; vec++)
    {
      // 9.)
      // Read the name of the vec-th additional vector
      std::string vec_name;
      if (this->processor_id() == 0)
        io.data (vec_name);
      this->comm().broadcast(vec_name);

      if (read_additional_data)
        {
          // Systems now can handle adding post-initialization vectors
          //  libmesh_assert(this->_can_add_vectors);
          // Some systems may have added their own vectors already
          //  libmesh_assert_equal_to (this->_vectors.count(vec_name), 0);

          this->add_vector(vec_name);
        }
    }
}
void libMesh::System::read_legacy_data ( Xdr io,
const bool  read_additional_data = true 
)

Reads additional data, namely vectors, for this System.

Definition at line 310 of file system_io.C.

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

{
  libmesh_deprecated();

  // This method implements the output of the vectors
  // contained in this System object, embedded in the
  // output of an EquationSystems<T_sys>.
  //
  //   10.) The global solution vector, re-ordered to be node-major
  //       (More on this later.)
  //
  //      for each additional vector in the object
  //
  //      11.) The global additional vector, re-ordered to be
  //           node-major (More on this later.)
  libmesh_assert (io.reading());

  // read and reordering buffers
  std::vector<Number> global_vector;
  std::vector<Number> reordered_vector;

  // 10.)
  // Read and set the solution vector
  {
    if (this->processor_id() == 0)
      io.data (global_vector);
    this->comm().broadcast(global_vector);

    // Remember that the stored vector is node-major.
    // We need to put it into whatever application-specific
    // ordering we may have using the dof_map.
    reordered_vector.resize(global_vector.size());

    //libMesh::out << "global_vector.size()=" << global_vector.size() << std::endl;
    //libMesh::out << "this->n_dofs()=" << this->n_dofs() << std::endl;

    libmesh_assert_equal_to (global_vector.size(), this->n_dofs());

    dof_id_type cnt=0;

    const unsigned int sys = this->number();
    const unsigned int nv  = cast_int<unsigned int>
      (this->_written_var_indices.size());
    libmesh_assert_less_equal (nv, this->n_vars());

    for (unsigned int data_var=0; data_var<nv; data_var++)
      {
        const unsigned int var = _written_var_indices[data_var];

        // First reorder the nodal DOF values
        {
          MeshBase::node_iterator
            it  = this->get_mesh().nodes_begin(),
            end = this->get_mesh().nodes_end();

          for (; it != end; ++it)
            for (unsigned int index=0; index<(*it)->n_comp(sys,var); index++)
              {
                libmesh_assert_not_equal_to ((*it)->dof_number(sys, var, index),
                                             DofObject::invalid_id);

                libmesh_assert_less (cnt, global_vector.size());

                reordered_vector[(*it)->dof_number(sys, var, index)] =
                  global_vector[cnt++];
              }
        }

        // Then reorder the element DOF values
        {
          MeshBase::element_iterator
            it  = this->get_mesh().active_elements_begin(),
            end = this->get_mesh().active_elements_end();

          for (; it != end; ++it)
            for (unsigned int index=0; index<(*it)->n_comp(sys,var); index++)
              {
                libmesh_assert_not_equal_to ((*it)->dof_number(sys, var, index),
                                             DofObject::invalid_id);

                libmesh_assert_less (cnt, global_vector.size());

                reordered_vector[(*it)->dof_number(sys, var, index)] =
                  global_vector[cnt++];
              }
        }
      }

    *(this->solution) = reordered_vector;
  }

  // For each additional vector, simply go through the list.
  // ONLY attempt to do this IF additional data was actually
  // written to the file for this system (controlled by the
  // _additional_data_written flag).
  if (this->_additional_data_written)
    {
      std::map<std::string, NumericVector<Number>* >::iterator
        pos = this->_vectors.begin();

      for (; pos != this->_vectors.end(); ++pos)
        {
          // 11.)
          // Read the values of the vec-th additional vector.
          // Prior do _not_ clear, but fill with zero, since the
          // additional vectors _have_ to have the same size
          // as the solution vector
          std::fill (global_vector.begin(), global_vector.end(), libMesh::zero);

          if (this->processor_id() == 0)
            io.data (global_vector);
          this->comm().broadcast(global_vector);

          // If read_additional_data==true, then we will keep this vector, otherwise
          // we are going to throw it away.
          if (read_additional_data)
            {
              // Remember that the stored vector is node-major.
              // We need to put it into whatever application-specific
              // ordering we may have using the dof_map.
              std::fill (reordered_vector.begin(),
                         reordered_vector.end(),
                         libMesh::zero);

              reordered_vector.resize(global_vector.size());

              libmesh_assert_equal_to (global_vector.size(), this->n_dofs());

              dof_id_type cnt=0;

              const unsigned int sys = this->number();
              const unsigned int nv  = cast_int<unsigned int>
                (this->_written_var_indices.size());
              libmesh_assert_less_equal (nv, this->n_vars());

              for (unsigned int data_var=0; data_var<nv; data_var++)
                {
                  const unsigned int var = _written_var_indices[data_var];
                  // First reorder the nodal DOF values
                  {
                    MeshBase::node_iterator
                      it  = this->get_mesh().nodes_begin(),
                      end = this->get_mesh().nodes_end();

                    for (; it!=end; ++it)
                      for (unsigned int index=0; index<(*it)->n_comp(sys,var); index++)
                        {
                          libmesh_assert_not_equal_to ((*it)->dof_number(sys, var, index),
                                                       DofObject::invalid_id);

                          libmesh_assert_less (cnt, global_vector.size());

                          reordered_vector[(*it)->dof_number(sys, var, index)] =
                            global_vector[cnt++];
                        }
                  }

                  // Then reorder the element DOF values
                  {
                    MeshBase::element_iterator
                      it  = this->get_mesh().active_elements_begin(),
                      end = this->get_mesh().active_elements_end();

                    for (; it!=end; ++it)
                      for (unsigned int index=0; index<(*it)->n_comp(sys,var); index++)
                        {
                          libmesh_assert_not_equal_to ((*it)->dof_number(sys, var, index),
                                                       DofObject::invalid_id);

                          libmesh_assert_less (cnt, global_vector.size());

                          reordered_vector[(*it)->dof_number(sys, var, index)] =
                            global_vector[cnt++];
                        }
                  }
                }

              // use the overloaded operator=(std::vector) to assign the values
              *(pos->second) = reordered_vector;
            }
        }
    } // end if (_additional_data_written)
}
template<typename InValType >
template void libMesh::System::read_parallel_data< Real > ( Xdr io,
const bool  read_additional_data 
)

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

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

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

for each additional vector in the object

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

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

Definition at line 498 of file system_io.C.

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

{
  // PerfLog pl("IO Performance",false);
  // pl.push("read_parallel_data");
  dof_id_type total_read_size = 0;

  libmesh_assert (io.reading());
  libmesh_assert (io.is_open());

  // build the ordered nodes and element maps.
  // when writing/reading parallel files we need to iterate
  // over our nodes/elements in order of increasing global id().
  // however, this is not guaranteed to be ordering we obtain
  // by using the node_iterators/element_iterators directly.
  // so build a set, sorted by id(), that provides the ordering.
  // further, for memory economy build the set but then transfer
  // its contents to vectors, which will be sorted.
  std::vector<const DofObject*> ordered_nodes, ordered_elements;
  {
    std::set<const DofObject*, CompareDofObjectsByID>
      ordered_nodes_set (this->get_mesh().local_nodes_begin(),
                         this->get_mesh().local_nodes_end());

    ordered_nodes.insert(ordered_nodes.end(),
                         ordered_nodes_set.begin(),
                         ordered_nodes_set.end());
  }
  {
    std::set<const DofObject*, CompareDofObjectsByID>
      ordered_elements_set (this->get_mesh().local_elements_begin(),
                            this->get_mesh().local_elements_end());

    ordered_elements.insert(ordered_elements.end(),
                            ordered_elements_set.begin(),
                            ordered_elements_set.end());
  }

  //  std::vector<Number> io_buffer;
  std::vector<InValType> io_buffer;

  // 9.)
  //
  // Actually read the solution components
  // for the ith system to disk
  io.data(io_buffer);

  total_read_size += cast_int<dof_id_type>(io_buffer.size());

  const unsigned int sys_num = this->number();
  const unsigned int nv      = cast_int<unsigned int>
    (this->_written_var_indices.size());
  libmesh_assert_less_equal (nv, this->n_vars());

  dof_id_type cnt=0;

  // Loop over each non-SCALAR variable and each node, and read out the value.
  for (unsigned int data_var=0; data_var<nv; data_var++)
    {
      const unsigned int var = _written_var_indices[data_var];
      if(this->variable(var).type().family != SCALAR)
        {
          // First read the node DOF values
          for (std::vector<const DofObject*>::const_iterator
                 it = ordered_nodes.begin(); it != ordered_nodes.end(); ++it)
            for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++)
              {
                libmesh_assert_not_equal_to ((*it)->dof_number(sys_num, var, comp),
                                             DofObject::invalid_id);
                libmesh_assert_less (cnt, io_buffer.size());
                this->solution->set((*it)->dof_number(sys_num, var, comp), io_buffer[cnt++]);
              }

          // Then read the element DOF values
          for (std::vector<const DofObject*>::const_iterator
                 it = ordered_elements.begin(); it != ordered_elements.end(); ++it)
            for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++)
              {
                libmesh_assert_not_equal_to ((*it)->dof_number(sys_num, var, comp),
                                             DofObject::invalid_id);
                libmesh_assert_less (cnt, io_buffer.size());
                this->solution->set((*it)->dof_number(sys_num, var, comp), io_buffer[cnt++]);
              }
        }
    }

  // Finally, read the SCALAR variables on the last processor
  for (unsigned int data_var=0; data_var<nv; data_var++)
    {
      const unsigned int var = _written_var_indices[data_var];
      if(this->variable(var).type().family == SCALAR)
        {
          if (this->processor_id() == (this->n_processors()-1))
            {
              const DofMap& dof_map = this->get_dof_map();
              std::vector<dof_id_type> SCALAR_dofs;
              dof_map.SCALAR_dof_indices(SCALAR_dofs, var);

              for(unsigned int i=0; i<SCALAR_dofs.size(); i++)
                {
                  this->solution->set( SCALAR_dofs[i], io_buffer[cnt++] );
                }
            }
        }
    }

  // And we're done setting solution entries
  this->solution->close();

  // Only read additional vectors if wanted
  if (read_additional_data)
    {
      std::map<std::string, NumericVector<Number>* >::const_iterator
        pos = _vectors.begin();

      for(; pos != this->_vectors.end(); ++pos)
        {
          cnt=0;
          io_buffer.clear();

          // 10.)
          //
          // Actually read the additional vector components
          // for the ith system to disk
          io.data(io_buffer);

          total_read_size += cast_int<dof_id_type>(io_buffer.size());

          // Loop over each non-SCALAR variable and each node, and read out the value.
          for (unsigned int data_var=0; data_var<nv; data_var++)
            {
              const unsigned int var = _written_var_indices[data_var];
              if(this->variable(var).type().family != SCALAR)
                {
                  // First read the node DOF values
                  for (std::vector<const DofObject*>::const_iterator
                         it = ordered_nodes.begin(); it != ordered_nodes.end(); ++it)
                    for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++)
                      {
                        libmesh_assert_not_equal_to ((*it)->dof_number(sys_num, var, comp),
                                                     DofObject::invalid_id);
                        libmesh_assert_less (cnt, io_buffer.size());
                        pos->second->set((*it)->dof_number(sys_num, var, comp), io_buffer[cnt++]);
                      }

                  // Then read the element DOF values
                  for (std::vector<const DofObject*>::const_iterator
                         it = ordered_elements.begin(); it != ordered_elements.end(); ++it)
                    for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++)
                      {
                        libmesh_assert_not_equal_to ((*it)->dof_number(sys_num, var, comp),
                                                     DofObject::invalid_id);
                        libmesh_assert_less (cnt, io_buffer.size());
                        pos->second->set((*it)->dof_number(sys_num, var, comp), io_buffer[cnt++]);
                      }
                }
            }

          // Finally, read the SCALAR variables on the last processor
          for (unsigned int data_var=0; data_var<nv; data_var++)
            {
              const unsigned int var = _written_var_indices[data_var];
              if(this->variable(var).type().family == SCALAR)
                {
                  if (this->processor_id() == (this->n_processors()-1))
                    {
                      const DofMap& dof_map = this->get_dof_map();
                      std::vector<dof_id_type> SCALAR_dofs;
                      dof_map.SCALAR_dof_indices(SCALAR_dofs, var);

                      for(unsigned int i=0; i<SCALAR_dofs.size(); i++)
                        {
                          pos->second->set( SCALAR_dofs[i], io_buffer[cnt++] );
                        }
                    }
                }
            }

          // And we're done setting entries for this variable
          pos->second->close();
        }
    }

  // const Real
  //   dt   = pl.get_elapsed_time(),
  //   rate = total_read_size*sizeof(Number)/dt;

  // libMesh::err << "Read " << total_read_size << " \"Number\" values\n"
  //     << " Elapsed time = " << dt << '\n'
  //     << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";

  // pl.pop("read_parallel_data");
}
void libMesh::System::read_parallel_data ( Xdr io,
const bool  read_additional_data 
) [inline]

Non-templated version for backward compatibility.

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

Definition at line 1290 of file system.h.

  { read_parallel_data<Number>(io, read_additional_data); }
unsigned int libMesh::System::read_SCALAR_dofs ( const unsigned int  var,
Xdr io,
NumericVector< Number > &  vec 
) const [private]

Reads the SCALAR dofs from the stream io and assigns the values to the appropriate entries of vec.

Returns the number of dofs read.

Definition at line 1092 of file system_io.C.

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

Referenced by read_serialized_vector(), and read_serialized_vectors().

{
  unsigned int n_assigned_vals = 0; // the number of values assigned, this will be returned.

  // Processor 0 will read the block from the buffer stream and send it to the last processor
  const unsigned int n_SCALAR_dofs = this->variable(var).type().order;
  std::vector<Number> input_buffer(n_SCALAR_dofs);
  if (this->processor_id() == 0)
    {
      io.data_stream(&input_buffer[0], n_SCALAR_dofs);
    }

#ifdef LIBMESH_HAVE_MPI
  if ( this->n_processors() > 1 )
    {
      const Parallel::MessageTag val_tag = this->comm().get_unique_tag(321);

      // Post the receive on the last processor
      if (this->processor_id() == (this->n_processors()-1))
        this->comm().receive(0, input_buffer, val_tag);

      // Send the data to processor 0
      if (this->processor_id() == 0)
        this->comm().send(this->n_processors()-1, input_buffer, val_tag);
    }
#endif

  // Finally, set the SCALAR values
  if (this->processor_id() == (this->n_processors()-1))
    {
      const DofMap& dof_map = this->get_dof_map();
      std::vector<dof_id_type> SCALAR_dofs;
      dof_map.SCALAR_dof_indices(SCALAR_dofs, var);

      for(unsigned int i=0; i<SCALAR_dofs.size(); i++)
        {
          vec.set (SCALAR_dofs[i], input_buffer[i]);
          ++n_assigned_vals;
        }
    }

  return n_assigned_vals;
}
template<typename iterator_type , typename InValType >
std::size_t libMesh::System::read_serialized_blocked_dof_objects ( const dof_id_type  n_objects,
const iterator_type  begin,
const iterator_type  end,
const InValType  dummy,
Xdr io,
const std::vector< NumericVector< Number > * > &  vecs,
const unsigned int  var_to_read = libMesh::invalid_uint 
) const [private]

Reads an input vector from the stream io and assigns the values to a set of DofObjects. This method uses blocked input and is safe to call on a distributed memory-mesh. Unless otherwise specified, all variables are read.

Definition at line 778 of file system_io.C.

References _written_var_indices, libMesh::Parallel::any_source, libMesh::ParallelObject::comm(), end, libMesh::NumericVector< T >::first_local_index(), libMesh::Parallel::Communicator::get_unique_tag(), libMesh::MeshTools::Generation::Private::idx(), libMesh::invalid_uint, libMesh::Threads::Thread::join(), libMesh::NumericVector< T >::last_local_index(), libMesh::libmesh_assert(), std::min(), libMesh::ParallelObject::n_processors(), n_vars(), number(), libMesh::Parallel::probe(), libMesh::ParallelObject::processor_id(), libMesh::Parallel::Communicator::receive(), libMesh::Parallel::Communicator::send(), libMesh::NumericVector< T >::set(), libMesh::Parallel::Status::source(), libMesh::Parallel::Communicator::sum(), and libMesh::Parallel::wait().

Referenced by read_serialized_vector(), and read_serialized_vectors().

{
  //-------------------------------------------------------
  // General order: (IO format 0.7.4 & greater)
  //
  // for (objects ...)
  //   for (vecs ....)
  //     for (vars ....)
  //       for (comps ...)
  //
  // where objects are nodes or elements, sorted to be
  // partition independent,
  // vecs are one or more *identically distributed* solution
  // coefficient vectors, vars are one or more variables
  // to write, and comps are all the components for said
  // vars on the object.

  typedef std::vector<NumericVector<Number>*>::const_iterator vec_iterator_type;

  // variables to read.  Unless specified otherwise, defaults to _written_var_indices.
  std::vector<unsigned int> vars_to_read (_written_var_indices);

  if (var_to_read != libMesh::invalid_uint)
    {
      vars_to_read.clear();
      vars_to_read.push_back(var_to_read);
    }

  const unsigned int
    sys_num    = this->number(),
    num_vecs   = cast_int<unsigned int>(vecs.size());
  const dof_id_type
    io_blksize = cast_int<dof_id_type>(std::min(max_io_blksize, static_cast<std::size_t>(n_objs))),
    num_blks   = std::ceil(static_cast<double>(n_objs)/static_cast<double>(io_blksize));

  libmesh_assert_less_equal (_written_var_indices.size(), this->n_vars());

  std::size_t n_read_values=0;

  std::vector<std::vector<dof_id_type> > xfer_ids(num_blks);  // The global IDs and # of components for the local objects in all blocks
  std::vector<std::vector<Number> >      recv_vals(num_blks); // The raw values for the local objects in all blocks
  std::vector<Parallel::Request>
    id_requests(num_blks), val_requests(num_blks);

  // ------------------------------------------------------
  // First pass - count the number of objects in each block
  // traverse all the objects and figure out which block they
  // will utlimately live in.
  std::vector<std::size_t>
    xfer_ids_size  (num_blks,0),
    recv_vals_size (num_blks,0);


  for (iterator_type it=begin; it!=end; ++it)
    {
      const dof_id_type
        id    = (*it)->id(),
        block = id/io_blksize;

      libmesh_assert_less (block, num_blks);

      xfer_ids_size[block] += 2; // for each object, we send its id, as well as the total number of components for all variables

      dof_id_type n_comp_tot=0;
      for (std::vector<unsigned int>::const_iterator var_it=vars_to_read.begin();
           var_it!=vars_to_read.end(); ++var_it)
        n_comp_tot += (*it)->n_comp(sys_num, *var_it); // for each variable, we will receive the nonzero components

      recv_vals_size[block] += n_comp_tot*num_vecs;
    }

  // knowing the recv_vals_size[block] for each processor allows
  // us to sum them and find the global size for each block.
  std::vector<std::size_t> tot_vals_size(recv_vals_size);
  this->comm().sum (tot_vals_size);


  //------------------------------------------
  // Collect the ids & number of values needed
  // for all local objects, binning them into
  // 'blocks' that will be sent to processor 0
  for (dof_id_type blk=0; blk<num_blks; blk++)
    {
      // Each processor should build up its transfer buffers for its
      // local objects in [first_object,last_object).
      const dof_id_type
        first_object = blk*io_blksize,
        last_object  = std::min(cast_int<dof_id_type>((blk+1)*io_blksize), n_objs);

      // convenience
      std::vector<dof_id_type> &ids  (xfer_ids[blk]);
      std::vector<Number>       &vals (recv_vals[blk]);

      // we now know the number of values we will store for each block,
      // so we can do efficient preallocation
      ids.clear();  ids.reserve (xfer_ids_size[blk]);
      vals.resize(recv_vals_size[blk]);

      if (recv_vals_size[blk] != 0) // only if there are nonzero values to receive
        for (iterator_type it=begin; it!=end; ++it)
          if (((*it)->id() >= first_object) && // object in [first_object,last_object)
              ((*it)->id() <   last_object))
            {
              ids.push_back((*it)->id());

              unsigned int n_comp_tot=0;

              for (std::vector<unsigned int>::const_iterator var_it=vars_to_read.begin();
                   var_it!=vars_to_read.end(); ++var_it)
                n_comp_tot += (*it)->n_comp(sys_num,*var_it);

              ids.push_back (n_comp_tot*num_vecs);
            }

#ifdef LIBMESH_HAVE_MPI
      Parallel::MessageTag id_tag  = this->comm().get_unique_tag(100*num_blks + blk);
      Parallel::MessageTag val_tag = this->comm().get_unique_tag(200*num_blks + blk);

      // nonblocking send the data for this block
      this->comm().send (0, ids,  id_requests[blk],  id_tag);

      // Go ahead and post the receive too
      this->comm().receive (0, vals, val_requests[blk], val_tag);
#endif
    }

  //---------------------------------------------------
  // Here processor 0 will read and distribute the data.
  // We have to do this block-wise to ensure that we
  // do not exhaust memory on processor 0.

  // give these variables scope outside the block to avoid reallocation
  std::vector<std::vector<dof_id_type> > recv_ids       (this->n_processors());
  std::vector<std::vector<Number> >      send_vals      (this->n_processors());
  std::vector<Parallel::Request>         reply_requests (this->n_processors());
  std::vector<unsigned int>              obj_val_offsets;          // map to traverse entry-wise rather than processor-wise
  std::vector<Number>                    input_vals;               // The input buffer for the current block
  std::vector<InValType>                 input_vals_tmp;               // The input buffer for the current block

  for (dof_id_type blk=0; blk<num_blks; blk++)
    {
      // Each processor should build up its transfer buffers for its
      // local objects in [first_object,last_object).
      const dof_id_type
        first_object  = blk*io_blksize,
        last_object   = std::min(cast_int<dof_id_type>((blk+1)*io_blksize), n_objs),
        n_objects_blk = last_object - first_object;

      // Processor 0 has a special job.  It needs to gather the requested indices
      // in [first_object,last_object) from all processors, read the data from
      // disk, and reply
      if (this->processor_id() == 0)
        {
          // we know the input buffer size for this block and can begin reading it now
          input_vals.resize(tot_vals_size[blk]);
          input_vals_tmp.resize(tot_vals_size[blk]);

          // a ThreadedIO object to perform asychronous file IO
          ThreadedIO<InValType> threaded_io(io, input_vals_tmp);
          Threads::Thread async_io(threaded_io);

          Parallel::MessageTag id_tag  = this->comm().get_unique_tag(100*num_blks + blk);
          Parallel::MessageTag val_tag = this->comm().get_unique_tag(200*num_blks + blk);

          // offset array. this will define where each object's values
          // map into the actual input_vals buffer.  this must get
          // 0-initialized because 0-component objects are not actually sent
          obj_val_offsets.resize (n_objects_blk);  std::fill (obj_val_offsets.begin(), obj_val_offsets.end(), 0);
          recv_vals_size.resize(this->n_processors()); // reuse this to count how many values are going to each processor

#ifndef NDEBUG
          std::size_t n_vals_blk = 0;
#endif

          // loop over all processors and process their index request
          for (unsigned int comm_step=0; comm_step<this->n_processors(); comm_step++)
            {
#ifdef LIBMESH_HAVE_MPI
              // blocking receive indices for this block, imposing no particular order on processor
              Parallel::Status id_status (this->comm().probe (Parallel::any_source, id_tag));
              std::vector<dof_id_type> &ids (recv_ids[id_status.source()]);
              std::size_t &n_vals_proc (recv_vals_size[id_status.source()]);
              this->comm().receive (id_status.source(), ids,  id_tag);
#else
              // straight copy without MPI
              std::vector<dof_id_type> &ids (recv_ids[0]);
              std::size_t &n_vals_proc (recv_vals_size[0]);
              ids = xfer_ids[blk];
#endif

              n_vals_proc = 0;

              // note its possible we didn't receive values for objects in
              // this block if they have no components allocated.
              for (dof_id_type idx=0; idx<ids.size(); idx+=2)
                {
                  const dof_id_type
                    local_idx          = ids[idx+0]-first_object,
                    n_vals_tot_allvecs = ids[idx+1];

                  libmesh_assert_less (local_idx, n_objects_blk);

                  obj_val_offsets[local_idx] = n_vals_tot_allvecs;
                  n_vals_proc += n_vals_tot_allvecs;
                }

#ifndef NDEBUG
              n_vals_blk += n_vals_proc;
#endif
            }

          // We need the offests into the input_vals vector for each object.
          // fortunately, this is simply the partial sum of the total number
          // of components for each object
          std::partial_sum(obj_val_offsets.begin(), obj_val_offsets.end(),
                           obj_val_offsets.begin());

          libmesh_assert_equal_to (n_vals_blk, obj_val_offsets.back());
          libmesh_assert_equal_to (n_vals_blk, tot_vals_size[blk]);

          // Wait for read completion
          async_io.join();
          // now copy the values back to the main vector for transfer
          for (unsigned int i_val=0; i_val<input_vals.size(); i_val++)
            input_vals[i_val] = input_vals_tmp[i_val];

          n_read_values += input_vals.size();

          // pack data replies for each processor
          for (processor_id_type proc=0; proc<this->n_processors(); proc++)
            {
              const std::vector<dof_id_type> &ids (recv_ids[proc]);
              std::vector<Number> &vals (send_vals[proc]);
              const std::size_t &n_vals_proc (recv_vals_size[proc]);

              vals.clear();  vals.reserve(n_vals_proc);

              for (std::size_t idx=0; idx<ids.size(); idx+=2)
                {
                  const dof_id_type
                    local_idx          = ids[idx+0]-first_object,
                    n_vals_tot_allvecs = ids[idx+1];

                  std::vector<Number>::const_iterator in_vals(input_vals.begin());
                  if (local_idx != 0)
                    std::advance (in_vals, obj_val_offsets[local_idx-1]);

                  for (unsigned int val=0; val<n_vals_tot_allvecs; val++, ++in_vals)
                    {
                      libmesh_assert (in_vals != input_vals.end());
                      //libMesh::out << "*in_vals=" << *in_vals << '\n';
                      vals.push_back(*in_vals);
                    }
                }

#ifdef LIBMESH_HAVE_MPI
              // send the relevant values to this processor
              this->comm().send (proc, vals, reply_requests[proc], val_tag);
#else
              recv_vals[blk] = vals;
#endif
            }
        } // end processor 0 read/reply

      // all processors complete the (already posted) read for this block
      {
        Parallel::wait (val_requests[blk]);

        const std::vector<Number> &vals (recv_vals[blk]);
        std::vector<Number>::const_iterator val_it(vals.begin());

        if (!recv_vals[blk].empty()) // nonzero values to receive
          for (iterator_type it=begin; it!=end; ++it)
            if (((*it)->id() >= first_object) && // object in [first_object,last_object)
                ((*it)->id() <   last_object))
              // unpack & set the values
              for (vec_iterator_type vec_it=vecs.begin(); vec_it!=vecs.end(); ++vec_it)
                {
                  NumericVector<Number> &vec(**vec_it);

                  for (std::vector<unsigned int>::const_iterator var_it=vars_to_read.begin();
                       var_it!=vars_to_read.end(); ++var_it)
                    {
                      const unsigned int n_comp = (*it)->n_comp(sys_num,*var_it);

                      for (unsigned int comp=0; comp<n_comp; comp++, ++val_it)
                        {
                          const dof_id_type dof_index = (*it)->dof_number (sys_num, *var_it, comp);
                          libmesh_assert (val_it != vals.end());
                          libmesh_assert_greater_equal (dof_index, vec.first_local_index());
                          libmesh_assert_less (dof_index, vec.last_local_index());
                          //libMesh::out << "dof_index, *val_it = \t" << dof_index << ", " << *val_it << '\n';
                          vec.set (dof_index, *val_it);
                        }
                    }
                }
      }

      // processor 0 needs to make sure all replies have been handed off
      if (this->processor_id () == 0)
        Parallel::wait(reply_requests);
    }

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

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

Definition at line 713 of file system_io.C.

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

{
  // This method implements the input of the vectors
  // contained in this System object, embedded in the
  // output of an EquationSystems<T_sys>.
  //
  //   10.) The global solution vector, re-ordered to be node-major
  //       (More on this later.)
  //
  //      for each additional vector in the object
  //
  //      11.) The global additional vector, re-ordered to be
  //          node-major (More on this later.)
  parallel_object_only();
  std::string comment;

  // PerfLog pl("IO Performance",false);
  // pl.push("read_serialized_data");
  // std::size_t total_read_size = 0;

  // 10.)
  // Read the global solution vector
  {
    // total_read_size +=
    this->read_serialized_vector<InValType>(io, *this->solution);

    // get the comment
    if (this->processor_id() == 0)
      io.comment (comment);
  }

  // 11.)
  // Only read additional vectors if wanted
  if (read_additional_data)
    {
      std::map<std::string, NumericVector<Number>* >::const_iterator
        pos = _vectors.begin();

      for(; pos != this->_vectors.end(); ++pos)
        {
          // total_read_size +=
          this->read_serialized_vector<InValType>(io, *pos->second);

          // get the comment
          if (this->processor_id() == 0)
            io.comment (comment);

        }
    }

  // const Real
  //   dt   = pl.get_elapsed_time(),
  //   rate = total_read_size*sizeof(Number)/dt;

  // libMesh::out << "Read " << total_read_size << " \"Number\" values\n"
  //     << " Elapsed time = " << dt << '\n'
  //     << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";

  // pl.pop("read_serialized_data");
}
void libMesh::System::read_serialized_data ( Xdr io,
const bool  read_additional_data = true 
) [inline]

Non-templated version for backward compatibility.

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

Definition at line 1248 of file system.h.

  { read_serialized_data<Number>(io, read_additional_data); }
template<typename InValType >
template numeric_index_type libMesh::System::read_serialized_vector< Real > ( Xdr io,
NumericVector< Number > &  vec 
) [private]

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

Returns the length of the vector read.

Definition at line 1140 of file system_io.C.

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

{
  parallel_object_only();

#ifndef NDEBUG
  // In parallel we better be reading a parallel vector -- if not
  // we will not set all of its components below!!
  if (this->n_processors() > 1)
    {
      libmesh_assert (vec.type() == PARALLEL ||
                      vec.type() == GHOSTED);
    }
#endif

  libmesh_assert (io.reading());

  // vector length
  unsigned int vector_length=0; // FIXME?  size_t would break binary compatibility...
#ifndef NDEBUG
  std::size_t n_assigned_vals=0;
#endif

  // Get the buffer size
  if (this->processor_id() == 0)
    io.data(vector_length, "# vector length");
  this->comm().broadcast(vector_length);

  const unsigned int nv = cast_int<unsigned int>
    (this->_written_var_indices.size());
  const dof_id_type
    n_nodes = this->get_mesh().n_nodes(),
    n_elem  = this->get_mesh().n_elem();

  libmesh_assert_less_equal (nv, this->n_vars());

  // for newer versions, read variables node/elem major
  if (io.version() >= LIBMESH_VERSION_ID(0,7,4))
    {
      //---------------------------------
      // Collect the values for all nodes
#ifndef NDEBUG
      n_assigned_vals +=
#endif
        this->read_serialized_blocked_dof_objects (n_nodes,
                                                   this->get_mesh().local_nodes_begin(),
                                                   this->get_mesh().local_nodes_end(),
                                                   InValType(),
                                                   io,
                                                   std::vector<NumericVector<Number>*> (1,&vec));


      //------------------------------------
      // Collect the values for all elements
#ifndef NDEBUG
      n_assigned_vals +=
#endif
        this->read_serialized_blocked_dof_objects (n_elem,
                                                   this->get_mesh().local_elements_begin(),
                                                   this->get_mesh().local_elements_end(),
                                                   InValType(),
                                                   io,
                                                   std::vector<NumericVector<Number>*> (1,&vec));
    }

  // for older versions, read variables var-major
  else
    {
      // Loop over each variable in the system, and then each node/element in the mesh.
      for (unsigned int data_var=0; data_var<nv; data_var++)
        {
          const unsigned int var = _written_var_indices[data_var];
          if(this->variable(var).type().family != SCALAR)
            {
              //---------------------------------
              // Collect the values for all nodes
#ifndef NDEBUG
              n_assigned_vals +=
#endif
                this->read_serialized_blocked_dof_objects (n_nodes,
                                                           this->get_mesh().local_nodes_begin(),
                                                           this->get_mesh().local_nodes_end(),
                                                           InValType(),
                                                           io,
                                                           std::vector<NumericVector<Number>*> (1,&vec),
                                                           var);


              //------------------------------------
              // Collect the values for all elements
#ifndef NDEBUG
              n_assigned_vals +=
#endif
                this->read_serialized_blocked_dof_objects (n_elem,
                                                           this->get_mesh().local_elements_begin(),
                                                           this->get_mesh().local_elements_end(),
                                                           InValType(),
                                                           io,
                                                           std::vector<NumericVector<Number>*> (1,&vec),
                                                           var);
            } // end variable loop
        }
    }

  //-------------------------------------------
  // Finally loop over all the SCALAR variables
  for (unsigned int data_var=0; data_var<nv; data_var++)
    {
      const unsigned int var = _written_var_indices[data_var];
      if(this->variable(var).type().family == SCALAR)
        {
#ifndef NDEBUG
          n_assigned_vals +=
#endif
            this->read_SCALAR_dofs (var, io, vec);
        }
    }

  vec.close();

#ifndef NDEBUG
  this->comm().sum (n_assigned_vals);
  libmesh_assert_equal_to (n_assigned_vals, vector_length);
#endif

  return vector_length;
}

Non-templated version for backward compatibility.

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

Returns the length of the vector read.

Definition at line 1719 of file system.h.

  { return read_serialized_vector<Number>(io, vec); }
template<typename InValType >
template std::size_t libMesh::System::read_serialized_vectors< Real > ( Xdr io,
const std::vector< NumericVector< Number > * > &  vectors 
) const

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

Definition at line 2193 of file system_io.C.

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

{
  parallel_object_only();

  // Error checking
  // #ifndef NDEBUG
  //   // In parallel we better be reading a parallel vector -- if not
  //   // we will not set all of its components below!!
  //   if (this->n_processors() > 1)
  //     {
  //       libmesh_assert (vec.type() == PARALLEL ||
  //       vec.type() == GHOSTED);
  //     }
  // #endif

  libmesh_assert (io.reading());

  if (this->processor_id() == 0)
    {
      // sizes
      unsigned int num_vecs=0;
      dof_id_type vector_length=0;

      // Get the number of vectors
      io.data(num_vecs);
      // Get the buffer size
      io.data(vector_length);

      libmesh_assert_equal_to (num_vecs, vectors.size());

      if (num_vecs != 0)
        {
          libmesh_assert_not_equal_to (vectors[0], 0);
          libmesh_assert_equal_to     (vectors[0]->size(), vector_length);
        }
    }

  // no need to actually communicate these.
  // this->comm().broadcast(num_vecs);
  // this->comm().broadcast(vector_length);

  // Cache these - they are not free!
  const dof_id_type
    n_nodes = this->get_mesh().n_nodes(),
    n_elem  = this->get_mesh().n_elem();

  std::size_t read_length = 0.;

  //---------------------------------
  // Collect the values for all nodes
  read_length +=
    this->read_serialized_blocked_dof_objects (n_nodes,
                                               this->get_mesh().local_nodes_begin(),
                                               this->get_mesh().local_nodes_end(),
                                               InValType(),
                                               io,
                                               vectors);

  //------------------------------------
  // Collect the values for all elements
  read_length +=
    this->read_serialized_blocked_dof_objects (n_elem,
                                               this->get_mesh().local_elements_begin(),
                                               this->get_mesh().local_elements_end(),
                                               InValType(),
                                               io,
                                               vectors);

  //-------------------------------------------
  // Finally loop over all the SCALAR variables
  for (unsigned int vec=0; vec<vectors.size(); vec++)
    for (unsigned int var=0; var<this->n_vars(); var++)
      if(this->variable(var).type().family == SCALAR)
        {
          libmesh_assert_not_equal_to (vectors[vec], 0);

          read_length +=
            this->read_SCALAR_dofs (var, io, *vectors[vec]);
        }

  //---------------------------------------
  // last step - must close all the vectors
  for (unsigned int vec=0; vec<vectors.size(); vec++)
    {
      libmesh_assert_not_equal_to (vectors[vec], 0);
      vectors[vec]->close();
    }

  return read_length;
}
std::size_t libMesh::System::read_serialized_vectors ( Xdr io,
const std::vector< NumericVector< Number > * > &  vectors 
) const [inline]

Non-templated version for backward compatibility.

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

Definition at line 1268 of file system.h.

  { return read_serialized_vectors<Number>(io, vectors); }
void libMesh::System::reinit ( ) [virtual]

Reinitializes degrees of freedom and other required data on the current mesh. Note that the matrix is not initialized at this time since it may not be required for all applications. Should be overloaded in derived classes.

Reimplemented in libMesh::NonlinearImplicitSystem, libMesh::LinearImplicitSystem, libMesh::DifferentiableSystem, libMesh::EigenSystem, libMesh::ImplicitSystem, libMesh::ExplicitSystem, libMesh::NewmarkSystem, and libMesh::TransientSystem< RBConstruction >.

Definition at line 383 of file system.C.

References current_local_solution, n_dofs(), n_local_dofs(), n_vars(), libMesh::PARALLEL, and solution.

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

{
  //If no variables have been added to this system
  //don't do anything
  if(!this->n_vars())
    return;

  // Constraints get handled in EquationSystems::reinit now
  //  _dof_map->create_dof_constraints(this->get_mesh());

  // Update the solution based on the projected
  // current_local_solution.
  solution->init (this->n_dofs(), this->n_local_dofs(), true, PARALLEL);

  libmesh_assert_equal_to (solution->size(), current_local_solution->size());
  // Not true with ghosted vectors
  // libmesh_assert_equal_to (solution->size(), current_local_solution->local_size());

  const dof_id_type first_local_dof = solution->first_local_index();
  const dof_id_type local_size      = solution->local_size();

  for (dof_id_type i=0; i<local_size; i++)
    solution->set(i+first_local_dof,
                  (*current_local_solution)(i+first_local_dof));

  solution->close();
}
void libMesh::System::remove_vector ( const std::string &  vec_name)

Removes the additional vector vec_name from this system

Definition at line 727 of file system.C.

References _vector_is_adjoint, _vector_projections, _vector_types, _vectors, and have_vector().

{
  //Return if the vector does not exist
  if ( !(this->have_vector(vec_name)) )
    return;

  _vectors[vec_name]->clear();
  delete _vectors[vec_name];
  _vectors[vec_name] = NULL;

  _vectors.erase(vec_name);
  _vector_projections.erase(vec_name);
  _vector_is_adjoint.erase(vec_name);
  _vector_types.erase(vec_name);
}
const NumericVector< Number > * libMesh::System::request_vector ( const std::string &  vec_name) const
Returns:
a const pointer to the vector if this System has a vector associated with the given name, NULL otherwise.

Definition at line 743 of file system.C.

References _vectors.

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

{
  const_vectors_iterator pos = _vectors.find(vec_name);

  if (pos == _vectors.end())
    return NULL;

  return pos->second;
}
NumericVector< Number > * libMesh::System::request_vector ( const std::string &  vec_name)
Returns:
a pointer to the vector if this System has a vector associated with the given name, NULL otherwise.

Definition at line 755 of file system.C.

References _vectors.

{
  vectors_iterator pos = _vectors.find(vec_name);

  if (pos == _vectors.end())
    return NULL;

  return pos->second;
}
const NumericVector< Number > * libMesh::System::request_vector ( const unsigned int  vec_num) const
Returns:
a const pointer to this system's additional vector number vec_num (where the vectors are counted starting with 0), or returns NULL if the system has no such vector.

Definition at line 767 of file system.C.

References vectors_begin(), and vectors_end().

{
  const_vectors_iterator v = vectors_begin();
  const_vectors_iterator v_end = vectors_end();
  unsigned int num = 0;
  while((num<vec_num) && (v!=v_end))
    {
      num++;
      ++v;
    }
  if (v==v_end)
    return NULL;
  return v->second;
}
NumericVector< Number > * libMesh::System::request_vector ( const unsigned int  vec_num)
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 784 of file system.C.

References vectors_begin(), and vectors_end().

{
  vectors_iterator v = vectors_begin();
  vectors_iterator v_end = vectors_end();
  unsigned int num = 0;
  while((num<vec_num) && (v!=v_end))
    {
      num++;
      ++v;
    }
  if (v==v_end)
    return NULL;
  return v->second;
}
void libMesh::System::restrict_solve_to ( const SystemSubset subset,
const SubsetSolveMode  subset_solve_mode = SUBSET_ZERO 
) [virtual]

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

Reimplemented in libMesh::LinearImplicitSystem.

Definition at line 466 of file system.C.

{
  if(subset!=NULL)
    {
      libmesh_not_implemented();
    }
}

Restrict vectors after the mesh has coarsened

Definition at line 320 of file system.C.

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

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

{
#ifdef LIBMESH_ENABLE_AMR
  // Restrict the _vectors on the coarsened cells
  for (vectors_iterator pos = _vectors.begin(); pos != _vectors.end(); ++pos)
    {
      NumericVector<Number>* v = pos->second;

      if (_vector_projections[pos->first])
        {
          this->project_vector (*v, this->vector_is_adjoint(pos->first));
        }
      else
        {
          ParallelType type = _vector_types[pos->first];

          if(type == GHOSTED)
            {
#ifdef LIBMESH_ENABLE_GHOSTED
              pos->second->init (this->n_dofs(), this->n_local_dofs(),
                                 _dof_map->get_send_list(), false,
                                 GHOSTED);
#else
              libmesh_error_msg("Cannot initialize ghosted vectors when they are not enabled.");
#endif
            }
          else
            pos->second->init (this->n_dofs(), this->n_local_dofs(), false, type);
        }
    }

  const std::vector<dof_id_type>& send_list = _dof_map->get_send_list ();

  // Restrict the solution on the coarsened cells
  if (_solution_projection)
    this->project_vector (*solution);

#ifdef LIBMESH_ENABLE_GHOSTED
  current_local_solution->init(this->n_dofs(),
                               this->n_local_dofs(), send_list,
                               false, GHOSTED);
#else
  current_local_solution->init(this->n_dofs());
#endif

  if (_solution_projection)
    solution->localize (*current_local_solution, send_list);

#endif // LIBMESH_ENABLE_AMR
}
std::pair< unsigned int, Real > libMesh::System::sensitivity_solve ( const ParameterVector parameters) [inline, virtual]

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

{
  libmesh_not_implemented();
}
void libMesh::System::set_adjoint_already_solved ( bool  setting) [inline]

Setter for the adjoint_already_solved boolean

Definition at line 381 of file system.h.

References adjoint_already_solved.

  { adjoint_already_solved = setting;}

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

References _basic_system_only.

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

{
  _basic_system_only = true;
}
void libMesh::System::set_vector_as_adjoint ( const std::string &  vec_name,
int  qoi_num 
)

Allows one to set the QoI index controlling whether the vector identified by vec_name represents a solution from the adjoint (qoi_num >= 0) or primal (qoi_num == -1) space. This becomes significant if those spaces have differing heterogeneous Dirichlet constraints.

qoi_num == -2 can be used to indicate a vector which should not be affected by constraints during projection operations.

Definition at line 912 of file system.C.

References _vector_is_adjoint.

Referenced by add_adjoint_solution(), and add_weighted_sensitivity_adjoint_solution().

{
  // We reserve -1 for vectors which get primal constraints, -2 for
  // vectors which get no constraints
  libmesh_assert_greater_equal(qoi_num, -2);
  _vector_is_adjoint[vec_name] = qoi_num;
}
void libMesh::System::set_vector_preservation ( const std::string &  vec_name,
bool  preserve 
)

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

Definition at line 894 of file system.C.

References _vector_projections.

{
  _vector_projections[vec_name] = preserve;
}
virtual std::string libMesh::System::system_type ( ) const [inline, virtual]
Returns:
the type of system, helpful in identifying which system type to use when reading equation system data from file. Should be overloaded in derived classes.

Reimplemented in libMesh::NonlinearImplicitSystem, libMesh::LinearImplicitSystem, libMesh::RBConstruction, libMesh::FrequencySystem, libMesh::EigenSystem, libMesh::ExplicitSystem, libMesh::ImplicitSystem, libMesh::NewmarkSystem, and libMesh::TransientSystem< RBConstruction >.

Definition at line 474 of file system.h.

Referenced by get_info().

{ return "Basic"; }
void libMesh::System::update ( ) [virtual]

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

Definition at line 421 of file system.C.

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

Referenced by libMesh::__libmesh_petsc_diff_solver_residual(), 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(), 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().

{
  libmesh_assert(solution->closed());

  const std::vector<dof_id_type>& send_list = _dof_map->get_send_list ();

  // Check sizes
  libmesh_assert_equal_to (current_local_solution->size(), solution->size());
  // More processors than elements => empty send_list
  //  libmesh_assert (!send_list.empty());
  libmesh_assert_less_equal (send_list.size(), solution->size());

  // Create current_local_solution from solution.  This will
  // put a local copy of solution into current_local_solution.
  // Only the necessary values (specified by the send_list)
  // are copied to minimize communication
  solution->localize (*current_local_solution, send_list);
}
void libMesh::System::update_global_solution ( std::vector< Number > &  global_soln) const

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

Definition at line 670 of file system.C.

References solution.

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

{
  global_soln.resize (solution->size());

  solution->localize (global_soln);
}
void libMesh::System::update_global_solution ( std::vector< Number > &  global_soln,
const processor_id_type  dest_proc 
) const

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

Definition at line 679 of file system.C.

References solution.

{
  global_soln.resize        (solution->size());

  solution->localize_to_one (global_soln, dest_proc);
}
void libMesh::System::user_assembly ( ) [virtual]

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

Definition at line 1934 of file system.C.

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

Referenced by assemble().

{
  // Call the user-provided assembly function,
  // if it was provided
  if (_assemble_system_function != NULL)
    this->_assemble_system_function (_equation_systems, this->name());

  // ...or the user-provided assembly object.
  else if (_assemble_system_object != NULL)
    this->_assemble_system_object->assemble();
}
void libMesh::System::user_constrain ( ) [virtual]

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

Definition at line 1948 of file system.C.

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

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

{
  // Call the user-provided constraint function,
  // if it was provided
  if (_constrain_system_function!= NULL)
    this->_constrain_system_function(_equation_systems, this->name());

  // ...or the user-provided constraint object.
  else if (_constrain_system_object != NULL)
    this->_constrain_system_object->constrain();
}

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

Definition at line 1920 of file system.C.

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

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

{
  // Call the user-provided intialization function,
  // if it was provided
  if (_init_system_function != NULL)
    this->_init_system_function (_equation_systems, this->name());

  // ...or the user-provided initialization object.
  else if (_init_system_object != NULL)
    this->_init_system_object->initialize();
}
void libMesh::System::user_QOI ( const QoISet qoi_indices) [virtual]

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

Definition at line 1962 of file system.C.

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

Referenced by assemble_qoi().

{
  // Call the user-provided quantity of interest function,
  // if it was provided
  if (_qoi_evaluate_function != NULL)
    this->_qoi_evaluate_function(_equation_systems, this->name(), qoi_indices);

  // ...or the user-provided QOI function object.
  else if (_qoi_evaluate_object != NULL)
    this->_qoi_evaluate_object->qoi(qoi_indices);
}
void libMesh::System::user_QOI_derivative ( const QoISet qoi_indices = QoISet(),
bool  include_liftfunc = true,
bool  apply_constraints = true 
) [virtual]

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

Definition at line 1976 of file system.C.

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

Referenced by assemble_qoi_derivative().

{
  // Call the user-provided quantity of interest derivative,
  // if it was provided
  if (_qoi_evaluate_derivative_function != NULL)
    this->_qoi_evaluate_derivative_function
      (_equation_systems, this->name(), qoi_indices, include_liftfunc,
       apply_constraints);

  // ...or the user-provided QOI derivative function object.
  else if (_qoi_evaluate_derivative_object != NULL)
    this->_qoi_evaluate_derivative_object->qoi_derivative
      (qoi_indices, include_liftfunc, apply_constraints);
}
const VariableGroup & libMesh::System::variable_group ( unsigned int  vg) const [inline]

Return a constant reference to VariableGroup vg.

Definition at line 2071 of file system.h.

References _variable_groups.

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

{
  libmesh_assert_less (vg, _variable_groups.size());

  return _variable_groups[vg];
}
unsigned short int libMesh::System::variable_number ( const std::string &  var) const
Returns:
the variable number assoicated with the user-specified variable named var.

Definition at line 1270 of file system.C.

References _variable_numbers, and _variables.

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

{
  // Make sure the variable exists
  std::map<std::string, unsigned short int>::const_iterator
    pos = _variable_numbers.find(var);

  if (pos == _variable_numbers.end())
    libmesh_error_msg("ERROR: variable " << var << " does not exist in this system!");

  libmesh_assert_equal_to (_variables[pos->second].name(), var);

  return pos->second;
}
unsigned int libMesh::System::variable_scalar_number ( const std::string &  var,
unsigned int  component 
) const [inline]
Returns:
an index, starting from 0 for the first component of the first variable, and incrementing for each component of each (potentially vector-valued) variable in the system in order. For systems with only scalar-valued variables, this will be the same as variable_number(var)

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

Definition at line 2092 of file system.h.

References variable_number().

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

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

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

Definition at line 2102 of file system.h.

References _variables.

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

Definition at line 2121 of file system.h.

References _variables, and variable_number().

{
  return _variables[this->variable_number(var)].type();
}
int libMesh::System::vector_is_adjoint ( const std::string &  vec_name) const
Returns:
the int describing whether the vector identified by vec_name represents a solution from an adjoint (non-negative) or the primal (-1) space.

Definition at line 923 of file system.C.

References _vector_is_adjoint, and libMesh::libmesh_assert().

Referenced by restrict_vectors().

{
  libmesh_assert(_vector_is_adjoint.find(vec_name) !=
                 _vector_is_adjoint.end());

  return _vector_is_adjoint.find(vec_name)->second;
}
const std::string & libMesh::System::vector_name ( const unsigned int  vec_num) const
Returns:
the name of this system's additional vector number vec_num (where the vectors are counted starting with 0).

Definition at line 859 of file system.C.

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

{
  const_vectors_iterator v = vectors_begin();
  const_vectors_iterator v_end = vectors_end();
  unsigned int num = 0;
  while((num<vec_num) && (v!=v_end))
    {
      num++;
      ++v;
    }
  libmesh_assert (v != v_end);
  return v->first;
}
const std::string & libMesh::System::vector_name ( const NumericVector< Number > &  vec_reference) const
Returns:
the name of a system vector, given a reference to that vector

Definition at line 873 of file system.C.

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

{
  const_vectors_iterator v = vectors_begin();
  const_vectors_iterator v_end = vectors_end();

  for(; v != v_end; ++v)
    {
      // Check if the current vector is the one whose name we want
      if(&vec_reference == v->second)
        break; // exit loop if it is
    }

  // Before returning, make sure we didnt loop till the end and not find any match
  libmesh_assert (v != v_end);

  // Return the string associated with the current vector
  return v->first;
}
bool libMesh::System::vector_preservation ( const std::string &  vec_name) const
Returns:
the boolean describing whether the vector identified by vec_name should be "preserved": projected to new meshes, saved, etc.

Definition at line 902 of file system.C.

References _vector_projections.

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

{
  if (_vector_projections.find(vec_name) == _vector_projections.end())
    return false;

  return _vector_projections.find(vec_name)->second;
}

Beginning of vectors container

Definition at line 2179 of file system.h.

References _vectors.

{
  return _vectors.begin();
}

End of vectors container

Definition at line 2191 of file system.h.

References _vectors.

{
  return _vectors.end();
}
std::pair< unsigned int, Real > libMesh::System::weighted_sensitivity_adjoint_solve ( const ParameterVector parameters,
const ParameterVector weights,
const QoISet qoi_indices = QoISet() 
) [inline, virtual]

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

{
  libmesh_not_implemented();
}
std::pair< unsigned int, Real > libMesh::System::weighted_sensitivity_solve ( const ParameterVector parameters,
const ParameterVector weights 
) [inline, virtual]

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

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

Writes the basic data header for this System.

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

for this system

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

for each variable in the system

6.) The name of the variable (string)

6.1.) subdomain where the variable lives

7.) Combined in an FEType:

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

end variable loop

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

for each additional vector in the system object

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

end system

Definition at line 1269 of file system_io.C.

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

{
  libmesh_assert (io.writing());


  // Only write the header information
  // if we are processor 0.
  if (this->get_mesh().processor_id() != 0)
    return;

  std::string comment;
  char buf[80];

  // 5.)
  // Write the number of variables in the system

  {
    // set up the comment
    comment = "# No. of Variables in System \"";
    comment += this->name();
    comment += "\"";

    unsigned int nv = this->n_vars();
    io.data (nv, comment.c_str());
  }


  for (unsigned int var=0; var<this->n_vars(); var++)
    {
      // 6.)
      // Write the name of the var-th variable
      {
        // set up the comment
        comment  = "#   Name, Variable No. ";
        std::sprintf(buf, "%u", var);
        comment += buf;
        comment += ", System \"";
        comment += this->name();
        comment += "\"";

        std::string var_name = this->variable_name(var);
        io.data (var_name, comment.c_str());
      }

      // 6.1.) Variable subdomains
      {
        // set up the comment
        comment  = "#     Subdomains, Variable \"";
        std::sprintf(buf, "%s", this->variable_name(var).c_str());
        comment += buf;
        comment += "\", System \"";
        comment += this->name();
        comment += "\"";

        const std::set<subdomain_id_type> & domains = this->variable(var).active_subdomains();
        std::vector<subdomain_id_type> domain_array;
        domain_array.assign(domains.begin(), domains.end());
        io.data (domain_array, comment.c_str());
      }

      // 7.)
      // Write the approximation order of the var-th variable
      // in this system
      {
        // set up the comment
        comment = "#     Approximation Order, Variable \"";
        std::sprintf(buf, "%s", this->variable_name(var).c_str());
        comment += buf;
        comment += "\", System \"";
        comment += this->name();
        comment += "\"";

        int order = static_cast<int>(this->variable_type(var).order);
        io.data (order, comment.c_str());
      }


#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS

      // do the same for radial_order
      {
        comment = "#     Radial Approximation Order, Variable \"";
        std::sprintf(buf, "%s", this->variable_name(var).c_str());
        comment += buf;
        comment += "\", System \"";
        comment += this->name();
        comment += "\"";

        int rad_order = static_cast<int>(this->variable_type(var).radial_order);
        io.data (rad_order, comment.c_str());
      }

#endif

      // Write the Finite Element type of the var-th variable
      // in this System
      {
        // set up the comment
        comment = "#     FE Family, Variable \"";
        std::sprintf(buf, "%s", this->variable_name(var).c_str());
        comment += buf;
        comment += "\", System \"";
        comment += this->name();
        comment += "\"";

        const FEType& type = this->variable_type(var);
        int fam = static_cast<int>(type.family);
        io.data (fam, comment.c_str());

#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS

        comment = "#     Radial FE Family, Variable \"";
        std::sprintf(buf, "%s", this->variable_name(var).c_str());
        comment += buf;
        comment += "\", System \"";
        comment += this->name();
        comment += "\"";

        int radial_fam = static_cast<int>(type.radial_family);
        io.data (radial_fam, comment.c_str());

        comment = "#     Infinite Mapping Type, Variable \"";
        std::sprintf(buf, "%s", this->variable_name(var).c_str());
        comment += buf;
        comment += "\", System \"";
        comment += this->name();
        comment += "\"";

        int i_map = static_cast<int>(type.inf_map);
        io.data (i_map, comment.c_str());
#endif
      }
    } // end of the variable loop

  // 8.)
  // Write the number of additional vectors in the System.
  // If write_additional_data==false, then write zero for
  // the number of additional vectors.
  {
    {
      // set up the comment
      comment = "# No. of Additional Vectors, System \"";
      comment += this->name();
      comment += "\"";

      unsigned int nvecs = write_additional_data ? this->n_vectors () : 0;
      io.data (nvecs, comment.c_str());
    }

    if (write_additional_data)
      {
        std::map<std::string, NumericVector<Number>* >::const_iterator
          vec_pos = this->_vectors.begin();
        unsigned int cnt=0;

        for (; vec_pos != this->_vectors.end(); ++vec_pos)
          {
            // 9.)
            // write the name of the cnt-th additional vector
            comment =  "# Name of ";
            std::sprintf(buf, "%d", cnt++);
            comment += buf;
            comment += "th vector";
            std::string vec_name = vec_pos->first;

            io.data (vec_name, comment.c_str());
          }
      }
  }
}
void libMesh::System::write_parallel_data ( Xdr io,
const bool  write_additional_data 
) const

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

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

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

for each additional vector in the object

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

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

Definition at line 1477 of file system_io.C.

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

{
  // PerfLog pl("IO Performance",false);
  // pl.push("write_parallel_data");
  // std::size_t total_written_size = 0;

  std::string comment;

  libmesh_assert (io.writing());

  std::vector<Number> io_buffer; io_buffer.reserve(this->solution->local_size());

  // build the ordered nodes and element maps.
  // when writing/reading parallel files we need to iterate
  // over our nodes/elements in order of increasing global id().
  // however, this is not guaranteed to be ordering we obtain
  // by using the node_iterators/element_iterators directly.
  // so build a set, sorted by id(), that provides the ordering.
  // further, for memory economy build the set but then transfer
  // its contents to vectors, which will be sorted.
  std::vector<const DofObject*> ordered_nodes, ordered_elements;
  {
    std::set<const DofObject*, CompareDofObjectsByID>
      ordered_nodes_set (this->get_mesh().local_nodes_begin(),
                         this->get_mesh().local_nodes_end());

    ordered_nodes.insert(ordered_nodes.end(),
                         ordered_nodes_set.begin(),
                         ordered_nodes_set.end());
  }
  {
    std::set<const DofObject*, CompareDofObjectsByID>
      ordered_elements_set (this->get_mesh().local_elements_begin(),
                            this->get_mesh().local_elements_end());

    ordered_elements.insert(ordered_elements.end(),
                            ordered_elements_set.begin(),
                            ordered_elements_set.end());
  }

  const unsigned int sys_num = this->number();
  const unsigned int nv      = this->n_vars();

  // Loop over each non-SCALAR variable and each node, and write out the value.
  for (unsigned int var=0; var<nv; var++)
    if (this->variable(var).type().family != SCALAR)
      {
        // First write the node DOF values
        for (std::vector<const DofObject*>::const_iterator
               it = ordered_nodes.begin(); it != ordered_nodes.end(); ++it)
          for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++)
            {
              //libMesh::out << "(*it)->id()=" << (*it)->id() << std::endl;
              libmesh_assert_not_equal_to ((*it)->dof_number(sys_num, var, comp),
                                           DofObject::invalid_id);

              io_buffer.push_back((*this->solution)((*it)->dof_number(sys_num, var, comp)));
            }

        // Then write the element DOF values
        for (std::vector<const DofObject*>::const_iterator
               it = ordered_elements.begin(); it != ordered_elements.end(); ++it)
          for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++)
            {
              libmesh_assert_not_equal_to ((*it)->dof_number(sys_num, var, comp),
                                           DofObject::invalid_id);

              io_buffer.push_back((*this->solution)((*it)->dof_number(sys_num, var, comp)));
            }
      }

  // Finally, write the SCALAR data on the last processor
  for (unsigned int var=0; var<this->n_vars(); var++)
    if(this->variable(var).type().family == SCALAR)
      {
        if (this->processor_id() == (this->n_processors()-1))
          {
            const DofMap& dof_map = this->get_dof_map();
            std::vector<dof_id_type> SCALAR_dofs;
            dof_map.SCALAR_dof_indices(SCALAR_dofs, var);

            for(unsigned int i=0; i<SCALAR_dofs.size(); i++)
              {
                io_buffer.push_back( (*this->solution)(SCALAR_dofs[i]) );
              }
          }
      }

  // 9.)
  //
  // Actually write the reordered solution vector
  // for the ith system to disk

  // set up the comment
  {
    comment = "# System \"";
    comment += this->name();
    comment += "\" Solution Vector";
  }

  io.data (io_buffer, comment.c_str());

  // total_written_size += io_buffer.size();

  // Only write additional vectors if wanted
  if (write_additional_data)
    {
      std::map<std::string, NumericVector<Number>* >::const_iterator
        pos = _vectors.begin();

      for(; pos != this->_vectors.end(); ++pos)
        {
          io_buffer.clear(); io_buffer.reserve( pos->second->local_size());

          // Loop over each non-SCALAR variable and each node, and write out the value.
          for (unsigned int var=0; var<nv; var++)
            if(this->variable(var).type().family != SCALAR)
              {
                // First write the node DOF values
                for (std::vector<const DofObject*>::const_iterator
                       it = ordered_nodes.begin(); it != ordered_nodes.end(); ++it)
                  for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++)
                    {
                      libmesh_assert_not_equal_to ((*it)->dof_number(sys_num, var, comp),
                                                   DofObject::invalid_id);

                      io_buffer.push_back((*pos->second)((*it)->dof_number(sys_num, var, comp)));
                    }

                // Then write the element DOF values
                for (std::vector<const DofObject*>::const_iterator
                       it = ordered_elements.begin(); it != ordered_elements.end(); ++it)
                  for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++)
                    {
                      libmesh_assert_not_equal_to ((*it)->dof_number(sys_num, var, comp),
                                                   DofObject::invalid_id);

                      io_buffer.push_back((*pos->second)((*it)->dof_number(sys_num, var, comp)));
                    }
              }

          // Finally, write the SCALAR data on the last processor
          for (unsigned int var=0; var<this->n_vars(); var++)
            if(this->variable(var).type().family == SCALAR)
              {
                if (this->processor_id() == (this->n_processors()-1))
                  {
                    const DofMap& dof_map = this->get_dof_map();
                    std::vector<dof_id_type> SCALAR_dofs;
                    dof_map.SCALAR_dof_indices(SCALAR_dofs, var);

                    for(unsigned int i=0; i<SCALAR_dofs.size(); i++)
                      {
                        io_buffer.push_back( (*pos->second)(SCALAR_dofs[i]) );
                      }
                  }
              }

          // 10.)
          //
          // Actually write the reordered additional vector
          // for this system to disk

          // set up the comment
          {
            comment = "# System \"";
            comment += this->name();
            comment += "\" Additional Vector \"";
            comment += pos->first;
            comment += "\"";
          }

          io.data (io_buffer, comment.c_str());

          // total_written_size += io_buffer.size();
        }
    }

  // const Real
  //   dt   = pl.get_elapsed_time(),
  //   rate = total_written_size*sizeof(Number)/dt;

  // libMesh::err << "Write " << total_written_size << " \"Number\" values\n"
  //     << " Elapsed time = " << dt << '\n'
  //     << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";

  // pl.pop("write_parallel_data");
}
unsigned int libMesh::System::write_SCALAR_dofs ( const NumericVector< Number > &  vec,
const unsigned int  var,
Xdr io 
) const [private]

Writes the SCALAR dofs associated with var to the stream io.

Returns the number of values written.

Definition at line 2092 of file system_io.C.

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

Referenced by write_serialized_vector(), and write_serialized_vectors().

{
  unsigned int written_length=0;
  std::vector<Number> vals; // The raw values for the local objects in the current block
  // Collect the SCALARs for the current variable
  if (this->processor_id() == (this->n_processors()-1))
    {
      const DofMap& dof_map = this->get_dof_map();
      std::vector<dof_id_type> SCALAR_dofs;
      dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
      const unsigned int n_scalar_dofs = cast_int<unsigned int>
        (SCALAR_dofs.size());

      for(unsigned int i=0; i<n_scalar_dofs; i++)
        {
          vals.push_back( vec(SCALAR_dofs[i]) );
        }
    }

#ifdef LIBMESH_HAVE_MPI
  if ( this->n_processors() > 1 )
    {
      const Parallel::MessageTag val_tag(1);

      // Post the receive on processor 0
      if ( this->processor_id() == 0 )
        {
          this->comm().receive(this->n_processors()-1, vals, val_tag);
        }

      // Send the data to processor 0
      if (this->processor_id() == (this->n_processors()-1))
        {
          this->comm().send(0, vals, val_tag);
        }
    }
#endif

  // -------------------------------------------------------
  // Write the output on processor 0.
  if (this->processor_id() == 0)
    {
      const unsigned int vals_size =
        cast_int<unsigned int>(vals.size());
      io.data_stream (&vals[0], vals_size);
      written_length += vals_size;
    }

  return written_length;
}
template<typename iterator_type >
std::size_t libMesh::System::write_serialized_blocked_dof_objects ( const std::vector< const NumericVector< Number > * > &  vecs,
const dof_id_type  n_objects,
const iterator_type  begin,
const iterator_type  end,
Xdr io,
const unsigned int  var_to_write = libMesh::invalid_uint 
) const [private]

Writes an output vector to the stream io for a set of DofObjects. This method uses blocked output and is safe to call on a distributed memory-mesh.

Returns the number of values written

Definition at line 1799 of file system_io.C.

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

Referenced by write_serialized_vector(), and write_serialized_vectors().

{
  //-------------------------------------------------------
  // General order: (IO format 0.7.4 & greater)
  //
  // for (objects ...)
  //   for (vecs ....)
  //     for (vars ....)
  //       for (comps ...)
  //
  // where objects are nodes or elements, sorted to be
  // partition independent,
  // vecs are one or more *identically distributed* solution
  // coefficient vectors, vars are one or more variables
  // to write, and comps are all the components for said
  // vars on the object.

  typedef std::vector<const NumericVector<Number>*>::const_iterator vec_iterator_type;

  // We will write all variables unless requested otherwise.
  std::vector<unsigned int> vars_to_write(1, var_to_write);

  if (var_to_write == libMesh::invalid_uint)
    {
      vars_to_write.clear();  vars_to_write.reserve(this->n_vars());
      for (unsigned int var=0; var<this->n_vars(); var++)
        vars_to_write.push_back(var);
    }

  const dof_id_type io_blksize = cast_int<dof_id_type>
    (std::min(max_io_blksize, static_cast<std::size_t>(n_objs)));

  const unsigned int
    sys_num    = this->number(),
    num_vecs   = cast_int<unsigned int>(vecs.size()),
    num_blks   = std::ceil(static_cast<double>(n_objs)/static_cast<double>(io_blksize));

  // libMesh::out << "io_blksize = "    << io_blksize
  //     << ", num_objects = " << n_objs
  //     << ", num_blks = "    << num_blks
  //     << std::endl;

  dof_id_type written_length=0;                                   // The numer of values written.  This will be returned
  std::vector<std::vector<dof_id_type> > xfer_ids(num_blks);      // The global IDs and # of components for the local objects in all blocks
  std::vector<std::vector<Number> >       send_vals(num_blks);     // The raw values for the local objects in all blocks
  std::vector<Parallel::Request>
    id_requests(num_blks), val_requests(num_blks);                 // send request handle for each block

  // ------------------------------------------------------
  // First pass - count the number of objects in each block
  // traverse all the objects and figure out which block they
  // will utlimately live in.
  std::vector<unsigned int>
    xfer_ids_size  (num_blks,0),
    send_vals_size (num_blks,0);

  for (iterator_type it=begin; it!=end; ++it)
    {
      const dof_id_type
        id    = (*it)->id(),
        block = id/io_blksize;

      libmesh_assert_less (block, num_blks);

      xfer_ids_size[block] += 2; // for each object, we store its id, as well as the total number of components for all variables

      unsigned int n_comp_tot=0;

      for (std::vector<unsigned int>::const_iterator var_it=vars_to_write.begin();
           var_it!=vars_to_write.end(); ++var_it)
        n_comp_tot += (*it)->n_comp(sys_num, *var_it); // for each variable, we will store the nonzero components

      send_vals_size[block] += n_comp_tot*num_vecs;
    }

  //-----------------------------------------
  // Collect the values for all local objects,
  // binning them into 'blocks' that will be
  // sent to processor 0
  for (unsigned int blk=0; blk<num_blks; blk++)
    {
      // libMesh::out << "Writing object block " << blk << std::endl;

      // Each processor should build up its transfer buffers for its
      // local objects in [first_object,last_object).
      const dof_id_type
        first_object = blk*io_blksize,
        last_object  = std::min(cast_int<dof_id_type>((blk+1)*io_blksize), n_objs);

      // convenience
      std::vector<dof_id_type> &ids  (xfer_ids[blk]);
      std::vector<Number>      &vals (send_vals[blk]);

      // we now know the number of values we will store for each block,
      // so we can do efficient preallocation
      ids.clear();   ids.reserve  (xfer_ids_size[blk]);
      vals.clear();  vals.reserve (send_vals_size[blk]);

      if (send_vals_size[blk] != 0) // only send if we have nonzero components to write
        for (iterator_type it=begin; it!=end; ++it)
          if (((*it)->id() >= first_object) && // object in [first_object,last_object)
              ((*it)->id() <   last_object))
            {
              ids.push_back((*it)->id());

              // count the total number of nonzeros transferred for this object
              {
                unsigned int n_comp_tot=0;

                for (std::vector<unsigned int>::const_iterator var_it=vars_to_write.begin();
                     var_it!=vars_to_write.end(); ++var_it)
                  n_comp_tot += (*it)->n_comp(sys_num,*var_it);

                ids.push_back (n_comp_tot*num_vecs); // even if 0 - processor 0 has no way of knowing otherwise...
              }

              // pack the values to send
              for (vec_iterator_type vec_it=vecs.begin(); vec_it!=vecs.end(); ++vec_it)
                {
                  const NumericVector<Number> &vec(**vec_it);

                  for (std::vector<unsigned int>::const_iterator var_it=vars_to_write.begin();
                       var_it!=vars_to_write.end(); ++var_it)
                    {
                      const unsigned int n_comp = (*it)->n_comp(sys_num,*var_it);

                      for (unsigned int comp=0; comp<n_comp; comp++)
                        {
                          libmesh_assert_greater_equal ((*it)->dof_number(sys_num, *var_it, comp), vec.first_local_index());
                          libmesh_assert_less ((*it)->dof_number(sys_num, *var_it, comp), vec.last_local_index());
                          vals.push_back(vec((*it)->dof_number(sys_num, *var_it, comp)));
                        }
                    }
                }
            }

#ifdef LIBMESH_HAVE_MPI
      Parallel::MessageTag id_tag  = this->comm().get_unique_tag(100*num_blks + blk);
      Parallel::MessageTag val_tag = this->comm().get_unique_tag(200*num_blks + blk);

      // nonblocking send the data for this block
      this->comm().send (0, ids,  id_requests[blk],  id_tag);
      this->comm().send (0, vals, val_requests[blk], val_tag);
#endif
    }


  if (this->processor_id() == 0)
    {
      std::vector<std::vector<dof_id_type> > recv_ids  (this->n_processors());
      std::vector<std::vector<Number> >      recv_vals (this->n_processors());
      std::vector<unsigned int> obj_val_offsets;          // map to traverse entry-wise rather than processor-wise
      std::vector<Number>       output_vals;              // The output buffer for the current block

      // a ThreadedIO object to perform asychronous file IO
      ThreadedIO<Number> threaded_io(io, output_vals);
      UniquePtr<Threads::Thread> async_io;

      for (unsigned int blk=0; blk<num_blks; blk++)
        {
          // Each processor should build up its transfer buffers for its
          // local objects in [first_object,last_object).
          const dof_id_type
            first_object  = cast_int<dof_id_type>(blk*io_blksize),
            last_object   = std::min(cast_int<dof_id_type>((blk+1)*io_blksize), n_objs),
            n_objects_blk = last_object - first_object;

          // offset array. this will define where each object's values
          // map into the actual output_vals buffer.  this must get
          // 0-initialized because 0-component objects are not actually sent
          obj_val_offsets.resize (n_objects_blk);  std::fill (obj_val_offsets.begin(), obj_val_offsets.end(), 0);

          std::size_t n_val_recvd_blk=0;

          // tags to select data received
          Parallel::MessageTag id_tag  (this->comm().get_unique_tag(100*num_blks + blk));
          Parallel::MessageTag val_tag (this->comm().get_unique_tag(200*num_blks + blk));

          // receive this block of data from all processors.
          for (unsigned int comm_step=0; comm_step<this->n_processors(); comm_step++)
            {
#ifdef LIBMESH_HAVE_MPI
              // blocking receive indices for this block, imposing no particular order on processor
              Parallel::Status id_status (this->comm().probe (Parallel::any_source, id_tag));
              std::vector<dof_id_type> &ids (recv_ids[id_status.source()]);
              this->comm().receive (id_status.source(), ids,  id_tag);
#else
              std::vector<dof_id_type> &ids (recv_ids[0]);
#endif

              // note its possible we didn't receive values for objects in
              // this block if they have no components allocated.
              for (dof_id_type idx=0; idx<ids.size(); idx+=2)
                {
                  const dof_id_type
                    local_idx          = ids[idx+0]-first_object,
                    n_vals_tot_allvecs = ids[idx+1];

                  libmesh_assert_less (local_idx, n_objects_blk);
                  libmesh_assert_less (local_idx, obj_val_offsets.size());

                  obj_val_offsets[local_idx] = n_vals_tot_allvecs;
                }

#ifdef LIBMESH_HAVE_MPI
              // blocking receive values for this block, imposing no particular order on processor
              Parallel::Status val_status  (this->comm().probe (Parallel::any_source, val_tag));
              std::vector<Number> &vals    (recv_vals[val_status.source()]);
              this->comm().receive (val_status.source(), vals, val_tag);
#else
              // straight copy without MPI
              std::vector<Number> &vals (recv_vals[0]);
              vals = send_vals[blk];
#endif

              n_val_recvd_blk += vals.size();
            }

          // We need the offests into the output_vals vector for each object.
          // fortunately, this is simply the partial sum of the total number
          // of components for each object
          std::partial_sum(obj_val_offsets.begin(), obj_val_offsets.end(),
                           obj_val_offsets.begin());

          // wait on any previous asynchronous IO - this *must* complete before
          // we start messing with the output_vals buffer!
          if (async_io.get()) async_io->join();

          // this is the actual output buffer that will be written to disk.
          // at ths point we finally know wha size it will be.
          output_vals.resize(n_val_recvd_blk);

          // pack data from all processors into output values
          for (unsigned int proc=0; proc<this->n_processors(); proc++)
            {
              const std::vector<dof_id_type> &ids (recv_ids [proc]);
              const std::vector<Number>      &vals(recv_vals[proc]);
              std::vector<Number>::const_iterator proc_vals(vals.begin());

              for (dof_id_type idx=0; idx<ids.size(); idx+=2)
                {
                  const dof_id_type
                    local_idx          = ids[idx+0]-first_object,
                    n_vals_tot_allvecs = ids[idx+1];

                  // put this object's data into the proper location
                  // in  the output buffer
                  std::vector<Number>::iterator out_vals(output_vals.begin());
                  if (local_idx != 0)
                    std::advance (out_vals, obj_val_offsets[local_idx-1]);

                  for (unsigned int val=0; val<n_vals_tot_allvecs; val++, ++out_vals, ++proc_vals)
                    {
                      libmesh_assert (out_vals  != output_vals.end());
                      libmesh_assert (proc_vals != vals.end());
                      *out_vals = *proc_vals;
                    }
                }
            }

          // output_vals buffer is now filled for this block.
          // write it to disk
          async_io.reset(new Threads::Thread(threaded_io));
          written_length += output_vals.size();
        }

      // wait on any previous asynchronous IO - this *must* complete before
      // our stuff goes out of scope
      async_io->join();
    }

  Parallel::wait(id_requests);
  Parallel::wait(val_requests);

  // we need some synchronization here.  Because this method
  // can be called for a range of nodes, then a range of elements,
  // we need some mechanism to prevent processors from racing past
  // to the next range and overtaking ongoing communication.  one
  // approach would be to figure out unique tags for each range,
  // but for now we just impose a barrier here.  And might as
  // well have it do some useful work.
  this->comm().broadcast(written_length);

  return written_length;
}
void libMesh::System::write_serialized_data ( Xdr io,
const bool  write_additional_data = true 
) const

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

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

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

for each additional vector in the object

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

Definition at line 1688 of file system_io.C.

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

{
  parallel_object_only();
  std::string comment;

  // PerfLog pl("IO Performance",false);
  // pl.push("write_serialized_data");
  // std::size_t total_written_size = 0;

  // total_written_size +=
  this->write_serialized_vector(io, *this->solution);

  // set up the comment
  if (this->processor_id() == 0)
    {
      comment = "# System \"";
      comment += this->name();
      comment += "\" Solution Vector";

      io.comment (comment);
    }

  // Only write additional vectors if wanted
  if (write_additional_data)
    {
      std::map<std::string, NumericVector<Number>* >::const_iterator
        pos = _vectors.begin();

      for(; pos != this->_vectors.end(); ++pos)
        {
          // total_written_size +=
          this->write_serialized_vector(io, *pos->second);

          // set up the comment
          if (this->processor_id() == 0)
            {
              comment = "# System \"";
              comment += this->name();
              comment += "\" Additional Vector \"";
              comment += pos->first;
              comment += "\"";
              io.comment (comment);
            }
        }
    }

  // const Real
  //   dt   = pl.get_elapsed_time(),
  //   rate = total_written_size*sizeof(Number)/dt;

  // libMesh::out << "Write " << total_written_size << " \"Number\" values\n"
  //     << " Elapsed time = " << dt << '\n'
  //     << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";

  // pl.pop("write_serialized_data");




  // // test the new method
  // {
  //   std::vector<std::string> names;
  //   std::vector<NumericVector<Number>*> vectors_to_write;

  //   names.push_back("Solution Vector");
  //   vectors_to_write.push_back(this->solution.get());

  //   // Only write additional vectors if wanted
  //   if (write_additional_data)
  //     {
  // std::map<std::string, NumericVector<Number>* >::const_iterator
  //   pos = _vectors.begin();

  // for(; pos != this->_vectors.end(); ++pos)
  //   {
  //     names.push_back("Additional Vector " + pos->first);
  //     vectors_to_write.push_back(pos->second);
  //   }
  //     }

  //   total_written_size =
  //     this->write_serialized_vectors (io, names, vectors_to_write);

  //   const Real
  //     dt2   = pl.get_elapsed_time(),
  //     rate2 = total_written_size*sizeof(Number)/(dt2-dt);

  //   libMesh::out << "Write (new) " << total_written_size << " \"Number\" values\n"
  //       << " Elapsed time = " << (dt2-dt) << '\n'
  //       << " Rate = " << rate2/1.e6 << "(MB/sec)\n\n";

  // }
}
dof_id_type libMesh::System::write_serialized_vector ( Xdr io,
const NumericVector< Number > &  vec 
) const [private]

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

Returns the number of values written.

Definition at line 2147 of file system_io.C.

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

Referenced by write_serialized_data().

{
  parallel_object_only();

  libmesh_assert (io.writing());

  dof_id_type vec_length = vec.size();
  if (this->processor_id() == 0) io.data (vec_length, "# vector length");

  dof_id_type written_length = 0;

  //---------------------------------
  // Collect the values for all nodes
  written_length += cast_int<dof_id_type>
    (this->write_serialized_blocked_dof_objects (std::vector<const NumericVector<Number>*>(1,&vec),
                                                 this->get_mesh().n_nodes(),
                                                 this->get_mesh().local_nodes_begin(),
                                                 this->get_mesh().local_nodes_end(),
                                                 io));

  //------------------------------------
  // Collect the values for all elements
  written_length += cast_int<dof_id_type>
    (this->write_serialized_blocked_dof_objects (std::vector<const NumericVector<Number>*>(1,&vec),
                                                 this->get_mesh().n_elem(),
                                                 this->get_mesh().local_elements_begin(),
                                                 this->get_mesh().local_elements_end(),
                                                 io));

  //-------------------------------------------
  // Finally loop over all the SCALAR variables
  for (unsigned int var=0; var<this->n_vars(); var++)
    if(this->variable(var).type().family == SCALAR)
      {
        written_length +=
          this->write_SCALAR_dofs (vec, var, io);
      }

  if (this->processor_id() == 0)
    libmesh_assert_equal_to (written_length, vec_length);

  return written_length;
}
std::size_t libMesh::System::write_serialized_vectors ( Xdr io,
const std::vector< const NumericVector< Number > * > &  vectors 
) const

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

Definition at line 2287 of file system_io.C.

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

{
  parallel_object_only();

  libmesh_assert (io.writing());

  // Cache these - they are not free!
  const dof_id_type
    n_nodes       = this->get_mesh().n_nodes(),
    n_elem        = this->get_mesh().n_elem();

  std::size_t written_length = 0.;

  if (this->processor_id() == 0)
    {
      unsigned int
        n_vec    = cast_int<unsigned int>(vectors.size());
      dof_id_type
        vec_size = vectors.empty() ? 0 : vectors[0]->size();
      // Set the number of vectors
      io.data(n_vec, "# number of vectors");
      // Set the buffer size
      io.data(vec_size, "# vector length");
    }

  //---------------------------------
  // Collect the values for all nodes
  written_length +=
    this->write_serialized_blocked_dof_objects (vectors,
                                                n_nodes,
                                                this->get_mesh().local_nodes_begin(),
                                                this->get_mesh().local_nodes_end(),
                                                io);

  //------------------------------------
  // Collect the values for all elements
  written_length +=
    this->write_serialized_blocked_dof_objects (vectors,
                                                n_elem,
                                                this->get_mesh().local_elements_begin(),
                                                this->get_mesh().local_elements_end(),
                                                io);

  //-------------------------------------------
  // Finally loop over all the SCALAR variables
  for (unsigned int vec=0; vec<vectors.size(); vec++)
    for (unsigned int var=0; var<this->n_vars(); var++)
      if(this->variable(var).type().family == SCALAR)
        {
          libmesh_assert_not_equal_to (vectors[vec], 0);

          written_length +=
            this->write_SCALAR_dofs (*vectors[vec], var, io);
        }

  return written_length;
}
void libMesh::System::zero_variable ( NumericVector< Number > &  v,
unsigned int  var_num 
) const

Zeroes all dofs in v that correspond to variable number var_num.

Definition at line 1340 of file system.C.

References libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), libMesh::DofObject::dof_number(), get_mesh(), libMesh::MeshBase::local_nodes_begin(), libMesh::MeshBase::local_nodes_end(), mesh, libMesh::DofObject::n_comp(), n_vars(), number(), and libMesh::NumericVector< T >::set().

{
  /* Make sure the call makes sense.  */
  libmesh_assert_less (var_num, this->n_vars());

  /* Get a reference to the mesh.  */
  const MeshBase& mesh = this->get_mesh();

  /* Check which system we are.  */
  const unsigned int sys_num = this->number();

  /* Loop over nodes.  */
  {
    MeshBase::const_node_iterator it = mesh.local_nodes_begin();
    const MeshBase::const_node_iterator end_it = mesh.local_nodes_end();
    for ( ; it != end_it; ++it)
      {
        const Node* node = *it;
        unsigned int n_comp = node->n_comp(sys_num,var_num);
        for(unsigned int i=0; i<n_comp; i++)
          {
            const dof_id_type index = node->dof_number(sys_num,var_num,i);
            v.set(index,0.0);
          }
      }
  }

  /* Loop over elements.  */
  {
    MeshBase::const_element_iterator it = mesh.active_local_elements_begin();
    const MeshBase::const_element_iterator end_it = mesh.active_local_elements_end();
    for ( ; it != end_it; ++it)
      {
        const Elem* elem = *it;
        unsigned int n_comp = elem->n_comp(sys_num,var_num);
        for(unsigned int i=0; i<n_comp; i++)
          {
            const dof_id_type index = elem->dof_number(sys_num,var_num,i);
            v.set(index,0.0);
          }
      }
  }
}

Member Data Documentation

bool libMesh::System::_active [private]

Flag stating if the system is active or not.

Definition at line 1861 of file system.h.

Referenced by activate(), active(), and deactivate().

This flag is used only when *reading* in a system from file. Based on the system header, it keeps track of whether or not additional vectors were actually written for this file.

Definition at line 1918 of file system.h.

Referenced by read_header(), and read_legacy_data().

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

Function that assembles the system.

Definition at line 1769 of file system.h.

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

Object that assembles the system.

Definition at line 1775 of file system.h.

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

Holds true if the components of more advanced system types (e.g. system matrices) should not be initialized.

Definition at line 1899 of file system.h.

Referenced by init(), and set_basic_system_only().

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

Function to impose constraints.

Definition at line 1780 of file system.h.

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

Object that constrains the system.

Definition at line 1786 of file system.h.

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

UniquePtr<DofMap> libMesh::System::_dof_map [private]

Data structure describing the relationship between nodes, variables, etc... and degrees of freedom.

Definition at line 1818 of file system.h.

Referenced by add_vector(), calculate_norm(), clear(), current_solution(), get_dof_map(), init_data(), n_constrained_dofs(), n_dofs(), n_local_constrained_dofs(), n_local_dofs(), project_solution(), restrict_vectors(), and update().

bool libMesh::ReferenceCounter::_enable_print_counter = true [static, protected, inherited]

Flag to control whether reference count information is printed when print_info is called.

Definition at line 137 of file reference_counter.h.

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

Constant reference to the EquationSystems object used for the simulation.

Definition at line 1824 of file system.h.

Referenced by get_equation_systems(), user_assembly(), user_constrain(), user_initialization(), user_QOI(), and user_QOI_derivative().

true when VariableGroup structures should be automatically identified, false otherwise. Defaults to true.

Definition at line 1911 of file system.h.

Referenced by identify_variable_groups().

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

Function that initializes the system.

Definition at line 1758 of file system.h.

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

Object that initializes the system.

Definition at line 1764 of file system.h.

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

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

Definition at line 1905 of file system.h.

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

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

Definition at line 1830 of file system.h.

Referenced by get_mesh(), and reinit_constraints().

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 131 of file reference_counter.h.

Threads::atomic< unsigned int > libMesh::ReferenceCounter::_n_objects [static, protected, inherited]

The number of objects. Print the reference count information when the number returns to 0.

Definition at line 126 of file reference_counter.h.

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

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

Function to evaluate quantity of interest derivative

Definition at line 1803 of file system.h.

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

Object to compute derivatives of quantities of interest.

Definition at line 1812 of file system.h.

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

void(* libMesh::System::_qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices) [private]

Function to evaluate quantity of interest

Definition at line 1791 of file system.h.

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

Object to compute quantities of interest.

Definition at line 1798 of file system.h.

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

Holds true if the solution vector should be projected onto a changed grid, false if it should be zeroed. This is true by default.

Definition at line 1893 of file system.h.

Referenced by project_solution_on_reinit(), and restrict_vectors().

const std::string libMesh::System::_sys_name [private]

A name associated with this system.

Definition at line 1835 of file system.h.

Referenced by compare(), and name().

const unsigned int libMesh::System::_sys_number [private]

The number associated with this system

Definition at line 1840 of file system.h.

Referenced by number().

The VariableGroup in this System.

Definition at line 1850 of file system.h.

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

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

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

Definition at line 1856 of file system.h.

Referenced by add_variable(), add_variables(), clear(), get_all_variable_numbers(), has_variable(), and variable_number().

std::map<std::string, int> libMesh::System::_vector_is_adjoint [private]

Holds non-negative if a vector by that name should be projected using adjoint constraints/BCs, -1 if primal

Definition at line 1881 of file system.h.

Referenced by add_vector(), clear(), remove_vector(), set_vector_as_adjoint(), and vector_is_adjoint().

std::map<std::string, bool> libMesh::System::_vector_projections [private]

Holds true if a vector by that name should be projected onto a changed grid, false if it should be zeroed.

Definition at line 1875 of file system.h.

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

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

Holds the type of a vector

Definition at line 1886 of file system.h.

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

std::map<std::string, NumericVector<Number>* > libMesh::System::_vectors [private]

Some systems need an arbitrary number of vectors. This map allows names to be associated with arbitrary vectors. All the vectors in this map will be distributed in the same way as the solution vector.

Definition at line 1869 of file system.h.

Referenced by add_vector(), clear(), compare(), get_vector(), have_vector(), init_data(), n_vectors(), read_legacy_data(), read_parallel_data(), read_serialized_data(), remove_vector(), request_vector(), restrict_vectors(), vectors_begin(), vectors_end(), write_header(), write_parallel_data(), and write_serialized_data().

std::vector<unsigned int> libMesh::System::_written_var_indices [private]

This vector is used only when *reading* in a system from file. Based on the system header, it keeps track of any index remapping between variable names in the data file and variable names in the already-constructed system. I.e. if we have a system with variables "A1", "A2", "B1", and "B2", but we read in a data file with only "A1" and "B1" defined, then we don't want to try and read in A2 or B2, and we don't want to assign A1 and B1 values to different dof indices.

Definition at line 1930 of file system.h.

Referenced by read_header(), read_legacy_data(), read_parallel_data(), read_serialized_blocked_dof_objects(), and read_serialized_vector().

Has the adjoint problem already been solved? If the user sets adjoint_already_solved to true, we won't waste time solving it again.

Definition at line 1937 of file system.h.

Referenced by is_adjoint_already_solved(), and set_adjoint_already_solved().

Flag which tells the system to whether or not to call the user assembly function during each call to solve(). By default, every call to solve() begins with a call to the user assemble, so this flag is true. (For explicit systems, "solving" the system occurs during the assembly step, so this flag is always true for explicit systems.)

You will only want to set this to false if you need direct control over when the system is assembled, and are willing to track the state of its assembly yourself. An example of such a case is an implicit system with multiple right hand sides. In this instance, a single assembly would likely be followed with multiple calls to solve.

The frequency system and Newmark system have their own versions of this flag, called _finished_assemble, which might be able to be replaced with this more general concept.

Definition at line 1468 of file system.h.

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

All the values I need to compute my contribution to the simulation at hand. Think of this as the current solution with any ghost values needed from other processors. This vector is necessarily larger than the solution vector in the case of a parallel simulation. The update() member is used to synchronize the contents of the solution and current_local_solution vectors.

Definition at line 1527 of file system.h.

Referenced by libMesh::__libmesh_petsc_snes_residual(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::NonlinearImplicitSystem::assembly(), libMesh::EquationSystems::build_solution_vector(), clear(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), current_solution(), DMlibMeshFunction(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::EquationSystems::get_solution(), init_data(), libMesh::FEMContext::pre_fe_reinit(), project_solution(), re_update(), reinit(), restrict_vectors(), and update().

A member int that can be employed to indicate increased or reduced quadrature order.

Note for FEMSystem users: By default, when calling the user-defined residual functions, the FEMSystem will first set up an appropriate FEType::default_quadrature_rule() object for performing the integration. This rule will integrate elements of order up to 2*p+1 exactly (where p is the sum of the base FEType and local p refinement levels), but if additional (or reduced) quadrature accuracy is desired then this extra_quadrature_order (default 0) will be added.

Definition at line 1500 of file system.h.

Referenced by libMesh::FEMContext::FEMContext().

Data structure to hold solution values.

Definition at line 1515 of file system.h.

Referenced by libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_petsc_snes_residual(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::AdaptiveTimeSolver::advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), libMesh::ContinuationSystem::apply_predictor(), libMesh::FEMSystem::assembly(), libMesh::LinearImplicitSystem::assembly(), libMesh::EquationSystems::build_solution_vector(), clear(), compare(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ContinuationSystem::continuation_solve(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::GMVIO::copy_nodal_solution(), DMlibMeshFunction(), libMesh::UnsteadySolver::du(), libMesh::DofMap::enforce_constraints_exactly(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::EigenSystem::get_eigenpair(), libMesh::EquationSystems::get_solution(), init_data(), libMesh::ContinuationSystem::initialize_tangent(), libMesh::DofMap::max_constraint_error(), libMesh::FEMSystem::mesh_position_get(), libMesh::ErrorVector::plot_error(), project_solution(), re_update(), read_legacy_data(), read_parallel_data(), read_serialized_data(), reinit(), restrict_vectors(), libMesh::MemorySolutionHistory::retrieve(), libMesh::ContinuationSystem::save_current_solution(), libMesh::TwostepTimeSolver::solve(), libMesh::NewtonSolver::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::FrequencySystem::solve(), libMesh::NonlinearImplicitSystem::solve(), libMesh::ContinuationSystem::solve_tangent(), libMesh::MemorySolutionHistory::store(), update(), update_global_solution(), libMesh::ContinuationSystem::update_solution(), libMesh::NewmarkSystem::update_u_v_a(), write_parallel_data(), and write_serialized_data().

A boolean to be set to true by systems using elem_fixed_solution, for optional use by e.g. stabilized methods. False by default.

Note for FEMSystem users: Warning: if this variable is set to true, it must be before init_data() is called.

Definition at line 1485 of file system.h.

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


The documentation for this class was generated from the following files: