https://mooseframework.inl.gov
KokkosCopyValueAux.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 "KokkosAuxKernel.h"
13 
18 {
19 public:
21 
23 
24  template <typename Derived>
25  KOKKOS_FUNCTION void computeElementInternal(const Derived & auxkernel,
26  AssemblyDatum & datum) const;
27  template <typename Derived>
28  KOKKOS_FUNCTION void computeNodeInternal(const Derived & auxkernel, AssemblyDatum & datum) const;
29 
30 protected:
32  unsigned short _state;
33 
36 
39 };
40 
41 template <typename Derived>
42 KOKKOS_FUNCTION void
43 KokkosCopyValueAux::computeElementInternal(const Derived & /* auxkernel */,
44  AssemblyDatum & datum) const
45 {
46  auto & sys = kokkosSystem(_kokkos_var.sys());
47  auto var = _kokkos_var.var();
48  auto tag = _kokkos_var.tag();
49  auto elem = datum.elem().id;
50 
51  for (unsigned int i = 0; i < datum.n_dofs(); ++i)
52  sys.getVectorDofValue(sys.getElemLocalDofIndex(elem, i, var), tag) = _v(datum, i);
53 }
54 
55 template <typename Derived>
56 KOKKOS_FUNCTION void
57 KokkosCopyValueAux::computeNodeInternal(const Derived & /* auxkernel */,
58  AssemblyDatum & datum) const
59 {
60  auto & sys = kokkosSystem(_kokkos_var.sys());
61  auto var = _kokkos_var.var();
62  auto tag = _kokkos_var.tag();
63  auto node = datum.node();
64 
65  sys.getVectorDofValue(sys.getNodeLocalDofIndex(node, 0, var), tag) = _v(datum, 0);
66 }
KOKKOS_FUNCTION TagID tag() const
Get the vector tag ID.
KOKKOS_FUNCTION unsigned int sys(unsigned int comp=0) const
Get the system number of a component.
unsigned short _state
Variable used to specify state being copied.
KokkosCopyValueAux(const InputParameters &parameters)
Class for stuff related to variables.
Definition: Adaptivity.h:31
The base class for a user to derive their own Kokkos auxiliary kernels.
KOKKOS_FUNCTION void computeNodeInternal(const Derived &auxkernel, AssemblyDatum &datum) const
KOKKOS_FUNCTION void computeElementInternal(const Derived &auxkernel, AssemblyDatum &datum) const
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseBase.h:131
Copies one variable onto an auxiliary variable.
Variable _kokkos_var
Kokkos variable.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const Moose::Kokkos::VariableValue _v
The variable value to copy from.
KOKKOS_FUNCTION const System & kokkosSystem(unsigned int sys) const
Get the const reference of a Kokkos system.
Definition: KokkosSystem.h:625
KOKKOS_FUNCTION ContiguousNodeID node() const
Get the contiguous node ID.
Definition: KokkosDatum.h:95
KOKKOS_FUNCTION const ElementInfo & elem() const
Get the element information object.
Definition: KokkosDatum.h:80
const MooseVariable & _source_variable
A reference to the variable to copy from.
The Kokkos object that holds thread-private data in the parallel operations of Kokkos kernels...
Definition: KokkosDatum.h:244
The Kokkos wrapper classes for MOOSE-like variable value access.
KOKKOS_FUNCTION unsigned int var(unsigned int comp=0) const
Get the variable number of a component.
KOKKOS_FUNCTION unsigned int n_dofs() const
Get the number of local DOFs.
Definition: KokkosDatum.h:304
static InputParameters validParams()
ContiguousElementID id
Contiguous element ID.
Definition: KokkosMesh.h:44