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 : #include "SeismicSourceAction.h" 15 : #include "SeismicSource.h" 16 : #include "MooseMesh.h" 17 : 18 : #include "FEProblem.h" 19 : #include "Factory.h" 20 : #include "Parser.h" 21 : 22 : /** 23 : * This action sets up the seismic source dirackernel in multiple directions. 24 : **/ 25 : registerMooseAction("MastodonApp", SeismicSourceAction, "add_dirac_kernel"); 26 : 27 : InputParameters 28 20 : SeismicSourceAction::validParams() 29 : { 30 20 : InputParameters params = Action::validParams(); 31 20 : params.addClassDescription("Set up Seismic source dirac kernels in multiple directions."); 32 20 : params += SeismicSource::commonParameters(); 33 40 : params.addRequiredParam<std::vector<NonlinearVariableName>>( 34 : "displacements", "The vector of displacement variables."); 35 20 : return params; 36 0 : } 37 : 38 20 : SeismicSourceAction::SeismicSourceAction(const InputParameters & params) : Action(params) {} 39 : 40 : void 41 20 : SeismicSourceAction::act() 42 : { 43 : std::vector<NonlinearVariableName> displacements = 44 60 : getParam<std::vector<NonlinearVariableName>>("displacements"); 45 : 46 20 : if (displacements.size() != _mesh->dimension()) 47 2 : mooseError("Error in " + name() + 48 : ". The number of displacement variables must match the mesh dimension."); 49 : 50 : // Apply parameters from the action level to the parameters of a 51 : // SeismicSource object 52 38 : InputParameters params = _factory.getValidParams("SeismicSource"); 53 19 : params.applyParameters(parameters()); 54 : 55 19 : std::string short_name = "mastodon_seismic_source"; 56 : 57 : // Loop over displacements and add SeismicSource object for each variable 58 40 : for (unsigned int i = 0; i < displacements.size(); ++i) 59 : { 60 31 : std::stringstream name; 61 : name << short_name; 62 : name << i; 63 : 64 31 : params.set<unsigned int>("component") = i; 65 31 : params.set<NonlinearVariableName>("variable") = displacements[i]; 66 : 67 52 : _problem->addDiracKernel("SeismicSource", name.str(), params); 68 21 : } 69 9 : }