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

This kernel calculates the main portion of the cahn-hilliard residual for the RFF form of the phase field crystal model. More...

#include <CHPFCRFF.h>

Inheritance diagram for CHPFCRFF:
[legend]

Public Member Functions

 CHPFCRFF (const InputParameters &parameters)
 

Protected Member Functions

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

Private Attributes

const MaterialProperty< Real > & _M
 
const bool _has_MJac
 
const MaterialProperty< Real > * _DM
 
const MooseEnum _log_approach
 
const Real _tol
 
const unsigned int _num_L
 
std::vector< unsigned int > _vals_var
 
std::vector< const VariableGradient * > _grad_vals
 
const unsigned int _n_exp_terms
 
const Real _a
 
const Real _b
 
const Real _c
 

Detailed Description

This kernel calculates the main portion of the cahn-hilliard residual for the RFF form of the phase field crystal model.

Definition at line 23 of file CHPFCRFF.h.

Constructor & Destructor Documentation

CHPFCRFF::CHPFCRFF ( const InputParameters &  parameters)

Definition at line 34 of file CHPFCRFF.C.

35  : Kernel(parameters),
36  _M(getMaterialProperty<Real>("mob_name")),
37  _has_MJac(getParam<bool>("has_MJac")),
38  _DM(_has_MJac ? &getMaterialProperty<Real>("Dmob_name") : NULL),
39  _log_approach(getParam<MooseEnum>("log_approach")),
40  _tol(getParam<Real>("tol")),
41  _num_L(coupledComponents("v")),
44  _n_exp_terms(getParam<Real>("n_exp_terms")),
45  _a(getParam<Real>("a")),
46  _b(getParam<Real>("b")),
47  _c(getParam<Real>("c"))
48 {
49  // Loop through grains and load coupled gradients into the arrays
50  for (unsigned int i = 0; i < _num_L; ++i)
51  {
52  _vals_var[i] = coupled("v", i);
53  _grad_vals[i] = &coupledGradient("v", i);
54  }
55 }
const MaterialProperty< Real > * _DM
Definition: CHPFCRFF.h:36
const Real _a
Definition: CHPFCRFF.h:46
const MooseEnum _log_approach
Definition: CHPFCRFF.h:38
std::vector< unsigned int > _vals_var
Definition: CHPFCRFF.h:42
const unsigned int _n_exp_terms
Definition: CHPFCRFF.h:45
const Real _tol
Definition: CHPFCRFF.h:39
const Real _b
Definition: CHPFCRFF.h:47
const Real _c
Definition: CHPFCRFF.h:48
std::vector< const VariableGradient * > _grad_vals
Definition: CHPFCRFF.h:43
const bool _has_MJac
Definition: CHPFCRFF.h:35
const unsigned int _num_L
Definition: CHPFCRFF.h:41
const MaterialProperty< Real > & _M
Definition: CHPFCRFF.h:34

Member Function Documentation

Real CHPFCRFF::computeQpJacobian ( )
protectedvirtual

Definition at line 124 of file CHPFCRFF.C.

125 {
126  Real c = _u[_qp];
127  RealGradient grad_c = _grad_u[_qp];
128  RealGradient sum_grad_L;
129 
130  for (unsigned int i = 0; i < _num_L; ++i)
131  sum_grad_L += (*_grad_vals[i])[_qp] * 0.5;
132 
133  Real frac, dfrac;
134  Real ln_expansion = 0.0;
135 
136  switch (_log_approach)
137  {
138  case 0: // approach using tolerance
139  if (1.0 + c < _tol)
140  {
141  frac = 1.0 / _tol;
142  dfrac = -1.0 / (_tol * _tol);
143  }
144  else
145  {
146  frac = 1.0 / (1.0 + c);
147  dfrac = -1.0 / ((1.0 + c) * (1.0 + c));
148  }
149  break;
150 
151  case 2:
152  for (unsigned int i = 2; i < (_n_exp_terms + 2.0); ++i)
153  {
154  // Apply Coefficents to Taylor Series defined in input file
155  Real temp_coeff;
156  if (i == 2)
157  temp_coeff = _c;
158  else if (i == 3)
159  temp_coeff = _a;
160  else if (i == 4)
161  temp_coeff = _b;
162  else
163  temp_coeff = 1.0;
164 
165  ln_expansion += temp_coeff * std::pow(-1.0, Real(i)) * std::pow(_u[_qp], Real(i) - 2.0);
166  }
167  break;
168  }
169 
170  RealGradient dGradDFDConsdC;
171  Real Dln_expansion = 0.0;
172 
173  switch (_log_approach)
174  {
175  case 0: // approach using tolerance
176  dGradDFDConsdC = _grad_phi[_j][_qp] * frac + _phi[_j][_qp] * grad_c * dfrac;
177  break;
178 
179  case 1: // approach using cancelation from the mobility
180  dGradDFDConsdC = _grad_phi[_j][_qp] - _phi[_j][_qp] * sum_grad_L;
181  break;
182 
183  case 2: // appraoch using substitution
184  for (unsigned int i = 2; i < (_n_exp_terms + 2.0); ++i)
185  {
186  Real temp_coeff;
187  if (i == 2)
188  temp_coeff = _c;
189  else if (i == 3)
190  temp_coeff = _a;
191  else if (i == 4)
192  temp_coeff = _b;
193  else
194  temp_coeff = 1.0;
195 
196  Dln_expansion += temp_coeff * std::pow(static_cast<Real>(-1.0), static_cast<Real>(i)) *
197  (static_cast<Real>(i) - 2.0) *
198  std::pow(_u[_qp], static_cast<Real>(i) - 3.0);
199  }
200 
201  dGradDFDConsdC = ln_expansion * _grad_phi[_j][_qp] + _phi[_j][_qp] * Dln_expansion * grad_c;
202  break;
203 
204  case 3: // Nothing special
205  dGradDFDConsdC =
206  _grad_phi[_j][_qp] / (1.0 + c) - grad_c / ((1.0 + c) * (1.0 + c)) * _phi[_j][_qp];
207  break;
208  }
209 
210  return _M[_qp] * dGradDFDConsdC * _grad_test[_i][_qp];
211 }
const Real _a
Definition: CHPFCRFF.h:46
const MooseEnum _log_approach
Definition: CHPFCRFF.h:38
const unsigned int _n_exp_terms
Definition: CHPFCRFF.h:45
const Real _tol
Definition: CHPFCRFF.h:39
const Real _b
Definition: CHPFCRFF.h:47
const Real _c
Definition: CHPFCRFF.h:48
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
std::vector< const VariableGradient * > _grad_vals
Definition: CHPFCRFF.h:43
const unsigned int _num_L
Definition: CHPFCRFF.h:41
const MaterialProperty< Real > & _M
Definition: CHPFCRFF.h:34
Real CHPFCRFF::computeQpOffDiagJacobian ( unsigned int  jvar)
protectedvirtual

Definition at line 214 of file CHPFCRFF.C.

215 {
216  Real c = _u[_qp];
217 
218  for (unsigned int i = 0; i < _num_L; ++i)
219  if (jvar == _vals_var[i])
220  {
221 
222  RealGradient dsum_grad_L = _grad_phi[_j][_qp] * 0.5;
223  RealGradient dGradDFDConsdL;
224  switch (_log_approach)
225  {
226  case 0: // approach using tolerance
227  dGradDFDConsdL = -dsum_grad_L;
228  break;
229 
230  case 1: // approach using cancelation from the mobility
231  dGradDFDConsdL = -(1.0 + c) * dsum_grad_L;
232  break;
233 
234  case 2: // appraoch using substitution
235  dGradDFDConsdL = -dsum_grad_L;
236  break;
237 
238  case 3: // nothing special
239  dGradDFDConsdL = -dsum_grad_L;
240  break;
241  }
242 
243  return _M[_qp] * dGradDFDConsdL * _grad_test[_i][_qp];
244  }
245 
246  return 0.0;
247 }
const MooseEnum _log_approach
Definition: CHPFCRFF.h:38
std::vector< unsigned int > _vals_var
Definition: CHPFCRFF.h:42
const unsigned int _num_L
Definition: CHPFCRFF.h:41
const MaterialProperty< Real > & _M
Definition: CHPFCRFF.h:34
Real CHPFCRFF::computeQpResidual ( )
protectedvirtual

Definition at line 58 of file CHPFCRFF.C.

