https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ADKernelStabilized.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 "ADKernelStabilized.h"
11#include "MathUtils.h"
12#include "Assembly.h"
13#include "SystemBase.h"
14#include "ADUtils.h"
15
16// libmesh includes
17#include "libmesh/threads.h"
18
19template <typename T>
25
26template <typename T>
31
32template <typename T>
33void
35{
36 prepareVectorTag(_assembly, _var.number());
37
38 precalculateResidual();
39 const unsigned int n_test = _grad_test.size();
40
41 if (_use_displaced_mesh)
42 for (_qp = 0; _qp < _qrule->n_points(); _qp++)
43 {
44 const auto value = precomputeQpStrongResidual() * _ad_JxW[_qp] * _ad_coord[_qp];
45 for (_i = 0; _i < n_test; _i++) // target for auto vectorization
46 _local_re(_i) += raw_value(_grad_test[_i][_qp] * computeQpStabilization() * value);
47 }
48 else
49 for (_qp = 0; _qp < _qrule->n_points(); _qp++)
50 {
51 const auto value = precomputeQpStrongResidual() * _JxW[_qp] * _coord[_qp];
52 for (_i = 0; _i < n_test; _i++) // target for auto vectorization
53 _local_re(_i) += raw_value(_regular_grad_test[_i][_qp] * computeQpStabilization() * value);
54 }
55
56 accumulateTaggedLocalResidual();
57
58 if (_has_save_in)
59 for (unsigned int i = 0; i < _save_in.size(); i++)
60 _save_in[i]->sys().solution().add_vector(_local_re, _save_in[i]->dofIndices());
61}
62
63template <typename T>
64void
66{
67 if (_residuals.size() != _grad_test.size())
68 _residuals.resize(_grad_test.size(), 0);
69 for (auto & r : _residuals)
70 r = 0;
71
72 precalculateResidual();
73
74 if (_use_displaced_mesh)
75 for (_qp = 0; _qp < _qrule->n_points(); _qp++)
76 {
77 const auto value = precomputeQpStrongResidual() * _ad_JxW[_qp] * _ad_coord[_qp];
78 for (_i = 0; _i < _grad_test.size(); _i++)
79 _residuals[_i] += _grad_test[_i][_qp] * computeQpStabilization() * value;
80 }
81 else
82 for (_qp = 0; _qp < _qrule->n_points(); _qp++)
83 {
84 const auto value = precomputeQpStrongResidual() * _JxW[_qp] * _coord[_qp];
85 for (_i = 0; _i < _grad_test.size(); _i++)
86 _residuals[_i] += _regular_grad_test[_i][_qp] * computeQpStabilization() * value;
87 }
88}
89
90template <typename T>
93{
94 mooseError("Override precomputeQpStrongResidual() in your ADKernelStabilized derived class!");
95}
96
DualNumber< Real, DNDerivativeType, true > ADReal
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
static InputParameters validParams()
ADKernelStabilizedTempl(const InputParameters &parameters)
void computeResidualsForJacobian() override
compute the _residuals member for filling the Jacobian.
virtual void computeResidual() override
Compute this object's contribution to the residual.
virtual ADReal computeQpResidual() override final
Compute this Kernel's contribution to the residual at the current quadrature point.
static InputParameters validParams()
Definition ADKernel.C:24
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.