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 
17 {
19  params.addClassDescription("Implementation of 'bubble' ranging from 0 to 1.");
20  params.addParam<RealVectorValue>(
21  "center", RealVectorValue(0.5, 0.5, 0), "The center of the bubble.");
22  params.addParam<Real>("radius", 0.15, "The radius of the bubble.");
23  params.addParam<Real>("epsilon", 0.01, "The interface thickness.");
24  return params;
25 }
26 
28  : Function(parameters),
29  _center(getParam<RealVectorValue>("center")),
30  _radius(getParam<Real>("radius")),
31  _epsilon(getParam<Real>("epsilon"))
32 {
33 }
34 
35 Real
36 LevelSetOlssonBubble::value(Real /*t*/, const Point & p) const
37 {
38  const auto x = ((p - _center).norm() - _radius) / _epsilon;
39  return 1.0 / (1 + std::exp(x));
40 }
41 
42 ADReal
43 LevelSetOlssonBubble::value(const ADReal & /*t*/, const ADPoint & p) const
44 {
45  const auto x = ((p - _center).norm() - _radius) / _epsilon;
46  return 1.0 / (1 + std::exp(x));
47 }
48 
50 LevelSetOlssonBubble::gradient(Real /*t*/, const Point & p) const
51 {
52  Real norm = (p - _center).norm();
53  Real g = (norm - _radius) / _epsilon;
54  RealGradient output;
55 
56  Real g_prime;
57  for (const auto i : make_range(Moose::dim))
58  {
59  g_prime = (p(i) - _center(i)) / (_epsilon * norm);
60  output(i) = -(g_prime * std::exp(g)) / ((std::exp(g) + 1) * (std::exp(g) + 1));
61  }
62  return output;
63 }
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
LevelSetOlssonBubble(const InputParameters &parameters)
Implements the "bubble" function from Olsson and Kreiss (2005).
virtual RealGradient gradient(Real, const Point &p) const override
static constexpr std::size_t dim
const Real & _radius
The radius of the bubble.
virtual Real value(Real, const Point &p) const override
const RealVectorValue & _center
The &#39;center&#39; of the bubble.
const std::vector< double > x
DualReal ADReal
auto norm(const T &a) -> decltype(std::abs(a))
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static InputParameters validParams()
IntRange< T > make_range(T beg, T end)
void addClassDescription(const std::string &doc_string)
registerMooseObject("LevelSetApp", LevelSetOlssonBubble)
static InputParameters validParams()
const Real & _epsilon
The interface thickness.