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

This class computes the "Chorin" Predictor equation in fully-discrete (both time and space) form. More...

#include <INSChorinPredictor.h>

Inheritance diagram for INSChorinPredictor:
[legend]

Public Member Functions

 INSChorinPredictor (const InputParameters &parameters)
 
virtual ~INSChorinPredictor ()
 

Protected Types

enum  PredictorType { OLD = 0, NEW = 1, STAR = 2 }
 

Protected Member Functions

virtual Real computeQpResidual ()
 
virtual Real computeQpJacobian ()
 
virtual Real computeQpOffDiagJacobian (unsigned jvar)
 

Protected Attributes

const VariableValue & _u_vel
 
const VariableValue & _v_vel
 
const VariableValue & _w_vel
 
const VariableValue & _u_vel_old
 
const VariableValue & _v_vel_old
 
const VariableValue & _w_vel_old
 
const VariableValue & _u_vel_star
 
const VariableValue & _v_vel_star
 
const VariableValue & _w_vel_star
 
const VariableGradient & _grad_u_vel
 
const VariableGradient & _grad_v_vel
 
const VariableGradient & _grad_w_vel
 
const VariableGradient & _grad_u_vel_old
 
const VariableGradient & _grad_v_vel_old
 
const VariableGradient & _grad_w_vel_old
 
const VariableGradient & _grad_u_vel_star
 
const VariableGradient & _grad_v_vel_star
 
const VariableGradient & _grad_w_vel_star
 
unsigned _u_vel_var_number
 
unsigned _v_vel_var_number
 
unsigned _w_vel_var_number
 
unsigned _u_vel_star_var_number
 
unsigned _v_vel_star_var_number
 
unsigned _w_vel_star_var_number
 
unsigned _component
 
std::string _predictor_type
 
MooseEnum _predictor_enum
 
const MaterialProperty< Real > & _mu
 
const MaterialProperty< Real > & _rho
 

Detailed Description

This class computes the "Chorin" Predictor equation in fully-discrete (both time and space) form.

Definition at line 22 of file INSChorinPredictor.h.

Member Enumeration Documentation

Enumerator
OLD 
NEW 
STAR 

Definition at line 90 of file INSChorinPredictor.h.

Constructor & Destructor Documentation

INSChorinPredictor::INSChorinPredictor ( const InputParameters &  parameters)

Definition at line 44 of file INSChorinPredictor.C.

