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 196 : DynamicSolidMechanicsPhysics::validParams()
39 : {
40 196 : InputParameters params = QuasiStaticSolidMechanicsPhysics::validParams();
41 196 : params.addClassDescription("Set up dynamic stress divergence kernels");
42 392 : params.addParam<bool>("static_initialization",
43 392 : 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 392 : params.addParam<std::vector<AuxVariableName>>(
50 : "velocities",
51 980 : std::vector<AuxVariableName>({"vel_x", "vel_y", "vel_z"}),
52 : "Names of the velocity variables");
53 392 : params.addParam<std::vector<AuxVariableName>>(
54 : "accelerations",
55 980 : std::vector<AuxVariableName>({"accel_x", "accel_y", "accel_z"}),
56 : "Names of the acceleration variables");
57 392 : params.addParamNamesToGroup("velocities accelerations", "Variables");
58 :
59 392 : params.addParam<Real>("hht_alpha",
60 392 : 0,
61 : "alpha parameter for mass dependent numerical damping induced "
62 : "by HHT time integration scheme");
63 392 : params.addParam<Real>("newmark_beta", 0.25, "beta parameter for Newmark Time integration");
64 392 : params.addParam<Real>("newmark_gamma", 0.5, "gamma parameter for Newmark Time integration");
65 392 : params.addParam<MaterialPropertyName>("mass_damping_coefficient",
66 392 : 0.0,
67 : "Name of material property or a constant real "
68 : "number defining mass Rayleigh parameter (eta).");
69 392 : params.addParam<MaterialPropertyName>("stiffness_damping_coefficient",
70 392 : 0.0,
71 : "Name of material property or a constant real "
72 : "number defining stiffness Rayleigh parameter (zeta).");
73 392 : params.addParam<MaterialPropertyName>(
74 : "density", "density", "Name of Material Property that provides the density");
75 392 : params.addParamNamesToGroup("hht_alpha newmark_beta newmark_gamma",
76 : "Time integration parameters");
77 :
78 196 : return params;
79 0 : }
80 :
81 196 : DynamicSolidMechanicsPhysics::DynamicSolidMechanicsPhysics(const InputParameters & params)
82 : : QuasiStaticSolidMechanicsPhysics(params),
83 196 : _velocities(getParam<std::vector<AuxVariableName>>("velocities")),
84 588 : _accelerations(getParam<std::vector<AuxVariableName>>("accelerations"))
85 : {
86 196 : }
87 :
88 : void
89 468 : DynamicSolidMechanicsPhysics::act()
90 : {
91 468 : const std::array<std::string, 3> dir{{"x", "y", "z"}};
92 :
93 468 : if (_velocities.size() < _ndisp)
94 0 : paramError("velocities", "Supply one velocity variable per displacement direction");
95 468 : 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 572 : if (_current_task == "add_aux_variable" && getParam<bool>("add_variables"))
100 : {
101 48 : auto params = _factory.getValidParams("MooseVariable");
102 : // determine necessary order
103 48 : const bool second = _problem->mesh().hasSecondOrderElements();
104 :
105 144 : params.set<MooseEnum>("order") = second ? "SECOND" : "FIRST";
106 96 : params.set<MooseEnum>("family") = "LAGRANGE";
107 :
108 168 : for (unsigned int i = 0; i < _ndisp; ++i)
109 : {
110 120 : _problem->addAuxVariable("MooseVariable", _velocities[i], params);
111 240 : _problem->addAuxVariable("MooseVariable", _accelerations[i], params);
112 : }
113 48 : }
114 :
115 : // Add aux kernel for velocities and accelerations
116 468 : 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 180 : for (unsigned int i = 0; i < _ndisp; ++i)
126 : {
127 : auto kernel_type = "NewmarkAccelAux";
128 128 : auto params = _factory.getValidParams(kernel_type);
129 256 : params.set<AuxVariableName>("variable") = _accelerations[i];
130 384 : params.set<std::vector<VariableName>>("displacement") = {_displacements[i]};
131 384 : params.set<std::vector<VariableName>>("velocity") = {_velocities[i]};
132 128 : params.set<ExecFlagEnum>("execute_on") = EXEC_TIMESTEP_END;
133 256 : params.set<Real>("beta") = getParam<Real>("newmark_beta");
134 128 : params.applyParameters(parameters());
135 256 : _problem->addAuxKernel(kernel_type, "TM_" + name() + '_' + _accelerations[i], params);
136 128 : }
137 :
138 : // velocity aux kernels
139 180 : for (unsigned int i = 0; i < _ndisp; ++i)
140 : {
141 : auto kernel_type = "NewmarkVelAux";
142 128 : auto params = _factory.getValidParams(kernel_type);
143 256 : params.set<AuxVariableName>("variable") = _velocities[i];
144 384 : params.set<std::vector<VariableName>>("acceleration") = {_accelerations[i]};
145 128 : params.set<ExecFlagEnum>("execute_on") = EXEC_TIMESTEP_END;
146 256 : params.set<Real>("gamma") = getParam<Real>("newmark_gamma");
147 128 : params.applyParameters(parameters());
148 256 : _problem->addAuxKernel(kernel_type, "TM_" + name() + '_' + _velocities[i], params);
149 128 : }
150 : }
151 :
152 : // add inertia kernel
153 468 : if (_current_task == "add_kernel")
154 : {
155 180 : for (unsigned int i = 0; i < _ndisp; ++i)
156 : {
157 128 : auto kernel_type = _use_ad ? "ADInertialForce" : "InertialForce";
158 128 : auto params = _factory.getValidParams(kernel_type);
159 :
160 256 : params.set<NonlinearVariableName>("variable") = _displacements[i];
161 384 : params.set<std::vector<VariableName>>("velocity") = {_velocities[i]};
162 384 : params.set<std::vector<VariableName>>("acceleration") = {_accelerations[i]};
163 128 : params.set<bool>("use_displaced_mesh") = false;
164 256 : params.set<Real>("beta") = getParam<Real>("newmark_beta");
165 256 : params.set<Real>("gamma") = getParam<Real>("newmark_gamma");
166 256 : params.set<Real>("alpha") = getParam<Real>("hht_alpha");
167 256 : params.set<MaterialPropertyName>("eta") =
168 256 : getParam<MaterialPropertyName>("mass_damping_coefficient");
169 :
170 128 : params.applyParameters(parameters());
171 :
172 384 : _problem->addKernel(kernel_type, "TM_" + name() + "_inertia_" + dir[i], params);
173 128 : }
174 : }
175 :
176 : // call parent class method
177 468 : QuasiStaticSolidMechanicsPhysics::act();
178 980 : }
179 :
180 : std::string
181 479 : DynamicSolidMechanicsPhysics::getKernelType()
182 : {
183 : // choose kernel type based on coordinate system
184 479 : if (_coord_system == Moose::COORD_XYZ)
185 479 : return "DynamicStressDivergenceTensors";
186 : else
187 0 : mooseError("Unsupported coordinate system");
188 : }
189 :
190 : InputParameters
191 487 : DynamicSolidMechanicsPhysics::getKernelParameters(std::string type)
192 : {
193 487 : InputParameters params = QuasiStaticSolidMechanicsPhysics::getKernelParameters(type);
194 :
195 974 : if (params.isParamDefined("alpha"))
196 958 : params.set<Real>("alpha") = getParam<Real>("hht_alpha");
197 974 : if (params.isParamDefined("zeta"))
198 958 : params.set<MaterialPropertyName>("zeta") =
199 958 : getParam<MaterialPropertyName>("stiffness_damping_coefficient");
200 :
201 487 : return params;
202 0 : }
|