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

Compute density, which may changed based on a deforming mesh. More...

#include <Density.h>

Inheritance diagram for Density:
[legend]

Public Member Functions

 Density (const InputParameters &params)
 

Protected Member Functions

virtual void initQpStatefulProperties () override
 
virtual void computeQpProperties () override
 

Protected Attributes

bool _is_coupled
 
Moose::CoordinateSystemType _coord_system
 
std::vector< const VariableGradient * > _grad_disp
 
const VariableValue & _disp_r
 
const Real _orig_density
 
MaterialProperty< Real > & _density
 

Detailed Description

Compute density, which may changed based on a deforming mesh.

Definition at line 15 of file Density.h.

Constructor & Destructor Documentation

Density::Density ( const InputParameters &  params)

Definition at line 31 of file Density.C.

32  : Material(parameters),
33  _is_coupled(true),
34  _disp_r(isCoupled("displacements") ? coupledValue("displacements", 0)
35  : (isCoupled("disp_r") ? coupledValue("disp_r") : _zero)),
36  _orig_density(getParam<Real>("density")),
37  _density(declareProperty<Real>("density"))
38 {
39  // new parameter scheme
40  if (isCoupled("displacements"))
41  {
42  // get coordinate system
43  _coord_system = getBlockCoordSystem();
44 
45  // get coupled gradients
46  const unsigned int ndisp = coupledComponents("displacements");
47  _grad_disp.resize(ndisp);
48  for (unsigned int i = 0; i < ndisp; ++i)
49  _grad_disp[i] = &coupledGradient("displacements", i);
50 
51  // fill remaining components with zero
52  _grad_disp.resize(3, &_grad_zero);
53  }
54 
55  // old deprecated parameters
56  else if (isCoupled("disp_x") || isCoupled("disp_r"))
57  {
58  // guess(!) coordinate system
59  if (isCoupled("disp_r"))
60  {
61  if (isCoupled("disp_z"))
62  _coord_system = Moose::COORD_RZ;
63  else
64  _coord_system = Moose::COORD_RSPHERICAL;
65  }
66  else
67  _coord_system = Moose::COORD_XYZ;
68 
69  // couple gradients
70  _grad_disp = {
71  isCoupled("disp_x") ? &coupledGradient("disp_x")
72  : (isCoupled("disp_r") ? &coupledGradient("disp_r") : &_grad_zero),
73  isCoupled("disp_y") ? &coupledGradient("disp_y")
74  : (isCoupled("disp_z") ? &coupledGradient("disp_z") : &_grad_zero),
75  _coord_system != Moose::COORD_RZ && isCoupled("disp_z") ? &coupledGradient("disp_z")
76  : &_grad_zero};
77  }
78 
79  // no coupling
80  else
81  {
82  _is_coupled = false;
83  // TODO: We should deprecate this case and have the user use a GenericConstantMaterial for this
84  }
85 }
bool _is_coupled
Definition: Density.h:24
Moose::CoordinateSystemType _coord_system
Definition: Density.h:25
const Real _orig_density
Definition: Density.h:29
MaterialProperty< Real > & _density
Definition: Density.h:30
std::vector< const VariableGradient * > _grad_disp
Definition: Density.h:26
const VariableValue & _disp_r
Definition: Density.h:27

Member Function Documentation

void Density::computeQpProperties ( )
overrideprotectedvirtual

Definition at line 94 of file Density.C.

95 {
96  Real density = _orig_density;
97  if (_is_coupled)
98  {
99  // rho * V = rho0 * V0
100  // rho = rho0 * V0 / V
101  // rho = rho0 / det(F)
102  // rho = rho0 / det(grad(u) + 1)
103 
104  const Real Axx = (*_grad_disp[0])[_qp](0) + 1.0;
105  const Real Axy = (*_grad_disp[0])[_qp](1);
106  const Real Axz = (*_grad_disp[0])[_qp](2);
107  const Real Ayx = (*_grad_disp[1])[_qp](0);
108  Real Ayy = (*_grad_disp[1])[_qp](1) + 1.0;
109  const Real Ayz = (*_grad_disp[1])[_qp](2);
110  const Real Azx = (*_grad_disp[2])[_qp](0);
111  const Real Azy = (*_grad_disp[2])[_qp](1);
112  Real Azz = (*_grad_disp[2])[_qp](2) + 1.0;
113 
114  switch (_coord_system)
115  {
116  case Moose::COORD_XYZ:
117  Azz = (*_grad_disp[2])[_qp](2) + 1.0;
118  break;
119 
120  case Moose::COORD_RZ:
121  if (_q_point[_qp](0) != 0.0)
122  Azz = _disp_r[_qp] / _q_point[_qp](0) + 1.0;
123  break;
124 
125  case Moose::COORD_RSPHERICAL:
126  if (_q_point[_qp](0) != 0.0)
127  Ayy = Azz = _disp_r[_qp] / _q_point[_qp](0) + 1.0;
128  break;
129  }
130 
131  const Real detF = Axx * Ayy * Azz + Axy * Ayz * Azx + Axz * Ayx * Azy - Azx * Ayy * Axz -
132  Azy * Ayz * Axx - Azz * Ayx * Axy;
133  density /= detF;
134  }
135 
136  _density[_qp] = density;
137 }
bool _is_coupled
Definition: Density.h:24
const std::string density
Definition: NS.h:15
Moose::CoordinateSystemType _coord_system
Definition: Density.h:25
const Real _orig_density
Definition: Density.h:29
MaterialProperty< Real > & _density
Definition: Density.h:30
std::vector< const VariableGradient * > _grad_disp
Definition: Density.h:26
const VariableValue & _disp_r
Definition: Density.h:27
void Density::initQpStatefulProperties ( )
overrideprotectedvirtual

Definition at line 88 of file Density.C.

89 {
90  _density[_qp] = _orig_density;
91 }
const Real _orig_density
Definition: Density.h:29
MaterialProperty< Real > & _density
Definition: Density.h:30

Member Data Documentation

Moose::CoordinateSystemType Density::_coord_system
protected

Definition at line 25 of file Density.h.

Referenced by computeQpProperties(), and Density().

MaterialProperty<Real>& Density::_density
protected

Definition at line 30 of file Density.h.

Referenced by computeQpProperties(), and initQpStatefulProperties().

const VariableValue& Density::_disp_r
protected

Definition at line 27 of file Density.h.

Referenced by computeQpProperties().

std::vector<const VariableGradient *> Density::_grad_disp
protected

Definition at line 26 of file Density.h.

Referenced by computeQpProperties(), and Density().

bool Density::_is_coupled
protected

Definition at line 24 of file Density.h.

Referenced by computeQpProperties(), and Density().

const Real Density::_orig_density
protected

Definition at line 29 of file Density.h.

Referenced by computeQpProperties(), and initQpStatefulProperties().


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