https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ADArrayIntegratedBC.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 "ADArrayIntegratedBC.h"
11
12#include "Assembly.h"
13#include "SubProblem.h"
14#include "SystemBase.h"
15
16#include "libmesh/quadrature.h"
17
25
27 : IntegratedBCBase(parameters),
28 MooseVariableInterface<RealEigenVector>(this,
29 false,
30 "variable",
31 Moose::VarKindType::VAR_SOLVER,
32 Moose::VarFieldType::VAR_FIELD_ARRAY),
34 _var(*mooseVariable()),
35 _ad_JxW(_assembly.adJxWFace()),
36 _ad_coord(_assembly.adCoordTransformation()),
37 _use_displaced_mesh(getParam<bool>("use_displaced_mesh")),
38 _normals(_assembly.adNormals()),
39 _test(_var.phiFace()),
40 _grad_test(_var.gradPhiFace()),
41 _u(_var.adSlnFace()),
42 _grad_u(_var.adGradSlnFace()),
43 _count(_var.count()),
44 _work_vector(_count),
45 _raw_work_vector(_count)
46{
49
50 if (!_save_in_strings.empty() || !_diag_save_in_strings.empty())
51 paramError("save_in", "Save-in is not supported by AD array boundary conditions");
52}
53
54void
56{
58
60 for (_qp = 0; _qp < _qrule->n_points(); _qp++)
61 {
63 for (_i = 0; _i < _test.size(); _i++)
64 {
65 _work_vector.setZero();
67 for (const auto c : make_range(_count))
71 }
72 }
73
75}
76
77void
79{
80 _local_ad_re.resize(_test.size() * _count);
81 for (auto & residual : _local_ad_re)
82 residual = 0;
83
85 for (_qp = 0; _qp < _qrule->n_points(); _qp++)
86 {
87 // on a displaced mesh the surface measure depends on the displacements, so its derivatives
88 // enter the Jacobian
90 : ADReal(_JxW[_qp] * _coord[_qp]);
92 for (_i = 0; _i < _test.size(); _i++)
93 {
94 _work_vector.setZero();
96 _work_vector *= jxw_c;
98 }
99 }
100}
101
102void
108
109void
116
117void
119{
120 // AD computes the derivatives with respect to all variables at once
121 if (jvar == _var.number())
123}
124
125void
DualNumber< Real, DNDerivativeType, true > ADReal
unsigned int count
Definition MortarUtils.C:53
virtual void computeQpResidual(ADRealEigenVector &residual)=0
Compute this boundary condition's contribution to the residual at the current quadrature point,...
virtual void computeOffDiagJacobian(unsigned int jvar) override
Computes this object's contribution to off-diagonal blocks of the system Jacobian matrix.
ArrayMooseVariable & _var
The array variable this boundary condition acts on.
virtual void computeResidual() override
Compute this object's contribution to the residual.
const MooseArray< ADReal > & _ad_JxW
Quadrature weights times the face Jacobian, with derivatives on a displaced mesh.
const MooseArray< ADReal > & _ad_coord
Coordinate transformation factors, with derivatives on a displaced mesh.
ADRealEigenVector _work_vector
Work vector for the residual at a quadrature point.
void computeResidualsForJacobian()
Fill _local_ad_re with the AD residuals of all test functions on the current face.
const ArrayVariableTestValue & _test
test function values (in QPs)
const unsigned int _count
Number of components of the array variable.
virtual void computeOffDiagJacobianScalar(unsigned int jvar) override
Computes jacobian block with respect to a scalar variable.
virtual void computeResidualAndJacobian() override
Compute this object's contribution to the residual and Jacobian simultaneously.
const bool _use_displaced_mesh
Whether this boundary condition is evaluated on the displaced mesh.
ADArrayIntegratedBC(const InputParameters &parameters)
static InputParameters validParams()
virtual void computeJacobian() override
Compute this object's contribution to the diagonal Jacobian entries.
std::vector< ADReal > _local_ad_re
Local AD residuals for the Jacobian computation.
RealEigenVector _raw_work_vector
Values of _work_vector without derivatives, for the residual computation.
virtual void initQpResidual()
Put necessary evaluations depending on qp but independent of test functions here.
An interface for accessing Moose::Functors for systems that care about automatic differentiation,...
static InputParameters validParams()
void saveLocalArrayResidual(DenseVector< Number > &re, unsigned int i, unsigned int ntest, const RealEigenVector &v) const
Helper function for assembling residual contriubutions on local quadrature points for an array kernel...
Definition Assembly.h:1815
void saveLocalADArray(std::vector< ADReal > &re, unsigned int i, unsigned int ntest, const ADRealEigenVector &v) const
Definition Assembly.C:3842
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
Base class for deriving any boundary condition of a integrated type.
static InputParameters validParams()
std::vector< AuxVariableName > _diag_save_in_strings
const QBase *const & _qrule
active quadrature rule
unsigned int _qp
quadrature point index
const MooseArray< Real > & _JxW
transformed Jacobian weights
unsigned int _i
i-th, j-th index for enumerating test and shape functions
std::vector< AuxVariableName > _save_in_strings
const MooseArray< Real > & _coord
coordinate transformation
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
Definition MooseBase.h:457
const std::vector< Real > & arrayScalingFactor() const
unsigned int number() const
Get variable number coming from libMesh.
void addMooseVariableDependency(MooseVariableFieldBase *var)
Call this function to add the passed in MooseVariableFieldBase as a variable that this object depends...
const std::vector< dof_id_type > & dofIndices() const final
Get local DoF indices.
Interface for objects that need to get values of MooseVariables.
MooseVariableFE< RealEigenVector > * mooseVariable() const
Return the MooseVariableFE object that this interface acts on.
virtual void precalculateJacobian()
Assembly & _assembly
Reference to this Kernel's assembly object.
SubProblem & _subproblem
Reference to this kernel's SubProblem.
virtual void precalculateResidual()
virtual void haveADObjects(bool have_ad_objects)
Method for setting whether we have any ad objects.
Definition SubProblem.h:778
void addJacobian(Assembly &assembly, const Residuals &residuals, const Indices &dof_indices, Real scaling_factor)
Add the provided residual derivatives into the Jacobian for the provided dof indices.
void accumulateTaggedLocalResidual()
Local residual blocks will be appended by adding the current local kernel residual.
void addResiduals(Assembly &assembly, const Residuals &residuals, const Indices &dof_indices, Real scaling_factor)
Add the provided incoming residuals corresponding to the provided dof indices.
void prepareVectorTag(Assembly &assembly, unsigned int ivar)
Prepare data for computing element residual according to active tags.
DenseVector< Number > _local_re
Holds local residual entries as they are accumulated by this Kernel.
virtual unsigned int size() const override final
auto raw_value(const Eigen::Map< T > &in)
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...