https://mooseframework.inl.gov
MaterialOutputAction.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 "Action.h"
13 #include "MaterialData.h"
14 #include "FEProblemBase.h"
15 
16 class MooseObjectAction;
17 class MaterialBase;
18 
23 {
24 public:
26 
27  MaterialOutputAction(const InputParameters & params);
28 
29  virtual void act() override;
30 
33  {
34  std::string _aux_kernel_name;
35  std::string _index_symbols;
36  std::vector<std::string> _param_names;
37  };
38 
39 protected:
43  virtual std::vector<std::string> materialOutput(const std::string & property_name,
44  const MaterialBase & material,
45  bool get_names_only);
46 
48  std::vector<std::string> outputHelper(const OutputMetaData & metadata,
49  const std::string & property_name,
50  const std::string & var_name_base,
51  const MaterialBase & material,
52  bool get_names_only);
53 
59  template <typename T>
60  bool hasProperty(const std::string & property_name);
61 
67  template <typename T>
68  bool hasADProperty(const std::string & property_name);
69 
75  template <typename T>
76  bool hasFunctorProperty(const std::string & property_name);
77 
87  InputParameters getParams(const std::string & type,
88  const std::string & property_name,
89  const std::string & variable_name,
90  const MaterialBase & material);
91 
92 private:
95 
98 
100  std::map<std::string, std::set<SubdomainID>> _block_variable_map;
101 
103  std::set<std::string> _material_variable_names;
104 
106  std::map<OutputName, std::set<std::string>> _material_variable_names_map;
107 
110 
113 };
114 
115 template <typename T>
116 bool
117 MaterialOutputAction::hasProperty(const std::string & property_name)
118 {
119  if (_block_material_data->haveProperty<T>(property_name) ||
120  _boundary_material_data->haveProperty<T>(property_name))
121  return true;
122  else
123  return false;
124 }
125 
126 template <typename T>
127 bool
128 MaterialOutputAction::hasADProperty(const std::string & property_name)
129 {
130  if (_block_material_data->haveADProperty<T>(property_name) ||
131  _boundary_material_data->haveADProperty<T>(property_name))
132  return true;
133  else
134  return false;
135 }
136 
137 template <typename T>
138 bool
139 MaterialOutputAction::hasFunctorProperty(const std::string & property_name)
140 {
141  return _problem->hasFunctorWithType<T>(property_name, 0);
142 }
virtual std::vector< std::string > materialOutput(const std::string &property_name, const MaterialBase &material, bool get_names_only)
A function to be overriden by derived actions to handle a set of material property types...
std::map< OutputName, std::set< std::string > > _material_variable_names_map
Map of output names and list of variables associated with the output.
static InputParameters validParams()
OutputWarehouse & _output_warehouse
Reference to the OutputWarehouse.
bool haveProperty(const std::string &prop_name) const
Returns true if the regular material property exists - defined by any material.
Definition: MaterialData.h:89
std::map< std::string, std::set< SubdomainID > > _block_variable_map
Map of variable name that contains the blocks to which the variable should be restricted.
bool hasFunctorProperty(const std::string &property_name)
Helper method for testing if the functor material property exists.
std::set< std::string > _material_variable_names
variables for the current MaterialBase object
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Base class for actions.
Definition: Action.h:33
Creates AuxVariables and AuxKernels for automatic output of material properties.
InputParameters getParams(const std::string &type, const std::string &property_name, const std::string &variable_name, const MaterialBase &material)
A method for retrieving and partially filling the InputParameters object for an AuxVariable.
const std::string & type() const
Get the type of this class.
Definition: MooseBase.h:51
bool hasProperty(const std::string &property_name)
Helper method for testing if the material exists as a block or boundary material. ...
Class for storing and utilizing output objects.
bool hasADProperty(const std::string &property_name)
Helper method for testing if the material exists as a block or boundary material. ...
MaterialOutputAction(const InputParameters &params)
const MaterialData * _block_material_data
Pointer the MaterialData object storing the block restricted materials.
bool haveADProperty(const std::string &prop_name) const
Returns true if the AD material property exists - defined by any material.
Definition: MaterialData.h:96
const bool _output_only_on_timestep_end
Output only on TIMESTEP_END, not on INITIAL?
std::shared_ptr< FEProblemBase > & _problem
Convenience reference to a problem this action works on.
Definition: Action.h:168
Proxy for accessing MaterialPropertyStorage.
Definition: MaterialData.h:33
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
std::vector< std::string > outputHelper(const OutputMetaData &metadata, const std::string &property_name, const std::string &var_name_base, const MaterialBase &material, bool get_names_only)
Universal output object setup function.
std::vector< std::string > _param_names
Meta data describing the setup of an output object.
MaterialBases compute MaterialProperties.
Definition: MaterialBase.h:62
const MaterialData * _boundary_material_data
Pointer the MaterialData object storing the boundary restricted materials.