libMesh::DiffContext Class Reference

#include <diff_context.h>

Inheritance diagram for libMesh::DiffContext:

Public Types

typedef std::map< const NumericVector< Number > *, std::pair< DenseVector< Number >, std::vector< DenseSubVector< Number > * > > >::iterator localized_vectors_iterator
 

Public Member Functions

 DiffContext (const System &)
 
virtual ~DiffContext ()
 
virtual void elem_reinit (Real)
 
virtual void elem_side_reinit (Real)
 
virtual void elem_edge_reinit (Real)
 
virtual void nonlocal_reinit (Real)
 
unsigned int n_vars () const
 
const Systemget_system () const
 
const DenseVector< Number > & get_elem_solution () const
 
DenseVector< Number > & get_elem_solution ()
 
const DenseSubVector< Number > & get_elem_solution (unsigned int var) const
 
DenseSubVector< Number > & get_elem_solution (unsigned int var)
 
const DenseVector< Number > & get_elem_solution_rate () const
 
DenseVector< Number > & get_elem_solution_rate ()
 
const DenseSubVector< Number > & get_elem_solution_rate (unsigned int var) const
 
DenseSubVector< Number > & get_elem_solution_rate (unsigned int var)
 
const DenseVector< Number > & get_elem_solution_accel () const
 
DenseVector< Number > & get_elem_solution_accel ()
 
const DenseSubVector< Number > & get_elem_solution_accel (unsigned int var) const
 
DenseSubVector< Number > & get_elem_solution_accel (unsigned int var)
 
const DenseVector< Number > & get_elem_fixed_solution () const
 
DenseVector< Number > & get_elem_fixed_solution ()
 
const DenseSubVector< Number > & get_elem_fixed_solution (unsigned int var) const
 
DenseSubVector< Number > & get_elem_fixed_solution (unsigned int var)
 
const DenseVector< Number > & get_elem_residual () const
 
DenseVector< Number > & get_elem_residual ()
 
const DenseSubVector< Number > & get_elem_residual (unsigned int var) const
 
DenseSubVector< Number > & get_elem_residual (unsigned int var)
 
const DenseMatrix< Number > & get_elem_jacobian () const
 
DenseMatrix< Number > & get_elem_jacobian ()
 
const DenseSubMatrix< Number > & get_elem_jacobian (unsigned int var1, unsigned int var2) const
 
DenseSubMatrix< Number > & get_elem_jacobian (unsigned int var1, unsigned int var2)
 
const std::vector< Number > & get_qois () const
 
std::vector< Number > & get_qois ()
 
const std::vector< DenseVector< Number > > & get_qoi_derivatives () const
 
std::vector< DenseVector< Number > > & get_qoi_derivatives ()
 
const DenseSubVector< Number > & get_qoi_derivatives (unsigned int qoi, unsigned int var) const
 
DenseSubVector< Number > & get_qoi_derivatives (unsigned int qoi, unsigned int var)
 
const std::vector< dof_id_type > & get_dof_indices () const
 
std::vector< dof_id_type > & get_dof_indices ()
 
const std::vector< dof_id_type > & get_dof_indices (unsigned int var) const
 
std::vector< dof_id_type > & get_dof_indices (unsigned int var)
 
Real get_system_time () const
 
Real get_time () const
 
void set_time (Real time_in)
 
Real get_elem_solution_derivative () const
 
Real get_elem_solution_rate_derivative () const
 
Real get_elem_solution_accel_derivative () const
 
Real get_fixed_solution_derivative () const
 
bool is_adjoint () const
 
bool & is_adjoint ()
 
void set_deltat_pointer (Real *dt)
 
Real get_deltat_value ()
 
void add_localized_vector (NumericVector< Number > &localized_vector, const System &sys)
 
DenseVector< Number > & get_localized_vector (const NumericVector< Number > &localized_vector)
 
const DenseVector< Number > & get_localized_vector (const NumericVector< Number > &localized_vector) const
 
DenseSubVector< Number > & get_localized_subvector (const NumericVector< Number > &localized_vector, unsigned int var)
 
const DenseSubVector< Number > & get_localized_subvector (const NumericVector< Number > &localized_vector, unsigned int var) const
 

Public Attributes

Real time
 
const Real system_time
 
Real elem_solution_derivative
 
Real elem_solution_rate_derivative
 
Real elem_solution_accel_derivative
 
Real fixed_solution_derivative
 

Protected Attributes

std::map< const NumericVector< Number > *, std::pair< DenseVector< Number >, std::vector< DenseSubVector< Number > * > > > _localized_vectors
 
DenseVector< Number_elem_solution
 
std::vector< DenseSubVector< Number > * > _elem_subsolutions
 
DenseVector< Number_elem_solution_rate
 
std::vector< DenseSubVector< Number > * > _elem_subsolution_rates
 
DenseVector< Number_elem_solution_accel
 
std::vector< DenseSubVector< Number > * > _elem_subsolution_accels
 
DenseVector< Number_elem_fixed_solution
 
std::vector< DenseSubVector< Number > * > _elem_fixed_subsolutions
 
DenseVector< Number_elem_residual
 
DenseMatrix< Number_elem_jacobian
 
std::vector< Number_elem_qoi
 
std::vector< DenseVector< Number > > _elem_qoi_derivative
 
std::vector< std::vector< DenseSubVector< Number > * > > _elem_qoi_subderivatives
 
std::vector< DenseSubVector< Number > * > _elem_subresiduals
 
std::vector< std::vector< DenseSubMatrix< Number > * > > _elem_subjacobians
 
std::vector< dof_id_type_dof_indices
 
std::vector< std::vector< dof_id_type > > _dof_indices_var
 

Private Attributes

Real_deltat
 
const System_system
 
bool _is_adjoint
 

Detailed Description

This class provides all data required for a physics package (e.g. a DifferentiableSystem subclass) to perform local element residual and jacobian integrations.

