https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
18class Coupleable;
19
20namespace Moose::Kokkos
21{
22
27{
28public:
30
34 Variable() = default;
41 Variable(const MooseVariableFieldBase & variable, const TagID tag) { init(variable, tag); }
49 {
50 init(variable, tag_name);
51 }
59 Variable(const std::vector<const MooseVariableFieldBase *> & variables, const TagID tag)
60 {
61 init(variables, tag);
62 }
63 Variable(const std::vector<MooseVariableFieldBase *> & variables, const TagID tag)
64 {
65 init(variables, tag);
66 }
68
75 Variable(const std::vector<const MooseVariableFieldBase *> & variables,
77 {
78 init(variables, tag_name);
79 }
80 Variable(const std::vector<MooseVariableFieldBase *> & variables,
82 {
83 init(variables, tag_name);
84 }
86
91 void init(const MooseVariableFieldBase & variable, const TagID tag);
97 void init(const MooseVariableFieldBase & variable,
105 void init(const std::vector<const MooseVariableFieldBase *> & variables, const TagID tag);
106 void init(const std::vector<MooseVariableFieldBase *> & variables, const TagID tag);
108
114 void init(const std::vector<const MooseVariableFieldBase *> & variables,
116 void init(const std::vector<MooseVariableFieldBase *> & variables,
119
123 void init(const std::vector<Real> & values, CoupleableKey);
128 void init(const std::vector<Real3> & values, CoupleableKey);
129
135 const MooseVariableFieldBase * mooseVar(unsigned int comp = 0)
136 {
137 return _moose_var.size() ? _moose_var[comp] : nullptr;
138 }
139
144 KOKKOS_FUNCTION bool initialized() const { return _initialized; }
149 KOKKOS_FUNCTION bool coupled() const { return _coupled; }
154 KOKKOS_FUNCTION bool nodal() const { return _nodal; }
159 KOKKOS_FUNCTION bool dot() const { return _dot; }
164 KOKKOS_FUNCTION bool old() const { return _old; }
169 KOKKOS_FUNCTION bool vector() const { return _vector; }
174 KOKKOS_FUNCTION unsigned int components() const { return _components; }
179 KOKKOS_FUNCTION TagID tag() const { return _tag; }
185 KOKKOS_FUNCTION unsigned int var(unsigned int comp = 0) const { return _var[comp]; }
191 KOKKOS_FUNCTION unsigned int sys(unsigned int comp = 0) const { return _sys[comp]; }
197 KOKKOS_FUNCTION Real value(unsigned int comp = 0) const
198 {
200
201 return _default_value[comp];
202 }
208 KOKKOS_FUNCTION Real3 vectorValue(unsigned int comp = 0) const
209 {
211
213 }
214
215private:
219 bool _initialized = false;
223 bool _coupled = false;
227 bool _nodal = false;
231 bool _dot = false;
235 bool _old = false;
239 bool _vector = false;
243 unsigned int _components = 1;
268};
269
270} // namespace Moose::Kokkos
unsigned int TagID
Definition MooseTypes.h:238
std::array< Real, 2 > values
Definition MortarUtils.C:52
Interface for objects that needs coupling capabilities.
Definition Coupleable.h:53
This class provides an interface for common operations on field variables of both FE and FV types wit...
KOKKOS_FUNCTION index_type size() const
Get the total array size.
The Kokkos array class.
The Kokkos variable object that carries the coupled variable and tag information.
TagID _tag
Vector tag ID.
bool _vector
Whether the variable is vector variable.
KOKKOS_FUNCTION unsigned int components() const
Get the number of components.
void init(const MooseVariableFieldBase &variable, const TagID tag)
Initialize the variable with a MOOSE variable and vector tag ID.
void init(const std::vector< Real3 > &values, CoupleableKey)
Initialize the variable with default coupled vector values.
KOKKOS_FUNCTION bool vector() const
Get whether the variable is vector variable.
KOKKOS_FUNCTION bool old() const
Get whether the tag is old/older value.
KOKKOS_FUNCTION Real value(unsigned int comp=0) const
Get the default value of a component.
bool _initialized
Whether the variable is initialized.
KOKKOS_FUNCTION unsigned int var(unsigned int comp=0) const
Get the variable number of a component.
void init(const MooseVariableFieldBase &variable, const TagName &tag_name=Moose::SOLUTION_TAG)
Initialize the variable with a MOOSE variable and vector tag name.
KOKKOS_FUNCTION bool coupled() const
Get whether the variable is coupled.
bool _dot
Whether the tag is time derivative.
void init(const std::vector< const MooseVariableFieldBase * > &variables, const TagName &tag_name=Moose::SOLUTION_TAG)
Initialize the variable with multiple MOOSE variables and vector tag name.
void init(const std::vector< MooseVariableFieldBase * > &variables, const TagID tag)
bool _old
Whether the tag is old/older value.
KOKKOS_FUNCTION bool nodal() const
Get whether the variable is nodal.
KOKKOS_FUNCTION TagID tag() const
Get the vector tag ID.
Array< unsigned int > _sys
System number of each component.
KOKKOS_FUNCTION Real3 vectorValue(unsigned int comp=0) const
Get the default vector value of a component.
bool _nodal
Whether the variable is nodal.
Array< unsigned int > _var
Variable number of each component.
KOKKOS_FUNCTION bool dot() const
Get whether the tag is time derivative.
Array< Real3 > _default_vector_value
Default vector value of each component when the variable is not coupled.
Array< const MooseVariableFieldBase * > _moose_var
MOOSE variable of each component.
const MooseVariableFieldBase * mooseVar(unsigned int comp=0)
Get the MOOSE variable of a component.
unsigned int _components
Number of components.
Array< Real > _default_value
Default value of each component when the variable is not coupled.
Variable(const std::vector< const MooseVariableFieldBase * > &variables, const TagID tag)
Constructor Initialize the variable with multiple MOOSE variables and vector tag ID.
Variable()=default
Default constructor.
bool _coupled
Whether the variable is coupled.
KOKKOS_FUNCTION bool initialized() const
Get whether the variable is initialized.
Variable(const MooseVariableFieldBase &variable, const TagName &tag_name=Moose::SOLUTION_TAG)
Constructor Initialize the variable with a MOOSE variable and vector tag name.
KOKKOS_FUNCTION unsigned int sys(unsigned int comp=0) const
Get the system number of a component.
void init(const std::vector< MooseVariableFieldBase * > &variables, const TagName &tag_name=Moose::SOLUTION_TAG)
void init(const std::vector< Real > &values, CoupleableKey)
Initialize the variable with default coupled values.
void init(const std::vector< const MooseVariableFieldBase * > &variables, const TagID tag)
Initialize the variable with multiple MOOSE variables and vector tag ID.
Variable(const std::vector< const MooseVariableFieldBase * > &variables, const TagName &tag_name=Moose::SOLUTION_TAG)
Constructor Initialize the variable with multiple MOOSE variables and vector tag name.
Variable(const std::vector< MooseVariableFieldBase * > &variables, const TagName &tag_name=Moose::SOLUTION_TAG)
Variable(const MooseVariableFieldBase &variable, const TagID tag)
Constructor Initialize the variable with a MOOSE variable and vector tag ID.
Variable(const std::vector< MooseVariableFieldBase * > &variables, const TagID tag)
const TagID INVALID_TAG_ID
Definition MooseTypes.C:23
const TagName SOLUTION_TAG
Definition MooseTypes.C:25