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

Constructor & Destructor Documentation

◆ CHPFCRFF()

CHPFCRFF::CHPFCRFF ( const InputParameters &  parameters)

Definition at line 38 of file CHPFCRFF.C.

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

Member Function Documentation

◆ computeQpJacobian()

Real CHPFCRFF::computeQpJacobian ( )
protectedvirtual

Definition at line 128 of file CHPFCRFF.C.

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

◆ computeQpOffDiagJacobian()

Real CHPFCRFF::computeQpOffDiagJacobian ( unsigned int  jvar)
protectedvirtual

Definition at line 219 of file CHPFCRFF.C.

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

◆ computeQpResidual()

Real CHPFCRFF::computeQpResidual ( )
protectedvirtual

Definition at line 62 of file CHPFCRFF.C.

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

Member Data Documentation

◆ _a

const Real CHPFCRFF::_a
private

Definition at line 48 of file CHPFCRFF.h.

Referenced by computeQpJacobian(), and computeQpResidual().

◆ _b

const Real CHPFCRFF::_b
private

Definition at line 49 of file CHPFCRFF.h.

Referenced by computeQpJacobian(), and computeQpResidual().

◆ _c

const Real CHPFCRFF::_c
private

Definition at line 50 of file CHPFCRFF.h.

Referenced by computeQpJacobian(), and computeQpResidual().

◆ _DM

const MaterialProperty<Real>* CHPFCRFF::_DM
private

Definition at line 38 of file CHPFCRFF.h.

◆ _grad_vals

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

Definition at line 45 of file CHPFCRFF.h.

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

◆ _has_MJac

const bool CHPFCRFF::_has_MJac
private

Definition at line 37 of file CHPFCRFF.h.

◆ _log_approach

const MooseEnum CHPFCRFF::_log_approach
private

Definition at line 40 of file CHPFCRFF.h.

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

◆ _M

const MaterialProperty<Real>& CHPFCRFF::_M
private

Definition at line 36 of file CHPFCRFF.h.

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

◆ _n_exp_terms

const unsigned int CHPFCRFF::_n_exp_terms
private

Definition at line 47 of file CHPFCRFF.h.

Referenced by computeQpJacobian(), and computeQpResidual().

◆ _num_L

const unsigned int CHPFCRFF::_num_L
private

◆ _tol

const Real CHPFCRFF::_tol
private

Definition at line 41 of file CHPFCRFF.h.

Referenced by computeQpJacobian(), and computeQpResidual().

◆ _vals_var

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

Definition at line 44 of file CHPFCRFF.h.

Referenced by CHPFCRFF(), and computeQpOffDiagJacobian().


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