https://mooseframework.inl.gov
KokkosIntegralPostprocessor.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 
14 
15 template <typename Base>
16 class KokkosIntegralPostprocessor : public Base
17 {
18 public:
20 
21  KokkosIntegralPostprocessor(const InputParameters & parameters);
22 
23  virtual void initialize() override;
24  virtual Real getValue() const override;
25  virtual void finalize() override;
26 
27  template <typename Derived>
28  KOKKOS_FUNCTION void reduce(Datum & datum, Real * result) const;
29  template <typename Derived>
30  KOKKOS_FUNCTION void join(Real * result, const Real * source) const;
31  template <typename Derived>
32  KOKKOS_FUNCTION void init(Real * result) const;
33 
34 protected:
35  const bool _average;
36 };
37 
38 template <typename Base>
39 template <typename Derived>
40 KOKKOS_FUNCTION void
41 KokkosIntegralPostprocessor<Base>::reduce(Datum & datum, Real * result) const
42 {
43  Real sum = 0;
44  Real vol = 0;
45 
46  for (unsigned int qp = 0; qp < datum.n_qps(); ++qp)
47  {
48  sum += datum.JxW(qp) * static_cast<const Derived *>(this)->computeQpIntegral(qp, datum);
49  vol += datum.JxW(qp);
50  }
51 
52  result[0] += sum;
53 
54  if (_average)
55  result[1] += vol;
56 }
57 
58 template <typename Base>
59 template <typename Derived>
60 KOKKOS_FUNCTION void
61 KokkosIntegralPostprocessor<Base>::join(Real * result, const Real * source) const
62 {
63  result[0] += source[0];
64 
65  if (_average)
66  result[1] += source[1];
67 }
68 
69 template <typename Base>
70 template <typename Derived>
71 KOKKOS_FUNCTION void
73 {
74  result[0] = 0;
75 
76  if (_average)
77  result[1] = 0;
78 }
79 
KOKKOS_FUNCTION void reduce(Datum &datum, Real *result) const
KOKKOS_FUNCTION void join(Real *result, const Real *source) const
The Kokkos object that holds thread-private data in the parallel operations of any Kokkos object...
Definition: KokkosDatum.h:23
KokkosIntegralPostprocessor< Moose::Kokkos::SidePostprocessor > KokkosSideIntegralPostprocessor
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual Real getValue() const override
KOKKOS_FUNCTION unsigned int n_qps() const
Get the number of local quadrature points.
Definition: KokkosDatum.h:118
KokkosIntegralPostprocessor< Moose::Kokkos::ElementPostprocessor > KokkosElementIntegralPostprocessor
KokkosIntegralPostprocessor(const InputParameters &parameters)
static InputParameters validParams()
KOKKOS_FUNCTION void init(Real *result) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void finalize() override
virtual void initialize() override
KOKKOS_FUNCTION Real JxW(const unsigned int qp)
Get the transformed Jacobian weight.
Definition: KokkosDatum.h:311