libMesh
Public Member Functions | Public Attributes | Protected Attributes | List of all members
libMesh::FEMPhysics Class Referenceabstract

This class provides a specific system class. More...

#include <fem_physics.h>

Inheritance diagram for libMesh::FEMPhysics:
[legend]

Public Member Functions

 FEMPhysics ()
 Constructor. More...
 
virtual ~FEMPhysics ()
 Destructor. More...
 
virtual bool eulerian_residual (bool request_jacobian, DiffContext &context) libmesh_override
 Adds a pseudo-convection contribution on elem to elem_residual, if the nodes of elem are being translated by a moving mesh. More...
 
virtual bool mass_residual (bool request_jacobian, DiffContext &) libmesh_override
 Subtracts a mass vector contribution on elem from elem_residual. More...
 
virtual UniquePtr< DifferentiablePhysicsclone_physics ()=0
 Copy of this object. More...
 
virtual void clear_physics ()
 Clear any data structures associated with the physics. More...
 
virtual void init_physics (const System &sys)
 Initialize any data structures associated with the physics. More...
 
virtual bool element_time_derivative (bool request_jacobian, DiffContext &)
 Adds the time derivative contribution on elem to elem_residual. More...
 
virtual bool element_constraint (bool request_jacobian, DiffContext &)
 Adds the constraint contribution on elem to elem_residual. More...
 
virtual bool side_time_derivative (bool request_jacobian, DiffContext &)
 Adds the time derivative contribution on side of elem to elem_residual. More...
 
virtual bool side_constraint (bool request_jacobian, DiffContext &)
 Adds the constraint contribution on side of elem to elem_residual. More...
 
