Line data Source code
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 : 12 : #include "KokkosNodalVariablePostprocessor.h" 13 : 14 : class KokkosNodalMaxValueId : public KokkosNodalVariablePostprocessor 15 : { 16 : public: 17 : static InputParameters validParams(); 18 : 19 : KokkosNodalMaxValueId(const InputParameters & parameters); 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 19573 : KOKKOS_FUNCTION Real computeValue(const unsigned int qp, Datum & datum) const 29 : { 30 19573 : 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: 39 : dof_id_type _node_id = libMesh::DofObject::invalid_id; 40 : }; 41 : 42 : template <typename Derived> 43 : KOKKOS_FUNCTION void 44 19573 : KokkosNodalMaxValueId::reduce(Datum & datum, Real * result) const 45 : { 46 19573 : if (datum.isNodalDefined(_u.variable())) 47 : { 48 19573 : Real value = static_cast<const Derived *>(this)->computeValue(0, datum); 49 : 50 19573 : if (value > result[0]) 51 : { 52 342 : result[0] = value; 53 342 : result[1] = datum.node(); 54 : } 55 : } 56 19573 : } 57 : 58 : template <typename Derived> 59 : KOKKOS_FUNCTION void 60 6 : KokkosNodalMaxValueId::join(Real * result, const Real * source) const 61 : { 62 6 : if (source[0] > result[0]) 63 : { 64 0 : result[0] = source[0]; 65 0 : result[1] = source[1]; 66 : } 67 6 : } 68 : 69 : template <typename Derived> 70 : KOKKOS_FUNCTION void 71 55 : KokkosNodalMaxValueId::init(Real * result) const 72 : { 73 55 : result[0] = Kokkos::Experimental::finite_min_v<Real>; 74 55 : }