https://mooseframework.inl.gov
Loading...
Searching...
No Matches
LevelSetOlssonBubble.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
10// MOOSE includes
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
35Real
36LevelSetOlssonBubble::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
43LevelSetOlssonBubble::value(const ADReal & /*t*/, const ADPoint & p) const
44{
45 using std::exp;
46 const auto x = ((p - _center).norm() - _radius) / _epsilon;
47 return 1.0 / (1 + exp(x));
48}
49
50RealGradient
51LevelSetOlssonBubble::gradient(Real /*t*/, const Point & p) const
52{
53 Real norm = (p - _center).norm();
54 Real g = (norm - _radius) / _epsilon;
55 RealGradient output;
56
57 Real g_prime;
58 for (const auto i : make_range(Moose::dim))
59 {
60 g_prime = (p(i) - _center(i)) / (_epsilon * norm);
61 output(i) = -(g_prime * std::exp(g)) / ((std::exp(g) + 1) * (std::exp(g) + 1));
62 }
63 return output;
64}
DualNumber< Real, DNDerivativeType, true > ADReal
const std::vector< double > x
const Real p
registerMooseObject("LevelSetApp", LevelSetOlssonBubble)
static InputParameters validParams()
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
Implements the "bubble" function from Olsson and Kreiss (2005).
const Real & _radius
The radius of the bubble.
LevelSetOlssonBubble(const InputParameters &parameters)
const Real & _epsilon
The interface thickness.
const RealVectorValue & _center
The 'center' of the bubble.
static InputParameters validParams()
virtual RealGradient gradient(Real, const Point &p) const override
virtual Real value(Real, const Point &p) const override
static constexpr std::size_t dim