https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PorousFlowAddBCAction.C
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
11#include "PorousFlowDictator.h"
12#include "NonlinearSystemBase.h"
13
14registerMooseAction("PorousFlowApp", PorousFlowAddBCAction, "add_porous_flow_bc");
15
18{
20 params.addClassDescription("Action that allows adding BCs using proxy classes.");
21 return params;
22}
23
28
29void
31{
32 if (_type == "PorousFlowSinkBC")
34 // NOTE: no reason to catch unknown types here - MOOSE will catch that much earlier
35}
36
37void
39{
40 std::string nm = name();
41
42 THREAD_ID tid = 0;
43 const InputParameters & obj_pars = getObjectParams();
44
45 // check that we have 2 porous flow variables
47 obj_pars.get<UserObjectName>("PorousFlowDictator"));
48 if (dictator.numVariables() != 2)
50 ": Number of porous flow variables in simulation is '",
51 dictator.numVariables(),
52 "', but this BC can be used only with pressure and temperature.");
53
54 if (obj_pars.isParamValid("porepressure_var"))
55 {
56 const std::vector<VariableName> & pressure_param =
57 obj_pars.get<std::vector<VariableName>>("porepressure_var");
58 if (pressure_param.size() != 1)
59 mooseError(name(), ": 'porepressure_var' parameter can currently take only a single value");
60 }
61 const std::vector<BoundaryName> & boundary = obj_pars.get<std::vector<BoundaryName>>("boundary");
62 const UserObjectName & dictator_name = obj_pars.get<UserObjectName>("PorousFlowDictator");
63 const FunctionName & flux_fn_name = obj_pars.get<FunctionName>("flux_function");
64
65 const MooseVariableFEBase & p_m_var =
66 _problem->getNonlinearSystemBase(/*nl_sys_num=*/0).getVariable(tid, 0);
67 const MooseVariableFEBase & T_m_var =
68 _problem->getNonlinearSystemBase(/*nl_sys_num=*/0).getVariable(tid, 1);
69
70 bool has_fluid_phase = obj_pars.isParamValid("fluid_phase");
71 {
72 const std::string class_name = "PorousFlowSink";
73 InputParameters pars = _factory.getValidParams(class_name);
74 _app.builder().extractParams(_name, pars); // extract global params
75 pars.set<NonlinearVariableName>("variable") = {p_m_var.name()};
76 pars.set<std::vector<BoundaryName>>("boundary") = boundary;
77 pars.set<UserObjectName>("PorousFlowDictator") = dictator_name;
78 pars.set<bool>("use_mobility") = false;
79 pars.set<bool>("use_relperm") = false;
80 if (has_fluid_phase)
81 pars.set<unsigned int>("fluid_phase") = obj_pars.get<unsigned int>("fluid_phase");
82 else
83 pars.set<std::vector<VariableName>>("porepressure_var") =
84 obj_pars.get<std::vector<VariableName>>("porepressure_var");
85 pars.set<FunctionName>("flux_function") = flux_fn_name;
86 _problem->addBoundaryCondition(class_name, nm + "_p_bc", pars);
87 }
88 {
89 const std::string class_name = "PorousFlowEnthalpySink";
90 InputParameters pars = _factory.getValidParams(class_name);
91 _app.builder().extractParams(_name, pars); // extract global params
92 pars.set<NonlinearVariableName>("variable") = {T_m_var.name()};
93 pars.set<std::vector<BoundaryName>>("boundary") = boundary;
94 pars.set<Real>("T_in") = obj_pars.get<Real>("T_in");
95 pars.set<UserObjectName>("fp") = obj_pars.get<UserObjectName>("fp");
96 pars.set<UserObjectName>("PorousFlowDictator") = dictator_name;
97 if (has_fluid_phase)
98 pars.set<unsigned int>("fluid_phase") = obj_pars.get<unsigned int>("fluid_phase");
99 else
100 pars.set<std::vector<VariableName>>("porepressure_var") =
101 obj_pars.get<std::vector<VariableName>>("porepressure_var");
102 pars.set<FunctionName>("flux_function") = flux_fn_name;
103 _problem->addBoundaryCondition(class_name, nm + "_T_bc", pars);
104 }
105}
unsigned int THREAD_ID
registerMooseAction("PorousFlowApp", PorousFlowAddBCAction, "add_porous_flow_bc")
std::shared_ptr< FEProblemBase > & _problem
InputParameters getValidParams(const std::string &name) const
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
void addClassDescription(const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
bool isParamValid(const std::string &name) const
Moose::Builder & builder()
const std::string & name() const
void mooseError(Args &&... args) const
const std::string & _name
static InputParameters validParams()
InputParameters & getObjectParams()
std::string _type
void extractParams(const hit::Node *const section_node, InputParameters &p)
Factory & _factory
Action that sets up BCs for porous flow module.
PorousFlowAddBCAction(const InputParameters &parameters)
virtual void act() override
void setupPorousFlowEnthalpySink()
Setup a BC corresponding to hot/cold fluid injection.
static InputParameters validParams()
This holds maps between the nonlinear variables used in a PorousFlow simulation and the variable numb...
unsigned int numVariables() const
The number of PorousFlow variables.
const T & getUserObject(const std::string &param_name, bool is_dependency=true) const