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 "KokkosKernel.h"
13 #include "KokkosMap.h"
14 
21 class KokkosMatCoupledForce final : public Moose::Kokkos::Kernel<KokkosMatCoupledForce>
22 {
23 public:
25 
27 
28  KOKKOS_FUNCTION Real computeQpResidual(const unsigned int i,
29  const unsigned int qp,
30  ResidualDatum & datum) const;
31  KOKKOS_FUNCTION Real computeQpOffDiagJacobian(const unsigned int i,
32  const unsigned int j,
33  const unsigned int jvar,
34  const unsigned int qp,
35  ResidualDatum & datum) const;
36 
37 private:
38  const unsigned int _n_coupled;
39  const bool _coupled_props;
40  std::vector<unsigned int> _v_var;
45 };
46 
47 KOKKOS_FUNCTION inline Real
49  const unsigned int qp,
50  ResidualDatum & datum) const
51 {
52  Real r = 0;
53  if (_coupled_props)
54  for (unsigned int j = 0; j < _n_coupled; ++j)
55  r += -_coef[j] * _mat_props[j](datum, qp) * _v(datum, qp, j);
56  else
57  for (unsigned int j = 0; j < _n_coupled; ++j)
58  r += -_coef[j] * _v(datum, qp, j);
59  return r * _test(datum, i, qp);
60 }
61 
62 KOKKOS_FUNCTION inline Real
64  const unsigned int j,
65  const unsigned int jvar,
66  const unsigned int qp,
67  ResidualDatum & datum) const
68 {
69  if (!_v_var_to_index.exists(jvar))
70  return 0;
71 
72  unsigned int p = _v_var_to_index[jvar];
73 
74  if (_coupled_props)
75  return -_coef[p] * _mat_props[p](datum, qp) * _phi(datum, j, qp) * _test(datum, i, qp);
76  return -_coef[p] * _phi(datum, j, qp) * _test(datum, i, qp);
77 }
const VariablePhiValue _phi
Current shape function.
Definition: KokkosKernel.h:159
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
KOKKOS_FUNCTION Real computeQpOffDiagJacobian(const unsigned int i, const unsigned int j, const unsigned int jvar, const unsigned int qp, ResidualDatum &datum) const
Moose::Kokkos::Array< Moose::Kokkos::MaterialProperty< Real > > _mat_props
const unsigned int _n_coupled
KOKKOS_FUNCTION Real computeQpResidual(const unsigned int i, const unsigned int qp, ResidualDatum &datum) const
KOKKOS_FUNCTION bool exists(const T1 &key) const
Get whether a key exists.
Definition: KokkosMap.h:161
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...
static InputParameters validParams()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< unsigned int > _v_var
KokkosMatCoupledForce(const InputParameters &parameters)
The Kokkos wrapper classes for MOOSE-like variable value access.
The base class for a user to derive their own Kokkos kernels.
Definition: KokkosKernel.h:53
The Kokkos object that holds thread-private data in the parallel operations of Kokkos residual object...
Definition: KokkosDatum.h:222
const VariableTestValue _test
Current test function.
Definition: KokkosKernel.h:151