45  : Kernel(parameters),
46 
47  // Current velocities
48  _u_vel(coupledValue("u")),
49  _v_vel(_mesh.dimension() >= 2 ? coupledValue("v") : _zero),
50  _w_vel(_mesh.dimension() == 3 ? coupledValue("w") : _zero),
51 
52  // Old velocities
53  _u_vel_old(coupledValueOld("u")),
54  _v_vel_old(_mesh.dimension() >= 2 ? coupledValueOld("v") : _zero),
55  _w_vel_old(_mesh.dimension() == 3 ? coupledValueOld("w") : _zero),
56 
57  // Star velocities
58  _u_vel_star(coupledValue("u_star")),
59  _v_vel_star(_mesh.dimension() >= 2 ? coupledValue("v_star") : _zero),
60  _w_vel_star(_mesh.dimension() == 3 ? coupledValue("w_star") : _zero),
61 
62  // Velocity Gradients
63  _grad_u_vel(coupledGradient("u")),
64  _grad_v_vel(_mesh.dimension() >= 2 ? coupledGradient("v") : _grad_zero),
65  _grad_w_vel(_mesh.dimension() == 3 ? coupledGradient("w") : _grad_zero),
66 
67  // Old Velocity Gradients
68  _grad_u_vel_old(coupledGradientOld("u")),
69  _grad_v_vel_old(_mesh.dimension() >= 2 ? coupledGradientOld("v") : _grad_zero),
70  _grad_w_vel_old(_mesh.dimension() == 3 ? coupledGradientOld("w") : _grad_zero),
71 
72  // Star Velocity Gradients
73  _grad_u_vel_star(coupledGradient("u_star")),
74  _grad_v_vel_star(_mesh.dimension() >= 2 ? coupledGradient("v_star") : _grad_zero),
75  _grad_w_vel_star(_mesh.dimension() == 3 ? coupledGradient("w_star") : _grad_zero),
76 
77  // Variable numberings
78  _u_vel_var_number(coupled("u")),
79  _v_vel_var_number(_mesh.dimension() >= 2 ? coupled("v") : libMesh::invalid_uint),
80  _w_vel_var_number(_mesh.dimension() == 3 ? coupled("w") : libMesh::invalid_uint),
81 
82  // Star velocity numberings
83  _u_vel_star_var_number(coupled("u_star")),
84  _v_vel_star_var_number(_mesh.dimension() >= 2 ? coupled("v_star") : libMesh::invalid_uint),
85  _w_vel_star_var_number(_mesh.dimension() == 3 ? coupled("w_star") : libMesh::invalid_uint),
86 
87  // Required parameters
88  _component(getParam<unsigned>("component")),
89  _predictor_type(getParam<std::string>("predictor_type")),
90  _predictor_enum("OLD, NEW, STAR, INVALID", _predictor_type),
91 
92  // Material properties
93  _mu(getMaterialProperty<Real>("mu_name")),
94  _rho(getMaterialProperty<Real>("rho_name"))
95 {
96 }
const MaterialProperty< Real > & _rho
const VariableValue & _w_vel
const MaterialProperty< Real > & _mu
const VariableValue & _u_vel
const VariableGradient & _grad_u_vel
const VariableGradient & _grad_v_vel_old
const VariableValue & _v_vel_old
const VariableValue & _w_vel_old
const VariableValue & _u_vel_old
const VariableValue & _v_vel
const VariableGradient & _grad_u_vel_old
const VariableGradient & _grad_w_vel
const VariableValue & _v_vel_star
const VariableGradient & _grad_v_vel_star
const VariableValue & _w_vel_star
std::string _predictor_type
const VariableGradient & _grad_w_vel_old
const VariableGradient & _grad_w_vel_star
const VariableGradient & _grad_u_vel_star
const VariableGradient & _grad_v_vel
const VariableValue & _u_vel_star
virtual INSChorinPredictor::~INSChorinPredictor ( )
inlinevirtual

Definition at line 27 of file INSChorinPredictor.h.

27 {}

Member Function Documentation

Real INSChorinPredictor::computeQpJacobian ( )
protectedvirtual

Definition at line 159 of file INSChorinPredictor.C.

Referenced by ~INSChorinPredictor().

160 {
161  // The mass matrix part is always there.
162  Real mass_part = _phi[_j][_qp] * _test[_i][_qp];
163 
164  // The on-diagonal Jacobian contribution depends on whether the predictor uses the
165  // 'new' or 'star' velocity.
166  Real other_part = 0.;
167  switch (_predictor_enum)
168  {
169  case OLD:
170  case NEW:
171  break;
172  case STAR:
173  {
174  RealVectorValue U_star(_u_vel_star[_qp], _v_vel_star[_qp], _w_vel_star[_qp]);
175  Real convective_part =
176  _dt * ((U_star * _grad_phi[_j][_qp]) + _phi[_j][_qp] * _grad_u[_qp](_component)) *
177  _test[_i][_qp];
178  Real viscous_part =
179  _dt * ((_mu[_qp] / _rho[_qp]) * (_grad_phi[_j][_qp] * _grad_test[_i][_qp]));
180  other_part = convective_part + viscous_part;
181  break;
182  }
183  default:
184  mooseError("Unrecognized Chorin predictor type requested.");
185  }
186 
187  return mass_part + other_part;
188 }
const MaterialProperty< Real > & _rho
const MaterialProperty< Real > & _mu
const VariableValue & _v_vel_star
const VariableValue & _w_vel_star
const VariableValue & _u_vel_star
Real INSChorinPredictor::computeQpOffDiagJacobian ( unsigned  jvar)
protectedvirtual

Definition at line 191 of file INSChorinPredictor.C.

Referenced by ~INSChorinPredictor().

192 {
193  switch (_predictor_enum)
194  {
195  case OLD:
196  {
197  return 0.;
198  }
199 
200  case NEW:
201  {
202  if ((jvar == _u_vel_var_number) || (jvar == _v_vel_var_number) || (jvar == _w_vel_var_number))
203  {
204  // Derivative of grad_U wrt the velocity component
205  RealTensorValue dgrad_U;
206 
207  // Initialize to invalid value, then determine correct value.
208  unsigned vel_index = 99;
209 
210  // Map jvar into the indices (0,1,2)
211  if (jvar == _u_vel_var_number)
212  vel_index = 0;
213 
214  else if (jvar == _v_vel_var_number)
215  vel_index = 1;
216 
217  else if (jvar == _w_vel_var_number)
218  vel_index = 2;
219 
220  // Fill in the vel_index'th row of dgrad_U with _grad_phi[_j][_qp]
221  for (unsigned k = 0; k < 3; ++k)
222  dgrad_U(vel_index, k) = _grad_phi[_j][_qp](k);
223 
224  // Vector object for test function
225  RealVectorValue test;
226  test(_component) = _test[_i][_qp];
227 
228  // Vector object for U
229  RealVectorValue U(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
230 
231  // Tensor object for test function gradient
232  RealTensorValue grad_test;
233  for (unsigned k = 0; k < 3; ++k)
234  grad_test(_component, k) = _grad_test[_i][_qp](k);
235 
236  // Compute the convective part
237  RealVectorValue convective_jac =
238  _phi[_j][_qp] * RealVectorValue(_grad_u_vel[_qp](vel_index),
239  _grad_v_vel[_qp](vel_index),
240  _grad_w_vel[_qp](vel_index));
241 
242  // Extra contribution in vel_index component
243  convective_jac(vel_index) += U * _grad_phi[_j][_qp];
244 
245  // Be sure to scale by _dt!
246  Real convective_part = _dt * (convective_jac * test);
247 
248  // Compute the viscous part, be sure to scale by _dt. Note: the contracted
249  // value should be zero unless vel_index and _component match.
250  Real viscous_part = _dt * (_mu[_qp] / _rho[_qp]) * dgrad_U.contract(grad_test);
251 
252  // Return the result
253  return convective_part + viscous_part;
254  }
255  else
256  return 0;
257  }
258 
259  case STAR:
260  {
261  if (jvar == _u_vel_star_var_number)
262  {
263  return _dt * _phi[_j][_qp] * _grad_u[_qp](0) * _test[_i][_qp];
264  }
265 
266  else if (jvar == _v_vel_star_var_number)
267  {
268  return _dt * _phi[_j][_qp] * _grad_u[_qp](1) * _test[_i][_qp];
269  }
270 
271  else if (jvar == _w_vel_star_var_number)
272  {
273  return _dt * _phi[_j][_qp] * _grad_u[_qp](2) * _test[_i][_qp];
274  }
275 
276  else
277  return 0;
278  }
279 
280  default:
281  mooseError("Unrecognized Chorin predictor type requested.");
282  }
283 }
const MaterialProperty< Real > & _rho
const VariableValue & _w_vel
const MaterialProperty< Real > & _mu
const VariableValue & _u_vel
const VariableGradient & _grad_u_vel
const VariableValue & _v_vel
const VariableGradient & _grad_w_vel
const VariableGradient & _grad_v_vel
Real INSChorinPredictor::computeQpResidual ( )
protectedvirtual

Definition at line 99 of file INSChorinPredictor.C.

Referenced by ~INSChorinPredictor().

100 {
101  // Vector object for test function
102  RealVectorValue test;
103  test(_component) = _test[_i][_qp];
104 
105  // Tensor object for test function gradient
106  RealTensorValue grad_test;
107  for (unsigned k = 0; k < 3; ++k)
108  grad_test(_component, k) = _grad_test[_i][_qp](k);
109 
110  // Decide what velocity vector, gradient to use:
111  RealVectorValue U;
112  RealTensorValue grad_U;
113 
114  switch (_predictor_enum)
115  {
116  case OLD:
117  {
118  U = RealVectorValue(_u_vel_old[_qp], _v_vel_old[_qp], _w_vel_old[_qp]);
119  grad_U = RealTensorValue(_grad_u_vel_old[_qp], _grad_v_vel_old[_qp], _grad_w_vel_old[_qp]);
120  break;
121  }
122  case NEW:
123  {
124  U = RealVectorValue(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
125  grad_U = RealTensorValue(_grad_u_vel[_qp], _grad_v_vel[_qp], _grad_w_vel[_qp]);
126  break;
127  }
128  case STAR:
129  {
130  // Note: Donea and Huerta's book says you are supposed to use "star" velocity to make Chorin
131  // implicit, not U^{n+1}.
132  U = RealVectorValue(_u_vel_star[_qp], _v_vel_star[_qp], _w_vel_star[_qp]);
133  grad_U = RealTensorValue(_grad_u_vel_star[_qp], _grad_v_vel_star[_qp], _grad_w_vel_star[_qp]);
134  break;
135  }
136  default:
137  mooseError("Unrecognized Chorin predictor type requested.");
138  }
139 
140  //
141  // Compute the different parts
142  //
143 
144  // Note: _u is the component'th entry of "u_star" in Chorin's method.
145  RealVectorValue U_old(_u_vel_old[_qp], _v_vel_old[_qp], _w_vel_old[_qp]);
146  Real symmetric_part = (_u[_qp] - U_old(_component)) * _test[_i][_qp];
147 
148  // Convective part. Remember to multiply by _dt!
149  Real convective_part = _dt * (grad_U * U) * test;
150 
151  // Viscous part - we are using the Laplacian form here for simplicity.
152  // Remember to multiply by _dt!
153  Real viscous_part = _dt * (_mu[_qp] / _rho[_qp]) * grad_U.contract(grad_test);
154 
155  return symmetric_part + convective_part + viscous_part;
156 }
const MaterialProperty< Real > & _rho
const VariableValue & _w_vel
const MaterialProperty< Real > & _mu
const VariableValue & _u_vel
const VariableGradient & _grad_u_vel
const VariableGradient & _grad_v_vel_old
const VariableValue & _v_vel_old
const VariableValue & _w_vel_old
const VariableValue & _u_vel_old
const VariableValue & _v_vel
const VariableGradient & _grad_u_vel_old
const VariableGradient & _grad_w_vel
const VariableValue & _v_vel_star
const VariableGradient & _grad_v_vel_star
const VariableValue & _w_vel_star
const VariableGradient & _grad_w_vel_old
const VariableGradient & _grad_w_vel_star
const VariableGradient & _grad_u_vel_star
const VariableGradient & _grad_v_vel
const VariableValue & _u_vel_star

Member Data Documentation

unsigned INSChorinPredictor::_component
protected
const VariableGradient& INSChorinPredictor::_grad_u_vel
protected

Definition at line 50 of file INSChorinPredictor.h.

Referenced by computeQpOffDiagJacobian(), and computeQpResidual().

const VariableGradient& INSChorinPredictor::_grad_u_vel_old
protected

Definition at line 55 of file INSChorinPredictor.h.

Referenced by computeQpResidual().

const VariableGradient& INSChorinPredictor::_grad_u_vel_star
protected

Definition at line 60 of file INSChorinPredictor.h.

Referenced by computeQpResidual().

const VariableGradient& INSChorinPredictor::_grad_v_vel
protected

Definition at line 51 of file INSChorinPredictor.h.

Referenced by computeQpOffDiagJacobian(), and computeQpResidual().

const VariableGradient& INSChorinPredictor::_grad_v_vel_old
protected

Definition at line 56 of file INSChorinPredictor.h.

Referenced by computeQpResidual().

const VariableGradient& INSChorinPredictor::_grad_v_vel_star
protected

Definition at line 61 of file INSChorinPredictor.h.

Referenced by computeQpResidual().

const VariableGradient& INSChorinPredictor::_grad_w_vel
protected

Definition at line 52 of file INSChorinPredictor.h.

Referenced by computeQpOffDiagJacobian(), and computeQpResidual().

const VariableGradient& INSChorinPredictor::_grad_w_vel_old
protected

Definition at line 57 of file INSChorinPredictor.h.

Referenced by computeQpResidual().

const VariableGradient& INSChorinPredictor::_grad_w_vel_star
protected

Definition at line 62 of file INSChorinPredictor.h.

Referenced by computeQpResidual().

const MaterialProperty<Real>& INSChorinPredictor::_mu
protected
MooseEnum INSChorinPredictor::_predictor_enum
protected
std::string INSChorinPredictor::_predictor_type
protected

Definition at line 83 of file INSChorinPredictor.h.

const MaterialProperty<Real>& INSChorinPredictor::_rho
protected
const VariableValue& INSChorinPredictor::_u_vel
protected

Definition at line 35 of file INSChorinPredictor.h.

Referenced by computeQpOffDiagJacobian(), and computeQpResidual().

const VariableValue& INSChorinPredictor::_u_vel_old
protected

Definition at line 40 of file INSChorinPredictor.h.

Referenced by computeQpResidual().

const VariableValue& INSChorinPredictor::_u_vel_star
protected

Definition at line 45 of file INSChorinPredictor.h.

Referenced by computeQpJacobian(), and computeQpResidual().

unsigned INSChorinPredictor::_u_vel_star_var_number
protected

Definition at line 70 of file INSChorinPredictor.h.

Referenced by computeQpOffDiagJacobian().

unsigned INSChorinPredictor::_u_vel_var_number
protected

Definition at line 65 of file INSChorinPredictor.h.

Referenced by computeQpOffDiagJacobian().

const VariableValue& INSChorinPredictor::_v_vel
protected

Definition at line 36 of file INSChorinPredictor.h.

Referenced by computeQpOffDiagJacobian(), and computeQpResidual().

const VariableValue& INSChorinPredictor::_v_vel_old
protected

Definition at line 41 of file INSChorinPredictor.h.

Referenced by computeQpResidual().

const VariableValue& INSChorinPredictor::_v_vel_star
protected

Definition at line 46 of file INSChorinPredictor.h.

Referenced by computeQpJacobian(), and computeQpResidual().

unsigned INSChorinPredictor::_v_vel_star_var_number
protected

Definition at line 71 of file INSChorinPredictor.h.

Referenced by computeQpOffDiagJacobian().

unsigned INSChorinPredictor::_v_vel_var_number
protected

Definition at line 66 of file INSChorinPredictor.h.

Referenced by computeQpOffDiagJacobian().

const VariableValue& INSChorinPredictor::_w_vel
protected

Definition at line 37 of file INSChorinPredictor.h.

Referenced by computeQpOffDiagJacobian(), and computeQpResidual().

const VariableValue& INSChorinPredictor::_w_vel_old
protected

Definition at line 42 of file INSChorinPredictor.h.

Referenced by computeQpResidual().

const VariableValue& INSChorinPredictor::_w_vel_star
protected

Definition at line 47 of file INSChorinPredictor.h.

Referenced by computeQpJacobian(), and computeQpResidual().

unsigned INSChorinPredictor::_w_vel_star_var_number
protected

Definition at line 72 of file INSChorinPredictor.h.

Referenced by computeQpOffDiagJacobian().

unsigned INSChorinPredictor::_w_vel_var_number
protected

Definition at line 67 of file INSChorinPredictor.h.

Referenced by computeQpOffDiagJacobian().


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