11 #include "MooseUtils.h"
12 #include "DelimitedFileReader.h"
23 params.addClassDescription(
"Computes the gravitational force for a given nodal mass.");
24 params.addRangeCheckedParam<Real>(
"alpha",
26 "alpha >= -0.3333 & alpha <= 0.0",
27 "Alpha parameter for mass dependent numerical damping induced "
28 "by HHT time integration scheme");
29 params.addParam<Real>(
"mass",
"Mass associated with the node");
30 params.addParam<FileName>(
32 "The file containing the nodal positions and the corresponding nodal masses.");
33 params.addParam<Real>(
"gravity_value", 0.0,
"Acceleration due to gravity.");
35 params.addParam<FunctionName>(
36 "function",
"1",
"A function that describes the gravitational force");
41 : NodalKernel(parameters),
42 _has_mass(isParamValid(
"mass")),
43 _has_nodal_mass_file(isParamValid(
"nodal_mass_file")),
44 _mass(_has_mass ? getParam<Real>(
"mass") : 0.0),
45 _alpha(getParam<Real>(
"alpha")),
46 _gravity_value(getParam<Real>(
"gravity_value")),
47 _function(getFunction(
"function"))
50 mooseError(
"NodalGravity: Please provide either mass or nodal_mass_file as input.");
52 mooseError(
"NodalGravity: Please provide either mass or nodal_mass_file as input, not both.");
56 MooseUtils::DelimitedFileReader nodal_mass_file(getParam<FileName>(
"nodal_mass_file"));
57 nodal_mass_file.setHeaderFlag(MooseUtils::DelimitedFileReader::HeaderFlag::OFF);
58 nodal_mass_file.read();
59 std::vector<std::vector<Real>> data = nodal_mass_file.getData();
61 mooseError(
"NodalGravity: The number of columns in ",
62 getParam<FileName>(
"nodal_mass_file"),
65 unsigned int node_found = 0;
66 const std::set<BoundaryID> bnd_ids = BoundaryRestrictable::boundaryIDs();
67 for (
auto & bnd_id : bnd_ids)
69 const std::vector<dof_id_type> & bnd_node_set = _mesh.getNodeList(bnd_id);
70 for (
auto & bnd_node : bnd_node_set)
72 const Node & node = _mesh.nodeRef(bnd_node);
75 for (
unsigned int i = 0; i < data[0].size(); ++i)
77 if (MooseUtils::absoluteFuzzyEqual(data[0][i], node(0), 1e-6) &&
78 MooseUtils::absoluteFuzzyEqual(data[1][i], node(1), 1e-6) &&
79 MooseUtils::absoluteFuzzyEqual(data[2][i], node(2), 1e-6))
88 if (node_found != data[0].size())
89 mooseError(
"NodalGravity: Out of ",
91 " nodal positions in ",
92 getParam<FileName>(
"nodal_mass_file"),
95 " nodes were found in the boundary.");
110 mooseError(
"NodalGravity: Unable to find an entry for the current node in the "
111 "_node_id_to_mass map.");
114 return mass * -factor;