59 {
60  Real c = _u[_qp];
61  RealGradient grad_c = _grad_u[_qp];
62  RealGradient sum_grad_L;
63 
64  for (unsigned int i = 0; i < _num_L; ++i)
65  sum_grad_L += (*_grad_vals[i])[_qp] * 0.5;
66 
67  Real frac;
68  Real ln_expansion = 0.0;
69 
70  switch (_log_approach)
71  {
72  case 0: // approach using tolerance
73  if (1.0 + c < _tol)
74  frac = 1.0 / _tol;
75  else
76  frac = 1.0 / (1.0 + c);
77  break;
78 
79  case 2:
80  for (unsigned int i = 2; i < (_n_exp_terms + 2.0); ++i)
81  {
82  // Apply Coefficents to Taylor Series defined in input file
83  Real temp_coeff;
84  if (i == 2)
85  temp_coeff = _c;
86  else if (i == 3)
87  temp_coeff = _a;
88  else if (i == 4)
89  temp_coeff = _b;
90  else
91  temp_coeff = 1.0;
92 
93  ln_expansion += temp_coeff * std::pow(-1.0, Real(i)) * std::pow(_u[_qp], Real(i) - 2.0);
94  }
95  break;
96  }
97 
98  RealGradient GradDFDCons;
99 
100  switch (_log_approach)
101  {
102  case 0: // approach using tolerance
103  GradDFDCons = grad_c * frac - sum_grad_L;
104  break;
105 
106  case 1: // approach using cancelation from the mobility
107  GradDFDCons = grad_c - (1.0 + c) * sum_grad_L;
108  break;
109 
110  case 2: // appraoch using substitution
111  GradDFDCons = ln_expansion * grad_c - sum_grad_L;
112  break;
113 
114  case 3: // Just using the log
115  GradDFDCons = grad_c / (1.0 + c) - sum_grad_L;
116  break;
117  }
118 
119  Real residual = _M[_qp] * GradDFDCons * _grad_test[_i][_qp];
120  return residual;
121 }
const Real _a
Definition: CHPFCRFF.h:46
const MooseEnum _log_approach
Definition: CHPFCRFF.h:38
const unsigned int _n_exp_terms
Definition: CHPFCRFF.h:45
const Real _tol
Definition: CHPFCRFF.h:39
const Real _b
Definition: CHPFCRFF.h:47
const Real _c
Definition: CHPFCRFF.h:48
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
std::vector< const VariableGradient * > _grad_vals
Definition: CHPFCRFF.h:43
const unsigned int _num_L
Definition: CHPFCRFF.h:41
const MaterialProperty< Real > & _M
Definition: CHPFCRFF.h:34

Member Data Documentation

const Real CHPFCRFF::_a
private

Definition at line 46 of file CHPFCRFF.h.

Referenced by computeQpJacobian(), and computeQpResidual().

const Real CHPFCRFF::_b
private

Definition at line 47 of file CHPFCRFF.h.

Referenced by computeQpJacobian(), and computeQpResidual().

const Real CHPFCRFF::_c
private

Definition at line 48 of file CHPFCRFF.h.

Referenced by computeQpJacobian(), and computeQpResidual().

const MaterialProperty<Real>* CHPFCRFF::_DM
private

Definition at line 36 of file CHPFCRFF.h.

std::vector<const VariableGradient *> CHPFCRFF::_grad_vals
private

Definition at line 43 of file CHPFCRFF.h.

Referenced by CHPFCRFF(), computeQpJacobian(), and computeQpResidual().

const bool CHPFCRFF::_has_MJac
private

Definition at line 35 of file CHPFCRFF.h.

const MooseEnum CHPFCRFF::_log_approach
private

Definition at line 38 of file CHPFCRFF.h.

Referenced by computeQpJacobian(), computeQpOffDiagJacobian(), and computeQpResidual().

const MaterialProperty<Real>& CHPFCRFF::_M
private

Definition at line 34 of file CHPFCRFF.h.

Referenced by computeQpJacobian(), computeQpOffDiagJacobian(), and computeQpResidual().

const unsigned int CHPFCRFF::_n_exp_terms
private

Definition at line 45 of file CHPFCRFF.h.

Referenced by computeQpJacobian(), and computeQpResidual().

const unsigned int CHPFCRFF::_num_L
private
const Real CHPFCRFF::_tol
private

Definition at line 39 of file CHPFCRFF.h.

Referenced by computeQpJacobian(), and computeQpResidual().

std::vector<unsigned int> CHPFCRFF::_vals_var
private

Definition at line 42 of file CHPFCRFF.h.

Referenced by CHPFCRFF(), and computeQpOffDiagJacobian().


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