virtual bool nonlocal_time_derivative (bool request_jacobian, DiffContext &)
 Adds any nonlocal time derivative contributions (e.g. More...
 
virtual bool nonlocal_constraint (bool request_jacobian, DiffContext &)
 Adds any nonlocal constraint contributions (e.g. More...
 
virtual void time_evolving (unsigned int var)
 Tells the DiffSystem that variable var is evolving with respect to time. More...
 
virtual void time_evolving (unsigned int var, unsigned int order)
 Tells the DiffSystem that variable var is evolving with respect to time. More...
 
bool is_time_evolving (unsigned int var) const
 
virtual bool side_mass_residual (bool request_jacobian, DiffContext &)
 Subtracts a mass vector contribution on side of elem from elem_residual. More...
 
virtual bool nonlocal_mass_residual (bool request_jacobian, DiffContext &c)
 Subtracts any nonlocal mass vector contributions (e.g. More...
 
virtual bool damping_residual (bool request_jacobian, DiffContext &)
 Subtracts a damping vector contribution on elem from elem_residual. More...
 
virtual bool side_damping_residual (bool request_jacobian, DiffContext &)
 Subtracts a damping vector contribution on side of elem from elem_residual. More...
 
virtual bool nonlocal_damping_residual (bool request_jacobian, DiffContext &)
 Subtracts any nonlocal damping vector contributions (e.g. More...
 
virtual void init_context (DiffContext &)
 
virtual void set_mesh_system (System *sys)
 Tells the DifferentiablePhysics that system sys contains the isoparametric Lagrangian variables which correspond to the coordinates of mesh nodes, in problems where the mesh itself is expected to move in time. More...
 
const Systemget_mesh_system () const
 
Systemget_mesh_system ()
 
virtual void set_mesh_x_var (unsigned int var)
 Tells the DifferentiablePhysics that variable var from the mesh system should be used to update the x coordinate of mesh nodes, in problems where the mesh itself is expected to move in time. More...
 
unsigned int get_mesh_x_var () const
 
virtual void set_mesh_y_var (unsigned int var)
 Tells the DifferentiablePhysics that variable var from the mesh system should be used to update the y coordinate of mesh nodes. More...
 
unsigned int get_mesh_y_var () const
 
virtual void set_mesh_z_var (unsigned int var)
 Tells the DifferentiablePhysics that variable var from the mesh system should be used to update the z coordinate of mesh nodes. More...
 
unsigned int get_mesh_z_var () const
 
bool _eulerian_time_deriv (bool request_jacobian, DiffContext &)
 This method simply combines element_time_derivative() and eulerian_residual(), which makes its address useful as a pointer-to-member-function when refactoring. More...
 
bool have_first_order_vars () const
 
const std::set< unsigned int > & get_first_order_vars () const
 
bool is_first_order_var (unsigned int var) const
 
bool have_second_order_vars () const
 
const std::set< unsigned int > & get_second_order_vars () const
 
bool is_second_order_var (unsigned int var) const
 

Public Attributes

bool compute_internal_sides
 compute_internal_sides is false by default, indicating that side_* computations will only be done on boundary sides. More...
 

Protected Attributes

System_mesh_sys
 System from which to acquire moving mesh information. More...
 
unsigned int _mesh_x_var
 Variables from which to acquire moving mesh information. More...
 
unsigned int _mesh_y_var
 
unsigned int _mesh_z_var
 
std::vector< unsigned int_time_evolving
 Stores unsigned int to tell us which variables are evolving as first order in time (1), second order in time (2), or are not time evolving (0). More...
 
std::set< unsigned int_first_order_vars
 Variable indices for those variables that are first order in time. More...
 
std::set< unsigned int_second_order_vars
 Variable indices for those variables that are second order in time. More...
 
std::map< unsigned int, unsigned int_second_order_dot_vars
 If the user adds any second order variables, then we need to also cache the map to their corresponding dot variable that will be added by this TimeSolver class. More...
 

Detailed Description

This class provides a specific system class.

It aims to generalize any system, linear or nonlinear, which provides both a residual and a Jacobian.

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
2012

Definition at line 44 of file fem_physics.h.

Constructor & Destructor Documentation

libMesh::FEMPhysics::FEMPhysics ( )

Constructor.

Definition at line 51 of file fem_physics.h.

51  :
53  {}
DifferentiablePhysics()
Constructor.
Definition: diff_physics.h:82
virtual libMesh::FEMPhysics::~FEMPhysics ( )
virtual

Destructor.

Definition at line 58 of file fem_physics.h.

References eulerian_residual(), and mass_residual().

58 {}

Member Function Documentation

bool libMesh::DifferentiablePhysics::_eulerian_time_deriv ( bool  request_jacobian,
DiffContext context 
)
inherited

This method simply combines element_time_derivative() and eulerian_residual(), which makes its address useful as a pointer-to-member-function when refactoring.

Definition at line 102 of file diff_physics.C.

References libMesh::DifferentiablePhysics::element_time_derivative(), and libMesh::DifferentiablePhysics::eulerian_residual().

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

104 {
105  // For any problem we need time derivative terms
106  request_jacobian =
107  this->element_time_derivative(request_jacobian, context);
108 
109  // For a moving mesh problem we may need the pseudoconvection term too
110  return this->eulerian_residual(request_jacobian, context) &&
111  request_jacobian;
112 }
virtual bool element_time_derivative(bool request_jacobian, DiffContext &)
Adds the time derivative contribution on elem to elem_residual.
Definition: diff_physics.h:123
virtual bool eulerian_residual(bool request_jacobian, DiffContext &)
Adds a pseudo-convection contribution on elem to elem_residual, if the nodes of elem are being transl...
Definition: diff_physics.h:293
void libMesh::DifferentiablePhysics::clear_physics ( )
virtualinherited

Clear any data structures associated with the physics.

Definition at line 33 of file diff_physics.C.

References libMesh::DifferentiablePhysics::_time_evolving.

Referenced by libMesh::DifferentiableSystem::clear(), libMesh::DifferentiablePhysics::DifferentiablePhysics(), and libMesh::DifferentiablePhysics::~DifferentiablePhysics().

34 {
35  _time_evolving.resize(0);
36 }
std::vector< unsigned int > _time_evolving
Stores unsigned int to tell us which variables are evolving as first order in time (1)...
Definition: diff_physics.h:553
virtual UniquePtr<DifferentiablePhysics> libMesh::DifferentiablePhysics::clone_physics ( )
pure virtualinherited

Copy of this object.

User should override to copy any needed state.

Implemented in libMesh::DifferentiableSystem.

Referenced by libMesh::DifferentiableSystem::attach_physics(), and libMesh::DifferentiablePhysics::DifferentiablePhysics().

virtual bool libMesh::DifferentiablePhysics::damping_residual ( bool  request_jacobian,
DiffContext  
)
virtualinherited

Subtracts a damping vector contribution on elem from elem_residual.

This method is not used in first-order-in-time problems. For second-order-in-time problems, this is the $ C(u,\ddot{u})\ddot{u} $ term. This method is only called for UnsteadySolver-based TimeSolvers.

If this method receives request_jacobian = true, then it should compute elem_jacobian and return true if possible. If elem_jacobian has not been computed then the method should return false.

If the problem has no damping, the default "do-nothing" is correct. Otherwise, this must be reimplemented.

Reimplemented in SecondOrderScalarSystemFirstOrderTimeSolverBase, and SecondOrderScalarSystemSecondOrderTimeSolverBase.

Definition at line 373 of file diff_physics.h.

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

374  {
375  return request_jacobian;
376  }
virtual bool libMesh::DifferentiablePhysics::element_constraint ( bool  request_jacobian,
DiffContext  
)
virtualinherited

Adds the constraint contribution on elem to elem_residual.

If this method receives request_jacobian = true, then it should compute elem_jacobian and return true if possible. If elem_jacobian has not been computed then the method should return false.

Users may need to reimplement this for their particular PDE.

To implement the constraint 0 = G(u), the user should examine u = elem_solution and add (G(u), phi_i) to elem_residual in elem_constraint().

Reimplemented in CoupledSystem, and NavierSystem.

Definition at line 141 of file diff_physics.h.

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

142  {
143  return request_jacobian;
144  }
virtual bool libMesh::DifferentiablePhysics::element_time_derivative ( bool  request_jacobian,
DiffContext  
)
virtualinherited

Adds the time derivative contribution on elem to elem_residual.

If this method receives request_jacobian = true, then it should compute elem_jacobian and return true if possible. If elem_jacobian has not been computed then the method should return false.

Users need to reimplement this for their particular PDE.

To implement the physics model du/dt = F(u), the user should examine u = elem_solution and add (F(u), phi_i) to elem_residual in elem_time_derivative().

Reimplemented in SecondOrderScalarSystemFirstOrderTimeSolverBase, FirstOrderScalarSystemBase, HeatSystem, CoupledSystem, ElasticitySystem, LaplaceSystem, CurlCurlSystem, LaplaceSystem, PoissonSystem, LaplaceSystem, LaplaceSystem, CurlCurlSystem, L2System, SolidSystem, NavierSystem, and HeatSystem.

Definition at line 123 of file diff_physics.h.

Referenced by libMesh::DifferentiablePhysics::_eulerian_time_deriv(), libMesh::SteadySolver::element_residual(), and libMesh::EigenTimeSolver::element_residual().

124  {
125  return request_jacobian;
126  }
bool libMesh::FEMPhysics::eulerian_residual ( bool  request_jacobian,
DiffContext context 
)
virtual

Adds a pseudo-convection contribution on elem to elem_residual, if the nodes of elem are being translated by a moving mesh.

This function assumes that the user's time derivative equations (except for any equations involving unknown mesh xyz coordinates themselves) are expressed in an Eulerian frame of reference, and that the user is satisfied with an unstabilized convection term. Lagrangian equations will probably require overriding eulerian_residual() with a blank function; ALE or stabilized formulations will require reimplementing eulerian_residual() entirely.

Reimplemented from libMesh::DifferentiablePhysics.

Reimplemented in SolidSystem.

Definition at line 39 of file fem_physics.C.

References libMesh::DifferentiablePhysics::_mesh_sys, libMesh::DifferentiablePhysics::_mesh_x_var, libMesh::DifferentiablePhysics::_mesh_y_var, libMesh::DifferentiablePhysics::_mesh_z_var, libMesh::FEMContext::get_element_qrule(), libMesh::FEMContext::interior_gradient(), libMesh::invalid_uint, libMesh::DifferentiablePhysics::is_time_evolving(), libMesh::libmesh_assert(), libmesh_nullptr, libMesh::libmesh_real(), libMesh::DiffContext::n_vars(), and libMesh::UnsteadySolver::old_nonlinear_solution().

Referenced by ~FEMPhysics().

41 {
42  // Only calculate a mesh movement residual if it's necessary
43  if (!_mesh_sys)
44  return request_jacobian;
45 
46  libmesh_not_implemented();
47 
48 #if 0
49  FEMContext & context = cast_ref<FEMContext &>(c);
50 
51  // This function only supports fully coupled mesh motion for now
52  libmesh_assert_equal_to (_mesh_sys, this);
53 
54  unsigned int n_qpoints = (context.get_element_qrule())->n_points();
55 
56  const unsigned int n_x_dofs = (_mesh_x_var == libMesh::invalid_uint) ?
57  0 : context.dof_indices_var[_mesh_x_var].size();
58  const unsigned int n_y_dofs = (_mesh_y_var == libMesh::invalid_uint) ?
59  0 : context.dof_indices_var[_mesh_y_var].size();
60  const unsigned int n_z_dofs = (_mesh_z_var == libMesh::invalid_uint) ?
61  0 : context.dof_indices_var[_mesh_z_var].size();
62 
63  const unsigned int mesh_xyz_var = n_x_dofs ? _mesh_x_var :
64  (n_y_dofs ? _mesh_y_var :
65  (n_z_dofs ? _mesh_z_var :
67 
68  // If we're our own _mesh_sys, we'd better be in charge of
69  // at least one coordinate, and we'd better have the same
70  // FE type for all coordinates we are in charge of
71  libmesh_assert_not_equal_to (mesh_xyz_var, libMesh::invalid_uint);
72  libmesh_assert(!n_x_dofs || context.element_fe_var[_mesh_x_var] ==
73  context.element_fe_var[mesh_xyz_var]);
74  libmesh_assert(!n_y_dofs || context.element_fe_var[_mesh_y_var] ==
75  context.element_fe_var[mesh_xyz_var]);
76  libmesh_assert(!n_z_dofs || context.element_fe_var[_mesh_z_var] ==
77  context.element_fe_var[mesh_xyz_var]);
78 
79  const std::vector<std::vector<Real>> & psi =
80  context.element_fe_var[mesh_xyz_var]->get_phi();
81 
82  for (unsigned int var = 0; var != context.n_vars(); ++var)
83  {
84  // Mesh motion only affects time-evolving variables
85  if (this->is_time_evolving(var))
86  continue;
87 
88  // The mesh coordinate variables themselves are Lagrangian,
89  // not Eulerian, and no convective term is desired.
90  if (/*_mesh_sys == this && */
91  (var == _mesh_x_var ||
92  var == _mesh_y_var ||
93  var == _mesh_z_var))
94  continue;
95 
96  // Some of this code currently relies on the assumption that
97  // we can pull mesh coordinate data from our own system
98  if (_mesh_sys != this)
99  libmesh_not_implemented();
100 
101  // This residual should only be called by unsteady solvers:
102  // if the mesh is steady, there's no mesh convection term!
103  UnsteadySolver * unsteady;
104  if (this->time_solver->is_steady())
105  return request_jacobian;
106  else
107  unsteady = cast_ptr<UnsteadySolver*>(this->time_solver.get());
108 
109  const std::vector<Real> & JxW =
110  context.element_fe_var[var]->get_JxW();
111 
112  const std::vector<std::vector<Real>> & phi =
113  context.element_fe_var[var]->get_phi();
114 
115  const std::vector<std::vector<RealGradient>> & dphi =
116  context.element_fe_var[var]->get_dphi();
117 
118  const unsigned int n_u_dofs = context.dof_indices_var[var].size();
119 
120  DenseSubVector<Number> & Fu = *context.elem_subresiduals[var];
121  DenseSubMatrix<Number> & Kuu = *context.elem_subjacobians[var][var];
122 
123  DenseSubMatrix<Number> * Kux = n_x_dofs ?
124  context.elem_subjacobians[var][_mesh_x_var] : libmesh_nullptr;
125  DenseSubMatrix<Number> * Kuy = n_y_dofs ?
126  context.elem_subjacobians[var][_mesh_y_var] : libmesh_nullptr;
127  DenseSubMatrix<Number> * Kuz = n_z_dofs ?
128  context.elem_subjacobians[var][_mesh_z_var] : libmesh_nullptr;
129 
130  std::vector<Real> delta_x(n_x_dofs, 0.);
131  std::vector<Real> delta_y(n_y_dofs, 0.);
132  std::vector<Real> delta_z(n_z_dofs, 0.);
133 
134  for (unsigned int i = 0; i != n_x_dofs; ++i)
135  {
136  unsigned int j = context.dof_indices_var[_mesh_x_var][i];
137  delta_x[i] = libmesh_real(this->current_solution(j)) -
138  libmesh_real(unsteady->old_nonlinear_solution(j));
139  }
140 
141  for (unsigned int i = 0; i != n_y_dofs; ++i)
142  {
143  unsigned int j = context.dof_indices_var[_mesh_y_var][i];
144  delta_y[i] = libmesh_real(this->current_solution(j)) -
145  libmesh_real(unsteady->old_nonlinear_solution(j));
146  }
147 
148  for (unsigned int i = 0; i != n_z_dofs; ++i)
149  {
150  unsigned int j = context.dof_indices_var[_mesh_z_var][i];
151  delta_z[i] = libmesh_real(this->current_solution(j)) -
152  libmesh_real(unsteady->old_nonlinear_solution(j));
153  }
154 
155  for (unsigned int qp = 0; qp != n_qpoints; ++qp)
156  {
157  Gradient grad_u = context.interior_gradient(var, qp);
158  RealGradient convection(0.);
159 
160  for (unsigned int i = 0; i != n_x_dofs; ++i)
161  convection(0) += delta_x[i] * psi[i][qp];
162  for (unsigned int i = 0; i != n_y_dofs; ++i)
163  convection(1) += delta_y[i] * psi[i][qp];
164  for (unsigned int i = 0; i != n_z_dofs; ++i)
165  convection(2) += delta_z[i] * psi[i][qp];
166 
167  for (unsigned int i = 0; i != n_u_dofs; ++i)
168  {
169  Number JxWxPhiI = JxW[qp] * phi[i][qp];
170  Fu(i) += (convection * grad_u) * JxWxPhiI;
171  if (request_jacobian)
172  {
173  Number JxWxPhiI = JxW[qp] * phi[i][qp];
174  for (unsigned int j = 0; j != n_u_dofs; ++j)
175  Kuu(i,j) += JxWxPhiI * (convection * dphi[j][qp]);
176 
177  Number JxWxPhiIoverDT = JxWxPhiI/this->deltat;
178 
179  Number JxWxPhiIxDUDXoverDT = JxWxPhiIoverDT * grad_u(0);
180  for (unsigned int j = 0; j != n_x_dofs; ++j)
181  (*Kux)(i,j) += JxWxPhiIxDUDXoverDT * psi[j][qp];
182 
183  Number JxWxPhiIxDUDYoverDT = JxWxPhiIoverDT * grad_u(1);
184  for (unsigned int j = 0; j != n_y_dofs; ++j)
185  (*Kuy)(i,j) += JxWxPhiIxDUDYoverDT * psi[j][qp];
186 
187  Number JxWxPhiIxDUDZoverDT = JxWxPhiIoverDT * grad_u(2);
188  for (unsigned int j = 0; j != n_z_dofs; ++j)
189  (*Kuz)(i,j) += JxWxPhiIxDUDZoverDT * psi[j][qp];
190  }
191  }
192  }
193  }
194 #endif // 0
195 
196  return request_jacobian;
197 }
T libmesh_real(T a)
RealVectorValue RealGradient
unsigned int _mesh_x_var
Variables from which to acquire moving mesh information.
Definition: diff_physics.h:546
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value.
Definition: libmesh.h:184
const class libmesh_nullptr_t libmesh_nullptr
bool is_time_evolving(unsigned int var) const
Definition: diff_physics.h:276
libmesh_assert(j)
System * _mesh_sys
System from which to acquire moving mesh information.
Definition: diff_physics.h:541
NumberVectorValue Gradient
const std::set<unsigned int>& libMesh::DifferentiablePhysics::get_first_order_vars ( ) const
inherited
Returns
The set of first order in time variable indices. May be empty.

Definition at line 516 of file diff_physics.h.

References libMesh::DifferentiablePhysics::_first_order_vars.

Referenced by libMesh::DifferentiableSystem::have_first_order_scalar_vars().

517  { return _first_order_vars; }
std::set< unsigned int > _first_order_vars
Variable indices for those variables that are first order in time.
Definition: diff_physics.h:558
const System * libMesh::DifferentiablePhysics::get_mesh_system ( ) const
inherited
Returns
A const reference to the system with variables corresponding to mesh nodal coordinates, or NULL if the mesh is fixed. Useful for ALE calculations.

Definition at line 623 of file diff_physics.h.

References libMesh::DifferentiablePhysics::_mesh_sys.

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

624 {
625  return _mesh_sys;
626 }
System * _mesh_sys
System from which to acquire moving mesh information.
Definition: diff_physics.h:541
System * libMesh::DifferentiablePhysics::get_mesh_system ( )
inherited
Returns
A reference to the system with variables corresponding to mesh nodal coordinates, or NULL if the mesh is fixed.

Definition at line 629 of file diff_physics.h.

References libMesh::DifferentiablePhysics::_mesh_sys.

630 {
631  return _mesh_sys;
632 }
System * _mesh_sys
System from which to acquire moving mesh information.
Definition: diff_physics.h:541
unsigned int libMesh::DifferentiablePhysics::get_mesh_x_var ( ) const
inherited
Returns
The variable number corresponding to the mesh x coordinate. Useful for ALE calculations.

Definition at line 635 of file diff_physics.h.

References libMesh::DifferentiablePhysics::_mesh_x_var.

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

636 {
637  return _mesh_x_var;
638 }
unsigned int _mesh_x_var
Variables from which to acquire moving mesh information.
Definition: diff_physics.h:546
unsigned int libMesh::DifferentiablePhysics::get_mesh_y_var ( ) const
inherited
Returns
The variable number corresponding to the mesh y coordinate. Useful for ALE calculations.

Definition at line 641 of file diff_physics.h.

References libMesh::DifferentiablePhysics::_mesh_y_var.

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

642 {
643  return _mesh_y_var;
644 }
unsigned int libMesh::DifferentiablePhysics::get_mesh_z_var ( ) const
inherited
Returns
The variable number corresponding to the mesh z coordinate. Useful for ALE calculations.

Definition at line 647 of file diff_physics.h.

References libMesh::DifferentiablePhysics::_mesh_z_var.

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

648 {
649  return _mesh_z_var;
650 }
const std::set<unsigned int>& libMesh::DifferentiablePhysics::get_second_order_vars ( ) const
inherited
Returns
The set of second order in time variable indices. May be empty.

Definition at line 529 of file diff_physics.h.

References libMesh::DifferentiablePhysics::_second_order_vars.

Referenced by libMesh::DifferentiableSystem::add_second_order_dot_vars(), libMesh::DiffContext::DiffContext(), libMesh::Euler2Solver::element_residual(), libMesh::DifferentiableSystem::have_second_order_scalar_vars(), and libMesh::FEMContext::pre_fe_reinit().

530  { return _second_order_vars; }
std::set< unsigned int > _second_order_vars
Variable indices for those variables that are second order in time.
Definition: diff_physics.h:563
bool libMesh::DifferentiablePhysics::have_first_order_vars ( ) const
inherited

Definition at line 510 of file diff_physics.h.

References libMesh::DifferentiablePhysics::_first_order_vars.

Referenced by libMesh::DifferentiableSystem::have_first_order_scalar_vars().

511  { return !_first_order_vars.empty(); }
std::set< unsigned int > _first_order_vars
Variable indices for those variables that are first order in time.
Definition: diff_physics.h:558
bool libMesh::DifferentiablePhysics::have_second_order_vars ( ) const
inherited

Definition at line 523 of file diff_physics.h.

References libMesh::DifferentiablePhysics::_second_order_vars.

Referenced by libMesh::EulerSolver::element_residual(), and libMesh::DifferentiableSystem::have_second_order_scalar_vars().

524  { return !_second_order_vars.empty(); }
std::set< unsigned int > _second_order_vars
Variable indices for those variables that are second order in time.
Definition: diff_physics.h:563
virtual void libMesh::DifferentiablePhysics::init_context ( DiffContext )
virtualinherited
void libMesh::DifferentiablePhysics::init_physics ( const System sys)
virtualinherited

Initialize any data structures associated with the physics.

Definition at line 40 of file diff_physics.C.

References libMesh::DifferentiablePhysics::_time_evolving, and libMesh::System::n_vars().

Referenced by libMesh::DifferentiableSystem::attach_physics(), libMesh::DifferentiablePhysics::DifferentiablePhysics(), and libMesh::DifferentiableSystem::init_data().

41 {
42  // give us flags for every variable that might be time evolving
43  _time_evolving.resize(sys.n_vars(), false);
44 }
ImplicitSystem & sys
unsigned int n_vars() const
Definition: system.h:2086
std::vector< unsigned int > _time_evolving
Stores unsigned int to tell us which variables are evolving as first order in time (1)...
Definition: diff_physics.h:553
bool libMesh::DifferentiablePhysics::is_first_order_var ( unsigned int  var) const
inherited

Definition at line 519 of file diff_physics.h.

References libMesh::DifferentiablePhysics::_first_order_vars.

520  { return _first_order_vars.find(var) != _first_order_vars.end(); }
std::set< unsigned int > _first_order_vars
Variable indices for those variables that are first order in time.
Definition: diff_physics.h:558
bool libMesh::DifferentiablePhysics::is_second_order_var ( unsigned int  var) const
inherited

Definition at line 532 of file diff_physics.h.

References libMesh::DifferentiablePhysics::_second_order_vars.

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

533  { return _second_order_vars.find(var) != _second_order_vars.end(); }
std::set< unsigned int > _second_order_vars
Variable indices for those variables that are second order in time.
Definition: diff_physics.h:563
bool libMesh::DifferentiablePhysics::is_time_evolving ( unsigned int  var) const
inherited
Returns
true iff variable var is evolving with respect to time. In general, the user's init() function should have set time_evolving() for any variables which behave like du/dt = F(u), and should not call time_evolving() for any variables which behave like 0 = G(u).

Definition at line 276 of file diff_physics.h.

References libMesh::DifferentiablePhysics::_time_evolving, and libMesh::libmesh_assert().

Referenced by eulerian_residual(), libMesh::FEMSystem::init_context(), mass_residual(), and libMesh::DifferentiablePhysics::nonlocal_mass_residual().

277  {
278  libmesh_assert_less(var,_time_evolving.size());
279  libmesh_assert( _time_evolving[var] == 0 ||
280  _time_evolving[var] == 1 ||
281  _time_evolving[var] == 2 );
282  return _time_evolving[var];
283  }
libmesh_assert(j)
std::vector< unsigned int > _time_evolving
Stores unsigned int to tell us which variables are evolving as first order in time (1)...
Definition: diff_physics.h:553
bool libMesh::FEMPhysics::mass_residual ( bool  request_jacobian,
DiffContext c 
)
virtual

Subtracts a mass vector contribution on elem from elem_residual.

If this method receives request_jacobian = true, then it should compute elem_jacobian and return true if possible. If elem_jacobian has not been computed then the method should return false.

Many problems can use the reimplementation in FEMPhysics::mass_residual which subtracts (du/dt,v) for each transient variable u; users with more complicated transient problems will need to reimplement this themselves.

Reimplemented from libMesh::DifferentiablePhysics.

Reimplemented in SecondOrderScalarSystemFirstOrderTimeSolverBase, SecondOrderScalarSystemSecondOrderTimeSolverBase, FirstOrderScalarSystemBase, ElasticitySystem, and NavierSystem.

Definition at line 201 of file fem_physics.C.

References libMesh::DiffContext::elem_solution_rate_derivative, libMesh::DiffContext::get_dof_indices(), libMesh::DiffContext::get_elem_jacobian(), libMesh::DiffContext::get_elem_residual(), libMesh::FEMContext::get_element_fe(), libMesh::FEMContext::get_element_qrule(), libMesh::FEAbstract::get_JxW(), libMesh::FEGenericBase< OutputType >::get_phi(), libMesh::FEMContext::interior_rate(), libMesh::DifferentiablePhysics::is_time_evolving(), libmesh_nullptr, libMesh::QBase::n_points(), and libMesh::DiffContext::n_vars().

Referenced by ~FEMPhysics().

203 {
204  FEMContext & context = cast_ref<FEMContext &>(c);
205 
206  unsigned int n_qpoints = context.get_element_qrule().n_points();
207 
208  for (unsigned int var = 0; var != context.n_vars(); ++var)
209  {
210  if (!this->is_time_evolving(var))
211  continue;
212 
213  FEBase * elem_fe = libmesh_nullptr;
214  context.get_element_fe( var, elem_fe );
215 
216  const std::vector<Real> & JxW = elem_fe->get_JxW();
217 
218  const std::vector<std::vector<Real>> & phi = elem_fe->get_phi();
219 
220  const unsigned int n_dofs = cast_int<unsigned int>
221  (context.get_dof_indices(var).size());
222 
223  DenseSubVector<Number> & Fu = context.get_elem_residual(var);
224  DenseSubMatrix<Number> & Kuu = context.get_elem_jacobian( var, var );
225 
226  for (unsigned int qp = 0; qp != n_qpoints; ++qp)
227  {
228  Number uprime;
229  context.interior_rate(var, qp, uprime);
230  const Number JxWxU = JxW[qp] * uprime;
231  for (unsigned int i = 0; i != n_dofs; ++i)
232  {
233  Fu(i) -= JxWxU * phi[i][qp];
234  if (request_jacobian && context.elem_solution_rate_derivative)
235  {
236  const Number JxWxPhiIxDeriv = JxW[qp] * phi[i][qp] *
237  context.elem_solution_rate_derivative;
238  Kuu(i,i) -= JxWxPhiIxDeriv * phi[i][qp];
239  for (unsigned int j = i+1; j < n_dofs; ++j)
240  {
241  const Number Kij = JxWxPhiIxDeriv * phi[j][qp];
242  Kuu(i,j) -= Kij;
243  Kuu(j,i) -= Kij;
244  }
245  }
246  }
247  }
248  }
249 
250  return request_jacobian;
251 }
const class libmesh_nullptr_t libmesh_nullptr
bool is_time_evolving(unsigned int var) const
Definition: diff_physics.h:276
FEGenericBase< Real > FEBase
virtual bool libMesh::DifferentiablePhysics::nonlocal_constraint ( bool  request_jacobian,
DiffContext  
)
virtualinherited

Adds any nonlocal constraint contributions (e.g.

some components of constraints in scalar variable equations) to elem_residual

If this method receives request_jacobian = true, then it should also modify elem_jacobian and return true if possible. If the Jacobian changes have not been computed then the method should return false.

Users may need to reimplement this for PDEs on systems to which SCALAR variables with non-transient equations have been added.

Definition at line 226 of file diff_physics.h.

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

227  {
228  return request_jacobian;
229  }
virtual bool libMesh::DifferentiablePhysics::nonlocal_damping_residual ( bool  request_jacobian,
DiffContext  
)
virtualinherited

Subtracts any nonlocal damping vector contributions (e.g.

any first time derivative coefficients in scalar variable equations) from elem_residual

If this method receives request_jacobian = true, then it should also modify elem_jacobian and return true if possible. If the Jacobian changes have not been computed then the method should return false.

Definition at line 405 of file diff_physics.h.

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

406  {
407  return request_jacobian;
408  }
bool libMesh::DifferentiablePhysics::nonlocal_mass_residual ( bool  request_jacobian,
DiffContext c 
)
virtualinherited

Subtracts any nonlocal mass vector contributions (e.g.

any time derivative coefficients in scalar variable equations) from elem_residual

If this method receives request_jacobian = true, then it should also modify elem_jacobian and return true if possible. If the Jacobian changes have not been computed then the method should return false.

Many problems can use the reimplementation in FEMPhysics::mass_residual which subtracts (du/dt,v) for each transient scalar variable u; users with more complicated transient scalar variable equations will need to reimplement this themselves.

Definition at line 63 of file diff_physics.C.

References libMesh::DiffContext::elem_solution_rate_derivative, libMesh::FEType::family, libMesh::DiffContext::get_dof_indices(), libMesh::DiffContext::get_elem_jacobian(), libMesh::DiffContext::get_elem_residual(), libMesh::DiffContext::get_elem_solution(), libMesh::DiffContext::get_system(), libMesh::DifferentiablePhysics::is_time_evolving(), libMesh::DiffContext::n_vars(), libMesh::SCALAR, libMesh::Variable::type(), and libMesh::System::variable().

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

65 {
66  FEMContext & context = cast_ref<FEMContext &>(c);
67 
68  for (unsigned int var = 0; var != context.n_vars(); ++var)
69  {
70  if (!this->is_time_evolving(var))
71  continue;
72 
73  if (c.get_system().variable(var).type().family != SCALAR)
74  continue;
75 
76  const std::vector<dof_id_type> & dof_indices =
77  context.get_dof_indices(var);
78 
79  const unsigned int n_dofs = cast_int<unsigned int>
80  (dof_indices.size());
81 
82  DenseSubVector<Number> & Fs = context.get_elem_residual(var);
83  DenseSubMatrix<Number> & Kss = context.get_elem_jacobian( var, var );
84 
86  context.get_elem_solution(var);
87 
88  for (unsigned int i=0; i != n_dofs; ++i)
89  {
90  Fs(i) -= Us(i);
91 
92  if (request_jacobian)
93  Kss(i,i) -= context.elem_solution_rate_derivative;
94  }
95  }
96 
97  return request_jacobian;
98 }
bool is_time_evolving(unsigned int var) const
Definition: diff_physics.h:276
Defines a dense subvector for use in finite element computations.
virtual bool libMesh::DifferentiablePhysics::nonlocal_time_derivative ( bool  request_jacobian,
DiffContext  
)
virtualinherited

Adds any nonlocal time derivative contributions (e.g.

some components of time derivatives in scalar variable equations) to elem_residual

If this method receives request_jacobian = true, then it should also modify elem_jacobian and return true if possible. If the Jacobian changes have not been computed then the method should return false.

Users may need to reimplement this for PDEs on systems to which SCALAR variables have been added.

Definition at line 208 of file diff_physics.h.

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

209  {
210  return request_jacobian;
211  }
void libMesh::DifferentiablePhysics::set_mesh_system ( System sys)
virtualinherited

Tells the DifferentiablePhysics that system sys contains the isoparametric Lagrangian variables which correspond to the coordinates of mesh nodes, in problems where the mesh itself is expected to move in time.

The system with mesh coordinate data (which may be this system itself, for fully coupled moving mesh problems) is currently assumed to have new (end of time step) mesh coordinates stored in solution, old (beginning of time step) mesh coordinates stored in _old_nonlinear_solution, and constant velocity motion during each time step.

Activating this function ensures that local (but not neighbor!) element geometry is correctly repositioned when evaluating element residuals.

Currently sys must be *this for a tightly coupled moving mesh problem or NULL to stop mesh movement; loosely coupled moving mesh problems are not implemented.

This code is experimental. "Trust but verify, and not in that order"

Definition at line 579 of file diff_physics.h.

References libMesh::DifferentiablePhysics::_mesh_sys, and libMesh::sys.

Referenced by libMesh::DifferentiablePhysics::init_context(), and SolidSystem::init_data().

580 {
581  // For now we assume that we're doing fully coupled mesh motion
582  // if (sys && sys != this)
583  // libmesh_not_implemented();
584 
585  // For the foreseeable future we'll assume that we keep these
586  // Systems in the same EquationSystems
587  // libmesh_assert_equal_to (&this->get_equation_systems(),
588  // &sys->get_equation_systems());
589 
590  // And for the immediate future this code may not even work
591  libmesh_experimental();
592 
593  _mesh_sys = sys;
594 }
ImplicitSystem & sys
System * _mesh_sys
System from which to acquire moving mesh information.
Definition: diff_physics.h:541
void libMesh::DifferentiablePhysics::set_mesh_x_var ( unsigned int  var)
virtualinherited

Tells the DifferentiablePhysics that variable var from the mesh system should be used to update the x coordinate of mesh nodes, in problems where the mesh itself is expected to move in time.

The system with mesh coordinate data (which may be this system itself, for fully coupled moving mesh problems) is currently assumed to have new (end of time step) mesh coordinates stored in solution, old (beginning of time step) mesh coordinates stored in _old_nonlinear_solution, and constant velocity motion during each time step.

Activating this function ensures that local (but not neighbor!) element geometry is correctly repositioned when evaluating element residuals.

Definition at line 599 of file diff_physics.h.

References libMesh::DifferentiablePhysics::_mesh_x_var.

Referenced by libMesh::DifferentiablePhysics::init_context(), and SolidSystem::init_data().

600 {
601  _mesh_x_var = var;
602 }
unsigned int _mesh_x_var
Variables from which to acquire moving mesh information.
Definition: diff_physics.h:546
void libMesh::DifferentiablePhysics::set_mesh_y_var ( unsigned int  var)
virtualinherited

Tells the DifferentiablePhysics that variable var from the mesh system should be used to update the y coordinate of mesh nodes.

Definition at line 607 of file diff_physics.h.

References libMesh::DifferentiablePhysics::_mesh_y_var.

Referenced by libMesh::DifferentiablePhysics::init_context(), and SolidSystem::init_data().

608 {
609  _mesh_y_var = var;
610 }
void libMesh::DifferentiablePhysics::set_mesh_z_var ( unsigned int  var)
virtualinherited

Tells the DifferentiablePhysics that variable var from the mesh system should be used to update the z coordinate of mesh nodes.

Definition at line 615 of file diff_physics.h.

References libMesh::DifferentiablePhysics::_mesh_z_var.

Referenced by libMesh::DifferentiablePhysics::init_context(), and SolidSystem::init_data().

616 {
617  _mesh_z_var = var;
618 }
virtual bool libMesh::DifferentiablePhysics::side_constraint ( bool  request_jacobian,
DiffContext  
)
virtualinherited

Adds the constraint contribution on side of elem to elem_residual.

If this method receives request_jacobian = true, then it should compute elem_jacobian and return true if possible. If elem_jacobian has not been computed then the method should return false.

Users may need to reimplement this for their particular PDE depending on the boundary conditions.

To implement a weak form of the constraint 0 = G(u), the user should examine u = elem_solution and add (G(u), phi_i) boundary integral contributions to elem_residual in side_constraint().

Reimplemented in LaplaceSystem, LaplaceSystem, LaplaceSystem, and NavierSystem.

Definition at line 190 of file diff_physics.h.

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

191  {
192  return request_jacobian;
193  }
virtual bool libMesh::DifferentiablePhysics::side_damping_residual ( bool  request_jacobian,
DiffContext  
)
virtualinherited

Subtracts a damping vector contribution on side of elem from elem_residual.

If this method receives request_jacobian = true, then it should compute elem_jacobian and return true if possible. If elem_jacobian has not been computed then the method should return false.

For most problems, the default implementation of "do nothing" is correct; users with boundary conditions including first time derivatives may need to reimplement this themselves.

Definition at line 390 of file diff_physics.h.

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

391  {
392  return request_jacobian;
393  }
virtual bool libMesh::DifferentiablePhysics::side_mass_residual ( bool  request_jacobian,
DiffContext  
)
virtualinherited

Subtracts a mass vector contribution on side of elem from elem_residual.

If this method receives request_jacobian = true, then it should compute elem_jacobian and return true if possible. If elem_jacobian has not been computed then the method should return false.

For most problems, the default implementation of "do nothing" is correct; users with boundary conditions including time derivatives may need to reimplement this themselves.

Definition at line 334 of file diff_physics.h.

References libMesh::DifferentiablePhysics::nonlocal_mass_residual().

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

335  {
336  return request_jacobian;
337  }
virtual bool libMesh::DifferentiablePhysics::side_time_derivative ( bool  request_jacobian,
DiffContext  
)
virtualinherited

Adds the time derivative contribution on side of elem to elem_residual.

If this method receives request_jacobian = true, then it should compute elem_jacobian and return true if possible. If elem_jacobian has not been computed then the method should return false.

Users may need to reimplement this for their particular PDE depending on the boundary conditions.

To implement a weak form of the source term du/dt = F(u) on sides, such as might arise in a flux boundary condition, the user should examine u = elem_solution and add (F(u), phi_i) boundary integral contributions to elem_residual in side_constraint().

Reimplemented in ElasticitySystem, CurlCurlSystem, CurlCurlSystem, and SolidSystem.

Definition at line 170 of file diff_physics.h.

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

171  {
172  return request_jacobian;
173  }
virtual void libMesh::DifferentiablePhysics::time_evolving ( unsigned int  var)
virtualinherited

Tells the DiffSystem that variable var is evolving with respect to time.

In general, the user's init() function should call time_evolving() for any variables which behave like du/dt = F(u), and should not call time_evolving() for any variables which behave like 0 = G(u).

Most derived systems will not have to reimplement this function; however any system which reimplements mass_residual() may have to reimplement time_evolving() to prepare data structures.

Deprecated:
Instead, use the time_evolving override and specify the order-in-time of the variable, either 1 or 2. This method assumes the variable is first order for backward compatibility.

Definition at line 248 of file diff_physics.h.

Referenced by libMesh::DifferentiableSystem::add_second_order_dot_vars(), CurlCurlSystem::init_data(), and HeatSystem::init_data().

249  {
250  libmesh_deprecated();
251  this->time_evolving(var,1);
252  }
virtual void time_evolving(unsigned int var)
Tells the DiffSystem that variable var is evolving with respect to time.
Definition: diff_physics.h:248
void libMesh::DifferentiablePhysics::time_evolving ( unsigned int  var,
unsigned int  order 
)
virtualinherited

Tells the DiffSystem that variable var is evolving with respect to time.

In general, the user's init() function should call time_evolving() with order 1 for any variables which behave like du/dt = F(u), with order 2 for any variables that behave like d^2u/dt^2 = F(u), and should not call time_evolving() for any variables which behave like 0 = G(u).

Most derived systems will not have to reimplement this function; however any system which reimplements mass_residual() may have to reimplement time_evolving() to prepare data structures.

Definition at line 46 of file diff_physics.C.

References libMesh::DifferentiablePhysics::_first_order_vars, libMesh::DifferentiablePhysics::_second_order_vars, and libMesh::DifferentiablePhysics::_time_evolving.

48 {
49  if (order != 1 && order != 2)
50  libmesh_error_msg("Input order must be 1 or 2!");
51 
52  if (_time_evolving.size() <= var)
53  _time_evolving.resize(var+1, 0);
54 
55  _time_evolving[var] = order;
56 
57  if (order == 1)
58  _first_order_vars.insert(var);
59  else
60  _second_order_vars.insert(var);
61 }
std::set< unsigned int > _second_order_vars
Variable indices for those variables that are second order in time.
Definition: diff_physics.h:563
std::set< unsigned int > _first_order_vars
Variable indices for those variables that are first order in time.
Definition: diff_physics.h:558
std::vector< unsigned int > _time_evolving
Stores unsigned int to tell us which variables are evolving as first order in time (1)...
Definition: diff_physics.h:553

Member Data Documentation

std::set<unsigned int> libMesh::DifferentiablePhysics::_first_order_vars
protectedinherited
System* libMesh::DifferentiablePhysics::_mesh_sys
protectedinherited
unsigned int libMesh::DifferentiablePhysics::_mesh_x_var
protectedinherited
unsigned int libMesh::DifferentiablePhysics::_mesh_y_var
protectedinherited
unsigned int libMesh::DifferentiablePhysics::_mesh_z_var
protectedinherited
std::map<unsigned int,unsigned int> libMesh::DifferentiablePhysics::_second_order_dot_vars
protectedinherited

If the user adds any second order variables, then we need to also cache the map to their corresponding dot variable that will be added by this TimeSolver class.

Definition at line 570 of file diff_physics.h.

Referenced by libMesh::DifferentiableSystem::add_second_order_dot_vars(), and libMesh::DifferentiableSystem::get_second_order_dot_var().

std::set<unsigned int> libMesh::DifferentiablePhysics::_second_order_vars
protectedinherited
std::vector<unsigned int> libMesh::DifferentiablePhysics::_time_evolving
protectedinherited

Stores unsigned int to tell us which variables are evolving as first order in time (1), second order in time (2), or are not time evolving (0).

Definition at line 553 of file diff_physics.h.

Referenced by libMesh::DifferentiablePhysics::clear_physics(), libMesh::DifferentiablePhysics::init_physics(), libMesh::DifferentiablePhysics::is_time_evolving(), and libMesh::DifferentiablePhysics::time_evolving().

bool libMesh::DifferentiablePhysics::compute_internal_sides
inherited

compute_internal_sides is false by default, indicating that side_* computations will only be done on boundary sides.

If compute_internal_sides is true, computations will be done on sides between elements as well.

Definition at line 152 of file diff_physics.h.


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