https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | Private 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 Types

typedef DataFileName DataFileParameterType
 

Public Member Functions

 PorousFlowAddMaterialJoiner (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
 
const std::string & name () const
 
std::string typeAndName () const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
MooseObjectName uniqueName () const
 
const InputParametersparameters () const
 
const hit::Node * getHitNode () const
 
bool hasBase () const
 
const std::string & getBase () const
 
const TgetParam (const std::string &name) const
 
std::vector< std::pair< T1, T2 > > getParam (const std::string &param1, const std::string &param2) const
 
const TqueryParam (const std::string &name) const
 
const TgetRenamedParam (const std::string &old_name, const std::string &new_name) const
 
T getCheckedPointerParam (const std::string &name, const std::string &error_string="") const
 
bool isParamValid (const std::string &name) const
 
bool isParamSetByUser (const std::string &name) const
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void paramError (const std::string &param, Args... args) const
 
void paramWarning (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
 
std::string messagePrefix (const bool hit_prefix=true) const
 
std::string errorPrefix (const std::string &) const
 
void mooseError (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseDeprecatedNoTrace (Args &&... args) const
 
void mooseInfo (Args &&... args) const
 
void callMooseError (std::string msg, const bool with_prefix, const hit::Node *node=nullptr, const bool show_trace=true) const
 
std::string getDataFileName (const std::string &param) const
 
std::string getDataFileNameByName (const std::string &relative_path) const
 
std::string getDataFilePath (const std::string &relative_path) const
 
PerfGraphperfGraph ()
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static InputParameters validParams ()
 
static void callMooseError (MooseApp *const app, const InputParameters &params, std::string msg, const bool with_prefix, const hit::Node *node, const bool show_trace=true)
 

Public Attributes

 usingCombinedWarningSolutionWarnings
 
const ConsoleStream _console
 

Static Public Attributes

static const std::string unique_action_name_param
 
static const std::string type_param
 
static const std::string name_param
 
static const std::string unique_name_param
 
static const std::string app_param
 
static const std::string moose_base_param
 
static const std::string kokkos_object_param
 
static constexpr auto SYSTEM
 
static constexpr auto NAME
 

Protected Member Functions

void addJoiner (bool at_nodes, bool is_ad, const std::string &material_property, const std::string &output_name)
 Adds a PorousFlowJoiner for the given material property.
 
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.
 
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 TgetMeshProperty (const std::string &data_name, const std::string &prefix)
 
const TgetMeshProperty (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
 
void flagInvalidSolutionInternal (const InvalidSolutionID invalid_solution_id) const
 
InvalidSolutionID registerInvalidSolutionInternal (const std::string &message, const bool warning) 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.
 
bool _block_restricted
 whether the Material that is currently being Joined is block-restricted
 
std::vector< SubdomainName > _blocks
 if _block_restricted == true, then these are the blocks that the Joiner will be restricted to
 
std::vector< std::string > _already_joined
 Vector of already joined materials (to avoid joining them again)
 
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
 
Factory_factory
 
ActionFactory_action_factory
 
const std::string & _type
 
const std::string & _name
 
const InputParameters_pars
 
MooseApp_pg_moose_app
 
const std::string _prefix
 
const Parallel::Communicator & _communicator
 

Private Member Functions

bool addRelationshipManager (Moose::RelationshipManagerType input_rm_type, const InputParameters &moose_object_pars, std::string rm_name, Moose::RelationshipManagerType rm_type, Moose::RelationshipManagerInputParameterCallback rm_input_parameter_func, Moose::RMSystemType sys_type=Moose::RMSystemType::NONE)
 
virtual std::string meshPropertyPrefix (const std::string &data_name) const
 
const RestartableDataValuegetMeshPropertyInternal (const std::string &data_name, const std::string &prefix) const
 
void mooseErrorInternal (Args &&... args) const
 

Static Private Member Functions

static const hit::Node * getHitNode (const InputParameters &params)
 
static std::string messagePrefix (const InputParameters &params, const bool hit_prefix)
 

Private Attributes

const ParallelParamObject_parent
 
MooseApp_meta_data_app
 
const MooseObject *const _meta_data_object
 
const MooseBase_si_moose_base
 
const FEProblemBase_si_problem
 

Detailed Description

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

Definition at line 18 of file PorousFlowAddMaterialJoiner.h.

Constructor & Destructor Documentation

◆ PorousFlowAddMaterialJoiner()

PorousFlowAddMaterialJoiner::PorousFlowAddMaterialJoiner ( const InputParameters params)

Definition at line 29 of file PorousFlowAddMaterialJoiner.C.

30 : Action(params), _already_joined()
31{
32}
std::vector< std::string > _already_joined
Vector of already joined materials (to avoid joining them again)

Member Function Documentation

◆ act()

void PorousFlowAddMaterialJoiner::act ( )
overridevirtual

Implements Action.

Definition at line 35 of file PorousFlowAddMaterialJoiner.C.

36{
37 // This task only runs after the UserObject and material actions have run,
38 // so we can get the name of the PorousFlowDictator UserObject and all material
39 // types
40 if (_current_task == "add_joiners")
41 {
42 // Get the user objects that have been added to get the name of the PorousFlowDictator
43 std::vector<UserObject *> userobjects;
44 _problem->theWarehouse()
45 .query()
46 .condition<AttribSystem>("UserObject")
47 .condition<AttribThread>(0)
48 .queryInto(userobjects);
49 for (auto & userobject : userobjects)
50 if (dynamic_cast<PorousFlowDictator *>(userobject))
51 _dictator_name = userobject->name();
52
53 // Get the list of materials that have been added
54 auto materials = _problem->getMaterialWarehouse().getObjects();
55 for (auto & mat : materials)
56 {
57 const InputParameters & params = mat->parameters();
58
59 // Only check PorousFlowMaterials
60 if (params.isParamValid("pf_material_type"))
61 {
62 const std::string pf_material_type = params.get<std::string>("pf_material_type");
63
64 _block_restricted = params.isParamValid("block");
66 (pf_material_type == "fluid_properties" || pf_material_type == "relative_permeability"))
67 {
68 // this Material is block-restricted, and we're about to add Joiners for it, so must get
69 // a union of all the blocks for this material type in order to block-restrict the Joiner
70 std::set<SubdomainName> unique_blocks;
71 for (auto & mat2 : _problem->getMaterialWarehouse().getObjects())
72 {
73 const InputParameters & params2 = mat2->parameters();
74 if (params2.isParamValid("pf_material_type") &&
75 params2.get<std::string>("pf_material_type") == pf_material_type)
76 {
77 if (!params2.isParamValid("block"))
78 {
79 // a Material of this type is not block-restricted, so the non-block-restricted
80 // Joiner can be added
81 _block_restricted = false;
82 break;
83 }
84 const std::vector<SubdomainName> & bl =
85 params2.get<std::vector<SubdomainName>>("block");
86 std::copy(bl.begin(), bl.end(), std::inserter(unique_blocks, unique_blocks.end()));
87 }
88 }
89 _blocks.assign(unique_blocks.begin(), unique_blocks.end());
90 }
91
92 // Check if the material is evaluated at the nodes or qps
93 const bool at_nodes = params.get<bool>("at_nodes");
94
95 // Add joiner material for fluid properties materials
96 if (pf_material_type == "fluid_properties")
97 {
98 // Check if the material defines AD material properties
99 const bool is_ad = params.get<bool>("is_ad");
100
101 // Key the addition of the joiner off the phase 0 fluid so it is only added once
102 if (params.get<unsigned int>("phase") == 0)
103 {
104 // Join density and viscosity if they are calculated
105 if (params.get<bool>("compute_density_and_viscosity"))
106 {
107 if (at_nodes)
108 {
109 addJoiner(at_nodes,
110 is_ad,
111 "PorousFlow_fluid_phase_density_nodal",
112 "PorousFlow_density_nodal_all");
113 addJoiner(at_nodes,
114 is_ad,
115 "PorousFlow_viscosity_nodal",
116 "PorousFlow_viscosity_nodal_all");
117 }
118 else
119 {
120 addJoiner(at_nodes,
121 is_ad,
122 "PorousFlow_fluid_phase_density_qp",
123 "PorousFlow_density_qp_all");
124 addJoiner(
125 at_nodes, is_ad, "PorousFlow_viscosity_qp", "PorousFlow_viscosity_qp_all");
126 }
127 }
128
129 // Join enthalpy if it is calculated
130 if (params.get<bool>("compute_enthalpy"))
131 {
132 if (at_nodes)
133 addJoiner(at_nodes,
134 is_ad,
135 "PorousFlow_fluid_phase_enthalpy_nodal",
136 "PorousFlow_enthalpy_nodal_all");
137 else
138 addJoiner(at_nodes,
139 is_ad,
140 "PorousFlow_fluid_phase_enthalpy_qp",
141 "PorousFlow_enthalpy_qp_all");
142 }
143
144 // Join internal energy if it is calculated
145 if (params.get<bool>("compute_internal_energy"))
146 {
147 if (at_nodes)
148 addJoiner(at_nodes,
149 is_ad,
150 "PorousFlow_fluid_phase_internal_energy_nodal",
151 "PorousFlow_internal_energy_nodal_all");
152 else
153 addJoiner(at_nodes,
154 is_ad,
155 "PorousFlow_fluid_phase_internal_energy_qp",
156 "PorousFlow_internal_energy_qp_all");
157 }
158 }
159 }
160
161 // Add joiner materials for relative permeability materials
162 if (pf_material_type == "relative_permeability")
163 {
164 // Check if the material defines AD material properties
165 const bool is_ad = params.get<bool>("is_ad");
166
167 // Key the addition of the joiner off the phase 0 fluid so it is only added once
168 if (params.get<unsigned int>("phase") == 0)
169 {
170 if (at_nodes)
171 addJoiner(at_nodes,
172 is_ad,
173 "PorousFlow_relative_permeability_nodal",
174 "PorousFlow_relative_permeability_nodal_all");
175 else
176 addJoiner(at_nodes,
177 is_ad,
178 "PorousFlow_relative_permeability_qp",
179 "PorousFlow_relative_permeability_qp_all");
180 }
181 }
182 }
183 }
184 }
185}
std::shared_ptr< FEProblemBase > & _problem
const std::string & _current_task
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
bool isParamValid(const std::string &name) const
const std::string & name() const
std::string _dictator_name
Name of the PorousFlowDictator.
bool _block_restricted
whether the Material that is currently being Joined is block-restricted
std::vector< SubdomainName > _blocks
if _block_restricted == true, then these are the blocks that the Joiner will be restricted to
void addJoiner(bool at_nodes, bool is_ad, const std::string &material_property, const std::string &output_name)
Adds a PorousFlowJoiner for the given material property.
This holds maps between the nonlinear variables used in a PorousFlow simulation and the variable numb...
if(subdm)

◆ addJoiner()

void PorousFlowAddMaterialJoiner::addJoiner ( bool  at_nodes,
bool  is_ad,
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
is_adif true: join AD materials, otherwise: join normal material
material_propertyjoin this PorousFlow material property
output_nameThe unique name given to this PorousFlowJoiner in the input file

Definition at line 188 of file PorousFlowAddMaterialJoiner.C.

192{
193 bool is_joined = false;
194
195 // Check if this material is already joined
196 if (std::find(_already_joined.begin(), _already_joined.end(), material_property) !=
197 _already_joined.end())
198 is_joined = true;
199
200 if (hasJoiner(material_property))
201 is_joined = true;
202
203 if (!is_joined)
204 {
205 std::string material_type;
206 is_ad ? material_type = "ADPorousFlowJoiner" : material_type = "PorousFlowJoiner";
207 InputParameters params = _factory.getValidParams(material_type);
208 params.set<UserObjectName>("PorousFlowDictator") = _dictator_name;
209 params.set<bool>("at_nodes") = at_nodes;
210 params.set<std::string>("material_property") = material_property;
212 params.set<std::vector<SubdomainName>>("block") = _blocks;
213 _problem->addMaterial(material_type, output_name, params);
214
215 // Add material to the already joined list
216 _already_joined.push_back(material_property);
217 }
218}
InputParameters getValidParams(const std::string &name) const
T & set(const std::string &name, bool quiet_mode=false)
Factory & _factory
bool hasJoiner(std::string property)
Helper method to determine if a PorousFLowJoiner material is already present in the input file for th...

Referenced by act().

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

222{
223 // Get the list of materials in the input file
224 auto actions = _awh.getActions<AddMaterialAction>();
225
226 for (auto & action : actions)
227 {
228 AddMaterialAction * material = const_cast<AddMaterialAction *>(action);
229
230 if (material->getMooseObjectType() == "PorousFlowJoiner")
231 {
232 // If a PorousFlowJoiner material has been included in the input file,
233 // let the user know that it should be removed
234 mooseDeprecated("PorousFlowJoiner materials are no longer required in the input "
235 "file.\nPlease remove all PorousFlowJoiner materials from this input file to "
236 "get rid of this warning");
237
238 const std::string joiner_property =
239 material->getObjectParams().get<std::string>("material_property");
240
241 // Check if the given material property is joined by this material
242 if (joiner_property == property)
243 return true;
244 }
245 }
246
247 // If no PorousFlowJoiner materials matched property, return false
248 return false;
249}
std::vector< const T * > getActions()
ActionWarehouse & _awh
void mooseDeprecated(Args &&... args) const
const std::string & getMooseObjectType() const
InputParameters & getObjectParams()

Referenced by addJoiner().

◆ validParams()

InputParameters PorousFlowAddMaterialJoiner::validParams ( )
static

Definition at line 21 of file PorousFlowAddMaterialJoiner.C.

22{
25 "Adds PorousFlowJoiner materials as required for each phase-dependent property");
26 return params;
27}
static InputParameters validParams()
void addClassDescription(const std::string &doc_string)

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 59 of file PorousFlowAddMaterialJoiner.h.

Referenced by addJoiner().

◆ _block_restricted

bool PorousFlowAddMaterialJoiner::_block_restricted
protected

whether the Material that is currently being Joined is block-restricted

Definition at line 53 of file PorousFlowAddMaterialJoiner.h.

Referenced by act(), and addJoiner().

◆ _blocks

std::vector<SubdomainName> PorousFlowAddMaterialJoiner::_blocks
protected

if _block_restricted == true, then these are the blocks that the Joiner will be restricted to

Definition at line 56 of file PorousFlowAddMaterialJoiner.h.

Referenced by act(), and addJoiner().

◆ _dictator_name

std::string PorousFlowAddMaterialJoiner::_dictator_name
protected

Name of the PorousFlowDictator.

Definition at line 50 of file PorousFlowAddMaterialJoiner.h.

Referenced by act(), and addJoiner().


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