This class is part of the new DifferentiableSystem framework, which is still experimental. Users of this framework should beware of bugs and future API changes.

Author
Roy H. Stogner
Date
2009

Definition at line 54 of file diff_context.h.

Member Typedef Documentation

typedef std::map<const NumericVector<Number> *, std::pair<DenseVector<Number>, std::vector<DenseSubVector<Number> *> > >::iterator libMesh::DiffContext::localized_vectors_iterator

Typedef for the localized_vectors iterator

Definition at line 527 of file diff_context.h.

Constructor & Destructor Documentation

libMesh::DiffContext::DiffContext ( const System sys)
explicit

Constructor. Optionally initializes required data structures.

Definition at line 29 of file diff_context.C.

References _elem_fixed_solution, _elem_fixed_subsolutions, _elem_jacobian, _elem_qoi, _elem_qoi_derivative, _elem_qoi_subderivatives, _elem_residual, _elem_solution, _elem_solution_accel, _elem_solution_rate, _elem_subjacobians, _elem_subresiduals, _elem_subsolution_accels, _elem_subsolution_rates, _elem_subsolutions, libMesh::DifferentiablePhysics::get_second_order_vars(), libMesh::DifferentiableSystem::get_time_solver(), libMesh::TimeSolver::is_steady(), libMesh::System::n_vars(), libMesh::System::qoi, libMesh::sys, libMesh::UnsteadySolver::time_order(), and libMesh::System::use_fixed_solution.

29  :
30  time(sys.time),
38  _system(sys),
39  _is_adjoint(false)
40 {
41  // Finally initialize solution/residual/jacobian data structures
42  unsigned int nv = sys.n_vars();
43 
44  _elem_subsolutions.reserve(nv);
45  _elem_subresiduals.reserve(nv);
46  _elem_subjacobians.resize(nv);
47  _elem_subsolution_rates.reserve(nv);
48  _elem_subsolution_accels.reserve(nv);
50  _elem_fixed_subsolutions.reserve(nv);
51 
52  // If the user resizes sys.qoi, it will invalidate us
53 
54  std::size_t n_qoi = sys.qoi.size();
55  _elem_qoi.resize(n_qoi);
56  _elem_qoi_derivative.resize(n_qoi);
57  _elem_qoi_subderivatives.resize(n_qoi);
58  for (std::size_t q=0; q != n_qoi; ++q)
59  _elem_qoi_subderivatives[q].reserve(nv);
60 
61  for (unsigned int i=0; i != nv; ++i)
62  {
63  _elem_subsolutions.push_back(new DenseSubVector<Number>(_elem_solution));
64  _elem_subresiduals.push_back(new DenseSubVector<Number>(_elem_residual));
65  for (std::size_t q=0; q != n_qoi; ++q)
66  _elem_qoi_subderivatives[q].push_back(new DenseSubVector<Number>(_elem_qoi_derivative[q]));
67  _elem_subjacobians[i].reserve(nv);
68 
69  // Only make space for these if we're using DiffSystem
70  // This is assuming *only* DiffSystem is using elem_solution_rate/accel
71  const DifferentiableSystem * diff_system = dynamic_cast<const DifferentiableSystem *>(&sys);
72  if (diff_system)
73  {
74  // Now, we only need these if the solver is unsteady
75  if (!diff_system->get_time_solver().is_steady())
76  {
77  _elem_subsolution_rates.push_back(new DenseSubVector<Number>(_elem_solution_rate));
78 
79  // We only need accel space if the TimeSolver is second order
80  const UnsteadySolver & time_solver = cast_ref<const UnsteadySolver &>(diff_system->get_time_solver());
81 
82  if (time_solver.time_order() >= 2 || !diff_system->get_second_order_vars().empty())
83  _elem_subsolution_accels.push_back(new DenseSubVector<Number>(_elem_solution_accel));
84  }
85  }
86 
88  _elem_fixed_subsolutions.push_back
89  (new DenseSubVector<Number>(_elem_fixed_solution));
90 
91  for (unsigned int j=0; j != nv; ++j)
92  {
93  _elem_subjacobians[i].push_back
94  (new DenseSubMatrix<Number>(_elem_jacobian));
95  }
96  }
97 }
std::vector< std::vector< dof_id_type > > _dof_indices_var
Definition: diff_context.h:621
std::vector< DenseSubVector< Number > * > _elem_subsolution_rates
Definition: diff_context.h:572
DenseVector< Number > _elem_solution
Definition: diff_context.h:564
std::vector< Number > _elem_qoi
Definition: diff_context.h:603
std::vector< std::vector< DenseSubMatrix< Number > * > > _elem_subjacobians
Definition: diff_context.h:615
DenseVector< Number > _elem_fixed_solution
Definition: diff_context.h:586
ImplicitSystem & sys
std::vector< DenseSubVector< Number > * > _elem_subsolution_accels
Definition: diff_context.h:579
std::vector< std::vector< DenseSubVector< Number > * > > _elem_qoi_subderivatives
Definition: diff_context.h:609
std::vector< DenseVector< Number > > _elem_qoi_derivative
Definition: diff_context.h:608
DenseMatrix< Number > _elem_jacobian
Definition: diff_context.h:598
const class libmesh_nullptr_t libmesh_nullptr
std::vector< DenseSubVector< Number > * > _elem_subresiduals
Definition: diff_context.h:614
Real elem_solution_rate_derivative
Definition: diff_context.h:490
std::vector< DenseSubVector< Number > * > _elem_fixed_subsolutions
Definition: diff_context.h:587
std::vector< Number > qoi
Definition: system.h:1551
bool use_fixed_solution
Definition: system.h:1491
const System & _system
Definition: diff_context.h:641
const Real system_time
Definition: diff_context.h:477
DenseVector< Number > _elem_residual
Definition: diff_context.h:592
unsigned int n_vars() const
Definition: system.h:2084
std::vector< DenseSubVector< Number > * > _elem_subsolutions
Definition: diff_context.h:565
DenseVector< Number > _elem_solution_accel
Definition: diff_context.h:578
Real elem_solution_accel_derivative
Definition: diff_context.h:497
DenseVector< Number > _elem_solution_rate
Definition: diff_context.h:571
libMesh::DiffContext::~DiffContext ( )
virtual

