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 "DynamicSolidMechanicsPhysics.h"
11 : #include "Factory.h"
12 : #include "FEProblem.h"
13 : #include "Parser.h"
14 :
15 : registerMooseAction("SolidMechanicsApp", DynamicSolidMechanicsPhysics, "meta_action");
16 :
17 : registerMooseAction("SolidMechanicsApp", DynamicSolidMechanicsPhysics, "setup_mesh_complete");
18 :
19 : registerMooseAction("SolidMechanicsApp",
20 : DynamicSolidMechanicsPhysics,
21 : "validate_coordinate_systems");
22 :
23 : registerMooseAction("SolidMechanicsApp", DynamicSolidMechanicsPhysics, "add_variable");
24 :
25 : registerMooseAction("SolidMechanicsApp", DynamicSolidMechanicsPhysics, "add_aux_variable");
26 :
27 : registerMooseAction("SolidMechanicsApp", DynamicSolidMechanicsPhysics, "add_kernel");
28 :
29 : registerMooseAction("SolidMechanicsApp", DynamicSolidMechanicsPhysics, "add_aux_kernel");
30 :
31 : registerMooseAction("SolidMechanicsApp", DynamicSolidMechanicsPhysics, "add_material");
32 :
33 : registerMooseAction("SolidMechanicsApp",
34 : DynamicSolidMechanicsPhysics,
35 : "add_master_action_material");
36 :
37 : InputParameters
38 346 : DynamicSolidMechanicsPhysics::validParams()
39 : {
40 346 : InputParameters params = QuasiStaticSolidMechanicsPhysics::validParams();
41 346 : params.addClassDescription("Set up dynamic stress divergence kernels");
42 692 : params.addParam<bool>("static_initialization",
43 692 : false,
44 : "Set to true get the system to "
45 : "equilibrium under gravity by running a "
46 : "quasi-static analysis (by solving Ku = F) "
47 : "in the first time step.");
48 :
49 692 : params.addParam<std::vector<AuxVariableName>>(
50 : "velocities",
51 1730 : std::vector<AuxVariableName>({"vel_x", "vel_y", "vel_z"}),
52 : "Names of the velocity variables");
53 692 : params.addParam<std::vector<AuxVariableName>>(
54 : "accelerations",
55 1730 : std::vector<AuxVariableName>({"accel_x", "accel_y", "accel_z"}),
56 : "Names of the acceleration variables");
57 692 : params.addParamNamesToGroup("velocities accelerations", "Variables");
58 :
59 692 : params.addParam<Real>("hht_alpha",
60 692 : 0,
61 : "alpha parameter for mass dependent numerical damping induced "
62 : "by HHT time integration scheme");
63 692 : params.addParam<Real>("newmark_beta", 0.25, "beta parameter for Newmark Time integration");
64 692 : params.addParam<Real>("newmark_gamma", 0.5, "gamma parameter for Newmark Time integration");
65 692 : params.addParam<MaterialPropertyName>("mass_damping_coefficient",
66 692 : 0.0,
67 : "Name of material property or a constant real "
68 : "number defining mass Rayleigh parameter (eta).");
69 692 : params.addParam<MaterialPropertyName>("stiffness_damping_coefficient",
70 692 : 0.0,
71 : "Name of material property or a constant real "
72 : "number defining stiffness Rayleigh parameter (zeta).");
73 692 : params.addParam<MaterialPropertyName>(
74 : "density", "density", "Name of Material Property that provides the density");
75 692 : params.addParamNamesToGroup("hht_alpha newmark_beta newmark_gamma",
76 : "Time integration parameters");
77 :
78 346 : return params;
79 0 : }
80 :
81 346 : DynamicSolidMechanicsPhysics::DynamicSolidMechanicsPhysics(const InputParameters & params)
82 : : QuasiStaticSolidMechanicsPhysics(params),
83 346 : _velocities(getParam<std::vector<AuxVariableName>>("velocities")),
84 1038 : _accelerations(getParam<std::vector<AuxVariableName>>("accelerations"))
85 : {
86 346 : }
87 :
88 : void
89 819 : DynamicSolidMechanicsPhysics::act()
90 : {
91 819 : const std::array<std::string, 3> dir{{"x", "y", "z"}};
92 :
93 819 : if (_velocities.size() < _ndisp)
94 0 : paramError("velocities", "Supply one velocity variable per displacement direction");
95 819 : if (_accelerations.size() < _ndisp)
96 0 : paramError("accelerations", "Supply one acceleration variable per displacement direction");
97 :
98 : // Add aux variables for velocities and accelerations
99 1001 : if (_current_task == "add_aux_variable" && getParam<bool>("add_variables"))
100 : {
101 84 : auto params = _factory.getValidParams("MooseVariable");
102 : // determine necessary order
103 84 : const bool second = _problem->mesh().hasSecondOrderElements();
104 :
105 252 : params.set<MooseEnum>("order") = second ? "SECOND" : "FIRST";
106 168 : params.set<MooseEnum>("family") = "LAGRANGE";
107 :
108 294 : for (unsigned int i = 0; i < _ndisp; ++i)
109 : {
110 210 : _problem->addAuxVariable("MooseVariable", _velocities[i], params);
111 420 : _problem->addAuxVariable("MooseVariable", _accelerations[i], params);
112 : }
113 84 : }
114 :
115 : // Add aux kernel for velocities and accelerations
116 819 : if (_current_task == "add_aux_kernel")
117 : {
118 : //
119 : // Note: AuxKernels that are limited to TIMESTEP_END to not get their dependencies
120 : // resolved automatically. Thus we _must_ construct the acceleration kernels _first_.
121 : // NewmarkAccelAux only uses the old velocity.
122 : //
123 :
124 : // acceleration aux kernels
125 315 : for (unsigned int i = 0; i < _ndisp; ++i)
126 : {
127 : auto kernel_type = "NewmarkAccelAux";
128 224 : auto params = _factory.getValidParams(kernel_type);
129 448 : params.set<AuxVariableName>("variable") = _accelerations[i];
130 672 : params.set<std::vector<VariableName>>("displacement") = {_displacements[i]};
131 672 : params.set<std::vector<VariableName>>("velocity") = {_velocities[i]};
132 224 : params.set<ExecFlagEnum>("execute_on") = EXEC_TIMESTEP_END;
133 448 : params.set<Real>("beta") = getParam<Real>("newmark_beta");
134 224 : params.applyParameters(parameters());
135 448 : _problem->addAuxKernel(kernel_type, "TM_" + name() + '_' + _accelerations[i], params);
136 224 : }
137 :
138 : // velocity aux kernels
139 315 : for (unsigned int i = 0; i < _ndisp; ++i)
140 : {
141 : auto kernel_type = "NewmarkVelAux";
142 224 : auto params = _factory.getValidParams(kernel_type);
143 448 : params.set<AuxVariableName>("variable") = _velocities[i];
144 672 : params.set<std::vector<VariableName>>("acceleration") = {_accelerations[i]};
145 224 : params.set<ExecFlagEnum>("execute_on") = EXEC_TIMESTEP_END;
146 448 : params.set<Real>("gamma") = getParam<Real>("newmark_gamma");
147 224 : params.applyParameters(parameters());
148 448 : _problem->addAuxKernel(kernel_type, "TM_" + name() + '_' + _velocities[i], params);
149 224 : }
150 : }
151 :
152 : // add inertia kernel
153 819 : if (_current_task == "add_kernel")
154 : {
155 315 : for (unsigned int i = 0; i < _ndisp; ++i)
156 : {
157 224 : auto kernel_type = _use_ad ? "ADInertialForce" : "InertialForce";
158 224 : auto params = _factory.getValidParams(kernel_type);
159 :
160 448 : params.set<NonlinearVariableName>("variable") = _displacements[i];
161 672 : params.set<std::vector<VariableName>>("velocity") = {_velocities[i]};
162 672 : params.set<std::vector<VariableName>>("acceleration") = {_accelerations[i]};
163 224 : params.set<bool>("use_displaced_mesh") = false;
164 448 : params.set<Real>("beta") = getParam<Real>("newmark_beta");
165 448 : params.set<Real>("gamma") = getParam<Real>("newmark_gamma");
166 448 : params.set<Real>("alpha") = getParam<Real>("hht_alpha");
167 448 : params.set<MaterialPropertyName>("eta") =
168 448 : getParam<MaterialPropertyName>("mass_damping_coefficient");
169 :
170 224 : params.applyParameters(parameters());
171 :
172 672 : _problem->addKernel(kernel_type, "TM_" + name() + "_inertia_" + dir[i], params);
173 224 : }
174 : }
175 :
176 : // call parent class method
177 819 : QuasiStaticSolidMechanicsPhysics::act();
178 1715 : }
179 :
180 : std::string
181 845 : DynamicSolidMechanicsPhysics::getKernelType()
182 : {
183 : // choose kernel type based on coordinate system
184 845 : if (_coord_system == Moose::COORD_XYZ)
185 845 : return "DynamicStressDivergenceTensors";
186 : else
187 0 : mooseError("Unsupported coordinate system");
188 : }
189 :
190 : InputParameters
191 859 : DynamicSolidMechanicsPhysics::getKernelParameters(std::string type)
192 : {
193 859 : InputParameters params = QuasiStaticSolidMechanicsPhysics::getKernelParameters(type);
194 :
195 1718 : if (params.isParamDefined("alpha"))
196 1690 : params.set<Real>("alpha") = getParam<Real>("hht_alpha");
197 1718 : if (params.isParamDefined("zeta"))
198 1690 : params.set<MaterialPropertyName>("zeta") =
199 1690 : getParam<MaterialPropertyName>("stiffness_damping_coefficient");
200 :
201 859 : return params;
202 0 : }
|