www.mooseframework.org
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
PorousFlowAddMaterialAction Class Reference

Action to automatically ensure that PorousFlowMaterials are correctly evaluated at either the qps, nodes, or both. More...

#include <PorousFlowAddMaterialAction.h>

Inheritance diagram for PorousFlowAddMaterialAction:
[legend]

Public Types

typedef DataFileName DataFileParameterType
 

Public Member Functions

 PorousFlowAddMaterialAction (const InputParameters &params)
 
virtual void act () override
 
void timedAct ()
 
virtual void addRelationshipManagers (Moose::RelationshipManagerType when_type)
 
MooseObjectName uniqueActionName () const
 
const std::string & specificTaskName () const
 
const std::set< std::string > & getAllTasks () const
 
void appendTask (const std::string &task)
 
MooseAppgetMooseApp () const
 
const std::string & type () const
 
virtual const std::string & name () const
 
std::string typeAndName () const
 
std::string errorPrefix (const std::string &error_type) const
 
void callMooseError (std::string msg, const bool with_prefix) const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
const InputParametersparameters () const
 
MooseObjectName uniqueName () const
 
const T & getParam (const std::string &name) const
 
std::vector< std::pair< T1, T2 > > getParam (const std::string &param1, const std::string &param2) const
 
const T & getRenamedParam (const std::string &old_name, const std::string &new_name) const
 
getCheckedPointerParam (const std::string &name, const std::string &error_string="") const
 
bool isParamValid (const std::string &name) const
 
bool isParamSetByUser (const std::string &nm) const
 
void paramError (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramInfo (const std::string &param, Args... args) const
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void mooseError (Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseInfo (Args &&... args) const
 
PerfGraphperfGraph ()
 
std::string getDataFileName (const std::string &param) const
 
std::string getDataFileNameByName (const std::string &name, const std::string *param=nullptr) const
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static InputParameters validParams ()
 

Public Attributes

const ConsoleStream _console
 

Static Public Attributes

static constexpr auto SYSTEM
 
static constexpr auto NAME
 

Protected Member Functions

void createDependencyList ()
 Creates a set of all actions, kernels, etc to check material dependency against in order to determine whether to add nodal and/or qp materials. More...
 
bool isPFMaterialRequired (std::string pf_material_type, bool at_nodes)
 Check to see if the material with a given at_nodes parameter is required. More...
 
bool isPFMaterialPresent (AddMaterialAction *material, bool at_nodes)
 Check to see if the material with a given at_nodes parameter has already been included in the input file (to void duplicate material property errors) More...
 
void addPFMaterial (AddMaterialAction *material, bool at_nodes)
 Adds the material for the given at_nodes parameter. More...
 
bool addRelationshipManagers (Moose::RelationshipManagerType when_type, const InputParameters &moose_object_pars)
 
void associateWithParameter (const std::string &param_name, InputParameters &params) const
 
void associateWithParameter (const InputParameters &from_params, const std::string &param_name, InputParameters &params) const
 
const T & getMeshProperty (const std::string &data_name, const std::string &prefix)
 
const T & getMeshProperty (const std::string &data_name)
 
bool hasMeshProperty (const std::string &data_name, const std::string &prefix) const
 
bool hasMeshProperty (const std::string &data_name, const std::string &prefix) const
 
bool hasMeshProperty (const std::string &data_name) const
 
bool hasMeshProperty (const std::string &data_name) const
 
std::string meshPropertyName (const std::string &data_name) const
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level) const
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level, const std::string &live_message, const bool print_dots=true) const
 
std::string timedSectionName (const std::string &section_name) const
 

Static Protected Member Functions

static std::string meshPropertyName (const std::string &data_name, const std::string &prefix)
 

Protected Attributes

std::string _dictator_name
 Name of the PorousFlowDictator. More...
 
std::set< std::string > _dependency_list
 List of kernels, actions etc that may depend on PorousFlow materials. More...
 
std::vector< AddMaterialAction * > _ama_materials
 List of all materials added in the input file by AddMaterialAction. More...
 
std::string _registered_identifier
 
std::string _specific_task_name
 
std::set< std::string > _all_tasks
 
ActionWarehouse_awh
 
const std::string & _current_task
 
std::shared_ptr< MooseMesh > & _mesh
 
std::shared_ptr< MooseMesh > & _displaced_mesh
 
std::shared_ptr< FEProblemBase > & _problem
 
PerfID _act_timer
 
MooseApp_app
 
const std::string _type
 
const std::string _name
 
const InputParameters_pars
 
Factory_factory
 
ActionFactory_action_factory
 
MooseApp_pg_moose_app
 
const std::string _prefix
 
const Parallel::Communicator & _communicator
 