Destructor.

Definition at line 101 of file diff_context.C.

References _elem_fixed_subsolutions, _elem_qoi_subderivatives, _elem_subjacobians, _elem_subresiduals, _elem_subsolution_accels, _elem_subsolution_rates, _elem_subsolutions, and _localized_vectors.

102 {
103  for (std::size_t i=0; i != _elem_subsolutions.size(); ++i)
104  {
105  delete _elem_subsolutions[i];
106  delete _elem_subresiduals[i];
107  for (std::size_t q=0; q != _elem_qoi_subderivatives.size(); ++q)
108  delete _elem_qoi_subderivatives[q][i];
109  if (!_elem_subsolution_rates.empty())
110  delete _elem_subsolution_rates[i];
111  if (!_elem_subsolution_accels.empty())
112  delete _elem_subsolution_accels[i];
113  if (!_elem_fixed_subsolutions.empty())
114  delete _elem_fixed_subsolutions[i];
115 
116  for (std::size_t j=0; j != _elem_subjacobians[i].size(); ++j)
117  delete _elem_subjacobians[i][j];
118  }
119 
120  // We also need to delete all the DenseSubVectors from the localized_vectors map
121  // localized_vectors iterators
122  std::map<const NumericVector<Number> *, std::pair<DenseVector<Number>, std::vector<DenseSubVector<Number> *> > >::iterator localized_vectors_it = _localized_vectors.begin();
123  std::map<const NumericVector<Number> *, std::pair<DenseVector<Number>, std::vector<DenseSubVector<Number> *> > >::iterator localized_vectors_end = _localized_vectors.end();
124 
125  // Loop over every localized_vector
126  for (; localized_vectors_it != localized_vectors_end; ++localized_vectors_it)
127  {
128  // Grab the DenseSubVector to be deleted
129  std::vector<DenseSubVector<Number> * > & localized_vector_dsv = localized_vectors_it->second.second;
130 
131  // Loop over that vector and delete each entry
132  for (std::size_t i=0; i != localized_vector_dsv.size(); ++i)
133  delete localized_vector_dsv[i];
134  }
135 }
std::vector< DenseSubVector< Number > * > _elem_subsolution_rates
Definition: diff_context.h:572
std::map< const NumericVector< Number > *, std::pair< DenseVector< Number >, std::vector< DenseSubVector< Number > * > > > _localized_vectors
Definition: diff_context.h:558
std::vector< std::vector< DenseSubMatrix< Number > * > > _elem_subjacobians
Definition: diff_context.h:615
std::vector< DenseSubVector< Number > * > _elem_subsolution_accels
Definition: diff_context.h:579
std::vector< std::vector< DenseSubVector< Number > * > > _elem_qoi_subderivatives
Definition: diff_context.h:609
std::vector< DenseSubVector< Number > * > _elem_subresiduals
Definition: diff_context.h:614
std::vector< DenseSubVector< Number > * > _elem_fixed_subsolutions
Definition: diff_context.h:587
std::vector< DenseSubVector< Number > * > _elem_subsolutions
Definition: diff_context.h:565

Member Function Documentation

void libMesh::DiffContext::add_localized_vector ( NumericVector< Number > &  localized_vector,
const System sys 
)

Adds a vector to the map of localized vectors. We can later evaluate interior_values, interior_gradients and side_values for these fields these vectors represent.

Definition at line 154 of file diff_context.C.

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

155 {
156  // Make an empty pair keyed with a reference to this _localized_vector
157  _localized_vectors[&localized_vector] = std::make_pair(DenseVector<Number>(), std::vector<DenseSubVector<Number> *>());
158 
159  unsigned int nv = sys.n_vars();
160 
161  _localized_vectors[&localized_vector].second.reserve(nv);
162 
163  // Fill the DenseSubVector with nv copies of DenseVector
164  for (unsigned int i=0; i != nv; ++i)
165  _localized_vectors[&localized_vector].second.push_back(new DenseSubVector<Number>(_localized_vectors[&localized_vector].first));
166 }
std::map< const NumericVector< Number > *, std::pair< DenseVector< Number >, std::vector< DenseSubVector< Number > * > > > _localized_vectors
Definition: diff_context.h:558
ImplicitSystem & sys
unsigned int n_vars() const
Definition: system.h:2084
virtual void libMesh::DiffContext::elem_edge_reinit ( Real  )
inlinevirtual

Gives derived classes the opportunity to reinitialize data needed for an edge integration at a new point within a timestep

Reimplemented in libMesh::FEMContext.

Definition at line 87 of file diff_context.h.

87 {}
virtual void libMesh::DiffContext::elem_reinit ( Real  )
inlinevirtual

Gives derived classes the opportunity to reinitialize data (FE objects in FEMSystem, for example) needed for an interior integration at a new point within a timestep

Reimplemented in libMesh::FEMContext.

Definition at line 75 of file diff_context.h.

Referenced by libMesh::EulerSolver::element_residual(), libMesh::Euler2Solver::element_residual(), and libMesh::NewmarkSolver::element_residual().

75 {}
virtual void libMesh::DiffContext::elem_side_reinit ( Real  )
inlinevirtual

Gives derived classes the opportunity to reinitialize data needed for a side integration at a new point within a timestep

Reimplemented in libMesh::FEMContext.

Definition at line 81 of file diff_context.h.

