www.mooseframework.org
LevelSetOlssonBubble.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
10 // MOOSE includes
11 #include "LevelSetOlssonBubble.h"
12 
14 
15 template <>
16 InputParameters
18 {
19  InputParameters params = validParams<Function>();
20  params.addClassDescription("Implementation of 'bubble' ranging from 0 to 1.");
21  params.addParam<RealVectorValue>(
22  "center", RealVectorValue(0.5, 0.5, 0), "The center of the bubble.");
23  params.addParam<Real>("radius", 0.15, "The radius of the bubble.");
24  params.addParam<Real>("epsilon", 0.01, "The interface thickness.");
25  return params;
26 }
27 
28 LevelSetOlssonBubble::LevelSetOlssonBubble(const InputParameters & parameters)
29  : Function(parameters),
30  _center(getParam<RealVectorValue>("center")),
31  _radius(getParam<Real>("radius")),
32  _epsilon(getParam<Real>("epsilon"))
33 {
34 }
35 
36 Real
37 LevelSetOlssonBubble::value(Real /*t*/, const Point & p) const
38 {
39  const Real x = ((p - _center).norm() - _radius) / _epsilon;
40  return 1.0 / (1 + std::exp(x));
41 }
42 
44 LevelSetOlssonBubble::gradient(Real /*t*/, const Point & p) const
45 {
46  Real norm = (p - _center).norm();
47  Real g = (norm - _radius) / _epsilon;
48  RealGradient output;
49 
50  Real g_prime;
51  for (unsigned int i = 0; i < LIBMESH_DIM; ++i)
52  {
53  g_prime = (p(i) - _center(i)) / (_epsilon * norm);
54  output(i) = (g_prime * std::exp(g)) / ((std::exp(g) + 1) * (std::exp(g) + 1));
55  }
56  return output;
57 }
LevelSetOlssonBubble.h
libMesh::RealGradient
VectorValue< Real > RealGradient
Definition: GrainForceAndTorqueInterface.h:17
registerMooseObject
registerMooseObject("LevelSetApp", LevelSetOlssonBubble)
LevelSetOlssonBubble::_epsilon
const Real & _epsilon
The interface thickness.
Definition: LevelSetOlssonBubble.h:40
LevelSetOlssonBubble::gradient
virtual RealGradient gradient(Real, const Point &p) const override
Definition: LevelSetOlssonBubble.C:44
LevelSetOlssonBubble::LevelSetOlssonBubble
LevelSetOlssonBubble(const InputParameters &parameters)
Definition: LevelSetOlssonBubble.C:28
validParams< LevelSetOlssonBubble >
InputParameters validParams< LevelSetOlssonBubble >()
Definition: LevelSetOlssonBubble.C:17
LevelSetOlssonBubble::_center
const RealVectorValue & _center
The 'center' of the bubble.
Definition: LevelSetOlssonBubble.h:34
LevelSetOlssonBubble::_radius
const Real & _radius
The radius of the bubble.
Definition: LevelSetOlssonBubble.h:37
LevelSetOlssonBubble
Implements the "bubble" function from Olsson and Kreiss (2005).
Definition: LevelSetOlssonBubble.h:23
LevelSetOlssonBubble::value
virtual Real value(Real, const Point &p) const override
Definition: LevelSetOlssonBubble.C:37