DependencyResolver< std::string > _deps
 All dependencies of kernels, auxkernels, materials, etc, are stored in _dependencies. More...
 

Detailed Description

Action to automatically ensure that PorousFlowMaterials are correctly evaluated at either the qps, nodes, or both.

This action works by checking all materials added in the input file. If a material is a valid PorousFlowMaterial, then it does one of the following: 1) If the at_nodes parameter has been set by the user, then it leaves that material alone (this assumes that the user has correctly added that material). 2) If the at_nodes parameter has not been set by the user, then the action checks to see if this material is required at the qps, nodes or both, and makes sure that the correct versions are added. 3) If a PorousFlowJoiner material is included in the input file, it does nothing (as the PorousFlowAddMaterialJoiner action will check for these and give a message that these materials are no longer required in the input file)

Definition at line 32 of file PorousFlowAddMaterialAction.h.

Constructor & Destructor Documentation

◆ PorousFlowAddMaterialAction()

PorousFlowAddMaterialAction::PorousFlowAddMaterialAction ( const InputParameters params)

Definition at line 35 of file PorousFlowAddMaterialAction.C.

36  : Action(params), PorousFlowDependencies()
37 {
38 }
Action(const InputParameters &parameters)

Member Function Documentation

◆ act()

void PorousFlowAddMaterialAction::act ( )
overridevirtual

Implements Action.

Definition at line 41 of file PorousFlowAddMaterialAction.C.

42 {
43  // Create the list of kernels, auxkernels, actions etc that each material may be
44  // required by
46 
47  // Get the list of materials that have been added
48  auto actions = _awh.getActions<AddMaterialAction>();
49 
50  for (auto & action : actions)
51  _ama_materials.push_back(const_cast<AddMaterialAction *>(action));
52 
53  for (auto & material : _ama_materials)
54  {
55  InputParameters & pars = material->getObjectParams();
56 
57  // Check if the material is a PorousFlow material
58  if (pars.isParamValid("pf_material_type"))
59  {
60  const std::string pf_material_type = pars.get<std::string>("pf_material_type");
61 
62  // PorousFlowJoiner materials are added automatically by the PorousFlowAddMaterialJoiner
63  // action, so no need to check these here
64  if (pf_material_type != "joiner")
65  {
66  // There are two possibilities that must be considered:
67  // 1) The parameter at_nodes has been set by the user. In this case, the material will
68  // be added as normal by AddMaterialAction
69  // 2) The parameter at_nodes has not been set by the user. In this case, this action
70  // will check to see if the material is required at the qps, at the nodes, or possibly both
71 
72  // Only check the second possibility
73  if (!pars.isParamSetByUser("at_nodes"))
74  {
75  bool qp_material_required = false;
76 
77  // First, check the case at_nodes = false, as this is the default behaviour for the
78  // at_nodes parameter. Note: the local variable at_nodes is set to true, so the material
79  // is at the qps when !at_nodes
80  const bool at_nodes = true;
81 
82  if (isPFMaterialRequired(pf_material_type, !at_nodes))
83  {
84  // This material is required at the qps, so add it as normal (setting the paramter
85  // at_nodes = false for clarity)
86  pars.set<bool>("at_nodes") = !at_nodes;
87  qp_material_required = true;
88  }
89 
90  // Check if the material is required at the nodes as well and that it isn't already
91  // added in the input file. If it is needed and not already supplied, then it is added
92  // in one of two ways: 1) If the material wasn't also required at the qps (checked above),
93  // then we can simply set the at_nodes parameter to true. 2) If it was also required at
94  // the qps, then a new material action is required to be added to the action warehouse
95  if (isPFMaterialRequired(pf_material_type, at_nodes) &&
96  !isPFMaterialPresent(material, at_nodes))
97  {
98  if (!qp_material_required)
99  pars.set<bool>("at_nodes") = at_nodes;
100  else
101  addPFMaterial(material, at_nodes);
102  }
103  }
104  }
105  }
106  }
107 }
bool isPFMaterialPresent(AddMaterialAction *material, bool at_nodes)
Check to see if the material with a given at_nodes parameter has already been included in the input f...
void addPFMaterial(AddMaterialAction *material, bool at_nodes)
Adds the material for the given at_nodes parameter.
ActionWarehouse & _awh
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
T & set(const std::string &name, bool quiet_mode=false)
bool isPFMaterialRequired(std::string pf_material_type, bool at_nodes)
Check to see if the material with a given at_nodes parameter is required.
bool isParamSetByUser(const std::string &name) const
std::vector< AddMaterialAction * > _ama_materials
List of all materials added in the input file by AddMaterialAction.
std::vector< const T *> getActions()
void createDependencyList()
Creates a set of all actions, kernels, etc to check material dependency against in order to determine...
bool isParamValid(const std::string &name) const

