www.mooseframework.org
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< 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)
 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< 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 42 of file ShapeUserObject.h.

Constructor & Destructor Documentation

◆ ShapeUserObject()

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

Definition at line 100 of file ShapeUserObject.h.

101  : T(parameters),
102  _phi(type == ShapeType::Element ? this->_assembly.phi() : this->_assembly.phiFace()),
103  _grad_phi(type == ShapeType::Element ? this->_assembly.gradPhi()
104  : this->_assembly.gradPhiFace()),
105  _compute_jacobians(MooseObject::getParam<bool>("compute_jacobians"))
106 {
107  mooseWarning("Jacobian calculation in UserObjects is an experimental capability with a "
108  "potentially unstable interface.");
109 }
const bool _compute_jacobians
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
Definition: MooseError.h:220
MatType type
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 48 of file ShapeUserObject.h.

48 { 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 
)
protectedvirtual

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 123 of file ShapeUserObject.h.

124 {
125  MooseVariableFEBase * var = Coupleable::getVar(var_name, comp);
126 
127  // add to the set of variables for which executeJacobian will be called
129  _jacobian_moose_variables.insert(var);
130 
131  // return the variable number
132  return T::coupled(var_name, comp);
133 }
const bool _compute_jacobians
MooseVariable * getVar(const std::string &var_name, unsigned int comp)
Extract pointer to a coupled variable.
Definition: Coupleable.C:200
std::set< MooseVariableFEBase * > _jacobian_moose_variables
Moose::VarKindType kind() const
Kind of the variable (Nonlinear, Auxiliary, ...)

◆ 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 137 of file ShapeUserObject.h.

139 {
140  for (_j = 0; _j < _phi.size(); ++_j)
141  {
142  _j_global = dof_indices[_j];
143  executeJacobian(jvar);
144  }
145 }
dof_id_type _j_global
global DOF ID corresponding to _j
unsigned int _j
j-th index for enumerating the shape functions
unsigned int size() const
The number of elements that can currently be stored in the array.
Definition: MooseArray.h:245
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<MooseVariableFEBase *>& ShapeUserObject< T >::jacobianMooseVariables ( ) const
inline

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

Definition at line 53 of file ShapeUserObject.h.

54  {
56  }
std::set< MooseVariableFEBase * > _jacobian_moose_variables

◆ validParams()

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

Definition at line 113 of file ShapeUserObject.h.

Referenced by validParams< ShapeElementUserObject >(), and validParams< ShapeSideUserObject >().

114 {
116  params.addParam<bool>("compute_jacobians", true, "Compute Jacobians for coupled variables");
117  params.addParamNamesToGroup("compute_jacobians", "Advanced");
118  return params;
119 }
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 option 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 86 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 89 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 92 of file ShapeUserObject.h.

◆ _jacobian_moose_variables

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

◆ _phi

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

shape function values

Definition at line 83 of file ShapeUserObject.h.


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