www.mooseframework.org
LevelSetOlssonBubble.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
8 // MOOSE includes
9 #include "LevelSetOlssonBubble.h"
10 
11 template <>
12 InputParameters
14 {
15  InputParameters params = validParams<Function>();
16  params.addClassDescription("Implementation of 'bubble' ranging from 0 to 1.");
17  params.addParam<RealVectorValue>(
18  "center", RealVectorValue(0.5, 0.5, 0), "The center of the bubble.");
19  params.addParam<Real>("radius", 0.15, "The radius of the bubble.");
20  params.addParam<Real>("epsilon", 0.01, "The interface thickness.");
21  return params;
22 }
23 
24 LevelSetOlssonBubble::LevelSetOlssonBubble(const InputParameters & parameters)
25  : Function(parameters),
26  _center(getParam<RealVectorValue>("center")),
27  _radius(getParam<Real>("radius")),
28  _epsilon(getParam<Real>("epsilon"))
29 {
30 }
31 
32 Real
33 LevelSetOlssonBubble::value(Real /*t*/, const Point & p)
34 {
35  const Real x = ((p - _center).size() - _radius) / _epsilon;
36  return 1.0 / (1 + std::exp(x));
37 }
38 
39 RealGradient
40 LevelSetOlssonBubble::gradient(Real /*t*/, const Point & p)
41 {
42  Real norm = (p - _center).size();
43  Real g = (norm - _radius) / _epsilon;
44  RealGradient output;
45 
46  Real g_prime;
47  for (unsigned int i = 0; i < LIBMESH_DIM; ++i)
48  {
49  g_prime = (p(i) - _center(i)) / (_epsilon * norm);
50  output(i) = (g_prime * std::exp(g)) / ((std::exp(g) + 1) * (std::exp(g) + 1));
51  }
52  return output;
53 }
LevelSetOlssonBubble(const InputParameters &parameters)
InputParameters validParams< LevelSetOlssonBubble >()
const Real & _radius
The radius of the bubble.
const RealVectorValue & _center
The &#39;center&#39; of the bubble.
virtual Real value(Real, const Point &p) override
virtual RealGradient gradient(Real, const Point &p) override
const Real & _epsilon
The interface thickness.