◆ addPFMaterial()

void PorousFlowAddMaterialAction::addPFMaterial ( AddMaterialAction material,
bool  at_nodes 
)
protected

Adds the material for the given at_nodes parameter.

Parameters
materialpointer to the material in the action warehouse
at_nodestrue if material is evaluates at the nodes, false otherwise

Definition at line 210 of file PorousFlowAddMaterialAction.C.

Referenced by act().

211 {
212  const std::string nodal_ext = at_nodes ? "_nodal" : "_qp";
213 
214  // Input parameters for the material that is being added
215  InputParameters & pars = material->getObjectParams();
216 
217  // PorousFlowMaterial type
218  const std::string pf_material_type = pars.get<std::string>("pf_material_type");
219  const std::string moose_object_type = material->getMooseObjectType();
220 
221  // If it is a material that also has a fluid phase, then extract that to add to name
222  std::string phase_str;
223  if (pars.isParamValid("phase"))
224  {
225  unsigned int phase = pars.get<unsigned int>("phase");
226  phase_str = "_phase" + Moose::stringify(phase);
227  }
228 
229  // Add material to the action warehouse
230  InputParameters action_params = _action_factory.getValidParams("AddMaterialAction");
231  action_params.set<ActionWarehouse *>("awh") = &_awh;
232 
233  // Setup action for passed in material type
234  action_params.set<std::string>("type") = moose_object_type;
235 
236  const std::string material_name = material->name() + phase_str + nodal_ext;
237 
238  auto action = MooseSharedNamespace::dynamic_pointer_cast<MooseObjectAction>(
239  _action_factory.create("AddMaterialAction", material_name, action_params));
240 
241  action->getObjectParams().applyParameters(pars);
242  action->getObjectParams().set<bool>("at_nodes") = at_nodes;
243 
244  _awh.addActionBlock(action);
245 }
ActionWarehouse & _awh
InputParameters getValidParams(const std::string &name)
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
T & set(const std::string &name, bool quiet_mode=false)
void applyParameters(const InputParameters &common, const std::vector< std::string > &exclude={}, const bool allow_private=false)
void addActionBlock(std::shared_ptr< Action > blk)
virtual const std::string & name() const
std::shared_ptr< Action > create(const std::string &action, const std::string &action_name, InputParameters &parameters)
InputParameters & getObjectParams()
ActionFactory & _action_factory
std::string stringify(const T &t)
const std::string & getMooseObjectType() const
bool isParamValid(const std::string &name) const

◆ createDependencyList()

void PorousFlowAddMaterialAction::createDependencyList ( )
protected

Creates a set of all actions, kernels, etc to check material dependency against in order to determine whether to add nodal and/or qp materials.

Definition at line 110 of file PorousFlowAddMaterialAction.C.

Referenced by act().

111 {
112  // Unique list of kernels added in input file
113  auto kernels = _awh.getActions<AddKernelAction>();
114  for (auto & kernel : kernels)
115  _dependency_list.insert(kernel->getMooseObjectType());
116 
117  // Unique list of PorousFlowActions added in input file
118  auto actions = _awh.getActions<PorousFlowActionBase>();
119  for (auto & action : actions)
120  _dependency_list.insert(action->name());
121 
122  // Unique list of auxkernels added in input file
123  auto auxkernels = _awh.getActions<AddKernelAction>();
124  for (auto & auxkernel : auxkernels)
125  _dependency_list.insert(auxkernel->getMooseObjectType());
126 
127  // Unique list of postprocessors added in input file
128  auto postprocessors = _awh.getActions<AddPostprocessorAction>();
129  for (auto & postprocessor : postprocessors)
130  _dependency_list.insert(postprocessor->getMooseObjectType());
131 
132  // Unique list of userojects added in input file
133  auto userobjects = _awh.getActions<AddUserObjectAction>();
134  for (auto & userobject : userobjects)
135  _dependency_list.insert(userobject->getMooseObjectType());
136 
137  // Unique list of BCs added in input file
138  auto bcs = _awh.getActions<AddBCAction>();
139  for (auto & bc : bcs)
140  _dependency_list.insert(bc->getMooseObjectType());
141 
142  // Unique list of Dirac kernels added in input file
143  auto diracs = _awh.getActions<AddDiracKernelAction>();
144  for (auto & dirac : diracs)
145  _dependency_list.insert(dirac->getMooseObjectType());
146 }
ActionWarehouse & _awh
std::set< std::string > _dependency_list
List of kernels, actions etc that may depend on PorousFlow materials.
Base class for PorousFlow actions.
std::vector< const T *> getActions()

◆ isPFMaterialPresent()

