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 : // MOOSE includes 13 : #include "MooseUtils.h" 14 : #include "ParallelParamObject.h" 15 : #include "InputParameters.h" 16 : #include "ConsoleStreamInterface.h" 17 : #include "Registry.h" 18 : #include "MooseObjectParameterName.h" 19 : #include "SolutionInvalidInterface.h" 20 : 21 : #define usingMooseObjectMembers \ 22 : usingMooseBaseMembers; \ 23 : using MooseObject::enabled 24 : 25 : /** 26 : * Every object that can be built by the factory should be derived from this class. 27 : */ 28 : class MooseObject : public ParallelParamObject, 29 : public SolutionInvalidInterface, 30 : public std::enable_shared_from_this<MooseObject> 31 : { 32 : public: 33 : static InputParameters validParams(); 34 : 35 : MooseObject(const InputParameters & parameters); 36 : 37 : #ifdef MOOSE_KOKKOS_ENABLED 38 : /** 39 : * Special constructor used for Kokkos functor copy during parallel dispatch 40 : */ 41 : MooseObject(const MooseObject & object, const Moose::Kokkos::FunctorCopy & key); 42 : #endif 43 : 44 2597232 : virtual ~MooseObject() = default; 45 : 46 : /** 47 : * Return the enabled status of the object. 48 : */ 49 163912427 : virtual bool enabled() const { return _enabled; } 50 : 51 : /** 52 : * Get another shared pointer to this object that has the same ownership group. Wrapper around 53 : * shared_from_this(). 54 : */ 55 : std::shared_ptr<MooseObject> getSharedPtr(); 56 : std::shared_ptr<const MooseObject> getSharedPtr() const; 57 : 58 : #ifdef MOOSE_KOKKOS_ENABLED 59 : class IsKokkosObjectKey 60 : { 61 : friend class BlockRestrictable; 62 : friend class BoundaryRestrictable; 63 : friend class MaterialPropertyInterface; 64 : IsKokkosObjectKey() = default; 65 : IsKokkosObjectKey(const IsKokkosObjectKey &) = delete; 66 : IsKokkosObjectKey(IsKokkosObjectKey &&) = delete; 67 : }; 68 : 69 : /** 70 : * Get whether this object is a Kokkos functor 71 : * The parameter is set by the Kokkos base classes: 72 : * - Moose::Kokkos::ResidualObject in KokkosResidualObject.K 73 : * - Moose::Kokkos::MaterialBase in KokkosMaterialBase.K 74 : */ 75 1288388 : bool isKokkosObject(IsKokkosObjectKey &&) const 76 : { 77 1288388 : return parameters().isParamValid(MooseBase::kokkos_object_param); 78 : } 79 : #endif 80 : 81 : // To get warnings tracked in the SolutionInvalidityOutput 82 : usingCombinedWarningSolutionWarnings; 83 : 84 : protected: 85 : /// Reference to the "enable" InputParameters, used by Controls for toggling on/off MooseObjects 86 : const bool & _enabled; 87 : 88 : // Base classes have the same name for that attribute, pick one 89 : using MooseBase::_app; 90 : };