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< MooseVariable * > & 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< MooseVariable * > _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 47 of file ShapeUserObject.h.

Constructor & Destructor Documentation

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

Definition at line 105 of file ShapeUserObject.h.

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

Member Function Documentation

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

check if jacobian is to be computed in user objects

Definition at line 53 of file ShapeUserObject.h.

53 { return _compute_jacobians; }
const bool _compute_jacobians
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 128 of file ShapeUserObject.h.

129 {
130  MooseVariable * var = Coupleable::getVar(var_name, comp);
131 
132  // add to the set of variables for which executeJacobian will be called
134  _jacobian_moose_variables.insert(var);
135 
136  // return the variable number
137  return T::coupled(var_name, comp);
138 }
const bool _compute_jacobians
Class for stuff related to variables.
Definition: MooseVariable.h:43
std::set< MooseVariable * > _jacobian_moose_variables
Moose::VarKindType kind() const
Kind of the variable (Nonlinear, Auxiliary, ...)
MooseVariable * getVar(const std::string &var_name, unsigned int comp)
Extract pointer to a coupled variable.
Definition: Coupleable.C:117
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.

Referenced by ShapeUserObject< T >::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 142 of file ShapeUserObject.h.

Referenced by ComputeUserObjectsThread::onBoundary(), and ComputeUserObjectsThread::onElement().

144 {
145  for (_j = 0; _j < _phi.size(); ++_j)
146  {
147  _j_global = dof_indices[_j];
148  executeJacobian(jvar);
149  }
150 }
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.
unsigned int size() const
The number of elements that can currently be stored in the array.
Definition: MooseArray.h:250
const VariablePhiValue & _phi
shape function values
template<typename T>
const std::set<MooseVariable *>& ShapeUserObject< T >::jacobianMooseVariables ( ) const
inline

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

Definition at line 58 of file ShapeUserObject.h.

59  {
61  }
std::set< MooseVariable * > _jacobian_moose_variables
template<typename T >
InputParameters ShapeUserObject< T >::validParams ( )
static

Definition at line 118 of file ShapeUserObject.h.

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

119 {
121  params.addParam<bool>("compute_jacobians", true, "Compute Jacobians for coupled variables");
122  params.addParamNamesToGroup("compute_jacobians", "Advanced");
123  return params;
124 }
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

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

Definition at line 100 of file ShapeUserObject.h.

Referenced by ShapeUserObject< T >::coupled().

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

shape function gradients

Definition at line 91 of file ShapeUserObject.h.

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

j-th index for enumerating the shape functions

Definition at line 94 of file ShapeUserObject.h.

Referenced by ShapeUserObject< T >::executeJacobianWrapper().

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

global DOF ID corresponding to _j

Definition at line 97 of file ShapeUserObject.h.

Referenced by ShapeUserObject< T >::executeJacobianWrapper().

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

Definition at line 101 of file ShapeUserObject.h.

Referenced by ShapeUserObject< T >::coupled().

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

shape function values

Definition at line 88 of file ShapeUserObject.h.

Referenced by ShapeUserObject< T >::executeJacobianWrapper().


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