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 18 of file Density.h.

Constructor & Destructor Documentation

◆ Density()

Density::Density ( const InputParameters &  params)

Definition at line 35 of file Density.C.

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

Member Function Documentation

◆ computeQpProperties()

void Density::computeQpProperties ( )
overrideprotectedvirtual

Definition at line 98 of file Density.C.

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

◆ initQpStatefulProperties()

void Density::initQpStatefulProperties ( )
overrideprotectedvirtual

Definition at line 92 of file Density.C.

93 {
94  _density[_qp] = _orig_density;
95 }
const Real _orig_density
Definition: Density.h:32
MaterialProperty< Real > & _density
Definition: Density.h:33

Member Data Documentation

◆ _coord_system

Moose::CoordinateSystemType Density::_coord_system
protected

Definition at line 28 of file Density.h.

Referenced by computeQpProperties(), and Density().

◆ _density

MaterialProperty<Real>& Density::_density
protected

Definition at line 33 of file Density.h.

Referenced by computeQpProperties(), and initQpStatefulProperties().

◆ _disp_r

const VariableValue& Density::_disp_r
protected

Definition at line 30 of file Density.h.

Referenced by computeQpProperties().

◆ _grad_disp

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

Definition at line 29 of file Density.h.

Referenced by computeQpProperties(), and Density().

◆ _is_coupled

bool Density::_is_coupled
protected

Definition at line 27 of file Density.h.

Referenced by computeQpProperties(), and Density().

◆ _orig_density

const Real Density::_orig_density
protected

Definition at line 32 of file Density.h.

Referenced by computeQpProperties(), and initQpStatefulProperties().


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