https://mooseframework.inl.gov
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
ShapeUserObject< T > Class Template Referenceabstract

UserObject template class in which the _phi and _grad_phi shape function data is available and correctly initialized on EXEC_NONLINEAR (the Jacobian calculation). More...

#include <ShapeUserObject.h>

Inheritance diagram for ShapeUserObject< T >:
[legend]

Public Member Functions

 ShapeUserObject (const InputParameters &parameters, ShapeType type)
 
const bool & computeJacobianFlag () const
 check if jacobian is to be computed in user objects More...
 
const std::set< const MooseVariableFEBase * > & jacobianMooseVariables () const
 Returns the set of variables a Jacobian has been requested for. More...
 
virtual void executeJacobianWrapper (unsigned int jvar, const std::vector< dof_id_type > &dof_indices)
 This function will be called with the shape functions for jvar initialized. More...
 

Static Public Member Functions

static InputParameters validParams ()
 

Protected Member Functions

virtual void executeJacobian (unsigned int)=0
 Implement this function to compute Jacobian terms for this UserObject. More...
 
virtual unsigned int coupled (const std::string &var_name, unsigned int comp=0) const override
 Returns the index for a coupled variable by name and requests the computation of a Jacobian w.r.t. More...
 

Protected Attributes

const VariablePhiValue_phi
 shape function values More...
 
const VariablePhiGradient_grad_phi
 shape function gradients More...
 
unsigned int _j
 j-th index for enumerating the shape functions More...
 
dof_id_type _j_global
 global DOF ID corresponding to _j More...
 

Private Attributes

const bool _compute_jacobians
 
std::set< const MooseVariableFEBase * > _jacobian_moose_variables
 

Detailed Description

template<typename T>
class ShapeUserObject< T >

UserObject template class in which the _phi and _grad_phi shape function data is available and correctly initialized on EXEC_NONLINEAR (the Jacobian calculation).

This enables the calculation of Jacobian matrix contributions inside a UO.

Warning
It is up to the user to ensure _fe_problem.currentlyComputingJacobian() returns true before utilizing the shape functions.

Definition at line 41 of file ShapeUserObject.h.

Constructor & Destructor Documentation

◆ ShapeUserObject()

template<typename T >
ShapeUserObject< T >::ShapeUserObject ( const InputParameters parameters,
ShapeType  type 
)

Definition at line 99 of file ShapeUserObject.h.

100  : T(parameters),
101  _phi(type == ShapeType::Element ? this->_assembly.phi() : this->_assembly.phiFace()),
102  _grad_phi(type == ShapeType::Element ? this->_assembly.gradPhi()
103  : this->_assembly.gradPhiFace()),
104  _compute_jacobians(MooseObject::getParam<bool>("compute_jacobians"))
105 {
106  mooseWarning("Jacobian calculation in UserObjects is an experimental capability with a "
107  "potentially unstable interface.");
108 }
const bool _compute_jacobians
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
Definition: MooseError.h:336
const VariablePhiGradient & _grad_phi
shape function gradients
const VariablePhiValue & _phi
shape function values

Member Function Documentation

◆ computeJacobianFlag()

template<typename T>
const bool& ShapeUserObject< T >::computeJacobianFlag ( ) const
inline

check if jacobian is to be computed in user objects

Definition at line 49 of file ShapeUserObject.h.

49 { return _compute_jacobians; }
const bool _compute_jacobians

◆ coupled()

template<typename T >
unsigned int ShapeUserObject< T >::coupled ( const std::string &  var_name,
unsigned int  comp = 0 
) const
overrideprotectedvirtual

Returns the index for a coupled variable by name and requests the computation of a Jacobian w.r.t.

to this variable i.e. the call to executeJacobian() with shapefunctions initialized for this variable.

Definition at line 122 of file ShapeUserObject.h.

123 {
124  const auto * var = this->template getVarHelper<MooseVariable>(var_name, comp);
125 
126  // add to the set of variables for which executeJacobian will be called
127  if (_compute_jacobians && var->kind() == Moose::VAR_SOLVER)
128  _jacobian_moose_variables.insert(var);
129 
130  // return the variable number
131  return T::coupled(var_name, comp);
132 }
const bool _compute_jacobians
std::set< const MooseVariableFEBase * > _jacobian_moose_variables

◆ executeJacobian()

template<typename T>
virtual void ShapeUserObject< T >::executeJacobian ( unsigned  int)
protectedpure virtual

Implement this function to compute Jacobian terms for this UserObject.

The shape function index _j and its corrsponding global DOF index _j_global will be provided.

◆ executeJacobianWrapper()

template<typename T >
void ShapeUserObject< T >::executeJacobianWrapper ( unsigned int  jvar,
const std::vector< dof_id_type > &  dof_indices 
)
virtual

This function will be called with the shape functions for jvar initialized.

It can be used to compute Jacobian contributions of the by implementing executeJacobian.

Definition at line 136 of file ShapeUserObject.h.

138 {
139  for (_j = 0; _j < _phi.size(); ++_j)
140  {
141  _j_global = dof_indices[_j];
142  executeJacobian(jvar);
143  }
144 }
dof_id_type _j_global
global DOF ID corresponding to _j
unsigned int _j
j-th index for enumerating the shape functions
virtual void executeJacobian(unsigned int)=0
Implement this function to compute Jacobian terms for this UserObject.
const VariablePhiValue & _phi
shape function values

◆ jacobianMooseVariables()

template<typename T>
const std::set<const MooseVariableFEBase *>& ShapeUserObject< T >::jacobianMooseVariables ( ) const
inline

Returns the set of variables a Jacobian has been requested for.

Definition at line 54 of file ShapeUserObject.h.

55  {
57  }
std::set< const MooseVariableFEBase * > _jacobian_moose_variables

◆ validParams()

template<typename T >
InputParameters ShapeUserObject< T >::validParams ( )
static

Definition at line 112 of file ShapeUserObject.h.

Referenced by ShapeElementUserObject::validParams(), and ShapeSideUserObject::validParams().

113 {
115  params.addParam<bool>("compute_jacobians", true, "Compute Jacobians for coupled variables");
116  params.addParamNamesToGroup("compute_jacobians", "Advanced");
117  return params;
118 }
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters emptyInputParameters()
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
This method takes a space delimited list of parameter names and adds them to the specified group name...

Member Data Documentation

◆ _compute_jacobians

template<typename T>
const bool ShapeUserObject< T >::_compute_jacobians
private

◆ _grad_phi

template<typename T>
const VariablePhiGradient& ShapeUserObject< T >::_grad_phi
protected

shape function gradients

Definition at line 85 of file ShapeUserObject.h.

◆ _j

template<typename T>
unsigned int ShapeUserObject< T >::_j
protected

j-th index for enumerating the shape functions

Definition at line 88 of file ShapeUserObject.h.

◆ _j_global

template<typename T>
dof_id_type ShapeUserObject< T >::_j_global
protected

global DOF ID corresponding to _j

Definition at line 91 of file ShapeUserObject.h.

◆ _jacobian_moose_variables

template<typename T>
std::set<const MooseVariableFEBase *> ShapeUserObject< T >::_jacobian_moose_variables
mutableprivate

◆ _phi

template<typename T>
const VariablePhiValue& ShapeUserObject< T >::_phi
protected

shape function values

Definition at line 82 of file ShapeUserObject.h.


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