Referenced by libMesh::EulerSolver::side_residual(), libMesh::Euler2Solver::side_residual(), and libMesh::NewmarkSolver::side_residual().

81 {}
Real libMesh::DiffContext::get_deltat_value ( )
Returns
The value currently pointed to by this class's _deltat member

Definition at line 146 of file diff_context.C.

References _deltat, and libMesh::libmesh_assert().

Referenced by libMesh::FEMContext::_update_time_from_system().

147 {
149 
150  return *_deltat;
151 }
libmesh_assert(j)
const std::vector<dof_id_type>& libMesh::DiffContext::get_dof_indices ( ) const
inline
std::vector<dof_id_type>& libMesh::DiffContext::get_dof_indices ( )
inline

Non-const accessor for element dof indices

Definition at line 372 of file diff_context.h.

References _dof_indices.

373  { return _dof_indices; }
std::vector< dof_id_type > _dof_indices
Definition: diff_context.h:620
const std::vector<dof_id_type>& libMesh::DiffContext::get_dof_indices ( unsigned int  var) const
inline

Accessor for element dof indices of a particular variable corresponding to the index argument.

Definition at line 379 of file diff_context.h.

References _dof_indices_var.

380  {
381  libmesh_assert_greater(_dof_indices_var.size(), var);
382  return _dof_indices_var[var];
383  }
std::vector< std::vector< dof_id_type > > _dof_indices_var
Definition: diff_context.h:621
std::vector<dof_id_type>& libMesh::DiffContext::get_dof_indices ( unsigned int  var)
inline

Accessor for element dof indices of a particular variable corresponding to the index argument.

Definition at line 389 of file diff_context.h.

References _dof_indices_var.

390  {
391  libmesh_assert_greater(_dof_indices_var.size(), var);
392  return _dof_indices_var[var];
393  }
std::vector< std::vector< dof_id_type > > _dof_indices_var
Definition: diff_context.h:621
DenseVector<Number>& libMesh::DiffContext::get_elem_fixed_solution ( )
inline

Non-const accessor for element fixed solution.

Definition at line 220 of file diff_context.h.

References _elem_fixed_solution.

221  { return _elem_fixed_solution; }
DenseVector< Number > _elem_fixed_solution
Definition: diff_context.h:586
const DenseSubVector<Number>& libMesh::DiffContext::get_elem_fixed_solution ( unsigned int  var) const
inline

Accessor for element fixed solution of a particular variable corresponding to the variable index argument.

Definition at line 227 of file diff_context.h.

References _elem_fixed_subsolutions, and libMesh::libmesh_assert().

228  {
229  libmesh_assert_greater(_elem_fixed_subsolutions.size(), var);
231  return *(_elem_fixed_subsolutions[var]);
232  }
libmesh_assert(j)
std::vector< DenseSubVector< Number > * > _elem_fixed_subsolutions
Definition: diff_context.h:587
DenseSubVector<Number>& libMesh::DiffContext::get_elem_fixed_solution ( unsigned int  var)
inline

Accessor for element fixed solution of a particular variable corresponding to the variable index argument.

Definition at line 238 of file diff_context.h.

References _elem_fixed_subsolutions, and libMesh::libmesh_assert().

239  {
240  libmesh_assert_greater(_elem_fixed_subsolutions.size(), var);
242  return *(_elem_fixed_subsolutions[var]);
243  }
libmesh_assert(j)
std::vector< DenseSubVector< Number > * > _elem_fixed_subsolutions
Definition: diff_context.h:587
DenseMatrix<Number>& libMesh::DiffContext::get_elem_jacobian ( )
inline

Non-const accessor for element Jacobian.

Definition at line 288 of file diff_context.h.

References _elem_jacobian.

289  { return _elem_jacobian; }
DenseMatrix< Number > _elem_jacobian
Definition: diff_context.h:598
const DenseSubMatrix<Number>& libMesh::DiffContext::get_elem_jacobian ( unsigned int  var1,
unsigned int  var2 
) const
inline

Const accessor for element Jacobian of particular variables corresponding to the variable index arguments.

Definition at line 295 of file diff_context.h.

References _elem_subjacobians, and libMesh::libmesh_assert().

296  {
297  libmesh_assert_greater(_elem_subjacobians.size(), var1);
298  libmesh_assert_greater(_elem_subjacobians[var1].size(), var2);
299  libmesh_assert(_elem_subjacobians[var1][var2]);
300  return *(_elem_subjacobians[var1][var2]);
301  }
std::vector< std::vector< DenseSubMatrix< Number > * > > _elem_subjacobians
Definition: diff_context.h:615
libmesh_assert(j)
DenseSubMatrix<Number>& libMesh::DiffContext::get_elem_jacobian ( unsigned int  var1,
unsigned int  var2 
)
inline

Non-const accessor for element Jacobian of particular variables corresponding to the variable index arguments.

Definition at line 307 of file diff_context.h.

References _elem_subjacobians, and libMesh::libmesh_assert().

308  {
309  libmesh_assert_greater(_elem_subjacobians.size(), var1);
310  libmesh_assert_greater(_elem_subjacobians[var1].size(), var2);
311  libmesh_assert(_elem_subjacobians[var1][var2]);
312  return *(_elem_subjacobians[var1][var2]);
313  }
std::vector< std::vector< DenseSubMatrix< Number > * > > _elem_subjacobians
Definition: diff_context.h:615
libmesh_assert(j)
const DenseVector<Number>& libMesh::DiffContext::get_elem_residual ( ) const
inline
DenseVector<Number>& libMesh::DiffContext::get_elem_residual ( )
inline

Non-const accessor for element residual.

Definition at line 254 of file diff_context.h.

References _elem_residual.

255  { return _elem_residual; }
DenseVector< Number > _elem_residual
Definition: diff_context.h:592
const DenseSubVector<Number>& libMesh::DiffContext::get_elem_residual ( unsigned int  var) const
inline

