Line data Source code
1 : /*************************************************/ 2 : /* DO NOT MODIFY THIS HEADER */ 3 : /* */ 4 : /* MASTODON */ 5 : /* */ 6 : /* (c) 2015 Battelle Energy Alliance, LLC */ 7 : /* ALL RIGHTS RESERVED */ 8 : /* */ 9 : /* Prepared by Battelle Energy Alliance, LLC */ 10 : /* With the U. S. Department of Energy */ 11 : /* */ 12 : /* See COPYRIGHT for full restrictions */ 13 : /*************************************************/ 14 : 15 : // MOOSE includes 16 : #include "FEProblem.h" 17 : #include "Factory.h" 18 : #include "MooseMesh.h" 19 : 20 : // Mastodon includes 21 : #include "SeismicDisplacementAction.h" 22 : 23 : registerMooseAction("MastodonApp", SeismicDisplacementAction, "add_bc"); 24 : 25 : InputParameters 26 4 : SeismicDisplacementAction::validParams() 27 : { 28 4 : InputParameters params = Action::validParams(); 29 4 : params.addClassDescription("This action sets up seismic displacement boundary conditions."); 30 : 31 8 : params.addRequiredParam<std::vector<BoundaryName>>( 32 : "boundary", 33 : "The list of boundary IDs from the mesh where this boundary " 34 : "condition will be applied."); 35 8 : params.addRequiredParam<std::vector<VariableName>>( 36 : "displacements", "The nonlinear displacement variables for the problem."); 37 8 : params.addRequiredParam<std::vector<VariableName>>( 38 : "accelerations", 39 : "The vector of acceleration variables that are coupled " 40 : "to displacements. The size of this vector should be " 41 : "same as displacements."); 42 8 : params.addRequiredParam<std::vector<VariableName>>( 43 : "velocities", 44 : "The vector of velocity variables names. The input " 45 : "velocities can be obtained from this variable. The size " 46 : "of this vector must be same size as input_component."); 47 8 : params.addRequiredParam<std::vector<unsigned int>>( 48 : "input_components", "The directions in which the input ground motions are applied."); 49 8 : params.addRequiredParam<std::vector<FunctionName>>( 50 : "input_functions", 51 : "The vector of function names that describes the " 52 : "input ground motions. Must be same size as " 53 : "input_component."); 54 8 : params.addParam<Real>("beta", 0.0, "The beta parameter for newmark time integration."); 55 : 56 4 : return params; 57 0 : } 58 : 59 4 : SeismicDisplacementAction::SeismicDisplacementAction(const InputParameters & params) 60 : : Action(params), 61 4 : _boundary(getParam<std::vector<BoundaryName>>("boundary")), 62 8 : _displacements(getParam<std::vector<VariableName>>("displacements")), 63 8 : _accelerations(getParam<std::vector<VariableName>>("accelerations")), 64 8 : _velocities(getParam<std::vector<VariableName>>("velocities")), 65 8 : _input_components(getParam<std::vector<unsigned int>>("input_components")), 66 12 : _input_functions(getParam<std::vector<FunctionName>>("input_functions")) 67 : { 68 4 : if ((_displacements.size() != _input_components.size()) || 69 3 : (_displacements.size() != _accelerations.size()) || 70 7 : (_displacements.size() != _velocities.size()) || 71 3 : _displacements.size() != _input_functions.size()) 72 1 : mooseError("In the \"", 73 : name(), 74 : "\" block the 'displacements', " 75 : "'velocities', 'accelerations', " 76 : "'input_functions', and 'input_components' " 77 : "should be of the same size."); 78 3 : } 79 : 80 : void 81 3 : SeismicDisplacementAction::act() 82 : { 83 3 : InputParameters params = _factory.getValidParams("PresetDisplacement"); 84 3 : params.set<std::vector<BoundaryName>>("boundary") = _boundary; 85 6 : params.set<Real>("beta") = getParam<Real>("beta"); 86 : 87 3 : std::string prefix = "mastodon_preset_displacement"; 88 9 : for (unsigned int j = 0; j < _input_components.size(); ++j) 89 : { 90 6 : params.set<FunctionName>("function") = _input_functions[j]; 91 12 : params.set<NonlinearVariableName>("variable") = _displacements[j]; 92 18 : params.set<std::vector<VariableName>>("velocity") = {_velocities[j]}; 93 18 : params.set<std::vector<VariableName>>("acceleration") = {_accelerations[j]}; 94 : 95 6 : std::stringstream obj_name; 96 12 : obj_name << prefix << "_" << name() << "_" << j; 97 12 : _problem->addBoundaryCondition("PresetDisplacement", obj_name.str(), params); 98 6 : } 99 3 : }