www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
NodalGravity Class Reference

Calculates the gravitational force proportional to nodal mass. More...

#include <NodalGravity.h>

Inheritance diagram for NodalGravity:
[legend]

Public Member Functions

 NodalGravity (const InputParameters &parameters)
 

Protected Member Functions

virtual Real computeQpResidual () override
 

Protected Attributes

const Real _mass
 Mass associated with the node. More...
 
const Real _alpha
 HHT time integration parameter. More...
 
const Real _gravity_value
 Acceleration due to gravity. More...
 
Function & _function
 Time and space dependent factor multiplying acceleration due to gravity. More...
 
std::map< dof_id_type, Real > _node_id_to_mass
 Map between boundary nodes and nodal mass. More...
 

Detailed Description

Calculates the gravitational force proportional to nodal mass.

Definition at line 29 of file NodalGravity.h.

Constructor & Destructor Documentation

◆ NodalGravity()

NodalGravity::NodalGravity ( const InputParameters &  parameters)

Definition at line 44 of file NodalGravity.C.

45  : NodalKernel(parameters),
46  _mass(isParamValid("mass") ? getParam<Real>("mass") : 0.0),
47  _alpha(getParam<Real>("alpha")),
48  _gravity_value(getParam<Real>("gravity_value")),
49  _function(getFunction("function"))
50 {
51  if (!isParamValid("nodal_mass_file") && !isParamValid("mass"))
52  mooseError("NodalGravity: Please provide either mass or nodal_mass_file as input.");
53  else if (isParamValid("nodal_mass_file") && isParamValid("mass"))
54  mooseError("NodalGravity: Please provide either mass or nodal_mass_file as input, not both.");
55 
56  if (isParamValid("nodal_mass_file"))
57  {
58  MooseUtils::DelimitedFileReader nodal_mass_file(getParam<FileName>("nodal_mass_file"));
59  nodal_mass_file.setHeaderFlag(MooseUtils::DelimitedFileReader::HeaderFlag::OFF);
60  nodal_mass_file.read();
61  std::vector<std::vector<Real>> data = nodal_mass_file.getData();
62  if (data.size() != 4)
63  mooseError("NodalGravity: The number of columns in ",
64  getParam<FileName>("nodal_mass_file"),
65  " should be 4.");
66 
67  unsigned int node_found = 0;
68  const std::set<BoundaryID> bnd_ids = BoundaryRestrictable::boundaryIDs();
69  for (auto & bnd_id : bnd_ids)
70  {
71  const std::vector<dof_id_type> & bnd_node_set = _mesh.getNodeList(bnd_id);
72  for (auto & bnd_node : bnd_node_set)
73  {
74  const Node & node = _mesh.nodeRef(bnd_node);
75  _node_id_to_mass[bnd_node] = 0.0;
76 
77  for (unsigned int i = 0; i < data[0].size(); ++i)
78  {
79  if (MooseUtils::absoluteFuzzyEqual(data[0][i], node(0), 1e-6) &&
80  MooseUtils::absoluteFuzzyEqual(data[1][i], node(1), 1e-6) &&
81  MooseUtils::absoluteFuzzyEqual(data[2][i], node(2), 1e-6))
82  {
83  _node_id_to_mass[bnd_node] = data[3][i];
84  node_found += 1;
85  break;
86  }
87  }
88  }
89  }
90  if (node_found != data[0].size())
91  mooseError("NodalGravity: Out of ",
92  data[0].size(),
93  " nodal positions in ",
94  getParam<FileName>("nodal_mass_file"),
95  " only ",
96  node_found,
97  " nodes were found in the boundary.");
98  }
99 }
const Real _gravity_value
Acceleration due to gravity.
Definition: NodalGravity.h:44
Function & _function
Time and space dependent factor multiplying acceleration due to gravity.
Definition: NodalGravity.h:47
const Real _alpha
HHT time integration parameter.
Definition: NodalGravity.h:41
const Real _mass
Mass associated with the node.
Definition: NodalGravity.h:38
std::map< dof_id_type, Real > _node_id_to_mass
Map between boundary nodes and nodal mass.
Definition: NodalGravity.h:50

Member Function Documentation

◆ computeQpResidual()

Real NodalGravity::computeQpResidual ( )
overrideprotectedvirtual

Definition at line 102 of file NodalGravity.C.

103 {
104  Real mass = 0.0;
105  if (isParamValid("mass"))
106  mass = _mass;
107  else
108  {
109  if (_node_id_to_mass.find(_current_node->id()) != _node_id_to_mass.end())
110  mass = _node_id_to_mass[_current_node->id()];
111  else
112  mooseError("NodalGravity: Unable to find an entry for the current node in the "
113  "_node_id_to_mass map.");
114  }
115  Real factor = _gravity_value * _function.value(_t + _alpha * _dt, (*_current_node));
116  return mass * -factor;
117 }
const Real _gravity_value
Acceleration due to gravity.
Definition: NodalGravity.h:44
Function & _function
Time and space dependent factor multiplying acceleration due to gravity.
Definition: NodalGravity.h:47
const Real _alpha
HHT time integration parameter.
Definition: NodalGravity.h:41
const Real _mass
Mass associated with the node.
Definition: NodalGravity.h:38
std::map< dof_id_type, Real > _node_id_to_mass
Map between boundary nodes and nodal mass.
Definition: NodalGravity.h:50

Member Data Documentation

◆ _alpha

const Real NodalGravity::_alpha
protected

HHT time integration parameter.

Definition at line 41 of file NodalGravity.h.

Referenced by computeQpResidual().

◆ _function

Function& NodalGravity::_function
protected

Time and space dependent factor multiplying acceleration due to gravity.

Definition at line 47 of file NodalGravity.h.

Referenced by computeQpResidual().

◆ _gravity_value

const Real NodalGravity::_gravity_value
protected

Acceleration due to gravity.

Definition at line 44 of file NodalGravity.h.

Referenced by computeQpResidual().

◆ _mass

const Real NodalGravity::_mass
protected

Mass associated with the node.

Definition at line 38 of file NodalGravity.h.

Referenced by computeQpResidual().

◆ _node_id_to_mass

std::map<dof_id_type, Real> NodalGravity::_node_id_to_mass
protected

Map between boundary nodes and nodal mass.

Definition at line 50 of file NodalGravity.h.

Referenced by computeQpResidual(), and NodalGravity().


The documentation for this class was generated from the following files: