https://mooseframework.inl.gov
PressureAction.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 
10 #include "PressureAction.h"
11 #include "Factory.h"
12 #include "FEProblem.h"
13 #include "Conversion.h"
14 
16  const std::string & non_ad_pressure_bc_type,
17  const std::string & ad_pressure_bc_type)
18  : Action(params),
19  _non_ad_pressure_bc_type(non_ad_pressure_bc_type),
20  _ad_pressure_bc_type(ad_pressure_bc_type),
21  _use_ad(getParam<bool>("use_automatic_differentiation")),
22  _save_in_vars({getParam<std::vector<AuxVariableName>>("save_in_disp_x"),
23  getParam<std::vector<AuxVariableName>>("save_in_disp_y"),
24  getParam<std::vector<AuxVariableName>>("save_in_disp_z")}),
25  _has_save_in_vars({params.isParamValid("save_in_disp_x"),
26  params.isParamValid("save_in_disp_y"),
27  params.isParamValid("save_in_disp_z")})
28 {
29 }
30 
31 void
33 {
34  const auto bc_type = _use_ad ? _ad_pressure_bc_type : _non_ad_pressure_bc_type;
35 
36  std::vector<VariableName> displacements = getParam<std::vector<VariableName>>("displacements");
37  // Create pressure BCs
38  for (unsigned int i = 0; i < displacements.size(); ++i)
39  {
40  // Create unique kernel name for each of the components
41  std::string bc_name = bc_type + "_" + _name + "_" + Moose::stringify(i);
42 
43  InputParameters params = _factory.getValidParams(bc_type);
44  params.applyParameters(parameters());
45 
46  params.set<NonlinearVariableName>("variable") = displacements[i];
47  if (_has_save_in_vars[i])
48  params.set<std::vector<AuxVariableName>>("save_in") = _save_in_vars[i];
49 
50  _problem->addBoundaryCondition(bc_type, bc_name, params);
51 
52  // The three BCs can no longer be controlled independently.
53  // We agreed on PR#29603 that this was not a problem
54  if (isParamValid("enable"))
55  connectControllableParams("enable", bc_type, bc_name, "enable");
56  }
57 }
const std::vector< std::vector< AuxVariableName > > _save_in_vars
T & set(const std::string &name, bool quiet_mode=false)
InputParameters getValidParams(const std::string &name) const
void applyParameters(const InputParameters &common, const std::vector< std::string > &exclude={}, const bool allow_private=false)
PressureActionBase(const InputParameters &params, const std::string &non_ad_pressure_bc_type, const std::string &ad_pressure_bc_type)
bool isParamValid(const std::string &name) const
Factory & _factory
const std::vector< bool > _has_save_in_vars
const T & getParam(const std::string &name) const
const bool _use_ad
Flag to use automatic differentiation.
void connectControllableParams(const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
std::string stringify(const T &t)
const std::string _name
const std::string _ad_pressure_bc_type
virtual void act() override
std::shared_ptr< FEProblemBase > & _problem
const InputParameters & parameters() const
const std::string _non_ad_pressure_bc_type