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 "Material.h" 13 : 14 : /** 15 : * FunctorMaterials compute functor material properties 16 : */ 17 : class FunctorMaterial : public Material 18 : { 19 : public: 20 : static InputParameters validParams(); 21 : 22 : FunctorMaterial(const InputParameters & parameters); 23 1570 : void computeProperties() override final {} 24 : 25 192 : const std::set<std::string> & getSuppliedFunctors() const { return _supplied_functor_props; } 26 : 27 : protected: 28 0 : void computeQpProperties() override final {} 29 : 30 : /** 31 : * Declare a functor material property 32 : */ 33 : template <typename T, typename PolymorphicLambda> 34 : const Moose::FunctorBase<T> & 35 : addFunctorProperty(const std::string & name, 36 : PolymorphicLambda my_lammy, 37 : const std::set<ExecFlagType> & clearance_schedule = {EXEC_ALWAYS}); 38 : 39 : /** 40 : * Declare a functor material property with specified subdomain ids 41 : */ 42 : template <typename T, typename PolymorphicLambda> 43 : const Moose::FunctorBase<T> & 44 : addFunctorPropertyByBlocks(const std::string & name, 45 : PolymorphicLambda my_lammy, 46 : const std::set<SubdomainID> & sub_ids, 47 : const std::set<ExecFlagType> & clearance_schedule = {EXEC_ALWAYS}); 48 : 49 : private: 50 : /// List of the properties supplied 51 : std::set<std::string> _supplied_functor_props; 52 : }; 53 : 54 : template <typename T, typename PolymorphicLambda> 55 : const Moose::FunctorBase<T> & 56 7650 : FunctorMaterial::addFunctorProperty(const std::string & name, 57 : PolymorphicLambda my_lammy, 58 : const std::set<ExecFlagType> & clearance_schedule) 59 : { 60 7650 : return addFunctorPropertyByBlocks<T>(name, my_lammy, blockIDs(), clearance_schedule); 61 : } 62 : 63 : template <typename T, typename PolymorphicLambda> 64 : const Moose::FunctorBase<T> & 65 8432 : FunctorMaterial::addFunctorPropertyByBlocks(const std::string & name, 66 : PolymorphicLambda my_lammy, 67 : const std::set<SubdomainID> & sub_ids, 68 : const std::set<ExecFlagType> & clearance_schedule) 69 : { 70 : // Check if the supplied parameter is a valid input parameter key 71 8432 : std::string prop_name = name; 72 8432 : if (_pars.isParamValid(name)) 73 : { 74 1165 : if (_pars.have_parameter<MaterialPropertyName>(name)) 75 357 : prop_name = _pars.get<MaterialPropertyName>(name); 76 1165 : if (_pars.have_parameter<MooseFunctorName>(name)) 77 808 : prop_name = _pars.get<MooseFunctorName>(name); 78 : } 79 : 80 8432 : _supplied_functor_props.insert(name + (_declare_suffix.empty() ? "" : ("_" + _declare_suffix))); 81 16860 : return _subproblem.addPiecewiseByBlockLambdaFunctor<T>( 82 16860 : prop_name + (_declare_suffix.empty() ? "" : ("_" + _declare_suffix)), 83 : my_lammy, 84 : clearance_schedule, 85 8432 : _mesh, 86 : sub_ids, 87 16856 : _tid); 88 8428 : }