Line data Source code
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 : 10 : #include "PorousFlowAddBCAction.h" 11 : #include "PorousFlowDictator.h" 12 : #include "NonlinearSystemBase.h" 13 : 14 : registerMooseAction("PorousFlowApp", PorousFlowAddBCAction, "add_porous_flow_bc"); 15 : 16 : InputParameters 17 34 : PorousFlowAddBCAction::validParams() 18 : { 19 34 : InputParameters params = MooseObjectAction::validParams(); 20 34 : params.addClassDescription("Action that allows adding BCs using proxy classes."); 21 34 : return params; 22 0 : } 23 : 24 34 : PorousFlowAddBCAction::PorousFlowAddBCAction(const InputParameters & parameters) 25 34 : : MooseObjectAction(parameters) 26 : { 27 34 : } 28 : 29 : void 30 34 : PorousFlowAddBCAction::act() 31 : { 32 34 : if (_type == "PorousFlowSinkBC") 33 34 : setupPorousFlowEnthalpySink(); 34 : // NOTE: no reason to catch unknown types here - MOOSE will catch that much earlier 35 30 : } 36 : 37 : void 38 34 : PorousFlowAddBCAction::setupPorousFlowEnthalpySink() 39 : { 40 34 : 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 46 34 : const PorousFlowDictator & dictator = _problem->getUserObject<PorousFlowDictator>( 47 34 : obj_pars.get<UserObjectName>("PorousFlowDictator")); 48 34 : if (dictator.numVariables() != 2) 49 2 : mooseError(name(), 50 : ": Number of porous flow variables in simulation is '", 51 2 : dictator.numVariables(), 52 : "', but this BC can be used only with pressure and temperature."); 53 : 54 64 : if (obj_pars.isParamValid("porepressure_var")) 55 : { 56 : const std::vector<VariableName> & pressure_param = 57 2 : obj_pars.get<std::vector<VariableName>>("porepressure_var"); 58 2 : if (pressure_param.size() != 1) 59 2 : mooseError(name(), ": 'porepressure_var' parameter can currently take only a single value"); 60 : } 61 30 : const std::vector<BoundaryName> & boundary = obj_pars.get<std::vector<BoundaryName>>("boundary"); 62 30 : const UserObjectName & dictator_name = obj_pars.get<UserObjectName>("PorousFlowDictator"); 63 30 : const FunctionName & flux_fn_name = obj_pars.get<FunctionName>("flux_function"); 64 : 65 : const MooseVariableFEBase & p_m_var = 66 30 : _problem->getNonlinearSystemBase(/*nl_sys_num=*/0).getVariable(tid, 0); 67 : const MooseVariableFEBase & T_m_var = 68 30 : _problem->getNonlinearSystemBase(/*nl_sys_num=*/0).getVariable(tid, 1); 69 : 70 30 : bool has_fluid_phase = obj_pars.isParamValid("fluid_phase"); 71 : { 72 30 : const std::string class_name = "PorousFlowSink"; 73 30 : InputParameters pars = _factory.getValidParams(class_name); 74 30 : _app.builder().extractParams(_name, pars); // extract global params 75 60 : pars.set<NonlinearVariableName>("variable") = {p_m_var.name()}; 76 30 : pars.set<std::vector<BoundaryName>>("boundary") = boundary; 77 30 : pars.set<UserObjectName>("PorousFlowDictator") = dictator_name; 78 30 : pars.set<bool>("use_mobility") = false; 79 30 : pars.set<bool>("use_relperm") = false; 80 30 : if (has_fluid_phase) 81 30 : pars.set<unsigned int>("fluid_phase") = obj_pars.get<unsigned int>("fluid_phase"); 82 : else 83 0 : pars.set<std::vector<VariableName>>("porepressure_var") = 84 0 : obj_pars.get<std::vector<VariableName>>("porepressure_var"); 85 30 : pars.set<FunctionName>("flux_function") = flux_fn_name; 86 30 : _problem->addBoundaryCondition(class_name, nm + "_p_bc", pars); 87 30 : } 88 : { 89 30 : const std::string class_name = "PorousFlowEnthalpySink"; 90 30 : InputParameters pars = _factory.getValidParams(class_name); 91 30 : _app.builder().extractParams(_name, pars); // extract global params 92 60 : pars.set<NonlinearVariableName>("variable") = {T_m_var.name()}; 93 60 : pars.set<std::vector<BoundaryName>>("boundary") = boundary; 94 30 : pars.set<Real>("T_in") = obj_pars.get<Real>("T_in"); 95 30 : pars.set<UserObjectName>("fp") = obj_pars.get<UserObjectName>("fp"); 96 30 : pars.set<UserObjectName>("PorousFlowDictator") = dictator_name; 97 30 : if (has_fluid_phase) 98 30 : pars.set<unsigned int>("fluid_phase") = obj_pars.get<unsigned int>("fluid_phase"); 99 : else 100 0 : pars.set<std::vector<VariableName>>("porepressure_var") = 101 0 : obj_pars.get<std::vector<VariableName>>("porepressure_var"); 102 30 : pars.set<FunctionName>("flux_function") = flux_fn_name; 103 30 : _problem->addBoundaryCondition(class_name, nm + "_T_bc", pars); 104 30 : } 105 30 : }