https://mooseframework.inl.gov
KokkosMatCoupledForce.h
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 #pragma once
11 
12 #include "KokkosKernelValue.h"
13 #include "KokkosMap.h"
14 
22 {
23 public:
25 
27 
28  template <typename Derived>
29  KOKKOS_FUNCTION Real computeQpResidual(const unsigned int qp, AssemblyDatum & datum) const;
30  template <typename Derived>
31  KOKKOS_FUNCTION Real computeQpOffDiagJacobian(const unsigned int j,
32  const unsigned int jvar,
33  const unsigned int qp,
34  AssemblyDatum & datum) const;
35 
36 private:
37  const unsigned int _n_coupled;
38  const bool _coupled_props;
39  std::vector<unsigned int> _v_var;
44 };
45 
46 template <typename Derived>
47 KOKKOS_FUNCTION Real
48 KokkosMatCoupledForce::computeQpResidual(const unsigned int qp, AssemblyDatum & datum) const
49 {
50  Real r = 0;
51  if (_coupled_props)
52  for (unsigned int j = 0; j < _n_coupled; ++j)
53  r += -_coef[j] * _mat_props[j](datum, qp) * _v(datum, qp, j);
54  else
55  for (unsigned int j = 0; j < _n_coupled; ++j)
56  r += -_coef[j] * _v(datum, qp, j);
57  return r;
58 }
59 
60 template <typename Derived>
61 KOKKOS_FUNCTION Real
63  const unsigned int jvar,
64  const unsigned int qp,
65  AssemblyDatum & datum) const
66 {
67  if (!_v_var_to_index.exists(jvar))
68  return 0;
69 
70  unsigned int p = _v_var_to_index[jvar];
71 
72  if (_coupled_props)
73  return -_coef[p] * _mat_props[p](datum, qp) * _phi(datum, j, qp);
74  return -_coef[p] * _phi(datum, j, qp);
75 }
const Moose::Kokkos::VariableValue _v
Moose::Kokkos::Map< unsigned int, unsigned int > _v_var_to_index
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseBase.h:131
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Moose::Kokkos::Array< Real > _coef
The base class for a user to derive their own Kokkos kernels where the residual is of the form...
Moose::Kokkos::Array< Moose::Kokkos::MaterialProperty< Real > > _mat_props
const unsigned int _n_coupled
Represents a right hand side force term of the form Sum_j c_j * m_j * v_j, where c is a vector of rea...
KOKKOS_FUNCTION Real computeQpResidual(const unsigned int qp, AssemblyDatum &datum) const
The Kokkos wrapper classes for MOOSE-like variable value access.
static InputParameters validParams()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
The Kokkos wrapper class for standard map.
Definition: KokkosMap.h:58
The Kokkos object that holds thread-private data in the parallel operations of Kokkos kernels...
Definition: KokkosDatum.h:364
std::vector< unsigned int > _v_var
KokkosMatCoupledForce(const InputParameters &parameters)
const VariablePhiValue _phi
Current shape function.
Definition: KokkosKernel.h:181
KOKKOS_FUNCTION Real computeQpOffDiagJacobian(const unsigned int j, const unsigned int jvar, const unsigned int qp, AssemblyDatum &datum) const