https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
15template <typename Base>
16class KokkosIntegralPostprocessor : public Base
17{
18public:
20
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
34protected:
35 const bool _average;
36};
37
38template <typename Base>
39template <typename Derived>
40KOKKOS_FUNCTION void
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
58template <typename Base>
59template <typename Derived>
60KOKKOS_FUNCTION void
61KokkosIntegralPostprocessor<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
69template <typename Base>
70template <typename Derived>
71KOKKOS_FUNCTION void
73{
74 result[0] = 0;
75
76 if (_average)
77 result[1] = 0;
78}
79
KokkosIntegralPostprocessor< Moose::Kokkos::ElementPostprocessor > KokkosElementIntegralPostprocessor
KokkosIntegralPostprocessor< Moose::Kokkos::SidePostprocessor > KokkosSideIntegralPostprocessor
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
static InputParameters validParams()
KOKKOS_FUNCTION void init(Real *result) const
virtual Real getValue() const override
KOKKOS_FUNCTION void reduce(Datum &datum, Real *result) const
virtual void initialize() override
KOKKOS_FUNCTION void join(Real *result, const Real *source) const
KokkosIntegralPostprocessor(const InputParameters &parameters)
virtual void finalize() override
The Kokkos object that holds thread-private data in the parallel operations of any Kokkos object.
KOKKOS_FUNCTION Real JxW(const unsigned int qp)
Get the transformed Jacobian weight.
KOKKOS_FUNCTION unsigned int n_qps() const
Get the number of local quadrature points.