https://mooseframework.inl.gov
Gravity.C
Go to the documentation of this file.
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 "Gravity.h"
11 #include "Function.h"
12 
13 registerMooseObject("SolidMechanicsApp", Gravity);
14 registerMooseObject("SolidMechanicsApp", ADGravity);
15 
16 template <bool is_ad>
19 {
21  params.addClassDescription("Apply gravity. Value is in units of acceleration.");
22  params.addParam<bool>("use_displaced_mesh", true, "Displaced mesh defaults to true");
23  params.addRequiredParam<Real>(
24  "value", "Value multiplied against the residual, e.g. gravitational acceleration");
25  params.addParam<FunctionName>(
26  "function", "1", "A function that describes the gravitational force");
27  params.addParam<Real>("alpha", 0.0, "alpha parameter required for HHT time integration scheme");
28  params.addParam<MaterialPropertyName>("density", "density", "The density");
29  return params;
30 }
31 
32 template <bool is_ad>
34  : GenericKernel<is_ad>(parameters),
35  _density(this->template getGenericMaterialProperty<Real, is_ad>("density")),
36  _value(this->template getParam<Real>("value")),
37  _function(this->getFunction("function")),
38  _alpha(this->template getParam<Real>("alpha"))
39 {
40 }
41 
42 template <bool is_ad>
45 {
46  Real factor = _value * _function.value(_t + _alpha * _dt, _q_point[_qp]);
47  return _density[_qp] * _test[_i][_qp] * -factor;
48 }
49 
50 template class GravityTempl<false>;
51 template class GravityTempl<true>;
Moose::GenericType< Real, is_ad > GenericReal
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
registerMooseObject("SolidMechanicsApp", Gravity)
virtual GenericReal< is_ad > computeQpResidual() override
Definition: Gravity.C:44
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addClassDescription(const std::string &doc_string)
GravityTempl(const InputParameters &parameters)
Definition: Gravity.C:33
Gravity computes the body force (force/volume) given the acceleration of gravity (value) and the dens...
Definition: Gravity.h:21
static InputParameters validParams()
Definition: Gravity.C:18