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...
 
std::vector< std::string > _already_joined
 Vector of already joined materials (to avoid joining them again) 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), _already_joined()
32 {
33 }
std::vector< std::string > _already_joined
Vector of already joined materials (to avoid joining them again)

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  bool is_joined = false;
146 
147  // Check if this material is already joined
148  if (std::find(_already_joined.begin(), _already_joined.end(), material_property) !=
149  _already_joined.end())
150  is_joined = true;
151 
152  if (hasJoiner(material_property))
153  is_joined = true;
154 
155  if (!is_joined)
156  {
157  std::string material_type = "PorousFlowJoiner";
158  InputParameters params = _factory.getValidParams(material_type);
159  params.set<UserObjectName>("PorousFlowDictator") = _dictator_name;
160  params.set<bool>("at_nodes") = at_nodes;
161  params.set<std::string>("material_property") = material_property;
162  _problem->addMaterial(material_type, output_name, params);
163 
164  // Add material to the already joined list
165  _already_joined.push_back(material_property);
166  }
167 }
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...
std::vector< std::string > _already_joined
Vector of already joined materials (to avoid joining them again)

◆ 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 170 of file PorousFlowAddMaterialJoiner.C.

Referenced by addJoiner().

171 {
172  // Get the list of materials in the input file
173  auto actions = _awh.getActions<AddMaterialAction>();
174 
175  for (auto & action : actions)
176  {
177  AddMaterialAction * material = const_cast<AddMaterialAction *>(action);
178 
179  if (material->getMooseObjectType() == "PorousFlowJoiner")
180  {
181  // If a PorousFlowJoiner material has been included in the input file,
182  // let the user know that it should be removed
183  mooseDeprecated("PorousFlowJoiner materials are no longer required in the input "
184  "file.\nPlease remove all PorousFlowJoiner materials from this input file to "
185  "get rid of this warning");
186 
187  const std::string joiner_property =
188  material->getObjectParams().get<std::string>("material_property");
189 
190  // Check if the given material property is joined by this material
191  if (joiner_property == property)
192  return true;
193  }
194  }
195 
196  // If no PorousFlowJoiner materials matched property, return false
197  return false;
198 }

Member Data Documentation

◆ _already_joined

std::vector<std::string> PorousFlowAddMaterialJoiner::_already_joined
protected

Vector of already joined materials (to avoid joining them again)

Definition at line 54 of file PorousFlowAddMaterialJoiner.h.

Referenced by addJoiner().

◆ _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: