https://mooseframework.inl.gov
KokkosDatum.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 #include "KokkosAssembly.h"
14 #include "KokkosSystem.h"
15 #include "KokkosVariable.h"
16 
17 namespace Moose
18 {
19 namespace Kokkos
20 {
21 
25 class Datum
26 {
27 public:
35  KOKKOS_FUNCTION
37  const unsigned int side,
38  const Assembly & assembly,
39  const Array<System> & systems)
41  _systems(systems),
42  _elem(assembly.kokkosMesh().getElementInfo(elem)),
43  _side(side),
44  _neighbor(_side != libMesh::invalid_uint ? assembly.kokkosMesh().getNeighbor(_elem.id, side)
45  : libMesh::DofObject::invalid_id),
46  _n_qps(side == libMesh::invalid_uint ? assembly.getNumQps(_elem)
47  : assembly.getNumFaceQps(_elem, side)),
49  : assembly.getQpFaceOffset(_elem, side))
50  {
51  }
58  KOKKOS_FUNCTION
59  Datum(const ContiguousElementID elem, const Assembly & assembly, const Array<System> & systems)
60  : Datum(elem, libMesh::invalid_uint, assembly, systems)
61  {
62  }
63 
68  KOKKOS_FUNCTION const Assembly & assembly() const { return _assembly; }
74  KOKKOS_FUNCTION const System & system(unsigned int sys) const { return _systems[sys]; }
75 
80  KOKKOS_FUNCTION const ElementInfo & elem() const { return _elem; }
85  KOKKOS_FUNCTION ContiguousSubdomainID subdomain() const { return _elem.subdomain; }
90  KOKKOS_FUNCTION unsigned int side() const { return _side; }
95  KOKKOS_FUNCTION unsigned int n_qps() const { return _n_qps; }
100  KOKKOS_FUNCTION dof_id_type qpOffset() const { return _qp_offset; }
105  KOKKOS_FUNCTION bool hasNeighbor() const { return _neighbor != libMesh::DofObject::invalid_id; }
106 
115  KOKKOS_FUNCTION const Real33 & J(const unsigned int qp)
116  {
117  reinitTransform(qp);
118 
119  return _J;
120  }
126  KOKKOS_FUNCTION Real JxW(const unsigned int qp)
127  {
128  reinitTransform(qp);
129 
130  return _JxW;
131  }
137  KOKKOS_FUNCTION Real3 q_point(const unsigned int qp)
138  {
139  reinitTransform(qp);
140 
141  return _xyz;
142  }
143 
147  KOKKOS_FUNCTION void reinit() { _transform_reinit = false; }
148 
149 protected:
165  const unsigned int _side;
173  const unsigned int _n_qps;
178 
179 private:
184  KOKKOS_FUNCTION void reinitTransform(const unsigned int qp);
185 
189  bool _transform_reinit = false;
193  Real33 _J;
198 };
199 
200 KOKKOS_FUNCTION inline void
201 Datum::reinitTransform(const unsigned int qp)
202 {
203  if (_transform_reinit)
204  return;
205 
207  {
208  _J = _assembly.getJacobian(_elem, qp);
209  _JxW = _assembly.getJxW(_elem, qp);
210  _xyz = _assembly.getQPoint(_elem, qp);
211  }
212  else
214 
215  _transform_reinit = true;
216 }
217 
222 class ResidualDatum : public Datum
223 {
224 public:
235  KOKKOS_FUNCTION
237  const unsigned int side,
238  const Assembly & assembly,
239  const Array<System> & systems,
240  const Variable & ivar,
241  const unsigned int jvar,
242  const unsigned int comp = 0)
243  : Datum(elem, side, assembly, systems),
244  _tag(ivar.tag()),
245  _ivar(ivar.var(comp)),
246  _jvar(jvar),
247  _ife(systems[ivar.sys(comp)].getFETypeID(_ivar)),
248  _jfe(systems[ivar.sys(comp)].getFETypeID(_jvar)),
249  _n_idofs(assembly.getNumDofs(_elem.type, _ife)),
250  _n_jdofs(assembly.getNumDofs(_elem.type, _jfe))
251  {
252  }
262  KOKKOS_FUNCTION
264  const Assembly & assembly,
265  const Array<System> & systems,
266  const Variable & ivar,
267  const unsigned int jvar,
268  const unsigned int comp = 0)
269  : ResidualDatum(elem, libMesh::invalid_uint, assembly, systems, ivar, jvar, comp)
270  {
271  }
272 
277  KOKKOS_FUNCTION unsigned int n_dofs() const { return _n_idofs; }
282  KOKKOS_FUNCTION unsigned int n_idofs() const { return _n_idofs; }
287  KOKKOS_FUNCTION unsigned int n_jdofs() const { return _n_jdofs; }
292  KOKKOS_FUNCTION unsigned int var() const { return _ivar; }
297  KOKKOS_FUNCTION unsigned int ivar() const { return _ivar; }
302  KOKKOS_FUNCTION unsigned int jvar() const { return _jvar; }
307  KOKKOS_FUNCTION unsigned int fe() const { return _ife; }
312  KOKKOS_FUNCTION unsigned int ife() const { return _ife; }
317  KOKKOS_FUNCTION unsigned int jfe() const { return _jfe; }
318 
319 protected:
323  const TagID _tag;
327  const unsigned int _ivar, _jvar;
331  const unsigned int _ife, _jfe;
335  const unsigned int _n_idofs, _n_jdofs;
336 };
337 
338 } // namespace Kokkos
339 } // namespace Moose
340 
const unsigned int _n_jdofs
Definition: KokkosDatum.h:335
KOKKOS_FUNCTION unsigned int n_jdofs() const
Get the number of local DOFs for the coupled variable.
Definition: KokkosDatum.h:287
The Kokkos array class.
Definition: KokkosArray.h:56
The Kokkos assembly class.
The Kokkos object that contains the information of an element The IDs used in Kokkos are different fr...
Definition: KokkosMesh.h:35
The Kokkos object that holds thread-private data in the parallel operations of any Kokkos object...
Definition: KokkosDatum.h:25
const unsigned int invalid_uint
const Assembly & _assembly
Reference of the Kokkos assembly.
Definition: KokkosDatum.h:153
unsigned int TagID
Definition: MooseTypes.h:210
KOKKOS_FUNCTION unsigned int var() const
Get the variable number.
Definition: KokkosDatum.h:292
KOKKOS_FUNCTION unsigned int fe() const
Get the variable FE type ID.
Definition: KokkosDatum.h:307
dof_id_type ContiguousElementID
Definition: KokkosMesh.h:20
const unsigned int _ife
FE type IDs of variables.
Definition: KokkosDatum.h:331
const unsigned int _jvar
Definition: KokkosDatum.h:327
Moose::Kokkos::Datum Datum
Definition: KokkosDatum.h:341
const unsigned int _jfe
Definition: KokkosDatum.h:331
const unsigned int _n_idofs
Number of local DOFs.
Definition: KokkosDatum.h:335
const unsigned int _side
Current side index.
Definition: KokkosDatum.h:165
Moose::Kokkos::ResidualDatum ResidualDatum
Definition: KokkosDatum.h:342
KOKKOS_FUNCTION Real3 q_point(const unsigned int qp)
Get the physical quadrature point coordinate.
Definition: KokkosDatum.h:137
const unsigned int _n_qps
Number of local quadrature points.
Definition: KokkosDatum.h:173
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
The Kokkos system class.
Definition: KokkosSystem.h:35
const ElementInfo _elem
Current element information object.
Definition: KokkosDatum.h:161
KOKKOS_FUNCTION unsigned int n_dofs() const
Get the number of local DOFs.
Definition: KokkosDatum.h:277
KOKKOS_FUNCTION const Real33 & J(const unsigned int qp)
Get the inverse of Jacobian matrix | dxi/dx deta/dx dzeta/dx | | dxi/dy deta/dy dzeta/dy | | dxi/dz d...
Definition: KokkosDatum.h:115
KOKKOS_FUNCTION unsigned int side() const
Get the side index.
Definition: KokkosDatum.h:90
const unsigned int _ivar
Variable numbers.
Definition: KokkosDatum.h:327
KOKKOS_FUNCTION unsigned int n_qps() const
Get the number of local quadrature points.
Definition: KokkosDatum.h:95
KOKKOS_FUNCTION unsigned int ife() const
Get the variable FE type ID.
Definition: KokkosDatum.h:312
static const dof_id_type invalid_id
KOKKOS_FUNCTION const Assembly & assembly() const
Get the Kokkos assembly.
Definition: KokkosDatum.h:68
KOKKOS_FUNCTION ResidualDatum(const ContiguousElementID elem, const unsigned int side, const Assembly &assembly, const Array< System > &systems, const Variable &ivar, const unsigned int jvar, const unsigned int comp=0)
Constructor.
Definition: KokkosDatum.h:236
KOKKOS_FUNCTION ContiguousSubdomainID subdomain() const
Get the contiguous subdomain ID.
Definition: KokkosDatum.h:85
KOKKOS_FUNCTION void reinitTransform(const unsigned int qp)
Compute and cache the physical transformation data.
Definition: KokkosDatum.h:201
KOKKOS_FUNCTION Real getJxW(ElementInfo info, unsigned int qp) const
Get the transformed Jacobian weight of an element quadrature point.
ContiguousSubdomainID subdomain
Contiguous subdomain ID.
Definition: KokkosMesh.h:48
const dof_id_type _qp_offset
Starting offset into the global quadrature point index.
Definition: KokkosDatum.h:177
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const TagID _tag
Solution tag ID.
Definition: KokkosDatum.h:323
bool _transform_reinit
Flag whether the physical transformation data was cached.
Definition: KokkosDatum.h:189
The Kokkos variable object that carries the coupled variable and tag information. ...
KOKKOS_FUNCTION const ElementInfo & elem() const
Get the element information object.
Definition: KokkosDatum.h:80
KOKKOS_FUNCTION ResidualDatum(const ContiguousElementID elem, const Assembly &assembly, const Array< System > &systems, const Variable &ivar, const unsigned int jvar, const unsigned int comp=0)
Constructor for elemental data.
Definition: KokkosDatum.h:263
const ContiguousElementID _neighbor
Current contiguous element ID of neighbor.
Definition: KokkosDatum.h:169
KOKKOS_FUNCTION Real JxW(const unsigned int qp)
Get the transformed Jacobian weight.
Definition: KokkosDatum.h:126
KOKKOS_FUNCTION Datum(const ContiguousElementID elem, const unsigned int side, const Assembly &assembly, const Array< System > &systems)
Constructor.
Definition: KokkosDatum.h:36
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
KOKKOS_FUNCTION Datum(const ContiguousElementID elem, const Assembly &assembly, const Array< System > &systems)
Constructor for elemental data.
Definition: KokkosDatum.h:59
KOKKOS_FUNCTION const System & system(unsigned int sys) const
Get the Kokkos system.
Definition: KokkosDatum.h:74
KOKKOS_FUNCTION dof_id_type qpOffset() const
Get the starting offset into the global quadrature point index.
Definition: KokkosDatum.h:100
KOKKOS_FUNCTION unsigned int jvar() const
Get the coupled variable number.
Definition: KokkosDatum.h:302
KOKKOS_FUNCTION unsigned int jfe() const
Get the coupled variable FE type ID.
Definition: KokkosDatum.h:317
The Kokkos object that holds thread-private data in the parallel operations of Kokkos residual object...
Definition: KokkosDatum.h:222
const Array< System > & _systems
Reference of the Kokkos systems.
Definition: KokkosDatum.h:157
KOKKOS_FUNCTION void reinit()
Reset the reinit flag.
Definition: KokkosDatum.h:147
KOKKOS_FUNCTION unsigned int n_idofs() const
Get the number of local DOFs.
Definition: KokkosDatum.h:282
KOKKOS_FUNCTION Real33 getJacobian(ElementInfo info, unsigned int qp) const
Get the inverse of Jacobian matrix of an element quadrature point.
KOKKOS_FUNCTION unsigned int ivar() const
Get the variable number.
Definition: KokkosDatum.h:297
KOKKOS_FUNCTION bool hasNeighbor() const
Get whether the current side has a neighbor.
Definition: KokkosDatum.h:105
uint8_t dof_id_type
Real33 _J
Cached physical transformation data.
Definition: KokkosDatum.h:194
KOKKOS_FUNCTION void computePhysicalMap(const ElementInfo info, const unsigned int qp, Real33 *const jacobian, Real *const JxW, Real3 *const q_points) const
Compute physical transformation data for an element.
KOKKOS_FUNCTION Real3 getQPoint(ElementInfo info, unsigned int qp) const
Get the coordinate of an element quadrature point.