bool PorousFlowAddMaterialAction::isPFMaterialPresent ( AddMaterialAction material,
bool  at_nodes 
)
protected

Check to see if the material with a given at_nodes parameter has already been included in the input file (to void duplicate material property errors)

Parameters
materialpointer to the material in the action warehouse
at_nodestrue if material is evaluated at the nodes, false otherwise
Returns
true is the material is already added in the input file, false otherwise

Definition at line 166 of file PorousFlowAddMaterialAction.C.

Referenced by act().

167 {
168  bool is_present = false;
169 
170  // Need to check that it hasn't been added in the input file also to
171  // avoid a duplicate material property error
172  for (auto & ama_material : _ama_materials)
173  {
174  if (ama_material->name() != material->name() &&
175  ama_material->getMooseObjectType() == material->getMooseObjectType())
176  {
177  InputParameters & mat_params = ama_material->getObjectParams();
178  const bool mat_at_nodes = mat_params.get<bool>("at_nodes");
179 
180  InputParameters & pars = material->getObjectParams();
181 
182  // If the material isn't related to a fluid phase, it is present if
183  // its at_nodes parameter is equal to the given at_nodes
184  if (mat_at_nodes == at_nodes && !pars.isParamValid("phase"))
185  is_present = true;
186 
187  // If the material is related to a fluid phase, it is present if
188  // its at_nodes parameter is equal to the given at_nodes, and its
189  // phase is equal to phase
190  if (pars.isParamValid("phase"))
191  {
192  const unsigned int phase = pars.get<unsigned int>("phase");
193 
194  if (mat_params.isParamValid("phase") && mat_params.get<unsigned int>("phase") == phase)
195  is_present = true;
196  }
197 
198  // Finally, if the material is block restricted then it is not already
199  // present if the block parameter is not identical
200  if (mat_params.get<std::vector<SubdomainName>>("block") !=
201  pars.get<std::vector<SubdomainName>>("block"))
202  is_present = false;
203  }
204  }
205 
206  return is_present;
207 }
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
virtual const std::string & name() const
InputParameters & getObjectParams()
const std::string & getMooseObjectType() const
std::vector< AddMaterialAction * > _ama_materials
List of all materials added in the input file by AddMaterialAction.
bool isParamValid(const std::string &name) const

◆ isPFMaterialRequired()

bool PorousFlowAddMaterialAction::isPFMaterialRequired ( std::string  pf_material_type,
bool  at_nodes 
)
protected

Check to see if the material with a given at_nodes parameter is required.

Parameters
at_nodestrue if material is evaluated at the nodes, false otherwise
Returns
true is the material is required, false otherwise

Definition at line 149 of file PorousFlowAddMaterialAction.C.

Referenced by act().

150 {
151  const std::string nodal_ext = at_nodes ? "_nodal" : "_qp";
152 
153  // Check if this material is required by looping through the list of dependencies
154  bool required = false;
155  for (auto item : _dependency_list)
156  {
157  required = _deps.dependsOn(item, pf_material_type + nodal_ext);
158  if (required)
159  break;
160  }
161 
162  return required;
163 }
bool dependsOn(const std::string &key, const std::string &value)
std::set< std::string > _dependency_list
List of kernels, actions etc that may depend on PorousFlow materials.
DependencyResolver< std::string > _deps
All dependencies of kernels, auxkernels, materials, etc, are stored in _dependencies.

◆ validParams()

InputParameters PorousFlowAddMaterialAction::validParams ( )
static

Definition at line 27 of file PorousFlowAddMaterialAction.C.

28 {
30  params.addClassDescription(
31  "Makes sure that the correct nodal and/or qp materials are added for each property");
32  return params;
33 }
static InputParameters validParams()
void addClassDescription(const std::string &doc_string)

Member Data Documentation

◆ _ama_materials

std::vector<AddMaterialAction *> PorousFlowAddMaterialAction::_ama_materials
protected

List of all materials added in the input file by AddMaterialAction.

Definition at line 77 of file PorousFlowAddMaterialAction.h.

Referenced by act(), and isPFMaterialPresent().

◆ _dependency_list

std::set<std::string> PorousFlowAddMaterialAction::_dependency_list
protected

List of kernels, actions etc that may depend on PorousFlow materials.

Definition at line 75 of file PorousFlowAddMaterialAction.h.

Referenced by createDependencyList(), and isPFMaterialRequired().

◆ _deps

DependencyResolver<std::string> PorousFlowDependencies::_deps
protectedinherited

◆ _dictator_name

std::string PorousFlowAddMaterialAction::_dictator_name
protected

Name of the PorousFlowDictator.

Definition at line 73 of file PorousFlowAddMaterialAction.h.


The documentation for this class was generated from the following files: