https://mooseframework.inl.gov
KokkosVariable.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "KokkosTypes.h"
13 
14 #include "MooseTypes.h"
15 #include "MooseVariableBase.h"
16 #include "MoosePassKey.h"
17 
18 class Coupleable;
19 
20 namespace Moose
21 {
22 namespace Kokkos
23 {
24 
28 class Variable
29 {
30 public:
32 
36  Variable() = default;
43  Variable(const MooseVariableBase & variable, const TagID tag) { init(variable, tag); }
50  Variable(const MooseVariableBase & variable, const TagName & tag_name = Moose::SOLUTION_TAG)
51  {
52  init(variable, tag_name);
53  }
59  void init(const MooseVariableBase & variable, const TagID tag);
65  void init(const MooseVariableBase & variable, const TagName & tag_name = Moose::SOLUTION_TAG);
71  void
72  init(const std::vector<const MooseVariableBase *> & variables, const TagID tag, CoupleableKey);
77  void init(const std::vector<Real> & values, CoupleableKey);
78 
83  KOKKOS_FUNCTION bool coupled() const { return _coupled; }
88  KOKKOS_FUNCTION unsigned int components() { return _components; }
93  KOKKOS_FUNCTION TagID tag() const { return _tag; }
99  KOKKOS_FUNCTION unsigned int var(unsigned int comp = 0) const { return _var[comp]; }
105  KOKKOS_FUNCTION unsigned int sys(unsigned int comp = 0) const { return _sys[comp]; }
111  KOKKOS_FUNCTION Real value(unsigned int comp = 0) const
112  {
113  KOKKOS_ASSERT(!_coupled);
114 
115  return _default_value[comp];
116  }
117 
118 private:
122  bool _coupled = false;
126  unsigned int _components = 1;
143 };
144 
145 } // namespace Kokkos
146 } // namespace Moose
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.
::Moose::PassKey<::Coupleable > CoupleableKey
unsigned int TagID
Definition: MooseTypes.h:210
Variable(const MooseVariableBase &variable, const TagID tag)
Constructor Initialize the variable with a MOOSE variable and vector tag ID.
Array< Real > _default_value
Default value of each component when the variable is not coupled.
KOKKOS_FUNCTION bool coupled() const
Get whether the variable is coupled.
Variable(const MooseVariableBase &variable, const TagName &tag_name=Moose::SOLUTION_TAG)
Constructor Initialize the variable with a MOOSE variable and vector tag name.
Variable()=default
Default constructor.
KOKKOS_FUNCTION unsigned int components()
Get the number of components.
Array< unsigned int > _sys
System number of each component.
Interface for objects that needs coupling capabilities.
Definition: Coupleable.h:49
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
bool _coupled
Whether the variable is coupled.
TagID _tag
Vector tag ID.
const TagID INVALID_TAG_ID
Definition: MooseTypes.C:23
KOKKOS_FUNCTION Real value(unsigned int comp=0) const
Get the default value of a component.
The Kokkos variable object that carries the coupled variable and tag information. ...
void init(const MooseVariableBase &variable, const TagID tag)
Initialize the variable with a MOOSE variable and vector tag ID.
const TagName SOLUTION_TAG
Definition: MooseTypes.C:25
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
KOKKOS_FUNCTION unsigned int var(unsigned int comp=0) const
Get the variable number of a component.
unsigned int _components
Number of components.
Array< unsigned int > _var
Variable number of each component.
Base variable class.