Poster of Linux kernelThe best gift for a Linux geek
NewmarkSystem

NewmarkSystem

Section: C Library Functions (3) Updated: Thu Apr 7 2011
Local index Up
 

NAME

NewmarkSystem -  

SYNOPSIS


#include <newmark_system.h>

Inherits LinearImplicitSystem.  

Public Types


typedef NewmarkSystem sys_type

typedef ImplicitSystem Parent

typedef std::map< std::string, SparseMatrix< Number > * >::iterator matrices_iterator

typedef std::map< std::string, SparseMatrix< Number > * >::const_iterator const_matrices_iterator

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


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

~NewmarkSystem ()

virtual void clear ()

virtual void reinit ()

virtual void assemble ()

virtual std::string system_type () const

void initial_conditions ()

void compute_matrix ()

void update_rhs ()

void update_u_v_a ()

void set_newmark_parameters (const Real delta_T=_default_timestep, const Real alpha=_default_alpha, const Real delta=_default_delta)

sys_type & system ()

virtual void solve ()

virtual void adjoint_solve ()

virtual void qoi_parameter_sensitivity (std::vector< Number * > &parameters, std::vector< Number > &sensitivities)

unsigned int n_linear_iterations () const

Real final_linear_residual () const

void attach_shell_matrix (ShellMatrix< Number > *shell_matrix)

void detach_shell_matrix (void)

ShellMatrix< Number > * get_shell_matrix (void)

SparseMatrix< Number > & add_matrix (const std::string &mat_name)

bool have_matrix (const std::string &mat_name) const

const SparseMatrix< Number > & get_matrix (const std::string &mat_name) const

SparseMatrix< Number > & get_matrix (const std::string &mat_name)

unsigned int n_matrices () const

virtual void assemble_qoi ()

virtual void assemble_qoi_derivative ()

void init ()

virtual void update ()

virtual bool compare (const System &other_system, const Real threshold, const bool verbose) const

const std::string & name () 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), Parameters &parameters) 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), Parameters &parameters, NumericVector< Number > &new_vector) const

unsigned int number () const

void update_global_solution (std::vector< Number > &global_soln) const

void update_global_solution (std::vector< Number > &global_soln, const unsigned int dest_proc) const

const MeshBase & get_mesh () const

MeshBase & get_mesh ()

const DofMap & get_dof_map () const

DofMap & get_dof_map ()

const EquationSystems & get_equation_systems () const

EquationSystems & get_equation_systems ()

bool active () const

void activate ()

void deactivate ()

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)

bool & project_solution_on_reinit (void)

bool have_vector (const std::string &vec_name) const

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)

NumericVector< Number > & get_adjoint_solution ()

const NumericVector< Number > & get_adjoint_solution () const

unsigned int n_vectors () const

unsigned int n_vars () const

unsigned int n_dofs () const

unsigned int n_active_dofs () const

unsigned int n_constrained_dofs () const

unsigned int 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)

const Variable & variable (unsigned int var) 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

const FEType & variable_type (const unsigned int i) const

const FEType & variable_type (const std::string &var) const

Real calculate_norm (NumericVector< Number > &v, unsigned int var=0, FEMNormType norm_type=L2) const

Real calculate_norm (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)

void read_serialized_data (Xdr &io, const bool read_additional_data=true)

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

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_assemble_function (void fptr(EquationSystems &es, const std::string &name))

void attach_constraint_function (void fptr(EquationSystems &es, const std::string &name))

void attach_QOI_function (void fptr(EquationSystems &es, const std::string &name))

void attach_QOI_derivative (void fptr(EquationSystems &es, const std::string &name))

virtual void user_initialization ()

virtual void user_assembly ()

virtual void user_constrain ()

virtual void user_QOI ()

virtual void user_QOI_derivative ()

virtual void re_update ()

virtual void restrict_vectors ()

virtual void prolong_vectors ()

Number current_solution (const unsigned int global_dof_number) const

void local_dof_indices (const unsigned int var, std::set< unsigned int > &var_indices) const

void zero_variable (NumericVector< Number > &v, unsigned int var_num) const
 

Static Public Member Functions


static std::string get_info ()

static void print_info ()

static unsigned int n_objects ()
 

Public Attributes


AutoPtr< LinearSolver< Number > > linear_solver

SparseMatrix< Number > * matrix

NumericVector< Number > * rhs

bool assemble_before_solve

AutoPtr< NumericVector< Number > > solution

AutoPtr< NumericVector< Number > > current_local_solution

Number qoi
 

Protected Types


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

Protected Member Functions


virtual void init_data ()

virtual void init_matrices ()

void project_vector (NumericVector< Number > &) const

void project_vector (const NumericVector< Number > &, NumericVector< Number > &) const

void increment_constructor_count (const std::string &name)

void increment_destructor_count (const std::string &name)
 

Protected Attributes


unsigned int _n_linear_iterations

Real _final_linear_residual

ShellMatrix< Number > * _shell_matrix
 

Static Protected Attributes


static Counts _counts

static Threads::atomic< unsigned int > _n_objects

static Threads::spin_mutex _mutex
 

Private Attributes


Real _a_0

Real _a_1

Real _a_2

Real _a_3

Real _a_4

Real _a_5

Real _a_6

Real _a_7

bool _finished_assemble
 

Static Private Attributes


static const Real _default_alpha = .25

static const Real _default_delta = .5

static const Real _default_timestep = 1.
 

Detailed Description

This class contains a specific system class. It provides an implicit time integration scheme known as the Newmark method.

In the algorithm implemented here the system is solved for displacements. Curently the Newmark scheme is implemented for constant time step sizes only. This time step is stored in the EquationSystems parameter named 'Newmark \p time \p step'. For the case of constant time steps the matrix only has to be assembled once, whereas the rhs has to be updated in each timestep. Default values of the Newmark parameters alpha and delta used for time integration are provided. For details refer to the examples section.

Definition at line 53 of file newmark_system.h.  

Member Typedef Documentation

 

typedef std::map<std::string, SparseMatrix<Number>* >::const_iterator ImplicitSystem::const_matrices_iterator [inherited]

Definition at line 112 of file implicit_system.h.  

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

Definition at line 279 of file system.h.  

typedef std::map<std::string, std::pair<unsigned int, unsigned int> > ReferenceCounter::Counts [protected, inherited]Data structure to log the information. The log is identified by the class name.

Definition at line 105 of file reference_counter.h.  

typedef std::map<std::string, SparseMatrix<Number>* >::iterator ImplicitSystem::matrices_iterator [inherited]Matrix iterator typedefs.

Definition at line 111 of file implicit_system.h.  

typedef ImplicitSystem LinearImplicitSystem::Parent [inherited]The type of the parent.

Reimplemented from ImplicitSystem.

Definition at line 72 of file linear_implicit_system.h.  

typedef NewmarkSystem NewmarkSystem::sys_typeThe type of system.

Reimplemented from LinearImplicitSystem.

Definition at line 74 of file newmark_system.h.  

typedef std::map<std::string, NumericVector<Number>* >::iterator System::vectors_iterator [inherited]Vector iterator typedefs.

Definition at line 278 of file system.h.  

Constructor & Destructor Documentation

 

NewmarkSystem::NewmarkSystem (EquationSystems &es, const std::string &name, const unsigned intnumber)Constructor. Optionally initializes required data structures.

Definition at line 44 of file newmark_system.C.

References _default_alpha, _default_delta, _default_timestep, ImplicitSystem::add_matrix(), System::add_vector(), EquationSystems::parameters, and Parameters::set().

                                                         :  
  LinearImplicitSystem (es, name, number),
  _a_0                 (1./(_default_alpha*_default_timestep*_default_timestep)),
  _a_1                 (_default_delta/(_default_alpha*_default_timestep)),
  _a_2                 (1./(_default_alpha*_default_timestep)),
  _a_3                 (1./(2.*_default_alpha)-1.),
  _a_4                 (_default_delta/_default_alpha -1.),
  _a_5                 (_default_timestep/2.*(_default_delta/_default_alpha-2.)),
  _a_6                 (_default_timestep*(1.-_default_delta)),
  _a_7                 (_default_delta*_default_timestep),
  _finished_assemble   (false)
  
{
  // default values of the newmark parameters
  es.parameters.set<Real>('Newmark alpha') = _default_alpha;
  es.parameters.set<Real>('Newmark delta') = _default_delta;

  // time step size.
  // should be handled at a later stage through EquationSystems?
  es.parameters.set<Real>('Newmark time step') = _default_timestep;

  // add additional matrices and vectors that will be used in the
  // newmark algorithm to the data structure
  // functions LinearImplicitSystem::add_matrix and LinearImplicitSystem::add_vector
  // are used so we do not have to bother about initialization and
  // dof mapping

  // system matrices
  this->add_matrix ('stiffness');
  this->add_matrix ('damping');
  this->add_matrix ('mass');

  // load vector  
  this->add_vector ('force');

  // the displacement and the time derivatives  
  this->add_vector ('displacement');
  this->add_vector ('velocity');
  this->add_vector ('acceleration');

  // contributions to the rhs
  this->add_vector ('rhs_m');
  this->add_vector ('rhs_c');
  
  // results from the previous time step
  this->add_vector ('old_solution');
  this->add_vector ('old_acceleration');
}
 

NewmarkSystem::~NewmarkSystem ()Destructor.

Definition at line 97 of file newmark_system.C.

References clear().

{
  this->clear();
}
 

Member Function Documentation

 

void System::activate () [inline, inherited]Activates the system. Only active systems are solved.

Definition at line 1103 of file system.h.

References System::_active.

{
  _active = true;
}
 

bool System::active () const [inline, inherited]Returns:

true if the system is active, false otherwise. An active system will be solved.

Definition at line 1095 of file system.h.

References System::_active.

{
  return _active;  
}
 

SparseMatrix< Number > & ImplicitSystem::add_matrix (const std::string &mat_name) [inherited]Adds the additional matrix mat_name to this system. Only allowed prior to assemble(). All additional matrices have the same sparsity pattern as the matrix used during solution. When not System but the user wants to initialize the mayor matrix, then all the additional matrices, if existent, have to be initialized by the user, too.

Definition at line 168 of file implicit_system.C.

References ImplicitSystem::_can_add_matrices, ImplicitSystem::_matrices, and ImplicitSystem::have_matrix().

Referenced by ImplicitSystem::add_system_matrix(), EigenTimeSolver::init(), and NewmarkSystem().

{
  // only add matrices before initializing...
  if (!_can_add_matrices)
    {
      std::cerr << 'ERROR: Too late.  Cannot add matrices to the system after initialization'
                << std::endl
                << ' any more.  You should have done this earlier.'
                << std::endl;
      libmesh_error();
    }

  // Return the matrix if it is already there.
  if (this->have_matrix(mat_name))
    return *(_matrices[mat_name]);

  // Otherwise build the matrix and return it.
  SparseMatrix<Number>* buf = SparseMatrix<Number>::build().release();
  _matrices.insert (std::make_pair (mat_name, buf));

  return *buf;
}
 

unsigned int System::add_variable (const std::string &var, const FEType &type, const std::set< subdomain_id_type > *constactive_subdomains = NULL) [inherited]Adds the variable var to the list of variables for this system. Returns the index number for the new variable.

Definition at line 652 of file system.C.

References System::_dof_map, System::_variable_numbers, System::_variables, System::n_vars(), System::number(), System::variable_name(), and System::variable_type().

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

{  
  // 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();

        std::cerr << 'ERROR: incompatible variable '
                  << var
                  << ' has already been added for this system!'
                  << std::endl;
        libmesh_error();
      }

  const unsigned int curr_n_vars = this->n_vars();                                              

  // Add the variable to the list
  _variables.push_back((active_subdomains == NULL) ?
                       Variable(var, curr_n_vars, type) :
                       Variable(var, curr_n_vars, type, *active_subdomains));

  libmesh_assert ((curr_n_vars+1) == this->n_vars());

  _variable_numbers[var] = curr_n_vars;

  // Add the variable to the _dof_map
  _dof_map->add_variable (_variables.back());

  // Return the number of the new variable
  return curr_n_vars;
}
 

unsigned int System::add_variable (const std::string &var, const Orderorder = FIRST, const FEFamilyfamily = LAGRANGE, const std::set< subdomain_id_type > *constactive_subdomains = NULL) [inherited]Adds the variable var to the list of variables for this system. Same as before, but assumes LAGRANGE as default value for FEType.family.

Definition at line 691 of file system.C.

References System::add_variable().

{
  return this->add_variable(var, 
                            FEType(order, family), 
                            active_subdomains);
}
 

NumericVector< Number > & System::add_vector (const std::string &vec_name, const boolprojections = true) [inherited]Adds the additional vector vec_name to this system. Only allowed prior to init(). 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 530 of file system.C.

References System::_can_add_vectors, System::_vector_projections, System::_vectors, System::have_vector(), NumericVector< T >::init(), System::n_dofs(), System::n_local_dofs(), and libMeshEnums::PARALLEL.

Referenced by ExplicitSystem::add_system_rhs(), NonlinearImplicitSystem::adjoint_solve(), NewtonSolver::adjoint_solve(), LinearImplicitSystem::adjoint_solve(), UnsteadySolver::init(), ContinuationSystem::init_data(), NewmarkSystem(), System::read_header(), FrequencySystem::set_frequencies(), FrequencySystem::set_frequencies_by_range(), and 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().release();
  _vectors.insert (std::make_pair (vec_name, buf));
  _vector_projections.insert (std::make_pair (vec_name, projections));

  // Initialize it if necessary
  if (!_can_add_vectors)
    buf->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);

  return *buf;
}
 

void LinearImplicitSystem::adjoint_solve () [virtual, inherited]Assembles & solves the linear adjoint system A^T*x=q.

Reimplemented from ExplicitSystem.

Definition at line 145 of file linear_implicit_system.C.

References LinearImplicitSystem::_final_linear_residual, LinearImplicitSystem::_n_linear_iterations, LinearImplicitSystem::_shell_matrix, System::add_vector(), ImplicitSystem::assemble(), System::assemble_before_solve, ExplicitSystem::assemble_qoi_derivative(), Parameters::get(), System::get_equation_systems(), ImplicitSystem::get_matrix(), SparseMatrix< T >::get_transpose(), ImplicitSystem::have_matrix(), LinearImplicitSystem::linear_solver, ImplicitSystem::matrix, EquationSystems::parameters, ExplicitSystem::rhs, and System::update().

{
  // The adjoint_solve API (and all APIs using it) are about to see a
  // series of non-backwards-compatible changes, primarily to add
  // multiple-QoI support
  libmesh_experimental();

  // We currently don't support adjoint solves of shell matrices
  // FIXME - we should let shell matrices support
  // vector_transpose_mult so that we can use them here.
  if(_shell_matrix!=NULL)
    libmesh_not_implemented();

  // Adding an adjoint_solution vector, allocate an adjoint_solution if it doesn't already exist 

  NumericVector<Number> & adjoint_solution = System::add_vector('adjoint_solution');     

  if (this->assemble_before_solve)
    {
      // Assemble the linear system
      this->assemble (); 

      // And take the adjoint
      matrix->get_transpose(*matrix);

      // Including of any separate preconditioner
      if(this->have_matrix('Preconditioner'))
        {
          SparseMatrix<Number> &pre = this->get_matrix('Preconditioner');
          pre.get_transpose(pre);
        }

      // But now replace the right hand side with the quantity of
      // interest functional's derivative
      this->assemble_qoi_derivative();
    }

  // Get a reference to the EquationSystems
  const EquationSystems& es =
    this->get_equation_systems();
  
  // Get the user-specifiied linear solver tolerance
  const Real tol            =
    es.parameters.get<Real>('adjoint solver tolerance');

  // Get the user-specified maximum # of linear solver iterations
  const unsigned int maxits =
    es.parameters.get<unsigned int>('adjoint solver maximum iterations');

  // Solve the linear system.  Several cases:
  std::pair<unsigned int, Real> rval = std::make_pair(0,0.0);
  if(this->have_matrix('Preconditioner'))
    {
      // 3.) No shell matrix, but with user-supplied preconditioner
      rval = linear_solver->solve (*matrix, this->get_matrix('Preconditioner'), adjoint_solution, *rhs, tol, maxits);
    }
  else
    {
      // 4.) No shell matrix, and use system matrix for the preconditioner
      rval = linear_solver->solve (*matrix, adjoint_solution, *rhs, tol, maxits);
    }

  // Store the number of linear iterations required to
  // solve and the final residual.
  _n_linear_iterations   = rval.first;
  _final_linear_residual = rval.second;
    
  // Stop logging the linear solve
  // This gets done by the LinearSolver classes now [RHS]
  // STOP_LOG('solve()', 'System');

  // Update the system after the solve
  this->update();  
}
 

void NewmarkSystem::assemble () [virtual]Assemble the linear system. Does not actually call the solver.

Reimplemented from ImplicitSystem.

Definition at line 137 of file newmark_system.C.

References _finished_assemble, compute_matrix(), and initial_conditions().

{
  if (!_finished_assemble)
    {
      // prepare matrix with the help of the _dof_map, 
      // fill with sparsity pattern
      LinearImplicitSystem::assemble();

      // compute the effective system matrix
      this->compute_matrix();

      // apply initial conditions
      this->initial_conditions();
      
      _finished_assemble = true;
    }
}
 

void ExplicitSystem::assemble_qoi () [virtual, inherited]Prepares qoi for quantity of interest assembly, then calls user qoi function. Can be overloaded in derived classes.

Reimplemented from System.

Reimplemented in FEMSystem.

Definition at line 89 of file explicit_system.C.

References System::assemble_qoi(), NumericVector< T >::initialized(), System::qoi, and ExplicitSystem::rhs.

{
  libmesh_assert (rhs    != NULL);
  libmesh_assert (rhs->initialized());

  // The user quantity of interest assembly gets to expect to
  // accumulate on an initially zero value
  qoi = 0;

  Parent::assemble_qoi ();
}
 

void ExplicitSystem::assemble_qoi_derivative () [virtual, inherited]Prepares rhs for quantity of interest derivative assembly, then calls user qoi derivative function. Can be overloaded in derived classes.

Reimplemented from System.

Reimplemented in FEMSystem.

Definition at line 103 of file explicit_system.C.

References System::assemble_qoi_derivative(), NumericVector< T >::initialized(), ExplicitSystem::rhs, and NumericVector< T >::zero().

Referenced by PetscDiffSolver::adjoint_solve(), NonlinearImplicitSystem::adjoint_solve(), NewtonSolver::adjoint_solve(), and LinearImplicitSystem::adjoint_solve().

{
  libmesh_assert (rhs    != NULL);
  libmesh_assert (rhs->initialized());

  // The user quantity of interest derivative assembly gets to expect
  // to accumulate on an initially empty vector
  rhs->zero ();

  Parent::assemble_qoi_derivative ();
}
 

void System::attach_assemble_function (void fptrEquationSystems &es,const std::string &name) [inherited]Register a user function to use in assembling the system matrix and RHS.

Definition at line 1084 of file system.C.

References System::_assemble_system.

{
  libmesh_assert (fptr != NULL);
  
  _assemble_system = fptr;  
}
 

void System::attach_constraint_function (void fptrEquationSystems &es,const std::string &name) [inherited]Register a user function for imposing constraints.

Definition at line 1094 of file system.C.

References System::_constrain_system.

{
  libmesh_assert (fptr != NULL);
  
  _constrain_system = fptr;  
}
 

void System::attach_init_function (void fptrEquationSystems &es,const std::string &name) [inherited]Register a user function to use in initializing the system.

Definition at line 1074 of file system.C.

References System::_init_system.

{
  libmesh_assert (fptr != NULL);
  
  _init_system = fptr;
}
 

void System::attach_QOI_derivative (void fptrEquationSystems &es,const std::string &name) [inherited]Register a user function for evaluating derivatives of a quantity of interest with respect to test functions, whose values should be placed in System::rhs

Definition at line 1114 of file system.C.

References System::_qoi_evaluate_derivative.

{
  libmesh_assert (fptr != NULL);
  
  _qoi_evaluate_derivative = fptr;  
}
 

void System::attach_QOI_function (void fptrEquationSystems &es,const std::string &name) [inherited]Register a user function for evaluating a quantity of interest, whose value should be placed in System::qoi

Definition at line 1104 of file system.C.

References System::_qoi_evaluate.

{
  libmesh_assert (fptr != NULL);
  
  _qoi_evaluate = fptr;  
}
 

void LinearImplicitSystem::attach_shell_matrix (ShellMatrix< Number > *shell_matrix) [inherited]This function enables the user to provide a shell matrix, i.e. a matrix that is not stored element-wise, but as a function. When you register your shell matrix using this function, calling solve() will no longer use the matrix member but the registered shell matrix instead. You can reset this behaviour to its original state by supplying a NULL pointer to this function.

Definition at line 322 of file linear_implicit_system.C.

References LinearImplicitSystem::_shell_matrix.

Referenced by LinearImplicitSystem::detach_shell_matrix().

{
  _shell_matrix = shell_matrix;
}
 

Real System::calculate_norm (NumericVector< Number > &v, unsigned intvar = 0, FEMNormTypenorm_type = L2) const [inherited]Returns:

a norm of variable var in the vector v, in the specified norm (e.g. L2, H0, H1)

Definition at line 824 of file system.C.

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

Referenced by AdaptiveTimeSolver::calculate_norm(), and 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 System::calculate_norm (NumericVector< Number > &v, const SystemNorm &norm) const [inherited]Returns:

a norm of the vector v, using component_norm and component_scale to choose and weight the norms of each variable.

Definition at line 845 of file system.C.

References System::_dof_map, MeshBase::active_local_elements_begin(), MeshBase::active_local_elements_end(), TypeTensor< T >::add_scaled(), TypeVector< T >::add_scaled(), FEBase::build(), FEType::default_quadrature_rule(), libMeshEnums::DISCRETE_L1, libMeshEnums::DISCRETE_L2, libMeshEnums::DISCRETE_L_INF, System::discrete_var_norm(), DofMap::dof_indices(), AutoPtr< Tp >::get(), System::get_dof_map(), System::get_mesh(), libMeshEnums::H1, libMeshEnums::H1_SEMINORM, libMeshEnums::H2, libMeshEnums::H2_SEMINORM, SystemNorm::is_discrete(), NumericVector< T >::l1_norm(), libMeshEnums::L2, NumericVector< T >::l2_norm(), libmesh_norm(), NumericVector< T >::linfty_norm(), NumericVector< T >::localize(), MeshBase::mesh_dimension(), System::n_vars(), libMeshEnums::SERIAL, NumericVector< T >::size(), TypeTensor< T >::size_sq(), TypeVector< T >::size_sq(), SystemNorm::type(), DofMap::variable_type(), SystemNorm::weight(), and SystemNorm::weight_sq().

{
  // This function must be run on all processors at once
  parallel_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
      unsigned int check_var = 0;
      for (; check_var != this->n_vars(); ++check_var)
        if(norm.weight(check_var) != 1.0)
          break;

      //All weights were 1.0 so just do the full vector discrete norm
      if(check_var == this->n_vars())
        {
          FEMNormType norm_type = norm.type(0);
          
          if(norm_type == DISCRETE_L1)
            return v.l1_norm();
          if(norm_type == DISCRETE_L2)
            return v.l2_norm();
          if(norm_type == DISCRETE_L_INF)
            return v.linfty_norm();
          else
            libmesh_error();
        }

      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
  AutoPtr<NumericVector<Number> > local_v = NumericVector<Number>::build();
  local_v->init(v.size(), true, SERIAL);
  v.localize (*local_v, _dof_map->get_send_list()); 

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

  // Loop over all variables
  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;

      const FEType& fe_type = this->get_dof_map().variable_type(var);
      AutoPtr<QBase> qrule =
        fe_type.default_quadrature_rule (dim);
      AutoPtr<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(var) == H1 ||
          norm.type(var) == H2 ||
          norm.type(var) == L2)
        phi = &(fe->get_phi());

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

      std::vector<unsigned int> 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 = dof_indices.size();

          // Begin the loop over the Quadrature points.
          for (unsigned int qp=0; qp<n_qp; qp++)
            {
              if (norm.type(var) == H1 ||
                  norm.type(var) == H2 ||
                  norm.type(var) == 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(var) *
                            JxW[qp] * libmesh_norm(u_h);
                }

              if (norm.type(var) == H1 ||
                  norm.type(var) == H2 ||
                  norm.type(var) == 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(var) *
                            JxW[qp] * grad_u_h.size_sq();
                }

#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
              if (norm.type(var) == H2 ||
                  norm.type(var) == 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(var) *
                            JxW[qp] * hess_u_h.size_sq();
                }
#endif
            }
        }
    }

  Parallel::sum(v_norm);

  STOP_LOG ('calculate_norm()', 'System');

  return std::sqrt(v_norm);
}
 

void NewmarkSystem::clear () [virtual]Clear all the data structures associated with the system.

Reimplemented from LinearImplicitSystem.

Definition at line 104 of file newmark_system.C.

References _default_alpha, _default_delta, _default_timestep, _finished_assemble, System::get_equation_systems(), EquationSystems::parameters, and Parameters::set().

Referenced by ~NewmarkSystem().

{
  // use parent clear this will also clear the
  // matrices and vectors added in the constructor
  LinearImplicitSystem::clear();

  // Get a reference to the EquationSystems
  EquationSystems& es =
    this->get_equation_systems();
  
  // default values of the newmark parameters
  es.parameters.set<Real>('Newmark alpha') = _default_alpha;
  es.parameters.set<Real>('Newmark delta') = _default_delta;

  // time step size.  should be handled at a later stage through EquationSystems?
  es.parameters.set<Real>('Newmark time step') = _default_timestep;

  // set bool to false
  _finished_assemble = false;
}
 

bool System::compare (const System &other_system, const Realthreshold, const boolverbose) const [virtual, inherited]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 380 of file system.C.

References System::_can_add_vectors, System::_sys_name, System::_vectors, AutoPtr< Tp >::get(), System::get_vector(), System::n_vectors(), System::name(), and System::solution.

