https://mooseframework.inl.gov
FunctorMaterial.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 
12 #include "Material.h"
13 
17 class FunctorMaterial : public Material
18 {
19 public:
21 
23  void computeProperties() override final {}
24 
25  const std::set<std::string> & getSuppliedFunctors() const { return _supplied_functor_props; }
26 
27 protected:
28  void computeQpProperties() override final {}
29 
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 
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:
51  std::set<std::string> _supplied_functor_props;
52 };
53 
54 template <typename T, typename PolymorphicLambda>
56 FunctorMaterial::addFunctorProperty(const std::string & name,
57  PolymorphicLambda my_lammy,
58  const std::set<ExecFlagType> & clearance_schedule)
59 {
60  return addFunctorPropertyByBlocks<T>(name, my_lammy, blockIDs(), clearance_schedule);
61 }
62 
63 template <typename T, typename PolymorphicLambda>
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  std::string prop_name = name;
72  if (_pars.isParamValid(name))
73  {
74  if (_pars.have_parameter<MaterialPropertyName>(name))
75  prop_name = _pars.get<MaterialPropertyName>(name);
76  if (_pars.have_parameter<MooseFunctorName>(name))
77  prop_name = _pars.get<MooseFunctorName>(name);
78  }
79 
80  _supplied_functor_props.insert(name + (_declare_suffix.empty() ? "" : ("_" + _declare_suffix)));
82  prop_name + (_declare_suffix.empty() ? "" : ("_" + _declare_suffix)),
83  my_lammy,
84  clearance_schedule,
85  _mesh,
86  sub_ids,
87  _tid);
88 }
const MaterialPropertyName _declare_suffix
Suffix to append to the name of the material property/ies when declaring it/them. ...
Definition: MaterialBase.h:409
Base class template for functor objects.
Definition: MooseFunctor.h:137
void computeQpProperties() override final
Users must override this method.
static InputParameters validParams()
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
SubProblem & _subproblem
Definition: MaterialBase.h:314
std::set< std::string > _supplied_functor_props
List of the properties supplied.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual const std::set< SubdomainID > & blockIDs() const
Return the block subdomain ids for this object Note, if this is not block restricted, this function returns all mesh subdomain ids.
const ExecFlagType EXEC_ALWAYS
Definition: Moose.C:49
virtual const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:57
FunctorMaterials compute functor material properties.
MooseMesh & _mesh
Definition: MaterialBase.h:326
THREAD_ID _tid
Definition: MaterialBase.h:317
const Moose::FunctorBase< T > & addFunctorPropertyByBlocks(const std::string &name, PolymorphicLambda my_lammy, const std::set< SubdomainID > &sub_ids, const std::set< ExecFlagType > &clearance_schedule={EXEC_ALWAYS})
Declare a functor material property with specified subdomain ids.
Materials compute MaterialProperties.
Definition: Material.h:34
bool have_parameter(std::string_view name) const
A wrapper around the Parameters base class method.
FunctorMaterial(const InputParameters &parameters)
const Moose::FunctorBase< T > & addFunctorProperty(const std::string &name, PolymorphicLambda my_lammy, const std::set< ExecFlagType > &clearance_schedule={EXEC_ALWAYS})
Declare a functor material property.
const std::set< std::string > & getSuppliedFunctors() const
const Moose::FunctorBase< T > & addPiecewiseByBlockLambdaFunctor(const std::string &name, PolymorphicLambda my_lammy, const std::set< ExecFlagType > &clearance_schedule, const MooseMesh &mesh, const std::set< SubdomainID > &block_ids, const THREAD_ID tid)
Add a functor that has block-wise lambda definitions, e.g.
Definition: SubProblem.h:1338
const InputParameters & _pars
Parameters of this object, references the InputParameters stored in the InputParametersWarehouse.
const InputParameters & parameters() const
Get the parameters of the object.
void computeProperties() override final
Performs the quadrature point loop, calling computeQpProperties.
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another, i.e.