https://mooseframework.inl.gov
InterfaceNormalCurvatures.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
11 #include "Assembly.h"
12 
14 
17 {
19  params.addClassDescription(
20  "Computes the two normal curvatures kappa_1 and kappa_2 of a diffuse interface "
21  "from an order parameter eta.");
22  params.addRequiredCoupledVar("eta", "Order parameter that defines the interface");
23  params.addParam<Real>(
24  "gradient_threshold",
25  1e-6,
26  "If |grad(eta)| is less than this threshold at a point, curvatures are set to zero there.");
27  params.addParam<std::string>("base_name", "", "Optional prefix for all material property names");
28  return params;
29 }
30 
32  : Material(params),
33  _eta(coupledValue("eta")),
34  _grad_eta(coupledGradient("eta")),
35  _second_eta(coupledSecond("eta")),
36  _grad_threshold(getParam<Real>("gradient_threshold")),
37  _kappa1(declareProperty<Real>(getParam<std::string>("base_name") + "kappa1")),
38  _kappa2(declareProperty<Real>(getParam<std::string>("base_name") + "kappa2")),
39  _kappa_mean(declareProperty<Real>(getParam<std::string>("base_name") + "kappa_mean"))
40 {
41 }
42 
43 void
45 {
46  // -- 1. Interface normal -------------------------------------------------
47  const RealVectorValue & g = _grad_eta[_qp];
48  const Real g_mag = g.norm();
49  if (g_mag < _grad_threshold)
50  _kappa1[_qp] = _kappa2[_qp] = _kappa_mean[_qp] = 0;
51  else
52  {
53  const RealVectorValue nhat = g / g_mag; // n (unit normal)
54 
55  // -- 2. Tangent frame ----------------------------------------------------
56  static const RealVectorValue ZHAT(0., 0., 1.);
57  static const RealVectorValue XHAT(1., 0., 0.);
58 
59  RealVectorValue t1 = ZHAT.cross(nhat); // chosen to lie in xy-plane
60  const Real t1_mag = t1.norm();
61  if (t1_mag < 1e-12)
62  t1 = XHAT; // if n = +/- z, choose x to be in-plane tangent t_1
63  else
64  t1 /= t1_mag;
65 
66  const RealVectorValue t2 = nhat.cross(t1); // already unit length
67 
68  // -- 3. Shape operator S ------------------------------------------------
69 
70  const RankTwoTensor & H = _second_eta[_qp]; // Hessian (3 x 3)
71 
72  RealVectorValue Hn;
73  for (unsigned i = 0; i < 3; ++i)
74  for (unsigned j = 0; j < 3; ++j)
75  Hn(i) += H(i, j) * nhat(j);
76 
77  // Normal curvature along a unit tangent v:
78  auto vHv = [&](const RealVectorValue & v) -> Real
79  {
80  Real val = 0.;
81  for (unsigned i = 0; i < 3; ++i)
82  for (unsigned j = 0; j < 3; ++j)
83  val += v(i) * H(i, j) * v(j);
84  return val;
85  };
86 
87  _kappa1[_qp] = -vHv(t1) / g_mag; // curvature in t_1 direction
88  _kappa2[_qp] = -vHv(t2) / g_mag; // curvature in t_2 direction
89 
90  // -- 4. Mean curvature ---------------------------------------------------
91 
92  const Real nHn = nhat * Hn;
93  _kappa_mean[_qp] = -(H.tr() - nHn) / g_mag / 2;
94  }
95 }
const VariableGradient & _grad_eta
auto norm() const
MaterialProperty< Real > & _kappa_mean
normal curvature along t_2
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
Computes two normal curvatures of a diffuse interface defined by an order parameter eta using n = gra...
InterfaceNormalCurvatures(const InputParameters &params)
const double v
virtual void computeQpProperties() override
unsigned int _qp
const VariableSecond & _second_eta
static InputParameters validParams()
MaterialProperty< Real > & _kappa2
normal curvature along t_1
TypeVector< typename CompareTypes< Real, T2 >::supertype > cross(const TypeVector< T2 > &v) const
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static InputParameters validParams()
void addClassDescription(const std::string &doc_string)
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
MaterialProperty< Real > & _kappa1
threshold for grad(eta) (avoids /0)
registerMooseObject("PhaseFieldApp", InterfaceNormalCurvatures)