https://mooseframework.inl.gov
KokkosNodalMaxValueId.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 
13 
15 {
16 public:
18 
20 
21  virtual void initialize() override;
22  virtual void finalize() override;
23  virtual Real getValue() const override;
24 
25  template <typename Derived>
26  KOKKOS_FUNCTION void reduce(Datum & datum, Real * result) const;
27 
28  KOKKOS_FUNCTION Real computeValue(const unsigned int qp, Datum & datum) const
29  {
30  return _u(datum, qp);
31  }
32 
33  template <typename Derived>
34  KOKKOS_FUNCTION void join(Real * result, const Real * source) const;
35  template <typename Derived>
36  KOKKOS_FUNCTION void init(Real * result) const;
37 
38 protected:
40 };
41 
42 template <typename Derived>
43 KOKKOS_FUNCTION void
44 KokkosNodalMaxValueId::reduce(Datum & datum, Real * result) const
45 {
46  if (datum.isNodalDefined(_u.variable()))
47  {
48  Real value = static_cast<const Derived *>(this)->computeValue(0, datum);
49 
50  if (value > result[0])
51  {
52  result[0] = value;
53  result[1] = datum.node();
54  }
55  }
56 }
57 
58 template <typename Derived>
59 KOKKOS_FUNCTION void
60 KokkosNodalMaxValueId::join(Real * result, const Real * source) const
61 {
62  if (source[0] > result[0])
63  {
64  result[0] = source[0];
65  result[1] = source[1];
66  }
67 }
68 
69 template <typename Derived>
70 KOKKOS_FUNCTION void
71 KokkosNodalMaxValueId::init(Real * result) const
72 {
73  result[0] = Kokkos::Experimental::finite_min_v<Real>;
74 }
The Kokkos object that holds thread-private data in the parallel operations of any Kokkos object...
Definition: KokkosDatum.h:23
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseBase.h:131
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
KOKKOS_FUNCTION void init(Real *result) const
KOKKOS_FUNCTION bool isNodalDefined(const Variable &var) const
Get whether the a variable is defined on the current node.
Definition: KokkosDatum.h:291
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
KokkosNodalMaxValueId(const InputParameters &parameters)
KOKKOS_FUNCTION Real computeValue(const unsigned int qp, Datum &datum) const
const Moose::Kokkos::VariableValue _u
KOKKOS_FUNCTION void join(Real *result, const Real *source) const
static constexpr dof_id_type invalid_id
KOKKOS_FUNCTION void reduce(Datum &datum, Real *result) const
virtual void finalize() override
We provide default finalize() as getValue() has been abused to perform the final aggregation for a lo...
virtual const OutputTools< Real >::VariableValue & value()
The value of the variable this object is operating on.
static InputParameters validParams()
KOKKOS_FUNCTION const Variable & variable() const
Get the Kokkos variable.
KOKKOS_FUNCTION ContiguousNodeID node() const
Get the contiguous node ID.
Definition: KokkosDatum.h:113
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
uint8_t dof_id_type