https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ArrayTimeDerivative.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#include "ArrayTimeDerivative.h"
11#include "FEProblemBase.h"
13
15
18{
20 params.addClassDescription("Array time derivative operator with the weak form of $(\\psi_i, "
21 "\\frac{\\partial u_h}{\\partial t})$.");
22 params.addParam<MaterialPropertyName>("time_derivative_coefficient",
23 "The name of the time derivative coefficient. "
24 "Can be scalar, vector, or matrix material property.");
25 return params;
26}
27
29 : ArrayTimeKernel(parameters),
30 _has_coefficient(isParamValid("time_derivative_coefficient")),
31 _coeff(_has_coefficient && hasMaterialProperty<Real>("time_derivative_coefficient")
32 ? &getMaterialProperty<Real>("time_derivative_coefficient")
33 : nullptr),
34 _coeff_array(_has_coefficient &&
35 hasMaterialProperty<RealEigenVector>("time_derivative_coefficient")
36 ? &getMaterialProperty<RealEigenVector>("time_derivative_coefficient")
37 : nullptr),
38 _coeff_2d_array(_has_coefficient &&
39 hasMaterialProperty<RealEigenMatrix>("time_derivative_coefficient")
40 ? &getMaterialProperty<RealEigenMatrix>("time_derivative_coefficient")
41 : nullptr)
42{
44 {
45 MaterialPropertyName mat = getParam<MaterialPropertyName>("time_derivative_coefficient");
46 mooseError("Property " + mat + " is of unsupported type for ArrayTimeDerivative");
47 }
48}
49
50void
61
62void
63ArrayTimeDerivative::computeQpResidual(RealEigenVector & residual)
64{
66 residual = _u_dot[_qp] * _test[_i][_qp];
67 else if (_coeff)
68 residual = (*_coeff)[_qp] * _u_dot[_qp] * _test[_i][_qp];
69 else if (_coeff_array)
70 {
71 mooseAssert((*_coeff_array)[_qp].size() == _var.count(),
72 "time_derivative_coefficient size is inconsistent with the number of components "
73 "in array variable");
74 // WARNING: use noalias() syntax with caution. See ArrayDiffusion.C for more details.
75 residual.noalias() = (*_coeff_array)[_qp].asDiagonal() * _u_dot[_qp] * _test[_i][_qp];
76 }
77 else
78 {
79 mooseAssert((*_coeff_2d_array)[_qp].cols() == _var.count(),
80 "time_derivative_coefficient size is inconsistent with the number of components "
81 "in array variable");
82 mooseAssert((*_coeff_2d_array)[_qp].rows() == _var.count(),
83 "time_derivative_coefficient size is inconsistent with the number of components "
84 "in array variable");
85 // WARNING: use noalias() syntax with caution. See ArrayDiffusion.C for more details.
86 residual.noalias() = (*_coeff_2d_array)[_qp] * _u_dot[_qp] * _test[_i][_qp];
87 }
88}
89
90RealEigenVector
92{
93 Real tmp = _test[_i][_qp] * _phi[_j][_qp] * _du_dot_du[_qp];
95 return RealEigenVector::Constant(_var.count(), tmp);
96 else if (_coeff)
97 return RealEigenVector::Constant(_var.count(), tmp * (*_coeff)[_qp]);
98 else if (_coeff_array)
99 return tmp * (*_coeff_array)[_qp];
100 else
101 return tmp * (*_coeff_2d_array)[_qp].diagonal();
102}
103
104RealEigenMatrix
106{
107 if (jvar.number() == _var.number() && _coeff_2d_array)
108 return _phi[_j][_qp] * _test[_i][_qp] * _du_dot_du[_qp] * (*_coeff_2d_array)[_qp];
109 else
111}
registerMooseObject("MooseApp", ArrayTimeDerivative)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
const ArrayVariableTestValue & _test
the current test function
Definition ArrayKernel.h:88
ArrayMooseVariable & _var
This is an array kernel so we cast to a ArrayMooseVariable.
Definition ArrayKernel.h:85
virtual RealEigenMatrix computeQpOffDiagJacobian(const MooseVariableFEBase &jvar)
This is the virtual that derived classes should override for computing a full Jacobian component.
const ArrayVariablePhiValue & _phi
the current shape functions
Definition ArrayKernel.h:95
virtual RealEigenVector computeQpJacobian() override
Compute this Kernel's contribution to the diagonal Jacobian at the current quadrature point.
virtual RealEigenMatrix computeQpOffDiagJacobian(const MooseVariableFEBase &jvar) override
This is the virtual that derived classes should override for computing a full Jacobian component.
const MaterialProperty< RealEigenVector > *const _coeff_array
array time derivative coefficient
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job.
const MaterialProperty< RealEigenMatrix > *const _coeff_2d_array
matrix time derivative coefficient
virtual void computeQpResidual(RealEigenVector &residual) override
Compute this Kernel's contribution to the residual at the current quadrature point,...
const MaterialProperty< Real > *const _coeff
scalar time derivative coefficient
static InputParameters validParams()
const bool _has_coefficient
whether or not the coefficient property is provided
ArrayTimeDerivative(const InputParameters &parameters)
All array time kernels should inherit from this class.
const VariableValue & _du_dot_du
Derivative of u_dot with respect to u.
const ArrayVariableValue & _u_dot
Time derivative of \vec{u}.
static InputParameters validParams()
virtual const std::set< SubdomainID > & blockIDs() const
Return the block subdomain ids for this object Note, if this is not block restricted,...
const std::set< SubdomainID > & meshBlockIDs() const
Return all of the SubdomainIDs for the mesh.
virtual bool blockRestricted() const
Returns true if this object has been restricted to a block.
const MaterialWarehouse & getMaterialWarehouse() const
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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 addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
unsigned int _qp
The current quadrature point index.
Definition KernelBase.h:43
unsigned int _j
current index for the shape function
Definition KernelBase.h:61
unsigned int _i
current index for the test function
Definition KernelBase.h:58
unsigned int number() const
Get variable number coming from libMesh.
unsigned int count() const
Get the number of components Note: For standard and vector variables, the number is one.
This class provides an interface for common operations on field variables of both FE and FV types wit...
FEProblemBase & _fe_problem
Reference to this kernel's FEProblemBase.
void checkArrayMaterialPropertySize(const MooseObject &object, const MaterialWarehouse &warehouse, const std::set< SubdomainID > &blocks, const std::string &param_name, std::size_t count, bool is_matrix)
Check during setup that an array material property used as a coefficient has one entry per component ...