Const accessor for element residual of a particular variable corresponding to the variable index argument.

Definition at line 261 of file diff_context.h.

References _elem_subresiduals, and libMesh::libmesh_assert().

262  {
263  libmesh_assert_greater(_elem_subresiduals.size(), var);
265  return *(_elem_subresiduals[var]);
266  }
std::vector< DenseSubVector< Number > * > _elem_subresiduals
Definition: diff_context.h:614
libmesh_assert(j)
DenseSubVector<Number>& libMesh::DiffContext::get_elem_residual ( unsigned int  var)
inline

Non-const accessor for element residual of a particular variable corresponding to the variable index argument.

Definition at line 272 of file diff_context.h.

References _elem_subresiduals, and libMesh::libmesh_assert().

273  {
274  libmesh_assert_greater(_elem_subresiduals.size(), var);
276  return *(_elem_subresiduals[var]);
277  }
std::vector< DenseSubVector< Number > * > _elem_subresiduals
Definition: diff_context.h:614
libmesh_assert(j)
DenseVector<Number>& libMesh::DiffContext::get_elem_solution ( )
inline

Non-const accessor for element solution.

Definition at line 116 of file diff_context.h.

References _elem_solution.

117  { return _elem_solution; }
DenseVector< Number > _elem_solution
Definition: diff_context.h:564
const DenseSubVector<Number>& libMesh::DiffContext::get_elem_solution ( unsigned int  var) const
inline

Accessor for element solution of a particular variable corresponding to the variable index argument.

Definition at line 123 of file diff_context.h.

References _elem_subsolutions, and libMesh::libmesh_assert().

124  {
125  libmesh_assert_greater(_elem_subsolutions.size(), var);
127  return *(_elem_subsolutions[var]);
128  }
libmesh_assert(j)
std::vector< DenseSubVector< Number > * > _elem_subsolutions
Definition: diff_context.h:565
DenseSubVector<Number>& libMesh::DiffContext::get_elem_solution ( unsigned int  var)
inline

Accessor for element solution of a particular variable corresponding to the variable index argument.

Definition at line 134 of file diff_context.h.

References _elem_subsolutions, and libMesh::libmesh_assert().

135  {
136  libmesh_assert_greater(_elem_subsolutions.size(), var);
138  return *(_elem_subsolutions[var]);
139  }
libmesh_assert(j)
std::vector< DenseSubVector< Number > * > _elem_subsolutions
Definition: diff_context.h:565
const DenseVector<Number>& libMesh::DiffContext::get_elem_solution_accel ( ) const
inline
DenseVector<Number>& libMesh::DiffContext::get_elem_solution_accel ( )
inline

Non-const accessor for element solution accel of change w.r.t. time.

Definition at line 186 of file diff_context.h.

References _elem_solution_accel.

187  { return _elem_solution_accel; }
DenseVector< Number > _elem_solution_accel
Definition: diff_context.h:578
const DenseSubVector<Number>& libMesh::DiffContext::get_elem_solution_accel ( unsigned int  var) const
inline

Accessor for element solution accel for a particular variable corresponding to the variable index argument.

Definition at line 193 of file diff_context.h.

References _elem_subsolution_accels, and libMesh::libmesh_assert().

194  {
195  libmesh_assert_greater(_elem_subsolution_accels.size(), var);
197  return *(_elem_subsolution_accels[var]);
198  }
std::vector< DenseSubVector< Number > * > _elem_subsolution_accels
Definition: diff_context.h:579
libmesh_assert(j)
DenseSubVector<Number>& libMesh::DiffContext::get_elem_solution_accel ( unsigned int  var)
inline

Accessor for element solution accel for a particular variable corresponding to the variable index argument.

Definition at line 204 of file diff_context.h.

References _elem_subsolution_accels, and libMesh::libmesh_assert().

205  {
206  libmesh_assert_greater(_elem_subsolution_accels.size(), var);
208  return *(_elem_subsolution_accels[var]);
209  }
std::vector< DenseSubVector< Number > * > _elem_subsolution_accels
Definition: diff_context.h:579
libmesh_assert(j)
Real libMesh::DiffContext::get_elem_solution_accel_derivative ( ) const
inline

The derivative of the current elem_solution_accel w.r.t. the unknown solution. Corresponding Jacobian contributions should be multiplied by this amount, or may be skipped if get_elem_solution_accel_derivative() is 0.

Definition at line 437 of file diff_context.h.

References elem_solution_accel_derivative.

Real elem_solution_accel_derivative
Definition: diff_context.h:497
Real libMesh::DiffContext::get_elem_solution_derivative ( ) const
inline

The derivative of the current elem_solution w.r.t. the unknown solution. Corresponding Jacobian contributions should be multiplied by this amount, or may be skipped if get_elem_solution_derivative() is 0.

Definition at line 419 of file diff_context.h.

References elem_solution_derivative.

Referenced by libMesh::FirstOrderUnsteadySolver::compute_second_order_eqns().

420  { return elem_solution_derivative; }
const DenseVector<Number>& libMesh::DiffContext::get_elem_solution_rate ( ) const
inline
DenseVector<Number>& libMesh::DiffContext::get_elem_solution_rate ( )
inline

Non-const accessor for element solution rate of change w.r.t. time.

Definition at line 151 of file diff_context.h.

References _elem_solution_rate.

152  { return _elem_solution_rate; }
DenseVector< Number > _elem_solution_rate
Definition: diff_context.h:571
const DenseSubVector<Number>& libMesh::DiffContext::get_elem_solution_rate ( unsigned int  var) const
inline

Accessor for element solution rate for a particular variable corresponding to the variable index argument.

Definition at line 158 of file diff_context.h.

References _elem_subsolution_rates, and libMesh::libmesh_assert().

159  {
160  libmesh_assert_greater(_elem_subsolution_rates.size(), var);
162  return *(_elem_subsolution_rates[var]);
163  }
std::vector< DenseSubVector< Number > * > _elem_subsolution_rates
Definition: diff_context.h:572
libmesh_assert(j)
DenseSubVector<Number>& libMesh::DiffContext::get_elem_solution_rate ( unsigned int  var)
inline

Accessor for element solution rate for a particular variable corresponding to the variable index argument.

Definition at line 169 of file diff_context.h.

References _elem_subsolution_rates, and libMesh::libmesh_assert().

170  {
171  libmesh_assert_greater(_elem_subsolution_rates.size(), var);
173  return *(_elem_subsolution_rates[var]);
174  }
std::vector< DenseSubVector< Number > * > _elem_subsolution_rates
Definition: diff_context.h:572
libmesh_assert(j)
Real libMesh::DiffContext::get_elem_solution_rate_derivative ( ) const
inline

The derivative of the current elem_solution_rate w.r.t. the unknown solution. Corresponding Jacobian contributions should be multiplied by this amount, or may be skipped if get_elem_solution_rate_derivative() is 0.

Definition at line 428 of file diff_context.h.

References elem_solution_rate_derivative.

Referenced by libMesh::FirstOrderUnsteadySolver::compute_second_order_eqns(), and libMesh::FirstOrderUnsteadySolver::prepare_accel().

Real elem_solution_rate_derivative
Definition: diff_context.h:490
Real libMesh::DiffContext::get_fixed_solution_derivative ( ) const
inline

The derivative of the current fixed_elem_solution w.r.t. the unknown solution. Corresponding Jacobian contributions should be multiplied by this amount, or may be skipped if get_fixed_elem_solution_derivative() is 0.

Definition at line 446 of file diff_context.h.

References fixed_solution_derivative.

447  { return fixed_solution_derivative; }
DenseSubVector< Number > & libMesh::DiffContext::get_localized_subvector ( const NumericVector< Number > &  localized_vector,
unsigned int  var 
)

Return a reference to DenseSubVector localization of localized_vector at variable var contained in the _localized_vectors map

Definition at line 184 of file diff_context.C.

References _localized_vectors.

Referenced by libMesh::FEMContext::interior_gradients(), libMesh::FEMContext::interior_hessians(), libMesh::FEMContext::interior_values(), libMesh::FEMContext::side_gradients(), libMesh::FEMContext::side_hessians(), and libMesh::FEMContext::side_values().

185 {
186  return *_localized_vectors[&localized_vector].second[var];
187 }
std::map< const NumericVector< Number > *, std::pair< DenseVector< Number >, std::vector< DenseSubVector< Number > * > > > _localized_vectors
Definition: diff_context.h:558
const DenseSubVector< Number > & libMesh::DiffContext::get_localized_subvector ( const NumericVector< Number > &  localized_vector,
unsigned int  var 
) const

const accessible version of get_localized_subvector function

Definition at line 190 of file diff_context.C.

References _localized_vectors, and libMesh::libmesh_assert().

191 {
192  std::map<const NumericVector<Number> *, std::pair<DenseVector<Number>, std::vector<DenseSubVector<Number> *> > >::const_iterator
193  localized_vectors_it = _localized_vectors.find(&localized_vector);
194  libmesh_assert(localized_vectors_it != _localized_vectors.end());
195  return *localized_vectors_it->second.second[var];
196 }
std::map< const NumericVector< Number > *, std::pair< DenseVector< Number >, std::vector< DenseSubVector< Number > * > > > _localized_vectors
Definition: diff_context.h:558
libmesh_assert(j)
DenseVector< Number > & libMesh::DiffContext::get_localized_vector ( const NumericVector< Number > &  localized_vector)

Return a reference to DenseVector localization of localized_vector contained in the _localized_vectors map

Definition at line 169 of file diff_context.C.

References _localized_vectors.

170 {
171  return _localized_vectors[&localized_vector].first;
172 }
std::map< const NumericVector< Number > *, std::pair< DenseVector< Number >, std::vector< DenseSubVector< Number > * > > > _localized_vectors
Definition: diff_context.h:558
const DenseVector< Number > & libMesh::DiffContext::get_localized_vector ( const NumericVector< Number > &  localized_vector) const

const accessible version of get_localized_vector function

Definition at line 175 of file diff_context.C.

References _localized_vectors, and libMesh::libmesh_assert().

176 {
177  std::map<const NumericVector<Number> *, std::pair<DenseVector<Number>, std::vector<DenseSubVector<Number> *> > >::const_iterator
178  localized_vectors_it = _localized_vectors.find(&localized_vector);
179  libmesh_assert(localized_vectors_it != _localized_vectors.end());
180  return localized_vectors_it->second.first;
181 }
std::map< const NumericVector< Number > *, std::pair< DenseVector< Number >, std::vector< DenseSubVector< Number > * > > > _localized_vectors
Definition: diff_context.h:558
libmesh_assert(j)
const std::vector<DenseVector<Number> >& libMesh::DiffContext::get_qoi_derivatives ( ) const
inline

Const accessor for QoI derivatives.

Definition at line 330 of file diff_context.h.

References _elem_qoi_derivative.

Referenced by libMesh::FEMContext::pre_fe_reinit().

331  { return _elem_qoi_derivative; }
std::vector< DenseVector< Number > > _elem_qoi_derivative
Definition: diff_context.h:608
std::vector<DenseVector<Number> >& libMesh::DiffContext::get_qoi_derivatives ( )
inline

Non-const accessor for QoI derivatives.

Definition at line 336 of file diff_context.h.

References _elem_qoi_derivative.

337  { return _elem_qoi_derivative; }
std::vector< DenseVector< Number > > _elem_qoi_derivative
Definition: diff_context.h:608
const DenseSubVector<Number>& libMesh::DiffContext::get_qoi_derivatives ( unsigned int  qoi,
unsigned int  var 
) const
inline

Const accessor for QoI derivative of a particular qoi and variable corresponding to the index arguments.

Definition at line 343 of file diff_context.h.

References _elem_qoi_subderivatives, and libMesh::libmesh_assert().

344  {
345  libmesh_assert_greater(_elem_qoi_subderivatives.size(), qoi);
346  libmesh_assert_greater(_elem_qoi_subderivatives[qoi].size(), var);
348  return *(_elem_qoi_subderivatives[qoi][var]);
349  }
std::vector< std::vector< DenseSubVector< Number > * > > _elem_qoi_subderivatives
Definition: diff_context.h:609
libmesh_assert(j)
DenseSubVector<Number>& libMesh::DiffContext::get_qoi_derivatives ( unsigned int  qoi,
unsigned int  var 
)
inline

Non-const accessor for QoI derivative of a particular qoi and variable corresponding to the index arguments.

Definition at line 355 of file diff_context.h.

References _elem_qoi_subderivatives, and libMesh::libmesh_assert().

356  {
357  libmesh_assert_greater(_elem_qoi_subderivatives.size(), qoi);
358  libmesh_assert_greater(_elem_qoi_subderivatives[qoi].size(), var);
360  return *(_elem_qoi_subderivatives[qoi][var]);
361  }
std::vector< std::vector< DenseSubVector< Number > * > > _elem_qoi_subderivatives
Definition: diff_context.h:609
libmesh_assert(j)
const std::vector<Number>& libMesh::DiffContext::get_qois ( ) const
inline

Const accessor for QoI vector.

Definition at line 318 of file diff_context.h.

References _elem_qoi.

319  { return _elem_qoi; }
std::vector< Number > _elem_qoi
Definition: diff_context.h:603
std::vector<Number>& libMesh::DiffContext::get_qois ( )
inline

Non-const accessor for QoI vector.

Definition at line 324 of file diff_context.h.

References _elem_qoi.

325  { return _elem_qoi; }
std::vector< Number > _elem_qoi
Definition: diff_context.h:603
const System& libMesh::DiffContext::get_system ( ) const
inline

Accessor for associated system.

Definition at line 104 of file diff_context.h.

References _system.

Referenced by libMesh::FirstOrderUnsteadySolver::compute_second_order_eqns(), and libMesh::DGFEMContext::neighbor_side_fe_reinit().

105  { return _system; }
const System & _system
Definition: diff_context.h:641
Real libMesh::DiffContext::get_system_time ( ) const
inline

Accessor for the time variable stored in the system class.

Definition at line 398 of file diff_context.h.

References system_time.

Referenced by libMesh::FEMContext::_update_time_from_system().

399  { return system_time; }
const Real system_time
Definition: diff_context.h:477
Real libMesh::DiffContext::get_time ( ) const
inline

Accessor for the time for which the current nonlinear_solution is defined.

Definition at line 404 of file diff_context.h.

References time.

405  { return time; }
bool libMesh::DiffContext::is_adjoint ( ) const
inline

Accessor for querying whether we need to do a primal or adjoint solve

Definition at line 453 of file diff_context.h.

References _is_adjoint.

Referenced by libMesh::FEMSystem::build_context().

454  { return _is_adjoint; }
bool& libMesh::DiffContext::is_adjoint ( )
inline

Accessor for setting whether we need to do a primal or adjoint solve

Definition at line 460 of file diff_context.h.

References _is_adjoint.

461  { return _is_adjoint; }
unsigned int libMesh::DiffContext::n_vars ( ) const
inline
virtual void libMesh::DiffContext::nonlocal_reinit ( Real  )
inlinevirtual

Gives derived classes the opportunity to reinitialize data needed for nonlocal calculations at a new point within a timestep

Reimplemented in libMesh::FEMContext.

Definition at line 93 of file diff_context.h.

Referenced by libMesh::EulerSolver::nonlocal_residual(), libMesh::Euler2Solver::nonlocal_residual(), and libMesh::NewmarkSolver::nonlocal_residual().

93 {}
void libMesh::DiffContext::set_deltat_pointer ( Real dt)

Points the _deltat member of this class at a timestep value stored in the creating System, for example DiffSystem::deltat

Definition at line 138 of file diff_context.C.

References _deltat.

Referenced by libMesh::FEMSystem::build_context(), libMesh::DifferentiableSystem::build_context(), and libMesh::FEMSystem::init_context().

139 {
140  // We may actually want to be able to set this pointer to NULL, so
141  // don't report an error for that.
142  _deltat = dt;
143 }
void libMesh::DiffContext::set_time ( Real  time_in)
inline

Set the time for which the current nonlinear_solution is defined.

Definition at line 410 of file diff_context.h.

References time.

Referenced by libMesh::FEMContext::_update_time_from_system().

411  { time = time_in; }

Member Data Documentation

Real* libMesh::DiffContext::_deltat
private

Default NULL, can optionally be used to point to a timestep value in the System-derived class responsible for creating this DiffContext.

In DiffSystem's build_context() function, is assigned to point to the deltat member of that class.

Accessible via public get_deltat()/set_deltat() methods of this class.

Always test for NULL before using!

Definition at line 636 of file diff_context.h.

Referenced by get_deltat_value(), and set_deltat_pointer().

std::vector<dof_id_type> libMesh::DiffContext::_dof_indices
protected

Global Degree of freedom index lists

Definition at line 620 of file diff_context.h.

Referenced by get_dof_indices().

std::vector<std::vector<dof_id_type> > libMesh::DiffContext::_dof_indices_var
protected

Definition at line 621 of file diff_context.h.

Referenced by get_dof_indices(), and n_vars().

DenseVector<Number> libMesh::DiffContext::_elem_fixed_solution
protected

Element by element components of nonlinear_solution at a fixed point in a timestep, for optional use by e.g. stabilized methods

Definition at line 586 of file diff_context.h.

Referenced by DiffContext(), and get_elem_fixed_solution().

DenseMatrix<Number> libMesh::DiffContext::_elem_jacobian
protected

Element jacobian: derivatives of elem_residual with respect to elem_solution

Definition at line 598 of file diff_context.h.

Referenced by DiffContext(), and get_elem_jacobian().

std::vector<Number> libMesh::DiffContext::_elem_qoi
protected

Element quantity of interest contributions

Definition at line 603 of file diff_context.h.

Referenced by DiffContext(), and get_qois().

std::vector<DenseVector<Number> > libMesh::DiffContext::_elem_qoi_derivative
protected

Element quantity of interest derivative contributions

Definition at line 608 of file diff_context.h.

Referenced by DiffContext(), and get_qoi_derivatives().

std::vector<std::vector<DenseSubVector<Number> *> > libMesh::DiffContext::_elem_qoi_subderivatives
protected
DenseVector<Number> libMesh::DiffContext::_elem_residual
protected

Element residual vector

Definition at line 592 of file diff_context.h.

Referenced by DiffContext(), and get_elem_residual().

DenseVector<Number> libMesh::DiffContext::_elem_solution
protected

Element by element components of nonlinear_solution as adjusted by a time_solver

Definition at line 564 of file diff_context.h.

Referenced by DiffContext(), and get_elem_solution().

DenseVector<Number> libMesh::DiffContext::_elem_solution_accel
protected

Element by element components of du/dt as adjusted by a time_solver

Definition at line 578 of file diff_context.h.

Referenced by DiffContext(), and get_elem_solution_accel().

DenseVector<Number> libMesh::DiffContext::_elem_solution_rate
protected

Element by element components of du/dt as adjusted by a time_solver

Definition at line 571 of file diff_context.h.

Referenced by DiffContext(), and get_elem_solution_rate().

std::vector<std::vector<DenseSubMatrix<Number> *> > libMesh::DiffContext::_elem_subjacobians
protected

Definition at line 615 of file diff_context.h.

Referenced by DiffContext(), get_elem_jacobian(), and ~DiffContext().

std::vector<DenseSubVector<Number> *> libMesh::DiffContext::_elem_subresiduals
protected

Element residual subvectors and Jacobian submatrices

Definition at line 614 of file diff_context.h.

Referenced by DiffContext(), get_elem_residual(), and ~DiffContext().

std::vector<DenseSubVector<Number> *> libMesh::DiffContext::_elem_subsolution_accels
protected

Definition at line 579 of file diff_context.h.

Referenced by DiffContext(), get_elem_solution_accel(), and ~DiffContext().

std::vector<DenseSubVector<Number> *> libMesh::DiffContext::_elem_subsolution_rates
protected

Definition at line 572 of file diff_context.h.

Referenced by DiffContext(), get_elem_solution_rate(), and ~DiffContext().

bool libMesh::DiffContext::_is_adjoint
private

Is this context to be used for a primal or adjoint solve?

Definition at line 646 of file diff_context.h.

Referenced by is_adjoint().

std::map<const NumericVector<Number> *, std::pair<DenseVector<Number>, std::vector<DenseSubVector<Number> *> > > libMesh::DiffContext::_localized_vectors
protected

Contains pointers to vectors the user has asked to be localized, keyed with pairs of element localized versions of that vector and per variable views

Definition at line 558 of file diff_context.h.

Referenced by add_localized_vector(), get_localized_subvector(), get_localized_vector(), libMesh::FEMContext::pre_fe_reinit(), and ~DiffContext().

const System& libMesh::DiffContext::_system
private

A reference to the system this context is constructed with

Definition at line 641 of file diff_context.h.

Referenced by get_system().

Real libMesh::DiffContext::elem_solution_accel_derivative

The derivative of elem_solution_accel with respect to the current nonlinear solution, for use by systems with non default mass_residual terms.

Definition at line 497 of file diff_context.h.

Referenced by libMesh::NewmarkSolver::_general_residual(), get_elem_solution_accel_derivative(), and libMesh::FirstOrderUnsteadySolver::prepare_accel().

Real libMesh::DiffContext::elem_solution_derivative
Real libMesh::DiffContext::elem_solution_rate_derivative

The derivative of elem_solution_rate with respect to the current nonlinear solution, for use by systems with non default mass_residual terms.

Definition at line 490 of file diff_context.h.

Referenced by libMesh::EulerSolver::_general_residual(), libMesh::Euler2Solver::_general_residual(), libMesh::NewmarkSolver::_general_residual(), libMesh::EigenTimeSolver::element_residual(), get_elem_solution_rate_derivative(), and libMesh::EigenTimeSolver::side_residual().

Real libMesh::DiffContext::fixed_solution_derivative

The derivative of elem_fixed_solution with respect to the nonlinear solution, for use by systems constructing jacobians with elem_fixed_solution based methods

Definition at line 504 of file diff_context.h.

Referenced by libMesh::EulerSolver::_general_residual(), libMesh::Euler2Solver::_general_residual(), libMesh::SteadySolver::_general_residual(), and get_fixed_solution_derivative().

const Real libMesh::DiffContext::system_time

This is the time stored in the System class at the time this context was created, i.e. the time at the beginning of the current timestep. This value gets set in the constructor and unlike DiffContext::time, is not tweaked mid-timestep by transient solvers: it remains equal to the value it was assigned at construction.

Definition at line 477 of file diff_context.h.

Referenced by get_system_time().

Real libMesh::DiffContext::time

For time-dependent problems, this is the time t for which the current nonlinear_solution is defined. FIXME - this needs to be tweaked mid-timestep by all transient solvers!

Definition at line 468 of file diff_context.h.

Referenced by get_time(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), and set_time().


The documentation for this class was generated from the following files: