https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
13registerMooseObject("SolidMechanicsApp", Gravity);
14registerMooseObject("SolidMechanicsApp", ADGravity);
15
16template <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
32template <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
42template <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
50template class GravityTempl<false>;
51template class GravityTempl<true>;
registerMooseObject("SolidMechanicsApp", Gravity)
Moose::GenericType< Real, is_ad > GenericReal
static InputParameters validParams()
Gravity computes the body force (force/volume) given the acceleration of gravity (value) and the dens...
Definition Gravity.h:22
static InputParameters validParams()
Definition Gravity.C:18
virtual GenericReal< is_ad > computeQpResidual() override
Definition Gravity.C:44
GravityTempl(const InputParameters &parameters)
Definition Gravity.C:33
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)