Referenced by EquationSystems::compare().

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

  if (verbose)
    {
      std::cout << '  Systems '' << _sys_name << ''' << std::endl;
      std::cout << '   comparing matrices not supported.' << std::endl;
      std::cout << '   comparing names...';
    }

  // compare the name: 0 means identical
  const int name_result = _sys_name.compare(other_system.name());
  if (verbose)
    {
      if (name_result == 0)
        std::cout << ' identical.' << std::endl;
      else
        std::cout << '  names not identical.' << std::endl;
      std::cout << '   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)
        std::cout << ' identical up to threshold.' << std::endl;
      else
        std::cout << '  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)
        {
          std::cout << '   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)
              std::cout << '   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)
                std::cout << ' identical up to threshold.' << std::endl;
              else
                std::cout << ' 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)
    {
      std::cout << '   finished comparisons, ';
      if (overall_result)
        std::cout << 'found no differences.' << std::endl << std::endl;
      else 
        std::cout << 'found differences.' << std::endl << std::endl;
    }
          
  return overall_result;
}
 

void NewmarkSystem::compute_matrix ()Compute the global matrix by adding up scaled mass damping and stiffness matrix.

Definition at line 176 of file newmark_system.C.

References _a_0, _a_1, SparseMatrix< T >::add(), SparseMatrix< T >::close(), ImplicitSystem::get_matrix(), ImplicitSystem::matrix, and SparseMatrix< T >::zero().

Referenced by assemble().

{
  // close the component matrices
  this->get_matrix ('stiffness').close();
  this->get_matrix ('mass'     ).close();
  this->get_matrix ('damping'  ).close();

  // close & zero the system matrix
  this->matrix->close (); this->matrix->zero();

  // add up the matrices
  this->matrix->add (1.,   this->get_matrix ('stiffness'));
  this->matrix->add (_a_0, this->get_matrix ('mass'));
  this->matrix->add (_a_1, this->get_matrix ('damping'));

}
 

Number System::current_solution (const unsigned intglobal_dof_number) const [inherited]Returns:

the current solution for the specified global DOF.

Definition at line 115 of file system.C.

References System::current_local_solution, and System::n_dofs().

Referenced by ExactSolution::_compute_error(), UniformRefinementEstimator::_estimate_error(), HPCoarsenTest::add_projection(), JumpErrorEstimator::estimate_error(), ExactErrorEstimator::estimate_error(), FEMSystem::eulerian_residual(), PatchRecoveryErrorEstimator::EstimateError::operator()(), FEMContext::reinit(), HPCoarsenTest::select_refinement(), VTKIO::solution_to_vtk(), EnsightIO::write_scalar_ascii(), and EnsightIO::write_vector_ascii().

{
  // Check the sizes
  libmesh_assert (global_dof_number < _dof_map->n_dofs());
  libmesh_assert (global_dof_number < current_local_solution->size());
   
  return (*current_local_solution)(global_dof_number);
}
 

void System::deactivate () [inline, inherited]Deactivates the system. Only active systems are solved.

Definition at line 1111 of file system.h.

References System::_active.

{
  _active = false;
}
 

void LinearImplicitSystem::detach_shell_matrix (void) [inline, inherited]Detaches a shell matrix. Same as attach_shell_matrix(NULL).

Definition at line 161 of file linear_implicit_system.h.

References LinearImplicitSystem::attach_shell_matrix().

{ attach_shell_matrix(NULL); }
 

Real LinearImplicitSystem::final_linear_residual () const [inline, inherited]Returns the final residual for the linear system solve.

Definition at line 145 of file linear_implicit_system.h.

References LinearImplicitSystem::_final_linear_residual.

{ return _final_linear_residual; }
 

NumericVector< Number > & System::get_adjoint_solution () [inherited]Returns:

a reference to the system's adjoint solution vector name adjoint_solution. Adjoint system needs to be solved first.

Definition at line 637 of file system.C.

References System::get_vector().

Referenced by AdjointResidualErrorEstimator::estimate_error().

{
  // Get the adjoint solution using the get_vector function declared above
  return this->get_vector('adjoint_solution');
}
 

const NumericVector< Number > & System::get_adjoint_solution () const [inherited]Returns:

a reference to the system's adjoint solution vector name adjoint_solution. Adjoint system needs to be solved first.

Definition at line 645 of file system.C.

References System::get_vector().

{
  return this->get_vector('adjoint_solution');
}
 

DofMap & System::get_dof_map () [inline, inherited]Returns:

a writeable reference to this system's _dof_map.

Definition at line 1087 of file system.h.

References System::_dof_map.

{
  return *_dof_map;
}
 

const DofMap & System::get_dof_map () const [inline, inherited]Returns:

a constant reference to this system's _dof_map.

Definition at line 1079 of file system.h.

References System::_dof_map.

Referenced by __libmesh_petsc_diff_solver_jacobian(), __libmesh_petsc_diff_solver_residual(), ExactSolution::_compute_error(), UniformRefinementEstimator::_estimate_error(), HPCoarsenTest::add_projection(), PetscDiffSolver::adjoint_solve(), NewtonSolver::adjoint_solve(), FEMSystem::assemble_qoi_derivative(), FEMSystem::assembly(), EquationSystems::build_discontinuous_solution_vector(), EquationSystems::build_solution_vector(), System::calculate_norm(), DofMap::enforce_constraints_exactly(), JumpErrorEstimator::estimate_error(), ExactErrorEstimator::estimate_error(), System::get_info(), EigenSystem::init_data(), ImplicitSystem::init_matrices(), System::local_dof_indices(), DofMap::max_constraint_error(), FEMSystem::mesh_position_get(), UnsteadySolver::old_nonlinear_solution(), System::ProjectVector::operator()(), PatchRecoveryErrorEstimator::EstimateError::operator()(), ErrorVector::plot_error(), System::project_vector(), FEMContext::reinit(), EquationSystems::reinit(), HPCoarsenTest::select_refinement(), UnsteadySolver::solve(), PetscDiffSolver::solve(), NewtonSolver::solve(), EnsightIO::write_scalar_ascii(), and EnsightIO::write_vector_ascii().

{
  return *_dof_map;
}
 

const EquationSystems& System::get_equation_systems () const [inline, inherited]Returns:

a constant reference to this system's parent EquationSystems object.

Definition at line 252 of file system.h.

References System::_equation_systems.

Referenced by UniformRefinementEstimator::_estimate_error(), LinearImplicitSystem::adjoint_solve(), clear(), FrequencySystem::clear_all(), ExactErrorEstimator::find_squared_element_error(), FrequencySystem::init_data(), FrequencySystem::n_frequencies(), FrequencySystem::set_current_frequency(), FrequencySystem::set_frequencies(), FrequencySystem::set_frequencies_by_range(), FrequencySystem::set_frequencies_by_steps(), set_newmark_parameters(), NonlinearImplicitSystem::set_solver_parameters(), LinearImplicitSystem::solve(), FrequencySystem::solve(), and EigenSystem::solve().

{ return _equation_systems; }
 

EquationSystems& System::get_equation_systems () [inline, inherited]Returns:

a reference to this system's parent EquationSystems object.

Definition at line 257 of file system.h.

References System::_equation_systems.

{ return _equation_systems; }
 

std::string System::get_info () const [inherited]Returns:

a string containing information about the system.

Definition at line 1001 of file system.C.

References Utility::enum_to_string< FEFamily >(), Utility::enum_to_string< InfMapType >(), Utility::enum_to_string< Order >(), FEType::family, System::get_dof_map(), FEType::inf_map, System::n_constrained_dofs(), System::n_dofs(), System::n_local_dofs(), System::n_vars(), System::n_vectors(), System::name(), FEType::order, FEType::radial_family, FEType::radial_order, System::system_type(), System::variable_name(), and DofMap::variable_type().

{
  std::ostringstream out;

  
  const std::string& sys_name = this->name();
      
  out << '   System '' << sys_name << ''
      << '    Type ''  << this->system_type() << ''
      << '    Variables=';
  
  for (unsigned int vn=0; vn<this->n_vars(); vn++)
      out << ''' << this->variable_name(vn) << '' ';
     
  out << ';

  out << '    Finite Element Types=';
#ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
  for (unsigned int vn=0; vn<this->n_vars(); vn++)
    out << '''
        << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_type(vn).family)
        << '' ';  
#else
  for (unsigned int vn=0; vn<this->n_vars(); vn++)
    {
      out << '''
          << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_type(vn).family)
          << '', ''
          << Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_type(vn).radial_family)
          << '' ';
    }

  out << ' << '    Infinite Element Mapping=';
  for (unsigned int vn=0; vn<this->n_vars(); vn++)
    out << '''
        << Utility::enum_to_string<InfMapType>(this->get_dof_map().variable_type(vn).inf_map)
        << '' ';
#endif      

  out << ';
      
  out << '    Approximation Orders=';
  for (unsigned int vn=0; vn<this->n_vars(); vn++)
    {
#ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
      out << '''
          << Utility::enum_to_string<Order>(this->get_dof_map().variable_type(vn).order)
          << '' ';
#else
      out << '''
          << Utility::enum_to_string<Order>(this->get_dof_map().variable_type(vn).order)
          << '', ''
          << Utility::enum_to_string<Order>(this->get_dof_map().variable_type(vn).radial_order)
          << '' ';
#endif
    }

  out << ';
      
  out << '    n_dofs()='             << this->n_dofs()             << ';
  out << '    n_local_dofs()='       << this->n_local_dofs()       << ';
#ifdef LIBMESH_ENABLE_AMR
  out << '    n_constrained_dofs()=' << this->n_constrained_dofs() << ';
#endif

  out << '    ' << 'n_vectors()='  << this->n_vectors()  << ';
//   out << '    ' << 'n_additional_matrices()=' << this->n_additional_matrices() << ';
  
  return out.str();
}
 

std::string ReferenceCounter::get_info () [static, inherited]Gets a string containing the reference information.

Definition at line 45 of file reference_counter.C.

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

Referenced by ReferenceCounter::print_info().

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

  std::ostringstream out;
  
  out << '
      << ' ---------------------------------------------------------------------------- 
      << '| Reference count information                                                |
      << ' ---------------------------------------------------------------------------- ;
  
  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;

      out << '| ' << name << ' reference count information:
          << '|  Creations:    ' << creations    << '
          << '|  Destructions: ' << destructions << ';
    }
  
  out << ' ---------------------------------------------------------------------------- ;

  return out.str();

#else

  return '';
  
#endif
}
 

SparseMatrix< Number > & ImplicitSystem::get_matrix (const std::string &mat_name) [inherited]Returns:

a writeable reference to this system's additional matrix named mat_name. None of these matrices is involved in the solution process. Access is only granted when the matrix is already properly initialized.

Definition at line 212 of file implicit_system.C.

References ImplicitSystem::_matrices.

{
  // Make sure the matrix exists
  matrices_iterator pos = _matrices.find (mat_name);
  
  if (pos == _matrices.end())
    {
      std::cerr << 'ERROR: matrix '
                << mat_name
                << ' does not exist in this system!'
                << std::endl;      
      libmesh_error();
    }
  
  return *(pos->second);
}
 

const SparseMatrix< Number > & ImplicitSystem::get_matrix (const std::string &mat_name) const [inherited]Returns:

a const reference to this system's additional matrix named mat_name. None of these matrices is involved in the solution process. Access is only granted when the matrix is already properly initialized.

Definition at line 193 of file implicit_system.C.

References ImplicitSystem::_matrices.

Referenced by PetscDiffSolver::adjoint_solve(), NewtonSolver::adjoint_solve(), LinearImplicitSystem::adjoint_solve(), compute_matrix(), NewtonSolver::solve(), LinearImplicitSystem::solve(), EigenTimeSolver::solve(), and update_rhs().

{
  // Make sure the matrix exists
  const_matrices_iterator pos = _matrices.find (mat_name);
  
  if (pos == _matrices.end())
    {
      std::cerr << 'ERROR: matrix '
                << mat_name
                << ' does not exist in this system!'
                << std::endl;      
      libmesh_error();
    }
  
  return *(pos->second);
}
 

const MeshBase & System::get_mesh () const [inline, inherited]Returns:

a constant reference to this systems's _mesh.

Definition at line 1063 of file system.h.

References System::_mesh.

Referenced by ExactSolution::_compute_error(), HPCoarsenTest::add_projection(), FEMSystem::assemble_qoi(), FEMSystem::assemble_qoi_derivative(), FEMSystem::assembly(), System::calculate_norm(), PatchRecoveryErrorEstimator::estimate_error(), JumpErrorEstimator::estimate_error(), ExactErrorEstimator::estimate_error(), AdjointResidualErrorEstimator::estimate_error(), System::init_data(), EigenSystem::init_data(), ImplicitSystem::init_matrices(), System::local_dof_indices(), DofMap::max_constraint_error(), FEMSystem::mesh_position_get(), FEMSystem::mesh_position_set(), System::ProjectVector::operator()(), PatchRecoveryErrorEstimator::EstimateError::operator()(), FEMSystem::postprocess(), System::project_vector(), System::read_header(), System::read_legacy_data(), System::read_parallel_data(), System::read_serialized_vector(), HPSingularity::select_refinement(), HPCoarsenTest::select_refinement(), System::write_header(), System::write_parallel_data(), System::write_serialized_vector(), and System::zero_variable().

{
  return _mesh;
}
 

MeshBase & System::get_mesh () [inline, inherited]Returns:

a reference to this systems's _mesh.

Definition at line 1071 of file system.h.

References System::_mesh.

{
  return _mesh;
}
 

ShellMatrix<Number>* LinearImplicitSystem::get_shell_matrix (void) [inline, inherited]Returns a pointer to the currently attached shell matrix, if any, or NULL else.

Definition at line 167 of file linear_implicit_system.h.

References LinearImplicitSystem::_shell_matrix.

{ return _shell_matrix; }
 

const NumericVector< Number > & System::get_vector (const std::string &vec_name) const [inherited]Returns:

a const reference to this system's additional vector named vec_name. Access is only granted when the vector is already properly initialized.

Definition at line 551 of file system.C.

References System::_vectors.

Referenced by UniformRefinementEstimator::_estimate_error(), UnsteadySolver::advance_timestep(), AdaptiveTimeSolver::advance_timestep(), System::compare(), UnsteadySolver::du(), System::get_adjoint_solution(), initial_conditions(), UnsteadySolver::solve(), TwostepTimeSolver::solve(), FrequencySystem::solve(), update_rhs(), and update_u_v_a().

{
  // Make sure the vector exists
  const_vectors_iterator pos = _vectors.find(vec_name);
  
  if (pos == _vectors.end())
    {
      std::cerr << 'ERROR: vector '
                << vec_name
                << ' does not exist in this system!'
                << std::endl;      
      libmesh_error();
    }
  
  return *(pos->second);
}
 

NumericVector< Number > & System::get_vector (const std::string &vec_name) [inherited]Returns:

a writeable reference to this system's additional vector named vec_name. Access is only granted when the vector is already properly initialized.

Definition at line 570 of file system.C.

References System::_vectors.

{
  // Make sure the vector exists
  vectors_iterator pos = _vectors.find(vec_name);
  
  if (pos == _vectors.end())
    {
      std::cerr << 'ERROR: vector '
                << vec_name
                << ' does not exist in this system!'
                << std::endl;      
      libmesh_error();
    }
  
  return *(pos->second);
}
 

const NumericVector< Number > & System::get_vector (const unsigned intvec_num) const [inherited]Returns:

a const reference to this system's additional vector number vec_num (where the vectors are counted starting with 0).

Definition at line 589 of file system.C.

References System::vectors_begin(), and System::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 > & System::get_vector (const unsigned intvec_num) [inherited]Returns:

a writeable reference to this system's additional vector number vec_num (where the vectors are counted starting with 0).

Definition at line 605 of file system.C.

References System::vectors_begin(), and System::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);
}
 

bool System::has_variable (const std::string &var) const [inherited]Returns:

true if a variable named var exists in this System

Definition at line 703 of file system.C.

References System::_variable_numbers.

Referenced by GMVIO::copy_nodal_solution().

{
  return _variable_numbers.count(var);
}
 

bool ImplicitSystem::have_matrix (const std::string &mat_name) const [inline, inherited]Returns:

true if this System has a matrix associated with the given name, false otherwise.

Definition at line 199 of file implicit_system.h.

References ImplicitSystem::_matrices.

Referenced by ImplicitSystem::add_matrix(), PetscDiffSolver::adjoint_solve(), NewtonSolver::adjoint_solve(), LinearImplicitSystem::adjoint_solve(), EigenTimeSolver::init(), NewtonSolver::solve(), and LinearImplicitSystem::solve().

