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
 
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 25 of file INSChorinPredictor.h.

Member Enumeration Documentation

◆ PredictorType

Enumerator
OLD 
NEW 
STAR 

Definition at line 89 of file INSChorinPredictor.h.

Constructor & Destructor Documentation

◆ INSChorinPredictor()

INSChorinPredictor::INSChorinPredictor ( const InputParameters &  parameters)

Definition at line 51 of file INSChorinPredictor.C.

52  : Kernel(parameters),
53 
54  // Current velocities
55  _u_vel(coupledValue("u")),
56  _v_vel(_mesh.dimension() >= 2 ? coupledValue("v") : _zero),
57  _w_vel(_mesh.dimension() == 3 ? coupledValue("w") : _zero),
58 
59  // Old velocities
60  _u_vel_old(coupledValueOld("u")),
61  _v_vel_old(_mesh.dimension() >= 2 ? coupledValueOld("v") : _zero),
62  _w_vel_old(_mesh.dimension() == 3 ? coupledValueOld("w") : _zero),
63 
64  // Star velocities
65  _u_vel_star(coupledValue("u_star")),
66  _v_vel_star(_mesh.dimension() >= 2 ? coupledValue("v_star") : _zero),
67  _w_vel_star(_mesh.dimension() == 3 ? coupledValue("w_star") : _zero),
68 
69  // Velocity Gradients
70  _grad_u_vel(coupledGradient("u")),
71  _grad_v_vel(_mesh.dimension() >= 2 ? coupledGradient("v") : _grad_zero),
72  _grad_w_vel(_mesh.dimension() == 3 ? coupledGradient("w") : _grad_zero),
73 
74  // Old Velocity Gradients
75  _grad_u_vel_old(coupledGradientOld("u")),
76  _grad_v_vel_old(_mesh.dimension() >= 2 ? coupledGradientOld("v") : _grad_zero),
77  _grad_w_vel_old(_mesh.dimension() == 3 ? coupledGradientOld("w") : _grad_zero),
78 
79  // Star Velocity Gradients
80  _grad_u_vel_star(coupledGradient("u_star")),
81  _grad_v_vel_star(_mesh.dimension() >= 2 ? coupledGradient("v_star") : _grad_zero),
82  _grad_w_vel_star(_mesh.dimension() == 3 ? coupledGradient("w_star") : _grad_zero),
83 
84  // Variable numberings
85  _u_vel_var_number(coupled("u")),
86  _v_vel_var_number(_mesh.dimension() >= 2 ? coupled("v") : libMesh::invalid_uint),
87  _w_vel_var_number(_mesh.dimension() == 3 ? coupled("w") : libMesh::invalid_uint),
88 
89  // Star velocity numberings
90  _u_vel_star_var_number(coupled("u_star")),
91  _v_vel_star_var_number(_mesh.dimension() >= 2 ? coupled("v_star") : libMesh::invalid_uint),
92  _w_vel_star_var_number(_mesh.dimension() == 3 ? coupled("w_star") : libMesh::invalid_uint),
93 
94  // Required parameters
95  _component(getParam<unsigned>("component")),
96  _predictor_enum(getParam<MooseEnum>("predictor_type")),
97 
98  // Material properties
99  _mu(getMaterialProperty<Real>("mu_name")),
100  _rho(getMaterialProperty<Real>("rho_name"))
101 {
102 }
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

◆ ~INSChorinPredictor()

virtual INSChorinPredictor::~INSChorinPredictor ( )
inlinevirtual

Definition at line 30 of file INSChorinPredictor.h.

30 {}

Member Function Documentation

◆ computeQpJacobian()

Real INSChorinPredictor::computeQpJacobian ( )
protectedvirtual

Definition at line 165 of file INSChorinPredictor.C.

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

◆ computeQpOffDiagJacobian()

Real INSChorinPredictor::computeQpOffDiagJacobian ( unsigned  jvar)
protectedvirtual

Definition at line 197 of file INSChorinPredictor.C.

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

◆ computeQpResidual()

Real INSChorinPredictor::computeQpResidual ( )
protectedvirtual

Definition at line 105 of file INSChorinPredictor.C.

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

◆ _component

unsigned INSChorinPredictor::_component
protected

◆ _grad_u_vel

const VariableGradient& INSChorinPredictor::_grad_u_vel
protected

Definition at line 53 of file INSChorinPredictor.h.

Referenced by computeQpOffDiagJacobian(), and computeQpResidual().

◆ _grad_u_vel_old

const VariableGradient& INSChorinPredictor::_grad_u_vel_old
protected

Definition at line 58 of file INSChorinPredictor.h.

Referenced by computeQpResidual().

◆ _grad_u_vel_star

const VariableGradient& INSChorinPredictor::_grad_u_vel_star
protected

Definition at line 63 of file INSChorinPredictor.h.

