www.mooseframework.org
ThermalContactAction.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "ThermalContactAction.h"
11 
12 #include "AddVariableAction.h"
13 #include "FEProblem.h"
14 #include "libmesh/string_to_enum.h"
15 #include "GapConductance.h"
16 #include "GapConductanceConstant.h"
17 #include "NonlinearSystem.h"
18 
19 registerMooseAction("HeatConductionApp", ThermalContactAction, "add_aux_kernel");
20 registerMooseAction("HeatConductionApp", ThermalContactAction, "add_aux_variable");
21 registerMooseAction("HeatConductionApp", ThermalContactAction, "add_bc");
22 registerMooseAction("HeatConductionApp", ThermalContactAction, "add_dirac_kernel");
23 registerMooseAction("HeatConductionApp", ThermalContactAction, "add_material");
24 registerMooseAction("HeatConductionApp", ThermalContactAction, "add_slave_flux_vector");
25 
27 
28 InputParameters
30 {
31  InputParameters params = Action::validParams();
32  params.addClassDescription(
33  "Action that controls the creation of all of the necessary objects for "
34  "calculation of Thermal Contact");
35 
36  params.addParam<std::string>(
37  "gap_aux_type",
38  "GapValueAux",
39  "A string representing the Moose object that will be used for computing the gap size");
40  params.addRequiredParam<NonlinearVariableName>("variable", "The variable for thermal contact");
41  params.addRequiredParam<BoundaryName>("master", "The master surface");
42  params.addRequiredParam<BoundaryName>("slave", "The slave surface");
43  params.addRangeCheckedParam<Real>("tangential_tolerance",
44  "tangential_tolerance>=0",
45  "Tangential distance to extend edges of contact surfaces");
46  params.addRangeCheckedParam<Real>(
47  "normal_smoothing_distance",
48  "normal_smoothing_distance>=0 & normal_smoothing_distance<=1",
49  "Distance from edge in parametric coordinates over which to smooth contact normal");
50  params.addParam<std::string>("normal_smoothing_method",
51  "Method to use to smooth normals (edge_based|nodal_normal_based)");
52 
53  MooseEnum orders(AddVariableAction::getNonlinearVariableOrders());
54  params.addParam<MooseEnum>("order", orders, "The finite element order");
55 
56  params.addParam<bool>(
57  "warnings", false, "Whether to output warning messages concerning nodes not being found");
58  params.addParam<bool>(
59  "quadrature", false, "Whether or not to use quadrature point based gap heat transfer");
60 
61  params.addParam<std::string>(
62  "appended_property_name", "", "Name appended to material properties to make them unique");
63  params.addRequiredParam<std::string>(
64  "type",
65  "A string representing the Moose object that will be used for heat conduction over the gap");
66 
67  params.addParam<std::vector<VariableName>>("disp_x", "The x displacement");
68  params.addParam<std::vector<VariableName>>("disp_y", "The y displacement");
69  params.addParam<std::vector<VariableName>>("disp_z", "The z displacement");
70  params.addParam<std::vector<VariableName>>(
71  "displacements",
72  "The displacements appropriate for the simulation geometry and coordinate system");
73 
74  params.addParam<std::vector<AuxVariableName>>(
75  "save_in", "The Auxiliary Variable to (optionally) save the boundary flux in");
76  params.addRangeCheckedParam<Real>("gap_conductivity",
77  1.0,
78  "gap_conductivity>0",
79  "The thermal conductivity of the gap material");
80  params.addParam<FunctionName>(
81  "gap_conductivity_function",
82  "Thermal conductivity of the gap material as a function. Multiplied by gap_conductivity.");
83  params.addParam<std::vector<VariableName>>(
84  "gap_conductivity_function_variable",
85  "Variable to be used in gap_conductivity_function in place of time");
86 
89 
90  return params;
91 }
92 
93 ThermalContactAction::ThermalContactAction(const InputParameters & params)
94  : Action(params),
95  _quadrature(getParam<bool>("quadrature")),
96  _order(getParam<MooseEnum>("order")),
97  _penetration_var_name(_quadrature ? "qpoint_penetration" : "penetration"),
98  _gap_value_name("paired_" + getParam<NonlinearVariableName>("variable")),
99  _gap_conductivity_name("paired_k_" + getParam<NonlinearVariableName>("variable"))
100 {
101 }
102 
103 void
105 {
106  if (_current_task == "add_aux_kernel")
107  addAuxKernels();
108  else if (_current_task == "add_aux_variable")
109  addAuxVariables();
110  else if (_current_task == "add_bc")
111  addBCs();
112  else if (_current_task == "add_dirac_kernel")
113  addDiracKernels();
114  else if (_current_task == "add_material")
115  addMaterials();
116  else if (_current_task == "add_slave_flux_vector")
118 }
119 
120 void
122 {
123  // Add gap aux kernel
124  {
125  InputParameters params = _factory.getValidParams(getParam<std::string>("gap_aux_type"));
126 
127  params.applySpecificParameters(parameters(),
128  {"tangential_tolerance",
129  "normal_smoothing_distance",
130  "normal_smoothing_method",
131  "order",
132  "warnings"});
133  params.set<AuxVariableName>("variable") = _gap_value_name;
134  params.set<ExecFlagEnum>("execute_on", true) = {EXEC_INITIAL, EXEC_LINEAR};
135  params.set<std::vector<BoundaryName>>("boundary") = {getParam<BoundaryName>("slave")};
136  params.set<BoundaryName>("paired_boundary") = getParam<BoundaryName>("master");
137  params.set<VariableName>("paired_variable") = getParam<NonlinearVariableName>("variable");
138 
139  _problem->addAuxKernel(getParam<std::string>("gap_aux_type"), "gap_value_" + name(), params);
140 
141  if (_quadrature)
142  {
143  params.set<std::vector<BoundaryName>>("boundary") = {getParam<BoundaryName>("master")};
144  params.set<BoundaryName>("paired_boundary") = getParam<BoundaryName>("slave");
145 
146  _problem->addAuxKernel(
147  getParam<std::string>("gap_aux_type"), "gap_value_master_" + name(), params);
148  }
149  }
150 
151  // Add penetration aux kernel
152  {
153  InputParameters params = _factory.getValidParams("PenetrationAux");
154 
155  params.applySpecificParameters(
156  parameters(),
157  {"tangential_tolerance", "normal_smoothing_distance", "normal_smoothing_method", "order"});
158  params.set<AuxVariableName>("variable") = _penetration_var_name;
159  params.set<ExecFlagEnum>("execute_on", true) = {EXEC_INITIAL, EXEC_LINEAR};
160  params.set<std::vector<BoundaryName>>("boundary") = {getParam<BoundaryName>("slave")};
161  params.set<BoundaryName>("paired_boundary") = getParam<BoundaryName>("master");
162 
163  _problem->addAuxKernel("PenetrationAux", "penetration_" + name(), params);
164  }
165 }
166 
167 void
169 {
170  // We need to add variables only once per variable name. However, we don't know how many unique
171  // variable names we will have. So, we'll always add them.
172 
173  MooseEnum order = getParam<MooseEnum>("order");
174  std::string family = "LAGRANGE";
175 
176  if (_quadrature)
177  {
178  order = "CONSTANT";
179  family = "MONOMIAL";
180  }
181 
182  auto var_type =
183  AddVariableAction::determineType(FEType(order, Utility::string_to_enum<FEFamily>(family)), 1);
184  auto var_params = _factory.getValidParams(var_type);
185  var_params.set<MooseEnum>("order") = order;
186  var_params.set<MooseEnum>("family") = family;
187 
188  _problem->addAuxVariable(var_type, _penetration_var_name, var_params);
189  _problem->addAuxVariable(var_type, _gap_value_name, var_params);
190 }
191 
192 void
194 {
195  const std::string object_name = getParam<std::string>("type");
196  InputParameters params = _factory.getValidParams(object_name);
197  params.applyParameters(parameters());
198 
199  if (_quadrature)
200  {
201  params.set<BoundaryName>("paired_boundary") = getParam<BoundaryName>("master");
202  params.set<bool>("use_displaced_mesh") = true;
203  }
204  else
205  {
206  params.set<std::vector<VariableName>>("gap_distance") = {"penetration"};
207  params.set<std::vector<VariableName>>("gap_temp") = {_gap_value_name};
208  }
209 
210  params.set<std::vector<BoundaryName>>("boundary") = {getParam<BoundaryName>("slave")};
211 
212  _problem->addBoundaryCondition(object_name, "gap_bc_" + name(), params);
213 
214  if (_quadrature)
215  {
216  // Swap master and slave for this one
217  params.set<std::vector<BoundaryName>>("boundary") = {getParam<BoundaryName>("master")};
218  params.set<BoundaryName>("paired_boundary") = getParam<BoundaryName>("slave");
219 
220  _problem->addBoundaryCondition(object_name, "gap_bc_master_" + name(), params);
221  }
222 }
223 
224 void
226 {
227  if (_quadrature)
228  return;
229 
230  const std::string object_name = "GapHeatPointSourceMaster";
231  InputParameters params = _factory.getValidParams(object_name);
232  params.applySpecificParameters(parameters(),
233  {"tangential_tolerance",
234  "normal_smoothing_distance",
235  "normal_smoothing_method",
236  "order",
237  "slave",
238  "variable"});
239  params.set<BoundaryName>("boundary") = getParam<BoundaryName>("master");
240 
241  _problem->addDiracKernel(object_name, object_name + "_" + name(), params);
242 }
243 
244 void
246 {
247  if (getParam<std::string>("type") != "GapHeatTransfer")
248  return;
249 
250  if (parameters().isParamSetByUser("gap_conductance"))
251  {
252  if (parameters().isParamSetByUser("gap_conductivity") ||
253  parameters().isParamSetByUser("gap_conductivity_function"))
254  mooseError(
255  "Cannot specify both gap_conductance and gap_conductivity or gap_conductivity_function");
256 
257  const std::string object_type = "GapConductanceConstant";
258  InputParameters params = _factory.getValidParams(object_type);
259  params.applyParameters(parameters());
260  params.set<std::vector<BoundaryName>>("boundary") = {getParam<BoundaryName>("slave")};
261  _problem->addMaterial(object_type, name() + "_" + "gap_value", params);
262 
263  if (_quadrature)
264  {
265  params.set<std::vector<BoundaryName>>("boundary") = {getParam<BoundaryName>("master")};
266  _problem->addMaterial(object_type, name() + "_" + "gap_value_master", params);
267  }
268  }
269  else
270  {
271  const std::string object_type = "GapConductance";
272 
273  InputParameters params = _factory.getValidParams(object_type);
274  params.applyParameters(parameters(), {"variable"});
275 
276  params.set<std::vector<VariableName>>("variable") = {
277  getParam<NonlinearVariableName>("variable")};
278  params.set<std::vector<BoundaryName>>("boundary") = {getParam<BoundaryName>("slave")};
279 
280  if (_quadrature)
281  {
282  params.set<BoundaryName>("paired_boundary") = getParam<BoundaryName>("master");
283  }
284  else
285  {
286  params.set<std::vector<VariableName>>("gap_temp") = {_gap_value_name};
287  params.set<std::vector<VariableName>>("gap_distance") = {"penetration"};
288  }
289 
290  _problem->addMaterial(object_type, name() + "_" + "gap_value", params);
291 
292  if (_quadrature)
293  {
294  params.set<BoundaryName>("paired_boundary") = getParam<BoundaryName>("slave");
295  params.set<std::vector<BoundaryName>>("boundary") = {getParam<BoundaryName>("master")};
296 
297  _problem->addMaterial(object_type, name() + "_" + "gap_value_master", params);
298  }
299  }
300 }
301 
302 void
304 {
305  _problem->getNonlinearSystemBase().addVector("slave_flux", false, GHOSTED);
306  _problem->getNonlinearSystemBase().zeroVectorForResidual("slave_flux");
307 
308  // It is risky to apply this optimization to contact problems
309  // since the problem configuration may be changed during Jacobian
310  // evaluation. We therefore turn it off for all contact problems so that
311  // PETSc-3.8.4 or higher will have the same behavior as PETSc-3.8.3 or older.
312  if (!_problem->isSNESMFReuseBaseSetbyUser())
313  _problem->setSNESMFReuseBase(false, false);
314 }
ThermalContactAction::addSlaveFluxVector
virtual void addSlaveFluxVector()
Definition: ThermalContactAction.C:303
ThermalContactAction.h
ThermalContactAction::addAuxVariables
virtual void addAuxVariables()
Definition: ThermalContactAction.C:168
GapConductanceConstant.h
ThermalContactAction::_quadrature
const bool _quadrature
Definition: ThermalContactAction.h:32
ThermalContactAction::act
virtual void act() override
Definition: ThermalContactAction.C:104
ThermalContactAction::addBCs
virtual void addBCs()
Definition: ThermalContactAction.C:193
ThermalContactAction
Definition: ThermalContactAction.h:16
GapConductance.h
registerMooseAction
registerMooseAction("HeatConductionApp", ThermalContactAction, "add_aux_kernel")
validParams
InputParameters validParams()
name
const std::string name
Definition: Setup.h:21
ThermalContactAction::addAuxKernels
virtual void addAuxKernels()
Definition: ThermalContactAction.C:121
ThermalContactAction::ThermalContactAction
ThermalContactAction(const InputParameters &params)
Definition: ThermalContactAction.C:93
GapConductanceConstant::actionParameters
static InputParameters actionParameters()
Definition: GapConductanceConstant.C:30
ThermalContactAction::addDiracKernels
virtual void addDiracKernels()
Definition: ThermalContactAction.C:225
ThermalContactAction::_gap_value_name
const AuxVariableName _gap_value_name
Definition: ThermalContactAction.h:35
ThermalContactAction::validParams
static InputParameters validParams()
Definition: ThermalContactAction.C:29
defineLegacyParams
defineLegacyParams(ThermalContactAction)
ThermalContactAction::addMaterials
virtual void addMaterials()
Definition: ThermalContactAction.C:245
ThermalContactAction::_penetration_var_name
const AuxVariableName _penetration_var_name
Definition: ThermalContactAction.h:34
GapConductance::actionParameters
static InputParameters actionParameters()
Definition: GapConductance.C:74