{
  return (_matrices.count(mat_name));
}
 

bool System::have_vector (const std::string &vec_name) const [inline, inherited]Returns:

true if this System has a vector associated with the given name, false otherwise.

Definition at line 1173 of file system.h.

References System::_vectors.

Referenced by System::add_vector().

{
  return (_vectors.count(vec_name));
}
 

void 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 149 of file reference_counter.h.

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

Referenced by ReferenceCountedObject< Value >::ReferenceCountedObject().

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

  p.first++;
}
 

void 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 167 of file reference_counter.h.

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

Referenced by ReferenceCountedObject< Value >::~ReferenceCountedObject().

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

  p.second++;
}
 

void System::init () [inherited]Initializes degrees of freedom on the current mesh. Sets the

Definition at line 156 of file system.C.

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

{ 
  // First initialize any required data
  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 ImplicitSystem::init_data () [protected, virtual, inherited]Initializes the member data fields associated with the system, so that, e.g., assemble() may be used.

Reimplemented from ExplicitSystem.

Reimplemented in ContinuationSystem, DifferentiableSystem, FEMSystem, and FrequencySystem.

Definition at line 78 of file implicit_system.C.

References ImplicitSystem::add_system_matrix(), ExplicitSystem::init_data(), and ImplicitSystem::init_matrices().

Referenced by DifferentiableSystem::init_data().

{
  // initialize parent data
  Parent::init_data();

  // Add the system matrix.
  this->add_system_matrix ();
  
  // Initialize the matrices for the system
  this->init_matrices ();
}
 

void ImplicitSystem::init_matrices () [protected, virtual, inherited]Initializes the matrices associated with this system.

Definition at line 92 of file implicit_system.C.

References ImplicitSystem::_can_add_matrices, ImplicitSystem::_matrices, DofMap::attach_matrix(), DofMap::compute_sparsity(), System::get_dof_map(), System::get_mesh(), SparseMatrix< T >::initialized(), and ImplicitSystem::matrix.

Referenced by ImplicitSystem::init_data(), and ImplicitSystem::reinit().

{
  libmesh_assert (matrix != NULL);

  // Check for quick return in case the system matrix
  // (and by extension all the matrices) has already
  // been initialized
  if (matrix->initialized())
    return;

  // Get a reference to the DofMap
  DofMap& dof_map = this->get_dof_map();
  
  // no chance to add other matrices
  _can_add_matrices = false;
  
  // Tell the matrices about the dof map, and vice versa
  for (matrices_iterator pos = _matrices.begin();
       pos != _matrices.end(); ++pos)
    {
      libmesh_assert (!pos->second->initialized());
      dof_map.attach_matrix (*(pos->second));
    }
  
  // Compute the sparsity pattern for the current
  // mesh and DOF distribution.  This also updates
  // additional matrices, 
DofMap now knows them dof_map.compute_sparsity (this->get_mesh()); // Initialize matrices for (matrices_iterator pos = _matrices.begin(); pos != _matrices.end(); ++pos) pos->second->init (); // Set the additional matrices to 0. for (matrices_iterator pos = _matrices.begin(); pos != _matrices.end(); ++pos) pos->second->zero (); }
 

void NewmarkSystem::initial_conditions ()Apply initial conditions.

Definition at line 156 of file newmark_system.C.

References System::get_vector(), System::user_initialization(), and NumericVector< T >::zero().

Referenced by assemble().

{
  // libmesh_assert (init_cond_fptr != NULL);

  // Log how long the user's matrix assembly code takes
  START_LOG('initial_conditions ()', 'NewmarkSystem');
  
  // Set all values to 0, then
  // call the user-specified function for initial conditions.
  this->get_vector('displacement').zero();
  this->get_vector('velocity').zero();
  this->get_vector('acceleration').zero();
  this->user_initialization();

  // Stop logging the user code
  STOP_LOG('initial_conditions ()', 'NewmarkSystem');
}
 

void System::local_dof_indices (const unsigned intvar, std::set< unsigned int > &var_indices) const [inherited]Fills the std::set with the degrees of freedom on the local processor corresponding the the variable number passed in.

Definition at line 730 of file system.C.

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

Referenced by System::discrete_var_norm().

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

  std::vector<unsigned int> 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 unsigned int 
    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++)
        {
          unsigned int 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]);
        }
    }
}
 

unsigned int System::n_active_dofs () const [inline, inherited]Returns the number of active degrees of freedom for this System.

Definition at line 1165 of file system.h.

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

{
  return this->n_dofs() - this->n_constrained_dofs();
}
 

unsigned int System::n_constrained_dofs () const [inherited]Returns:

the number of constrained degrees of freedom in the system.

Definition at line 93 of file system.C.

References System::_dof_map.

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

{
#ifdef LIBMESH_ENABLE_AMR

  return _dof_map->n_constrained_dofs();

#else

  return 0;

#endif
}
 

unsigned int System::n_dofs () const [inherited]Returns:

the number of degrees of freedom in the system

Definition at line 86 of file system.C.

References System::_dof_map.

Referenced by System::add_vector(), System::current_solution(), System::get_info(), System::init_data(), FEMSystem::mass_residual(), System::n_active_dofs(), System::ProjectVector::operator()(), System::project_vector(), System::read_legacy_data(), System::reinit(), System::restrict_vectors(), and UnsteadySolver::solve().

{
  return _dof_map->n_dofs();
}
 

unsigned int LinearImplicitSystem::n_linear_iterations () const [inline, inherited]Returns the number of iterations taken for the most recent linear solve.

Definition at line 140 of file linear_implicit_system.h.

References LinearImplicitSystem::_n_linear_iterations.

{ return _n_linear_iterations; }
 

unsigned int System::n_local_dofs () const [inherited]Returns:

the number of degrees of freedom local to this processor

Definition at line 108 of file system.C.

References System::_dof_map, and libMesh::processor_id().

Referenced by System::add_vector(), System::get_info(), System::init_data(), System::project_vector(), System::read_serialized_blocked_dof_objects(), System::reinit(), System::restrict_vectors(), and UnsteadySolver::solve().

{
  return _dof_map->n_dofs_on_processor (libMesh::processor_id());
}
 

unsigned int ImplicitSystem::n_matrices () const [inline, inherited]Returns:

the number of matrices handled by this system

Definition at line 206 of file implicit_system.h.

References ImplicitSystem::_matrices.

{
 return _matrices.size(); 
}
 

static unsigned int ReferenceCounter::n_objects () [inline, static, inherited]Prints the number of outstanding (created, but not yet destroyed) objects.

Definition at line 76 of file reference_counter.h.

References ReferenceCounter::_n_objects.

Referenced by System::read_serialized_blocked_dof_objects(), and System::write_serialized_blocked_dof_objects().

  { return _n_objects; }
 

unsigned int System::n_vars () const [inline, inherited]Returns:

the number of variables in the system

Definition at line 1119 of file system.h.

References System::_variables.

Referenced by UniformRefinementEstimator::_estimate_error(), System::add_variable(), EquationSystems::build_discontinuous_solution_vector(), EquationSystems::build_solution_vector(), System::calculate_norm(), DiffContext::DiffContext(), JumpErrorEstimator::estimate_error(), ExactErrorEstimator::estimate_error(), ErrorEstimator::estimate_errors(), FEMSystem::eulerian_residual(), ExactSolution::ExactSolution(), FEMContext::FEMContext(), System::get_info(), System::init(), FEMSystem::init_context(), DifferentiableSystem::init_data(), FEMSystem::mass_residual(), FEMSystem::mesh_position_get(), System::ProjectVector::operator()(), PatchRecoveryErrorEstimator::EstimateError::operator()(), System::project_vector(), System::re_update(), System::read_header(), System::read_legacy_data(), System::read_parallel_data(), System::read_serialized_vector(), System::reinit(), FEMContext::reinit(), EquationSystems::reinit(), HPCoarsenTest::select_refinement(), VTKIO::solution_to_vtk(), TecplotIO::write_ascii(), TecplotIO::write_binary(), System::write_header(), System::write_parallel_data(), System::write_serialized_vector(), and System::zero_variable().

{
  return _variables.size();
}
 

unsigned int System::n_vectors () const [inline, inherited]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 1181 of file system.h.

References System::_vectors.

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

{
  return _vectors.size(); 
}
 

const std::string & System::name () const [inline, inherited]Returns:

the system name.

Definition at line 1047 of file system.h.

References System::_sys_name.

Referenced by System::compare(), ExactErrorEstimator::estimate_error(), ExactSolution::ExactSolution(), ExactErrorEstimator::find_squared_element_error(), System::get_info(), System::ProjectVector::operator()(), System::project_vector(), FrequencySystem::solve(), System::user_assembly(), System::user_constrain(), System::user_initialization(), System::user_QOI(), System::user_QOI_derivative(), TecplotIO::write_binary(), System::write_header(), System::write_parallel_data(), and System::write_serialized_data().

{
  return _sys_name;
}
 

unsigned int System::number () const [inline, inherited]Returns:

the system number.

Definition at line 1055 of file system.h.

References System::_sys_number.

Referenced by System::add_variable(), FEMSystem::eulerian_residual(), FEMSystem::mesh_position_get(), FEMSystem::mesh_position_set(), FEMSystem::mesh_x_position(), FEMSystem::mesh_y_position(), FEMSystem::mesh_z_position(), FEMSystem::numerical_jacobian(), System::read_legacy_data(), System::read_parallel_data(), System::read_serialized_blocked_dof_objects(), HPCoarsenTest::select_refinement(), System::write_parallel_data(), System::write_serialized_blocked_dof_objects(), and System::zero_variable().

{
  return _sys_number;
}
 

void ReferenceCounter::print_info () [static, inherited]Prints the reference information to std::cout.

Definition at line 83 of file reference_counter.C.

References ReferenceCounter::get_info().

{
#if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
  
  std::cout << ReferenceCounter::get_info();
  
#endif
}
 

void 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, Parameters &parameters) const [inherited]Projects the continuous functions onto the current solution.

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

Definition at line 237 of file system_projection.C.

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

{
  this->project_vector(fptr, gptr, parameters, *solution);

  solution->localize(*current_local_solution);
}
 

bool& System::project_solution_on_reinit (void) [inline, inherited]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 319 of file system.h.

References System::_solution_projection.

Referenced by UniformRefinementEstimator::_estimate_error().

    { return _solution_projection; }
 

void System::project_vector (NumericVector< Number > &vector) const [protected, inherited]Projects the vector defined on the old mesh onto the new mesh.

Definition at line 43 of file system_projection.C.

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

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

  // Project the old vector to the new vector
  this->project_vector (*old_vector, vector);
}
 

void System::project_vector (const NumericVector< Number > &old_v, NumericVector< Number > &new_v) const [protected, inherited]Projects the vector defined on the old mesh onto the new mesh. The original vector is unchanged and the new vector is passed through the second argument.

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

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

Definition at line 60 of file system_projection.C.

References NumericVector< T >::clear(), NumericVector< T >::close(), DofMap::enforce_constraints_exactly(), FEType::family, AutoPtr< Tp >::get(), System::get_dof_map(), System::get_mesh(), libMeshEnums::GHOSTED, NumericVector< T >::init(), NumericVector< T >::local_size(), NumericVector< T >::localize(), System::n_dofs(), System::n_local_dofs(), libMesh::n_processors(), System::n_vars(), libMeshEnums::PARALLEL, Threads::parallel_for(), Threads::parallel_reduce(), libMesh::processor_id(), libMeshEnums::SCALAR, DofMap::SCALAR_dof_indices(), System::BuildProjectionList::send_list, libMeshEnums::SERIAL, NumericVector< T >::set(), NumericVector< T >::size(), System::Variable::type(), NumericVector< T >::type(), System::BuildProjectionList::unique(), and System::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;
  AutoPtr<NumericVector<Number> > new_vector_built;
  NumericVector<Number> *local_old_vector;
  AutoPtr<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();
      local_old_vector_built = NumericVector<Number>::build();
      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();
      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()
    {
      std::cerr << 'ERROR: Unknown old_v.type() == ' << old_v.type() 
                << std::endl;
      libmesh_error();
    }
  
  // 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(libMesh::processor_id() == (libMesh::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<unsigned int> 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 = 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)
    {
      AutoPtr<NumericVector<Number> > dist_v = NumericVector<Number>::build();
      dist_v->init(this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
      dist_v->close();
    
      for (unsigned int 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 (unsigned int i=0; i!=new_v.size(); i++)
        if (new_vector(i) != 0.0)
          new_v.set(i, new_vector(i));
      new_v.close();
    }

  this->get_dof_map().enforce_constraints_exactly(*this, &new_v);

#else

  // AMR is disabled: simply copy the vector
  new_v = old_v;
  
#endif // #ifdef LIBMESH_ENABLE_AMR

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

void 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, Parameters &parameters, NumericVector< Number > &new_vector) const [inherited]Projects the continuous functions onto the current mesh.

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

Definition at line 258 of file system_projection.C.

References NumericVector< T >::close(), DofMap::enforce_constraints_exactly(), FEType::family, System::get_dof_map(), System::get_mesh(), libMesh::n_processors(), System::n_vars(), System::name(), Threads::parallel_for(), libMesh::processor_id(), libMeshEnums::SCALAR, DofMap::SCALAR_dof_indices(), NumericVector< T >::set(), System::Variable::type(), System::variable(), and System::variable_name().

Referenced by System::project_solution(), System::project_vector(), and System::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(),
                                         1000),
                         ProjectSolution(*this,
                                         fptr,
                                         gptr,
                                         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(libMesh::processor_id() == (libMesh::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)
        {
          std::vector<unsigned int> SCALAR_indices;
          dof_map.SCALAR_dof_indices (SCALAR_indices, var);
          const unsigned int n_SCALAR_dofs = SCALAR_indices.size();

          for (unsigned int i=0; i<n_SCALAR_dofs; i++)
          {
            const unsigned int index = SCALAR_indices[i];

            // We pass the point (i,0,0) to the fptr to distinguish
            // the different scalars within the SCALAR variable
            Point p_i(i,0,0);
            new_vector.set( index, fptr(p_i,
                                        parameters,
                                        this->name(),
                                        this->variable_name(var))
                          );
          }
        }
  }

  new_vector.close();

#ifdef LIBMESH_ENABLE_AMR
  this->get_dof_map().enforce_constraints_exactly(*this, &new_vector);
#endif

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

void System::prolong_vectors () [virtual, inherited]Prolong vectors after the mesh has refined

Definition at line 253 of file system.C.

References System::restrict_vectors().

Referenced by EquationSystems::reinit().

{
#ifdef LIBMESH_ENABLE_AMR
  // Currently project_vector handles both restriction and prolongation
  this->restrict_vectors();
#endif
}
 

void LinearImplicitSystem::qoi_parameter_sensitivity (std::vector< Number * > &parameters, std::vector< Number > &sensitivities) [virtual, inherited]Solves for the derivative of the system's quantity of interest q with respect to each parameter p in parameters. Currently uses adjoint_solve, along with finite differenced derivatives (partial q / partial p) and (partial (b-Ax) / partial p).

TODO - Simultaneous sensitivity calculations for multiple QoIs are not yet implemented. Analytic options for partial derivatives are not yet implemented.

Reimplemented from ExplicitSystem.

Definition at line 223 of file linear_implicit_system.C.

{
  // Get ready to fill in senstivities:
  sensitivities.clear();
  sensitivities.resize(parameters.size(), 0);

  // An introduction to the problem:
  //
  // A(p)*u(p) = b(p), where x is determined implicitly.
  // Residual R(u(p),p) := b(p) - A(p)*u(p)
  // partial R / partial u = -A
  //
  // This implies that:
  // d/dp(R) = 0
  // (partial b / partial p) - 
  // (partial A / partial p) * u -
  // A * (partial u / partial p) = 0
  // A * (partial u / partial p) = (partial R / partial p)
  //   = (partial b / partial p) - (partial A / partial p) * u

  // We first do an adjoint solve:
  // A^T * z = (partial q / partial u)

  this->adjoint_solve();

  // We use the identities:
  // dq/dp = (partial q / partial p) + (partial q / partial u) *
  //         (partial u / partial p)
  // dq/dp = (partial q / partial p) + (A^T * z) *
  //         (partial u / partial p)
  // dq/dp = (partial q / partial p) + z * A *
  //         (partial u / partial p)
 
  // Leading to our final formula:
  // dq/dp = (partial q / partial p) - z * (partial R / partial p)

  for (unsigned int i=0; i != parameters.size(); ++i)
    {
      // We currently get partial derivatives via central differencing
      Number delta_p = 1e-6;

      // (partial q / partial p) ~= (q(p+dp)-q(p-dp))/(2*dp)

      Number old_parameter = *parameters[i];
      // Number old_qoi = this->qoi;

      *parameters[i] = old_parameter - delta_p;
      this->assemble_qoi();
      Number qoi_minus = this->qoi;

      *parameters[i] = old_parameter + delta_p;
      this->assemble_qoi();
      Number qoi_plus = this->qoi;
      Number partialq_partialp = (qoi_plus - qoi_minus) / (2.*delta_p);

      // (partial R / partial p) = (partial b / partial p) - 
      //                           (partial A / partial p) * u
      //   ~= (b(p+dp)-A(p+dp)*u-b(p-dp)+A(p-dp)*u)/(2*dp)

      // We're still at p+delta_p, so start with b(p+dp)
      this->assemble();
      this->rhs->close();
      this->matrix->close();
      AutoPtr<NumericVector<Number> > partialR_partialp = this->rhs->clone();

      // PETSc doesn't implement SGEMX, so neither does NumericVector,
      // so here's a hackish workaround for v-=A*u:
      *partialR_partialp *= -1;
      partialR_partialp->add_vector(*this->solution, *this->matrix);
      *partialR_partialp *= -1;
      
      *parameters[i] = old_parameter - delta_p;
      this->assemble();
      this->rhs->close();
      this->matrix->close();
      *partialR_partialp -= *this->rhs;
      partialR_partialp->add_vector(*this->solution, *this->matrix);

      *partialR_partialp /= (2.*delta_p);

      // Don't leave the parameter changed
      *parameters[i] = old_parameter;

      sensitivities[i] = partialq_partialp -
                         partialR_partialp->dot(this->get_adjoint_solution());
    }

  // All parameters have been reset.
  // Don't leave the qoi or system changed - principle of least
  // surprise.
  this->assemble();
  this->assemble_qoi();
  this->rhs->close();
  this->matrix->close();
}
 

void System::re_update () [virtual, inherited]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.

Definition at line 312 of file system.C.

References System::current_local_solution, Utility::iota(), System::n_vars(), and System::solution.

{
  //const std::vector<unsigned int>& send_list = _dof_map->get_send_list ();

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

  // Explicitly build a send_list
  std::vector<unsigned int> send_list(solution->size());
  Utility::iota (send_list.begin(), send_list.end(), 0);
  
  // Check sizes
  libmesh_assert (current_local_solution->size()       == solution->size());
  // Not true with ghosted vectors
  // libmesh_assert (current_local_solution->local_size() == solution->size());
  libmesh_assert (!send_list.empty());
  libmesh_assert (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 System::read_header (Xdr &io, const std::string &version, const boolread_header = true, const boolread_additional_data = true, const boolread_legacy_format = false) [inherited]Reads the basic data header for this System.

Definition at line 78 of file system_io.C.

References System::_additional_data_written, System::_can_add_vectors, System::add_variable(), System::add_vector(), System::clear(), Xdr::data(), FEType::family, System::get_mesh(), FEType::inf_map, MeshBase::mesh_dimension(), libMeshEnums::MONOMIAL, System::n_vars(), System::n_vectors(), libMesh::on_command_line(), FEType::order, libMesh::processor_id(), FEType::radial_family, FEType::radial_order, Xdr::reading(), and libMeshEnums::XYZ.

Referenced by 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)
  //     
  //     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)
    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 n_vars=0;
    if (libMesh::processor_id() == 0) io.data (n_vars);
    Parallel::broadcast(n_vars);
      
    for (unsigned int var=0; var<n_vars; var++)
      {             
        // 6.)
        // Read the name of the var-th variable
        std::string var_name;     
        if (libMesh::processor_id() == 0) io.data (var_name);
        Parallel::broadcast(var_name);
                
        // 7.)
        // Read the approximation order(s) of the var-th variable 
        int order=0;      
        if (libMesh::processor_id() == 0) io.data (order);
        Parallel::broadcast(order);
        
        
        // do the same for infinite element radial_order 
        int rad_order=0;
        if (read_ifem_info)
          {
            if (libMesh::processor_id() == 0) io.data(rad_order);
            Parallel::broadcast(rad_order);
          }


        // Read the finite element type of the var-th variable 
        int fam=0;
        if (libMesh::processor_id() == 0) io.data (fam);
        Parallel::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();
              std::cout << '*****************************************************************
                        << '* WARNING: reading a potentially incompatible restart file!!!   *
                        << '*  contact libmesh-users@lists.sourceforge.net for more details *
                        << '*****************************************************************'
                        << std::endl;
            }
                        
        // Read additional information for infinite elements    
        int radial_fam=0;
        int i_map=0;
        if (read_ifem_info)
          {
            if (libMesh::processor_id() == 0) io.data (radial_fam);
            Parallel::broadcast(radial_fam);
            if (libMesh::processor_id() == 0) io.data (i_map);
            Parallel::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) 
          this->add_variable (var_name, type);
      }
  }

  // 8.)  
  // Read the number of additional vectors.  
  unsigned int n_vectors=0;  
  if (libMesh::processor_id() == 0) io.data (n_vectors);
  Parallel::broadcast(n_vectors);
  
  // If n_vectors > 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 (n_vectors > 0)
    this->_additional_data_written = true;  
  
  for (unsigned int vec=0; vec<n_vectors; vec++)
    {
      // 9.)
      // Read the name of the vec-th additional vector
      std::string vec_name;      
      if (libMesh::processor_id() == 0) io.data (vec_name);
      Parallel::broadcast(vec_name);
      
      if (read_additional_data)
        {
          // sanity checks
          libmesh_assert(this->_can_add_vectors);
          // Some systems may have added their own vectors already
//        libmesh_assert(this->_vectors.count(vec_name) == 0);

          this->add_vector(vec_name);
        }
    }
}
 

void System::read_legacy_data (Xdr &io, const boolread_additional_data = true) [inherited]Reads additional data, namely vectors, for this System.

Definition at line 241 of file system_io.C.

References System::_additional_data_written, System::_vectors, MeshBase::active_elements_begin(), MeshBase::active_elements_end(), Xdr::data(), System::get_mesh(), DofObject::invalid_id, System::n_dofs(), System::n_vars(), MeshBase::nodes_begin(), MeshBase::nodes_end(), System::number(), libMesh::processor_id(), Xdr::reading(), System::solution, 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 (libMesh::processor_id() == 0) io.data (global_vector);    
    Parallel::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());

    //std::cout << 'global_vector.size()=' << global_vector.size() << std::endl;
    //std::cout << 'this->n_dofs()=' << this->n_dofs() << std::endl;
    
    libmesh_assert (global_vector.size() == this->n_dofs());
        
    unsigned int cnt=0;

    const unsigned int sys     = this->number();
    const unsigned int n_vars  = this->n_vars();

    for (unsigned int var=0; var<n_vars; 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 ((*it)->dof_number(sys, var, index) !=
                        DofObject::invalid_id);
                
                libmesh_assert (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 ((*it)->dof_number(sys, var, index) !=
                        DofObject::invalid_id);
                
                libmesh_assert (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 (libMesh::processor_id() == 0) io.data (global_vector);
          Parallel::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 (global_vector.size() == this->n_dofs());
        
              unsigned int cnt=0;

              const unsigned int sys     = this->number();
              const unsigned int n_vars  = this->n_vars();
        
              for (unsigned int var=0; var<n_vars; 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 ((*it)->dof_number(sys, var, index) !=
                                  DofObject::invalid_id);
                          
                          libmesh_assert (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 ((*it)->dof_number(sys, var, index) !=
                                  DofObject::invalid_id);
                          
                          libmesh_assert (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)    
}
 

void System::read_parallel_data (Xdr &io, const boolread_additional_data) [inherited]Reads additional data, namely vectors, for this System. This method may safely be called on a distributed-memory mesh. This method will read an individual file for each processor in the simulation where the local solution components for that processor are stored.

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

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

for each additional vector in the object

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

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

Definition at line 419 of file system_io.C.

References System::_vectors, Xdr::data(), System::get_mesh(), DofObject::invalid_id, Xdr::is_open(), System::n_vars(), System::number(), Xdr::reading(), and System::solution.

{
  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;
  
  // 9.)
  //
  // Actually read the solution components
  // for the ith system to disk
  io.data(io_buffer);
  
  const unsigned int sys_num = this->number();
  const unsigned int n_vars  = this->n_vars();

  unsigned int cnt=0;
  
  // Loop over each variable and each node, and read out the value.
  for (unsigned int var=0; var<n_vars; var++)
    {
      // 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 ((*it)->dof_number(sys_num, var, comp) !=
                    DofObject::invalid_id);
            libmesh_assert (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 ((*it)->dof_number(sys_num, var, comp) !=
                    DofObject::invalid_id);
            libmesh_assert (cnt < io_buffer.size());
            this->solution->set((*it)->dof_number(sys_num, var, comp), io_buffer[cnt++]);
          }      
    }
  
  // 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);
          
          // Loop over each variable and each node, and read out the value.
          for (unsigned int var=0; var<n_vars; var++)
            {
              // 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 ((*it)->dof_number(sys_num, var, comp) !=
                            DofObject::invalid_id);
                    libmesh_assert (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 ((*it)->dof_number(sys_num, var, comp) !=
                            DofObject::invalid_id);
                    libmesh_assert (cnt < io_buffer.size());
                    this->solution->set((*it)->dof_number(sys_num, var, comp), io_buffer[cnt++]);
                  }           
            }
        }
    }
}
 

void System::read_serialized_data (Xdr &io, const boolread_additional_data = true) [inherited]Reads additional data, namely vectors, for this System. This method may safely be called on a distributed-memory mesh.

Definition at line 559 of file system_io.C.

References System::_vectors, Xdr::comment(), libMesh::processor_id(), System::read_serialized_vector(), and System::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_only();
  std::string comment;

  // 10.)
  // Read the global solution vector
  {
    this->read_serialized_vector(io, *this->solution); 

    // get the comment
    if (libMesh::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)
        {
          this->read_serialized_vector(io, *pos->second);

          // get the comment
          if (libMesh::processor_id() == 0)
            io.comment (comment);         
            
        }
    }
}
 

void NewmarkSystem::reinit () [virtual]Reinitializes the member data fields associated with the system, so that, e.g., assemble() may be used.

Reimplemented from LinearImplicitSystem.

Definition at line 127 of file newmark_system.C.

{
  libmesh_error();
  
  // initialize parent data
  LinearImplicitSystem::reinit();
}
 

void System::restrict_vectors () [virtual, inherited]Restrict vectors after the mesh has coarsened

Definition at line 217 of file system.C.

References System::_dof_map, System::_solution_projection, System::_vector_projections, System::_vectors, System::current_local_solution, libMeshEnums::GHOSTED, NumericVector< T >::init(), System::n_dofs(), System::n_local_dofs(), libMeshEnums::PARALLEL, System::project_vector(), and System::solution.

Referenced by System::prolong_vectors(), and 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);
      else
        v->init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
    }

  const std::vector<unsigned int>& 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
}
 

void NewmarkSystem::set_newmark_parameters (const Realdelta_T = _default_timestep, const Realalpha = _default_alpha, const Realdelta = _default_delta)Set the time step size and the newmark parameter alpha and delta and calculate the constant parameters used for time integration.

Definition at line 264 of file newmark_system.C.

References _a_0, _a_1, _a_2, _a_3, _a_4, _a_5, _a_6, _a_7, System::get_equation_systems(), EquationSystems::parameters, and Parameters::set().

{
  libmesh_assert(delta_T != 0.);

    // Get a reference to the EquationSystems
  EquationSystems& es =
    this->get_equation_systems();

  // the newmark parameters
  es.parameters.set<Real>('Newmark alpha') = alpha;
  es.parameters.set<Real>('Newmark delta') = delta;

  // time step size.
  // should be handled at a later stage through EquationSystems?
  es.parameters.set<Real>('Newmark time step') = delta_T;

  // the constants for time integration
  _a_0 = 1./(alpha*delta_T*delta_T);
  _a_1 = delta/(alpha*delta_T);
  _a_2 = 1./(alpha*delta_T);
  _a_3 = 1./(2.*alpha)-1.;
  _a_4 = delta/alpha -1.;
  _a_5 = delta_T/2.*(delta/alpha-2.);
  _a_6 = delta_T*(1.-delta);
  _a_7 = delta*delta_T;
}
 

void LinearImplicitSystem::solve () [virtual, inherited]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. Assembles & solves the linear system A*x=b.

Reimplemented from ExplicitSystem.

Reimplemented in FrequencySystem.

Definition at line 79 of file linear_implicit_system.C.

References LinearImplicitSystem::_final_linear_residual, LinearImplicitSystem::_n_linear_iterations, LinearImplicitSystem::_shell_matrix, ImplicitSystem::assemble(), System::assemble_before_solve, Parameters::get(), System::get_equation_systems(), ImplicitSystem::get_matrix(), ImplicitSystem::have_matrix(), LinearImplicitSystem::linear_solver, ImplicitSystem::matrix, EquationSystems::parameters, ExplicitSystem::rhs, System::solution, and System::update().

{
  if (this->assemble_before_solve)
    // Assemble the linear system
    this->assemble (); 

  // Log how long the linear solve takes.
  // This gets done by the LinearSolver classes now [RHS]
  // START_LOG('solve()', 'System');

  // Get a reference to the EquationSystems
  const EquationSystems& es =
    this->get_equation_systems();
  
  // Get the user-specifiied linear solver tolerance
  const Real tol            =
    es.parameters.get<Real>('linear solver tolerance');

  // Get the user-specified maximum # of linear solver iterations
  const unsigned int maxits =
    es.parameters.get<unsigned int>('linear solver maximum iterations');

  // Solve the linear system.  Several cases:
  std::pair<unsigned int, Real> rval = std::make_pair(0,0.0);
  if(_shell_matrix!=NULL)
    {
      if(this->have_matrix('Preconditioner'))
        {
          // 1.) Shell matrix plus user-supplied preconditioner.
          rval = linear_solver->solve(*_shell_matrix, this->get_matrix('Preconditioner'), *solution, *rhs, tol, maxits);
        }
      else
        {
          // 2.) Shell matrix without user-supplied preconditioner.
          rval = linear_solver->solve(*_shell_matrix, *solution, *rhs, tol, maxits);
        }
    }
  else
    {
      if(this->have_matrix('Preconditioner'))
        {
          // 3.) No shell matrix, but with user-supplied preconditioner
          rval = linear_solver->solve (*matrix, this->get_matrix('Preconditioner'), *solution, *rhs, tol, maxits);
        }
      else
        {
          // 4.) No shell matrix, and use system matrix for the preconditioner
          rval = linear_solver->solve (*matrix, *solution, *rhs, tol, maxits);
        }
    }

  // Store the number of linear iterations required to
  // solve and the final residual.
  _n_linear_iterations   = rval.first;
  _final_linear_residual = rval.second;
    
  // Stop logging the linear solve
  // This gets done by the LinearSolver classes now [RHS]
  // STOP_LOG('solve()', 'System');

  // Update the system after the solve
  this->update();  
}
 

sys_type& LinearImplicitSystem::system () [inline, inherited]Returns:

a clever pointer to the system.

Reimplemented from ImplicitSystem.

Definition at line 77 of file linear_implicit_system.h.

{ return *this; }
 

virtual std::string NewmarkSystem::system_type () const [inline, virtual]Returns:

'Newmark'. Helps in identifying the system type in an equation system file.

Reimplemented from LinearImplicitSystem.

Definition at line 98 of file newmark_system.h.

{ return 'Newmark'; }
 

void System::update () [virtual, inherited]Update the local values to reflect the solution on neighboring processors.

Definition at line 293 of file system.C.

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

Referenced by __libmesh_petsc_diff_solver_jacobian(), __libmesh_petsc_diff_solver_residual(), UniformRefinementEstimator::_estimate_error(), PetscDiffSolver::adjoint_solve(), NonlinearImplicitSystem::adjoint_solve(), NewtonSolver::adjoint_solve(), LinearImplicitSystem::adjoint_solve(), FEMSystem::assemble_qoi(), FEMSystem::assemble_qoi_derivative(), FEMSystem::assembly(), Problem_Interface::computeF(), GMVIO::copy_nodal_solution(), FEMSystem::mesh_position_get(), FEMSystem::postprocess(), NonlinearImplicitSystem::solve(), NewtonSolver::solve(), LinearImplicitSystem::solve(), and ExplicitSystem::solve().

{
  const std::vector<unsigned int>& send_list = _dof_map->get_send_list ();

  // Check sizes
  libmesh_assert (current_local_solution->size() == solution->size());
// More processors than elements => empty send_list
//  libmesh_assert (!send_list.empty());
  libmesh_assert (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 System::update_global_solution (std::vector< Number > &global_soln) const [inherited]Fill the input vector global_soln so that it contains the global solution on all processors. Requires communication with all other processors.

Definition at line 511 of file system.C.

References System::solution.

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

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

  solution->localize (global_soln);
}
 

void System::update_global_solution (std::vector< Number > &global_soln, const unsigned intdest_proc) const [inherited]Fill the input vector global_soln so that it contains the global solution on processor dest_proc. Requires communication with all other processors.

Definition at line 520 of file system.C.

References System::solution.

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

  solution->localize_to_one (global_soln, dest_proc);
}
 

void NewmarkSystem::update_rhs ()Update the rhs.

Definition at line 195 of file newmark_system.C.

References _a_0, _a_1, _a_2, _a_3, _a_4, _a_5, NumericVector< T >::add(), NumericVector< T >::add_vector(), ImplicitSystem::get_matrix(), System::get_vector(), ExplicitSystem::rhs, and NumericVector< T >::zero().

{
  START_LOG('update_rhs ()', 'NewmarkSystem');
  
  // zero the rhs-vector
  NumericVector<Number>& rhs = *this->rhs;
  rhs.zero();

  // get writable references to some vectors
  NumericVector<Number>& rhs_m = this->get_vector('rhs_m');
  NumericVector<Number>& rhs_c = this->get_vector('rhs_c');


  // zero the vectors for matrix-vector product
  rhs_m.zero();
  rhs_c.zero();

  // compute auxiliary vectors rhs_m and rhs_c
  rhs_m.add(_a_0, this->get_vector('displacement'));
  rhs_m.add(_a_2, this->get_vector('velocity'));
  rhs_m.add(_a_3, this->get_vector('acceleration'));

  rhs_c.add(_a_1, this->get_vector('displacement'));
  rhs_c.add(_a_4, this->get_vector('velocity'));
  rhs_c.add(_a_5, this->get_vector('acceleration'));

  // compute rhs
  rhs.add(this->get_vector('force'));
  rhs.add_vector(rhs_m, this->get_matrix('mass'));
  rhs.add_vector(rhs_c, this->get_matrix('damping'));
  
  STOP_LOG('update_rhs ()', 'NewmarkSystem');
}
 

void NewmarkSystem::update_u_v_a ()Update displacement, velocity and acceleration.

Definition at line 231 of file newmark_system.C.

References _a_0, _a_2, _a_3, _a_6, _a_7, NumericVector< T >::add(), System::get_vector(), NumericVector< T >::scale(), and System::solution.

{
  START_LOG('update_u_v_a ()', 'NewmarkSystem');
  
  // get some references for convenience
  const NumericVector<Number>&  solu = *this->solution;

  NumericVector<Number>&  disp_vec   = this->get_vector('displacement');
  NumericVector<Number>&  vel_vec    = this->get_vector('velocity');
  NumericVector<Number>&  acc_vec    = this->get_vector('acceleration');
  NumericVector<Number>&  old_acc    = this->get_vector('old_acceleration');
  NumericVector<Number>&  old_solu   = this->get_vector('old_solution');

  // copy data
  old_solu = disp_vec;
  disp_vec = solu;
  old_acc  = acc_vec;

  // compute the new acceleration vector
  acc_vec.scale(-_a_3);
  acc_vec.add(_a_0, disp_vec);
  acc_vec.add(-_a_0, old_solu);
  acc_vec.add(-_a_2,vel_vec);

  // compute the new velocity vector
  vel_vec.add(_a_6,old_acc);
  vel_vec.add(_a_7,acc_vec);
  
  STOP_LOG('update_u_v_a ()', 'NewmarkSystem');
}
 

void System::user_assembly () [virtual, inherited]Calls user's attached assembly function, or is overloaded by the user in derived classes.

Definition at line 1133 of file system.C.

References System::_assemble_system, System::_equation_systems, and System::name().

Referenced by System::assemble().

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

void System::user_constrain () [virtual, inherited]Calls user's attached constraint function, or is overloaded by the user in derived classes.

Definition at line 1143 of file system.C.

References System::_constrain_system, System::_equation_systems, and System::name().

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

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

void System::user_initialization () [virtual, inherited]Calls user's attached initialization function, or is overloaded by the user in derived classes.

Definition at line 1124 of file system.C.

References System::_equation_systems, System::_init_system, and System::name().

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

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

void System::user_QOI () [virtual, inherited]Calls user's attached quantity of interest function, or is overloaded by the user in derived classes.

Definition at line 1153 of file system.C.

References System::_equation_systems, System::_qoi_evaluate, and System::name().

Referenced by System::assemble_qoi().

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

void System::user_QOI_derivative () [virtual, inherited]Calls user's attached quantity of interest derivative function, or is overloaded by the user in derived classes.

Definition at line 1163 of file system.C.

References System::_equation_systems, System::_qoi_evaluate_derivative, and System::name().

Referenced by System::assemble_qoi_derivative().

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

const System::Variable & System::variable (unsigned intvar) const [inline, inherited]Return a constant reference to Variable var.

Definition at line 1127 of file system.h.

References System::_variables.

Referenced by EquationSystems::build_solution_vector(), and System::project_vector().

{
  libmesh_assert (i < _variables.size());

  return _variables[i];
}
 

const std::string & System::variable_name (const unsigned inti) const [inline, inherited]Returns:

the name of variable i.

Definition at line 1137 of file system.h.

References System::_variables.

Referenced by System::add_variable(), KellyErrorEstimator::boundary_side_integration(), DiscontinuityMeasure::boundary_side_integration(), ExactErrorEstimator::estimate_error(), ExactSolution::ExactSolution(), System::get_info(), System::ProjectVector::operator()(), System::project_vector(), VTKIO::solution_to_vtk(), and System::write_header().

{
  libmesh_assert (i < _variables.size());

  return _variables[i].name();
}
 

unsigned short int System::variable_number (const std::string &var) const [inherited]Returns:

the variable number assoicated with the user-specified variable named var.

Definition at line 710 of file system.C.

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

Referenced by ExactSolution::_compute_error(), GMVIO::copy_nodal_solution(), ExactErrorEstimator::estimate_error(), ExactErrorEstimator::find_squared_element_error(), System::variable_type(), EnsightIO::write_scalar_ascii(), and 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())
    {
      std::cerr << 'ERROR: variable '
                << var
                << ' does not exist in this system!'
                << std::endl;      
      libmesh_error();
    }
  libmesh_assert (_variables[pos->second].name() == var);

  return pos->second;
}
 

const FEType & System::variable_type (const unsigned inti) const [inline, inherited]Returns:

the finite element type variable number i.

Definition at line 1147 of file system.h.

References System::_variables.

Referenced by System::add_variable(), EquationSystems::build_discontinuous_solution_vector(), EquationSystems::build_solution_vector(), GMVIO::copy_nodal_solution(), FEMContext::FEMContext(), System::write_header(), EnsightIO::write_scalar_ascii(), and EnsightIO::write_vector_ascii().

{
  libmesh_assert (i < _variables.size());
  
  return _variables[i].type();
}
 

const FEType & System::variable_type (const std::string &var) const [inline, inherited]Returns:

the finite element type for variable var.

Definition at line 1157 of file system.h.

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

{
  return _variables[this->variable_number(var)].type();
}
 

const std::string & System::vector_name (const unsigned intvec_num) [inherited]Returns:

the name of this system's additional vector number vec_num (where the vectors are counted starting with 0).

Definition at line 621 of file system.C.

References System::vectors_begin(), and System::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;
}
 

System::const_vectors_iterator System::vectors_begin () const [inline, inherited]Beginning of vectors container

Definition at line 1193 of file system.h.

References System::_vectors.

{
  return _vectors.begin();
}
 

System::vectors_iterator System::vectors_begin () [inline, inherited]Beginning of vectors container

Definition at line 1187 of file system.h.

References System::_vectors.

Referenced by UniformRefinementEstimator::_estimate_error(), System::get_vector(), VTKIO::system_vectors_to_vtk(), and System::vector_name().

{
  return _vectors.begin();
}
 

System::vectors_iterator System::vectors_end () [inline, inherited]End of vectors container

Definition at line 1199 of file system.h.

References System::_vectors.

Referenced by UniformRefinementEstimator::_estimate_error(), System::get_vector(), VTKIO::system_vectors_to_vtk(), and System::vector_name().

{
  return _vectors.end();
}
 

System::const_vectors_iterator System::vectors_end () const [inline, inherited]End of vectors container

Definition at line 1205 of file system.h.

References System::_vectors.

{
  return _vectors.end();
}
 

void System::write_header (Xdr &io, const std::string &version, const boolwrite_additional_data) const [inherited]Writes the basic data header for this System.

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

for this system

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

for each variable in the system

6.) The name of the variable (string)

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

References System::_vectors, Xdr::data(), FEType::family, System::get_mesh(), FEType::inf_map, System::n_vars(), System::n_vectors(), System::name(), FEType::order, MeshBase::processor_id(), FEType::radial_family, FEType::radial_order, System::variable_name(), System::variable_type(), and 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 n_vars = this->n_vars();   
    io.data (n_vars, 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, '%d', var);
        comment += buf;
        comment += ', System '';
        comment += this->name();
        comment += ''';
              
        std::string var_name = this->variable_name(var);             
        io.data (var_name, 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 n_vectors = write_additional_data ? this->n_vectors () : 0;
      io.data (n_vectors, 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 System::write_parallel_data (Xdr &io, const boolwrite_additional_data) const [inherited]Writes additional data, namely vectors, for this System. This method may safely be called on a distributed-memory mesh. This method will create an individual file for each processor in the simulation where the local solution components for that processor will be stored.

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

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

for each additional vector in the object

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

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

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

References System::_vectors, Xdr::data(), System::get_mesh(), DofObject::invalid_id, System::n_vars(), System::name(), System::number(), System::solution, and Xdr::writing().

{
  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 n_vars  = this->n_vars();
  
  // Loop over each variable and each node, and write out the value.
  for (unsigned int var=0; var<n_vars; var++)
    {
      // 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++)
          {
            //std::cout << '(*it)->id()=' << (*it)->id() << std::endl;
            libmesh_assert ((*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 ((*it)->dof_number(sys_num, var, comp) !=
                    DofObject::invalid_id);
              
            io_buffer.push_back((*this->solution)((*it)->dof_number(sys_num, var, comp)));    
          }
    }
  
  // 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());   
  
  // 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 variable and each node, and write out the value.
          for (unsigned int var=0; var<n_vars; var++)
            {
              // 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 ((*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 ((*it)->dof_number(sys_num, var, comp) !=
                            DofObject::invalid_id);
              
                    io_buffer.push_back((*pos->second)((*it)->dof_number(sys_num, var, comp)));
                  }
            }
          
          // 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());         
        }
    }
}
 

void System::write_serialized_data (Xdr &io, const boolwrite_additional_data = true) const [inherited]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 1370 of file system_io.C.

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

{
  parallel_only();
  std::string comment;

  this->write_serialized_vector(io, *this->solution); 

  // set up the comment
  if (libMesh::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)
        {
          this->write_serialized_vector(io, *pos->second);

          // set up the comment
          if (libMesh::processor_id() == 0)
            {
              comment = '# System '';
              comment += this->name(); 
              comment += '' Additional Vector '';
              comment += pos->first;
              comment += ''';
              io.comment (comment);       
            }
        }
    }
}
 

void System::zero_variable (NumericVector< Number > &v, unsigned intvar_num) const [inherited]Zeroes all dofs in v that correspond to variable number var_num.

Definition at line 763 of file system.C.

References MeshBase::active_local_elements_begin(), MeshBase::active_local_elements_end(), DofObject::dof_number(), System::get_mesh(), MeshBase::local_nodes_begin(), MeshBase::local_nodes_end(), DofObject::n_comp(), System::n_vars(), System::number(), and NumericVector< T >::set().

{
  /* Make sure the call makes sense.  */
  libmesh_assert(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 unsigned int 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 unsigned int index = elem->dof_number(sys_num,var_num,i);
            v.set(index,0.0);
          }
      }
  }
}
 

Member Data Documentation

 

Real NewmarkSystem::_a_0 [private]Constants used for the time integration.

Definition at line 143 of file newmark_system.h.

Referenced by compute_matrix(), set_newmark_parameters(), update_rhs(), and update_u_v_a().  

Real NewmarkSystem::_a_1 [private]

Definition at line 144 of file newmark_system.h.

Referenced by compute_matrix(), set_newmark_parameters(), and update_rhs().  

Real NewmarkSystem::_a_2 [private]

Definition at line 145 of file newmark_system.h.

Referenced by set_newmark_parameters(), update_rhs(), and update_u_v_a().  

Real NewmarkSystem::_a_3 [private]

Definition at line 146 of file newmark_system.h.

Referenced by set_newmark_parameters(), update_rhs(), and update_u_v_a().  

Real NewmarkSystem::_a_4 [private]

Definition at line 147 of file newmark_system.h.

Referenced by set_newmark_parameters(), and update_rhs().  

Real NewmarkSystem::_a_5 [private]

Definition at line 148 of file newmark_system.h.

Referenced by set_newmark_parameters(), and update_rhs().  

Real NewmarkSystem::_a_6 [private]

Definition at line 149 of file newmark_system.h.

Referenced by set_newmark_parameters(), and update_u_v_a().  

Real NewmarkSystem::_a_7 [private]

Definition at line 150 of file newmark_system.h.

Referenced by set_newmark_parameters(), and update_u_v_a().  

ReferenceCounter::Counts ReferenceCounter::_counts [static, protected, inherited]Actually holds the data.

Definition at line 110 of file reference_counter.h.

Referenced by ReferenceCounter::get_info(), ReferenceCounter::increment_constructor_count(), and ReferenceCounter::increment_destructor_count().  

const Real NewmarkSystem::_default_alpha = .25 [static, private]Default Newmark alpha

Definition at line 160 of file newmark_system.h.

Referenced by clear(), and NewmarkSystem().  

const Real NewmarkSystem::_default_delta = .5 [static, private]Default Newmark delta

Definition at line 165 of file newmark_system.h.

Referenced by clear(), and NewmarkSystem().  

const Real NewmarkSystem::_default_timestep = 1. [static, private]Default Newmark time step

Definition at line 170 of file newmark_system.h.

Referenced by clear(), and NewmarkSystem().  

Real LinearImplicitSystem::_final_linear_residual [protected, inherited]The final residual for the linear system Ax=b.

Definition at line 180 of file linear_implicit_system.h.

Referenced by LinearImplicitSystem::adjoint_solve(), LinearImplicitSystem::final_linear_residual(), LinearImplicitSystem::solve(), and FrequencySystem::solve().  

bool NewmarkSystem::_finished_assemble [private]Returns true if the matrix assembly is finished.

Definition at line 155 of file newmark_system.h.

Referenced by assemble(), and clear().  

Threads::spin_mutex ReferenceCounter::_mutex [static, protected, inherited]Mutual exclusion object to enable thread-safe reference counting.

Definition at line 123 of file reference_counter.h.  

unsigned int LinearImplicitSystem::_n_linear_iterations [protected, inherited]The number of linear iterations required to solve the linear system Ax=b.

Definition at line 175 of file linear_implicit_system.h.

Referenced by LinearImplicitSystem::adjoint_solve(), LinearImplicitSystem::n_linear_iterations(), LinearImplicitSystem::solve(), and FrequencySystem::solve().  

Threads::atomic< unsigned int > ReferenceCounter::_n_objects [static, protected, inherited]The number of objects. Print the reference count information when the number returns to 0.

Definition at line 118 of file reference_counter.h.

Referenced by ReferenceCounter::n_objects(), ReferenceCounter::ReferenceCounter(), and ReferenceCounter::~ReferenceCounter().  

ShellMatrix<Number>* LinearImplicitSystem::_shell_matrix [protected, inherited]User supplies shell matrix or NULL if no shell matrix is used.

Definition at line 185 of file linear_implicit_system.h.

Referenced by LinearImplicitSystem::adjoint_solve(), LinearImplicitSystem::attach_shell_matrix(), LinearImplicitSystem::get_shell_matrix(), and LinearImplicitSystem::solve().  

bool System::assemble_before_solve [inherited]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 713 of file system.h.

Referenced by NonlinearImplicitSystem::adjoint_solve(), LinearImplicitSystem::adjoint_solve(), LinearImplicitSystem::solve(), and EigenSystem::solve().  

AutoPtr<NumericVector<Number> > System::current_local_solution [inherited]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 740 of file system.h.

Referenced by UniformRefinementEstimator::_estimate_error(), NonlinearImplicitSystem::adjoint_solve(), System::clear(), Problem_Interface::computeF(), System::current_solution(), ExactErrorEstimator::estimate_error(), System::init_data(), System::project_solution(), System::re_update(), System::reinit(), System::restrict_vectors(), and System::update().  

AutoPtr<LinearSolver<Number> > LinearImplicitSystem::linear_solver [inherited]The LinearSolver defines the interface used to solve the linear_implicit system. This class handles all the details of interfacing with various linear algebra packages like PETSc or LASPACK.

Definition at line 134 of file linear_implicit_system.h.

Referenced by LinearImplicitSystem::adjoint_solve(), LinearImplicitSystem::clear(), LinearImplicitSystem::reinit(), LinearImplicitSystem::solve(), and FrequencySystem::solve().  

SparseMatrix<Number>* ImplicitSystem::matrix [inherited]The system matrix. Implicit systems are characterized by the need to solve the linear system Ax=b. This is the system matrix A.

Definition at line 156 of file implicit_system.h.

Referenced by __libmesh_petsc_diff_solver_jacobian(), ImplicitSystem::add_system_matrix(), PetscDiffSolver::adjoint_solve(), NonlinearImplicitSystem::adjoint_solve(), NewtonSolver::adjoint_solve(), LinearImplicitSystem::adjoint_solve(), ImplicitSystem::assemble(), FEMSystem::assembly(), ImplicitSystem::clear(), compute_matrix(), ContinuationSystem::continuation_solve(), ImplicitSystem::init_matrices(), PetscDiffSolver::solve(), NonlinearImplicitSystem::solve(), NewtonSolver::solve(), LinearImplicitSystem::solve(), FrequencySystem::solve(), EigenTimeSolver::solve(), and ContinuationSystem::solve_tangent().  

Number System::qoi [inherited]Value of the quantity of interest

Definition at line 745 of file system.h.

Referenced by FEMSystem::assemble_qoi(), and ExplicitSystem::assemble_qoi().  

NumericVector<Number>* ExplicitSystem::rhs [inherited]The system matrix. Implicit systems are characterized by the need to solve the linear system Ax=b. This is the right-hand-side vector b.

Definition at line 132 of file explicit_system.h.

Referenced by __libmesh_petsc_diff_solver_residual(), ExplicitSystem::add_system_rhs(), PetscDiffSolver::adjoint_solve(), NonlinearImplicitSystem::adjoint_solve(), NewtonSolver::adjoint_solve(), LinearImplicitSystem::adjoint_solve(), ImplicitSystem::assemble(), ExplicitSystem::assemble_qoi(), FEMSystem::assemble_qoi_derivative(), ExplicitSystem::assemble_qoi_derivative(), FEMSystem::assembly(), ExplicitSystem::clear(), ContinuationSystem::continuation_solve(), NewtonSolver::line_search(), PetscDiffSolver::solve(), NonlinearImplicitSystem::solve(), NewtonSolver::solve(), LinearImplicitSystem::solve(), FrequencySystem::solve(), ContinuationSystem::solve_tangent(), and update_rhs().  

AutoPtr<NumericVector<Number> > System::solution [inherited]Data structure to hold solution values.

Definition at line 728 of file system.h.

Referenced by __libmesh_petsc_diff_solver_jacobian(), __libmesh_petsc_diff_solver_residual(), ExactSolution::_compute_error(), UniformRefinementEstimator::_estimate_error(), PetscDiffSolver::adjoint_solve(), UnsteadySolver::advance_timestep(), AdaptiveTimeSolver::advance_timestep(), ContinuationSystem::apply_predictor(), FEMSystem::assembly(), System::clear(), System::compare(), Problem_Interface::computeF(), ContinuationSystem::continuation_solve(), GMVIO::copy_nodal_solution(), UnsteadySolver::du(), DofMap::enforce_constraints_exactly(), PatchRecoveryErrorEstimator::estimate_error(), JumpErrorEstimator::estimate_error(), ExactErrorEstimator::estimate_error(), EigenSystem::get_eigenpair(), System::init_data(), ContinuationSystem::initialize_tangent(), DofMap::max_constraint_error(), FEMSystem::mesh_position_get(), ErrorVector::plot_error(), System::project_solution(), System::re_update(), System::read_legacy_data(), System::read_parallel_data(), System::read_serialized_data(), System::reinit(), System::restrict_vectors(), ContinuationSystem::save_current_solution(), VTKIO::solution_to_vtk(), TwostepTimeSolver::solve(), PetscDiffSolver::solve(), NonlinearImplicitSystem::solve(), NewtonSolver::solve(), LinearImplicitSystem::solve(), FrequencySystem::solve(), ContinuationSystem::solve_tangent(), System::update(), System::update_global_solution(), ContinuationSystem::update_solution(), update_u_v_a(), System::write_parallel_data(), and System::write_serialized_data().

 

Author

Generated automatically by Doxygen for libMesh from the source code.


 

Index

NAME
SYNOPSIS
Public Types
Public Member Functions
Static Public Member Functions
Public Attributes
Protected Types
Protected Member Functions
Protected Attributes
Static Protected Attributes
Private Attributes
Static Private Attributes
Detailed Description
Member Typedef Documentation
typedef std::map<std::string, SparseMatrix<Number>* >::const_iterator ImplicitSystem::const_matrices_iterator [inherited]
typedef std::map<std::string, NumericVector<Number>* >::const_iterator System::const_vectors_iterator [inherited]
typedef std::map<std::string, std::pair<unsigned int, unsigned int> > ReferenceCounter::Counts [protected, inherited]Data structure to log the information. The log is identified by the class name.
typedef std::map<std::string, SparseMatrix<Number>* >::iterator ImplicitSystem::matrices_iterator [inherited]Matrix iterator typedefs.
typedef ImplicitSystem LinearImplicitSystem::Parent [inherited]The type of the parent.
typedef NewmarkSystem NewmarkSystem::sys_typeThe type of system.
typedef std::map<std::string, NumericVector<Number>* >::iterator System::vectors_iterator [inherited]Vector iterator typedefs.
Constructor & Destructor Documentation
NewmarkSystem::NewmarkSystem (EquationSystems &es, const std::string &name, const unsigned intnumber)Constructor. Optionally initializes required data structures.
NewmarkSystem::~NewmarkSystem ()Destructor.
Member Function Documentation
void System::activate () [inline, inherited]Activates the system. Only active systems are solved.
bool System::active () const [inline, inherited]Returns:
SparseMatrix< Number > & ImplicitSystem::add_matrix (const std::string &mat_name) [inherited]Adds the additional matrix mat_name to this system. Only allowed prior to assemble(). All additional matrices have the same sparsity pattern as the matrix used during solution. When not System but the user wants to initialize the mayor matrix, then all the additional matrices, if existent, have to be initialized by the user, too.
unsigned int System::add_variable (const std::string &var, const FEType &type, const std::set< subdomain_id_type > *constactive_subdomains = NULL) [inherited]Adds the variable var to the list of variables for this system. Returns the index number for the new variable.
unsigned int System::add_variable (const std::string &var, const Orderorder = FIRST, const FEFamilyfamily = LAGRANGE, const std::set< subdomain_id_type > *constactive_subdomains = NULL) [inherited]Adds the variable var to the list of variables for this system. Same as before, but assumes LAGRANGE as default value for FEType.family.
NumericVector< Number > & System::add_vector (const std::string &vec_name, const boolprojections = true) [inherited]Adds the additional vector vec_name to this system. Only allowed prior to init(). All the additional vectors are similarly distributed, like the solution, and inititialized to zero.
void LinearImplicitSystem::adjoint_solve () [virtual, inherited]Assembles & solves the linear adjoint system A^T*x=q.
void NewmarkSystem::assemble () [virtual]Assemble the linear system. Does not actually call the solver.
void ExplicitSystem::assemble_qoi () [virtual, inherited]Prepares qoi for quantity of interest assembly, then calls user qoi function. Can be overloaded in derived classes.
void ExplicitSystem::assemble_qoi_derivative () [virtual, inherited]Prepares rhs for quantity of interest derivative assembly, then calls user qoi derivative function. Can be overloaded in derived classes.
void System::attach_assemble_function (void fptrEquationSystems &es,const std::string &name) [inherited]Register a user function to use in assembling the system matrix and RHS.
void System::attach_constraint_function (void fptrEquationSystems &es,const std::string &name) [inherited]Register a user function for imposing constraints.
void System::attach_init_function (void fptrEquationSystems &es,const std::string &name) [inherited]Register a user function to use in initializing the system.
void System::attach_QOI_derivative (void fptrEquationSystems &es,const std::string &name) [inherited]Register a user function for evaluating derivatives of a quantity of interest with respect to test functions, whose values should be placed in System::rhs
void System::attach_QOI_function (void fptrEquationSystems &es,const std::string &name) [inherited]Register a user function for evaluating a quantity of interest, whose value should be placed in System::qoi
void LinearImplicitSystem::attach_shell_matrix (ShellMatrix< Number > *shell_matrix) [inherited]This function enables the user to provide a shell matrix, i.e. a matrix that is not stored element-wise, but as a function. When you register your shell matrix using this function, calling solve() will no longer use the matrix member but the registered shell matrix instead. You can reset this behaviour to its original state by supplying a NULL pointer to this function.
Real System::calculate_norm (NumericVector< Number > &v, unsigned intvar = 0, FEMNormTypenorm_type = L2) const [inherited]Returns:
Real System::calculate_norm (NumericVector< Number > &v, const SystemNorm &norm) const [inherited]Returns:
void NewmarkSystem::clear () [virtual]Clear all the data structures associated with the system.
bool System::compare (const System &other_system, const Realthreshold, const boolverbose) const [virtual, inherited]Returns:
void NewmarkSystem::compute_matrix ()Compute the global matrix by adding up scaled mass damping and stiffness matrix.
Number System::current_solution (const unsigned intglobal_dof_number) const [inherited]Returns:
void System::deactivate () [inline, inherited]Deactivates the system. Only active systems are solved.
void LinearImplicitSystem::detach_shell_matrix (void) [inline, inherited]Detaches a shell matrix. Same as attach_shell_matrix(NULL).
Real LinearImplicitSystem::final_linear_residual () const [inline, inherited]Returns the final residual for the linear system solve.
NumericVector< Number > & System::get_adjoint_solution () [inherited]Returns:
const NumericVector< Number > & System::get_adjoint_solution () const [inherited]Returns:
DofMap & System::get_dof_map () [inline, inherited]Returns:
const DofMap & System::get_dof_map () const [inline, inherited]Returns:
const EquationSystems& System::get_equation_systems () const [inline, inherited]Returns:
EquationSystems& System::get_equation_systems () [inline, inherited]Returns:
std::string System::get_info () const [inherited]Returns:
std::string ReferenceCounter::get_info () [static, inherited]Gets a string containing the reference information.
SparseMatrix< Number > & ImplicitSystem::get_matrix (const std::string &mat_name) [inherited]Returns:
const SparseMatrix< Number > & ImplicitSystem::get_matrix (const std::string &mat_name) const [inherited]Returns:
const MeshBase & System::get_mesh () const [inline, inherited]Returns:
MeshBase & System::get_mesh () [inline, inherited]Returns:
ShellMatrix<Number>* LinearImplicitSystem::get_shell_matrix (void) [inline, inherited]Returns a pointer to the currently attached shell matrix, if any, or NULL else.
const NumericVector< Number > & System::get_vector (const std::string &vec_name) const [inherited]Returns:
NumericVector< Number > & System::get_vector (const std::string &vec_name) [inherited]Returns:
const NumericVector< Number > & System::get_vector (const unsigned intvec_num) const [inherited]Returns:
NumericVector< Number > & System::get_vector (const unsigned intvec_num) [inherited]Returns:
bool System::has_variable (const std::string &var) const [inherited]Returns:
bool ImplicitSystem::have_matrix (const std::string &mat_name) const [inline, inherited]Returns:
bool System::have_vector (const std::string &vec_name) const [inline, inherited]Returns:
void 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.
void 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.
void System::init () [inherited]Initializes degrees of freedom on the current mesh. Sets the
void ImplicitSystem::init_data () [protected, virtual, inherited]Initializes the member data fields associated with the system, so that, e.g., assemble() may be used.
void ImplicitSystem::init_matrices () [protected, virtual, inherited]Initializes the matrices associated with this system.
void NewmarkSystem::initial_conditions ()Apply initial conditions.
void System::local_dof_indices (const unsigned intvar, std::set< unsigned int > &var_indices) const [inherited]Fills the std::set with the degrees of freedom on the local processor corresponding the the variable number passed in.
unsigned int System::n_active_dofs () const [inline, inherited]Returns the number of active degrees of freedom for this System.
unsigned int System::n_constrained_dofs () const [inherited]Returns:
unsigned int System::n_dofs () const [inherited]Returns:
unsigned int LinearImplicitSystem::n_linear_iterations () const [inline, inherited]Returns the number of iterations taken for the most recent linear solve.
unsigned int System::n_local_dofs () const [inherited]Returns:
unsigned int ImplicitSystem::n_matrices () const [inline, inherited]Returns:
static unsigned int ReferenceCounter::n_objects () [inline, static, inherited]Prints the number of outstanding (created, but not yet destroyed) objects.
unsigned int System::n_vars () const [inline, inherited]Returns:
unsigned int System::n_vectors () const [inline, inherited]Returns:
const std::string & System::name () const [inline, inherited]Returns:
unsigned int System::number () const [inline, inherited]Returns:
void ReferenceCounter::print_info () [static, inherited]Prints the reference information to std::cout.
void 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, Parameters &parameters) const [inherited]Projects the continuous functions onto the current solution.
bool& System::project_solution_on_reinit (void) [inline, inherited]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.
void System::project_vector (NumericVector< Number > &vector) const [protected, inherited]Projects the vector defined on the old mesh onto the new mesh.
void System::project_vector (const NumericVector< Number > &old_v, NumericVector< Number > &new_v) const [protected, inherited]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.
void 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, Parameters &parameters, NumericVector< Number > &new_vector) const [inherited]Projects the continuous functions onto the current mesh.
void System::prolong_vectors () [virtual, inherited]Prolong vectors after the mesh has refined
void LinearImplicitSystem::qoi_parameter_sensitivity (std::vector< Number * > &parameters, std::vector< Number > &sensitivities) [virtual, inherited]Solves for the derivative of the system's quantity of interest q with respect to each parameter p in parameters. Currently uses adjoint_solve, along with finite differenced derivatives (partial q / partial p) and (partial (b-Ax) / partial p).
void System::re_update () [virtual, inherited]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.
void System::read_header (Xdr &io, const std::string &version, const boolread_header = true, const boolread_additional_data = true, const boolread_legacy_format = false) [inherited]Reads the basic data header for this System.
void System::read_legacy_data (Xdr &io, const boolread_additional_data = true) [inherited]Reads additional data, namely vectors, for this System.
void System::read_parallel_data (Xdr &io, const boolread_additional_data) [inherited]Reads additional data, namely vectors, for this System. This method may safely be called on a distributed-memory mesh. This method will read an individual file for each processor in the simulation where the local solution components for that processor are stored.
void System::read_serialized_data (Xdr &io, const boolread_additional_data = true) [inherited]Reads additional data, namely vectors, for this System. This method may safely be called on a distributed-memory mesh.
void NewmarkSystem::reinit () [virtual]Reinitializes the member data fields associated with the system, so that, e.g., assemble() may be used.
void System::restrict_vectors () [virtual, inherited]Restrict vectors after the mesh has coarsened
void NewmarkSystem::set_newmark_parameters (const Realdelta_T = _default_timestep, const Realalpha = _default_alpha, const Realdelta = _default_delta)Set the time step size and the newmark parameter alpha and delta and calculate the constant parameters used for time integration.
void LinearImplicitSystem::solve () [virtual, inherited]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. Assembles & solves the linear system A*x=b.
sys_type& LinearImplicitSystem::system () [inline, inherited]Returns:
virtual std::string NewmarkSystem::system_type () const [inline, virtual]Returns:
void System::update () [virtual, inherited]Update the local values to reflect the solution on neighboring processors.
void System::update_global_solution (std::vector< Number > &global_soln) const [inherited]Fill the input vector global_soln so that it contains the global solution on all processors. Requires communication with all other processors.
void System::update_global_solution (std::vector< Number > &global_soln, const unsigned intdest_proc) const [inherited]Fill the input vector global_soln so that it contains the global solution on processor dest_proc. Requires communication with all other processors.
void NewmarkSystem::update_rhs ()Update the rhs.
void NewmarkSystem::update_u_v_a ()Update displacement, velocity and acceleration.
void System::user_assembly () [virtual, inherited]Calls user's attached assembly function, or is overloaded by the user in derived classes.
void System::user_constrain () [virtual, inherited]Calls user's attached constraint function, or is overloaded by the user in derived classes.
void System::user_initialization () [virtual, inherited]Calls user's attached initialization function, or is overloaded by the user in derived classes.
void System::user_QOI () [virtual, inherited]Calls user's attached quantity of interest function, or is overloaded by the user in derived classes.
void System::user_QOI_derivative () [virtual, inherited]Calls user's attached quantity of interest derivative function, or is overloaded by the user in derived classes.
const System::Variable & System::variable (unsigned intvar) const [inline, inherited]Return a constant reference to Variable var.
const std::string & System::variable_name (const unsigned inti) const [inline, inherited]Returns:
unsigned short int System::variable_number (const std::string &var) const [inherited]Returns:
const FEType & System::variable_type (const unsigned inti) const [inline, inherited]Returns:
const FEType & System::variable_type (const std::string &var) const [inline, inherited]Returns:
const std::string & System::vector_name (const unsigned intvec_num) [inherited]Returns:
System::const_vectors_iterator System::vectors_begin () const [inline, inherited]Beginning of vectors container
System::vectors_iterator System::vectors_begin () [inline, inherited]Beginning of vectors container
System::vectors_iterator System::vectors_end () [inline, inherited]End of vectors container
System::const_vectors_iterator System::vectors_end () const [inline, inherited]End of vectors container
void System::write_header (Xdr &io, const std::string &version, const boolwrite_additional_data) const [inherited]Writes the basic data header for this System.
void System::write_parallel_data (Xdr &io, const boolwrite_additional_data) const [inherited]Writes additional data, namely vectors, for this System. This method may safely be called on a distributed-memory mesh. This method will create an individual file for each processor in the simulation where the local solution components for that processor will be stored.
void System::write_serialized_data (Xdr &io, const boolwrite_additional_data = true) const [inherited]Writes additional data, namely vectors, for this System. This method may safely be called on a distributed-memory mesh.
void System::zero_variable (NumericVector< Number > &v, unsigned intvar_num) const [inherited]Zeroes all dofs in v that correspond to variable number var_num.
Member Data Documentation
Real NewmarkSystem::_a_0 [private]Constants used for the time integration.
Real NewmarkSystem::_a_1 [private]
Real NewmarkSystem::_a_2 [private]
Real NewmarkSystem::_a_3 [private]
Real NewmarkSystem::_a_4 [private]
Real NewmarkSystem::_a_5 [private]
Real NewmarkSystem::_a_6 [private]
Real NewmarkSystem::_a_7 [private]
ReferenceCounter::Counts ReferenceCounter::_counts [static, protected, inherited]Actually holds the data.
const Real NewmarkSystem::_default_alpha = .25 [static, private]Default Newmark alpha
const Real NewmarkSystem::_default_delta = .5 [static, private]Default Newmark delta
const Real NewmarkSystem::_default_timestep = 1. [static, private]Default Newmark time step
Real LinearImplicitSystem::_final_linear_residual [protected, inherited]The final residual for the linear system Ax=b.
bool NewmarkSystem::_finished_assemble [private]Returns true if the matrix assembly is finished.
Threads::spin_mutex ReferenceCounter::_mutex [static, protected, inherited]Mutual exclusion object to enable thread-safe reference counting.
unsigned int LinearImplicitSystem::_n_linear_iterations [protected, inherited]The number of linear iterations required to solve the linear system Ax=b.
Threads::atomic< unsigned int > ReferenceCounter::_n_objects [static, protected, inherited]The number of objects. Print the reference count information when the number returns to 0.
ShellMatrix<Number>* LinearImplicitSystem::_shell_matrix [protected, inherited]User supplies shell matrix or NULL if no shell matrix is used.
bool System::assemble_before_solve [inherited]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.)
AutoPtr<NumericVector<Number> > System::current_local_solution [inherited]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.
AutoPtr<LinearSolver<Number> > LinearImplicitSystem::linear_solver [inherited]The LinearSolver defines the interface used to solve the linear_implicit system. This class handles all the details of interfacing with various linear algebra packages like PETSc or LASPACK.
SparseMatrix<Number>* ImplicitSystem::matrix [inherited]The system matrix. Implicit systems are characterized by the need to solve the linear system Ax=b. This is the system matrix A.
Number System::qoi [inherited]Value of the quantity of interest
NumericVector<Number>* ExplicitSystem::rhs [inherited]The system matrix. Implicit systems are characterized by the need to solve the linear system Ax=b. This is the right-hand-side vector b.
AutoPtr<NumericVector<Number> > System::solution [inherited]Data structure to hold solution values.
Author

This document was created by man2html, using the manual pages.
Time: 21:51:24 GMT, April 16, 2011