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

Action to programatically add PorousFlowJoiner materials without having to manually enter them in the input file. More...

#include <PorousFlowAddMaterialJoiner.h>

Inheritance diagram for PorousFlowAddMaterialJoiner:
[legend]

Public Member Functions

 PorousFlowAddMaterialJoiner (const InputParameters &params)
 
virtual void act () override
 

Protected Member Functions

void addJoiner (bool at_nodes, const std::string &material_property, const std::string &output_name)
 Adds a PorousFlowJoiner for the given material property. More...
 
bool hasJoiner (std::string property)
 Helper method to determine if a PorousFLowJoiner material is already present in the input file for the given material property. More...
 

Protected Attributes

std::string _dictator_name
 Name of the PorousFlowDictator. More...
 

Detailed Description

Action to programatically add PorousFlowJoiner materials without having to manually enter them in the input file.

Definition at line 24 of file PorousFlowAddMaterialJoiner.h.

Constructor & Destructor Documentation

◆ PorousFlowAddMaterialJoiner()

PorousFlowAddMaterialJoiner::PorousFlowAddMaterialJoiner ( const InputParameters &  params)

Definition at line 30 of file PorousFlowAddMaterialJoiner.C.

31  : Action(params)
32 {
33 }

Member Function Documentation

◆ act()

void PorousFlowAddMaterialJoiner::act ( )
overridevirtual

Definition at line 36 of file PorousFlowAddMaterialJoiner.C.

37 {
38  // This task only runs after the UserObject and material actions have run,
39  // so we can get the name of the PorousFlowDictator UserObject and all material
40  // types
41  if (_current_task == "add_joiners")
42  {
43  // Get the user objects that have been added to get the name of the PorousFlowDictator
44  std::vector<UserObject *> userobjects;
45  _problem->theWarehouse()
46  .query()
47  .condition<AttribSystem>("UserObject")
48  .condition<AttribThread>(0)
49  .queryInto(userobjects);
50  for (auto & userobject : userobjects)
51  if (dynamic_cast<PorousFlowDictator *>(userobject))
52  _dictator_name = userobject->name();
53 
54  // Get the list of materials that have been added
55  auto materials = _problem->getMaterialWarehouse().getObjects();
56  for (auto & mat : materials)
57  {
58  const InputParameters & params = mat->parameters();
59 
60  // Only check PorousFlowMaterials
61  if (params.isParamValid("pf_material_type"))
62  {
63  const std::string pf_material_type = params.get<std::string>("pf_material_type");
64 
65  // Check if the material is evaluated at the nodes or qps
66  const bool at_nodes = params.get<bool>("at_nodes");
67 
68  // Add joiner material for fluid properties materials
69  if (pf_material_type == "fluid_properties")
70  {
71  // Key the addition of the joiner off the phase 0 fluid so it is only added once
72  if (params.get<unsigned int>("phase") == 0)
73  {
74  // Join density and viscosity if they are calculated
75  if (params.get<bool>("compute_density_and_viscosity"))
76  {
77  if (at_nodes)
78  {
79  addJoiner(at_nodes,
80  "PorousFlow_fluid_phase_density_nodal",
81  "PorousFlow_density_nodal_all");
82  addJoiner(at_nodes, "PorousFlow_viscosity_nodal", "PorousFlow_viscosity_nodal_all");
83  }
84  else
85  {
86  addJoiner(
87  at_nodes, "PorousFlow_fluid_phase_density_qp", "PorousFlow_density_qp_all");
88  addJoiner(at_nodes, "PorousFlow_viscosity_qp", "PorousFlow_viscosity_qp_all");
89  }
90  }
91 
92  // Join enthalpy if it is calculated
93  if (params.get<bool>("compute_enthalpy"))
94  {
95  if (at_nodes)
96  addJoiner(at_nodes,
97  "PorousFlow_fluid_phase_enthalpy_nodal",
98  "PorousFlow_enthalpy_nodal_all");
99  else
100  addJoiner(
101  at_nodes, "PorousFlow_fluid_phase_enthalpy_qp", "PorousFlow_enthalpy_qp_all");
102  }
103 
104  // Join internal energy if it is calculated
105  if (params.get<bool>("compute_internal_energy"))
106  {
107  if (at_nodes)
108  addJoiner(at_nodes,
109  "PorousFlow_fluid_phase_internal_energy_nodal",
110  "PorousFlow_internal_energy_nodal_all");
111  else
112  addJoiner(at_nodes,
113  "PorousFlow_fluid_phase_internal_energy_qp",
114  "PorousFlow_internal_energy_qp_all");
115  }
116  }
117  }
118 
119  // Add joiner materials for relative permeability materials
120  if (pf_material_type == "relative_permeability")
121  {
122  // Key the addition of the joiner off the phase 0 fluid so it is only added once
123  if (params.get<unsigned int>("phase") == 0)
124  {
125  if (at_nodes)
126  addJoiner(at_nodes,
127  "PorousFlow_relative_permeability_nodal",
128  "PorousFlow_relative_permeability_nodal_all");
129  else
130  addJoiner(at_nodes,
131  "PorousFlow_relative_permeability_qp",
132  "PorousFlow_relative_permeability_qp_all");
133  }
134  }
135  }
136  }
137  }
138 }
std::string _dictator_name
Name of the PorousFlowDictator.
void addJoiner(bool at_nodes, const std::string &material_property, const std::string &output_name)
Adds a PorousFlowJoiner for the given material property.