Referenced by computeQpResidual().

◆ _grad_v_vel

const VariableGradient& INSChorinPredictor::_grad_v_vel
protected

Definition at line 54 of file INSChorinPredictor.h.

Referenced by computeQpOffDiagJacobian(), and computeQpResidual().

◆ _grad_v_vel_old

const VariableGradient& INSChorinPredictor::_grad_v_vel_old
protected

Definition at line 59 of file INSChorinPredictor.h.

Referenced by computeQpResidual().

◆ _grad_v_vel_star

const VariableGradient& INSChorinPredictor::_grad_v_vel_star
protected

Definition at line 64 of file INSChorinPredictor.h.

Referenced by computeQpResidual().

◆ _grad_w_vel

const VariableGradient& INSChorinPredictor::_grad_w_vel
protected

Definition at line 55 of file INSChorinPredictor.h.

Referenced by computeQpOffDiagJacobian(), and computeQpResidual().

◆ _grad_w_vel_old

const VariableGradient& INSChorinPredictor::_grad_w_vel_old
protected

Definition at line 60 of file INSChorinPredictor.h.

Referenced by computeQpResidual().

◆ _grad_w_vel_star

const VariableGradient& INSChorinPredictor::_grad_w_vel_star
protected

Definition at line 65 of file INSChorinPredictor.h.

Referenced by computeQpResidual().

◆ _mu

const MaterialProperty<Real>& INSChorinPredictor::_mu
protected

◆ _predictor_enum

MooseEnum INSChorinPredictor::_predictor_enum
protected

◆ _rho

const MaterialProperty<Real>& INSChorinPredictor::_rho
protected

◆ _u_vel

const VariableValue& INSChorinPredictor::_u_vel
protected

Definition at line 38 of file INSChorinPredictor.h.

Referenced by computeQpOffDiagJacobian(), and computeQpResidual().

◆ _u_vel_old

const VariableValue& INSChorinPredictor::_u_vel_old
protected

Definition at line 43 of file INSChorinPredictor.h.

Referenced by computeQpResidual().

◆ _u_vel_star

const VariableValue& INSChorinPredictor::_u_vel_star
protected

Definition at line 48 of file INSChorinPredictor.h.

Referenced by computeQpJacobian(), and computeQpResidual().

◆ _u_vel_star_var_number

unsigned INSChorinPredictor::_u_vel_star_var_number
protected

Definition at line 73 of file INSChorinPredictor.h.

Referenced by computeQpOffDiagJacobian().

◆ _u_vel_var_number

unsigned INSChorinPredictor::_u_vel_var_number
protected

Definition at line 68 of file INSChorinPredictor.h.

Referenced by computeQpOffDiagJacobian().

◆ _v_vel

const VariableValue& INSChorinPredictor::_v_vel
protected

Definition at line 39 of file INSChorinPredictor.h.

Referenced by computeQpOffDiagJacobian(), and computeQpResidual().

◆ _v_vel_old

const VariableValue& INSChorinPredictor::_v_vel_old
protected

Definition at line 44 of file INSChorinPredictor.h.

Referenced by computeQpResidual().

◆ _v_vel_star

const VariableValue& INSChorinPredictor::_v_vel_star
protected

Definition at line 49 of file INSChorinPredictor.h.

Referenced by computeQpJacobian(), and computeQpResidual().

◆ _v_vel_star_var_number

unsigned INSChorinPredictor::_v_vel_star_var_number
protected

Definition at line 74 of file INSChorinPredictor.h.

Referenced by computeQpOffDiagJacobian().

◆ _v_vel_var_number

unsigned INSChorinPredictor::_v_vel_var_number
protected

Definition at line 69 of file INSChorinPredictor.h.

Referenced by computeQpOffDiagJacobian().

◆ _w_vel

const VariableValue& INSChorinPredictor::_w_vel
protected

Definition at line 40 of file INSChorinPredictor.h.

Referenced by computeQpOffDiagJacobian(), and computeQpResidual().

◆ _w_vel_old

const VariableValue& INSChorinPredictor::_w_vel_old
protected

Definition at line 45 of file INSChorinPredictor.h.

Referenced by computeQpResidual().

◆ _w_vel_star

const VariableValue& INSChorinPredictor::_w_vel_star
protected

Definition at line 50 of file INSChorinPredictor.h.

Referenced by computeQpJacobian(), and computeQpResidual().

◆ _w_vel_star_var_number

unsigned INSChorinPredictor::_w_vel_star_var_number
protected

Definition at line 75 of file INSChorinPredictor.h.

Referenced by computeQpOffDiagJacobian().

◆ _w_vel_var_number

unsigned INSChorinPredictor::_w_vel_var_number
protected

Definition at line 70 of file INSChorinPredictor.h.

Referenced by computeQpOffDiagJacobian().


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