◆ addJoiner()

void PorousFlowAddMaterialJoiner::addJoiner ( bool  at_nodes,
const std::string &  material_property,
const std::string &  output_name 
)
protected

Adds a PorousFlowJoiner for the given material property.

Parameters
at_nodesif true: produce a nodal material, otherwise: produce a qp material
material_propertyjoin this PorousFlow material property
output_nameThe unique name given to this PorousFlowJoiner in the input file

Definition at line 141 of file PorousFlowAddMaterialJoiner.C.

Referenced by act().

144 {
145  if (!hasJoiner(material_property))
146  {
147  std::string material_type = "PorousFlowJoiner";
148  InputParameters params = _factory.getValidParams(material_type);
149  params.set<UserObjectName>("PorousFlowDictator") = _dictator_name;
150  params.set<bool>("at_nodes") = at_nodes;
151  params.set<std::string>("material_property") = material_property;
152  _problem->addMaterial(material_type, output_name, params);
153  }
154 }
std::string _dictator_name
Name of the PorousFlowDictator.
bool hasJoiner(std::string property)
Helper method to determine if a PorousFLowJoiner material is already present in the input file for th...

◆ hasJoiner()

bool PorousFlowAddMaterialJoiner::hasJoiner ( std::string  property)
protected

Helper method to determine if a PorousFLowJoiner material is already present in the input file for the given material property.

Parameters
propertythe material property to check
Returns
true if a PorousFLowJoiner is already present for property, false otherwise

Definition at line 157 of file PorousFlowAddMaterialJoiner.C.

Referenced by addJoiner().

158 {
159  // Get the list of materials in the input file
160  auto actions = _awh.getActions<AddMaterialAction>();
161 
162  for (auto & action : actions)
163  {
164  AddMaterialAction * material = const_cast<AddMaterialAction *>(action);
165 
166  if (material->getMooseObjectType() == "PorousFlowJoiner")
167  {
168  // If a PorousFlowJoiner material has been included in the input file,
169  // let the user know that it should be removed
170  mooseDeprecated("PorousFlowJoiner materials are no longer required in the input "
171  "file.\nPlease remove all PorousFlowJoiner materials from this input file to "
172  "get rid of this warning");
173 
174  const std::string joiner_property =
175  material->getObjectParams().get<std::string>("material_property");
176 
177  // Check if the given material property is joined by this material
178  if (joiner_property == property)
179  return true;
180  }
181  }
182 
183  // If no PorousFlowJoiner materials matched property, return false
184  return false;
185 }

Member Data Documentation

◆ _dictator_name

std::string PorousFlowAddMaterialJoiner::_dictator_name
protected

Name of the PorousFlowDictator.

Definition at line 51 of file PorousFlowAddMaterialJoiner.h.

Referenced by act(), and addJoiner().


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