https://mooseframework.inl.gov
LevelSetOlssonPlane.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 #include "LevelSetOlssonPlane.h"
11 #include "libmesh/utility.h"
12 
14 
17 {
19  params.addClassDescription("Implementation of a level set function to represent a plane.");
20  params.addParam<RealVectorValue>("point", RealVectorValue(0, 0, 0), "A point on the plane.");
21  params.addParam<RealVectorValue>(
22  "normal", RealVectorValue(0, 1, 0), "The normal vector to the plane.");
23  params.addParam<Real>("epsilon", 0.01, "The interface thickness.");
24  return params;
25 }
26 
28  : Function(parameters),
29  _point(getParam<RealVectorValue>("point")),
30  _normal(getParam<RealVectorValue>("normal")),
31  _epsilon(getParam<Real>("epsilon"))
32 {
33 }
34 
35 Real
36 LevelSetOlssonPlane::value(Real /*t*/, const Point & p) const
37 {
38  const RealVectorValue unit_normal = _normal / _normal.norm();
39  const Real distance_from_orgin = -unit_normal * _point;
40  const Real x = -(unit_normal * p + distance_from_orgin) / _epsilon;
41 
42  return 1.0 / (1 + std::exp(x));
43 }
44 
46 LevelSetOlssonPlane::gradient(Real /*t*/, const Point & p) const
47 {
48  const RealVectorValue unit_normal = _normal / _normal.norm();
49  const Real distance_from_orgin = -unit_normal * _point;
50  const Real x = -(unit_normal * p + distance_from_orgin) / _epsilon;
51 
52  RealGradient output;
53  Real x_prime;
54 
55  for (const auto i : make_range(Moose::dim))
56  {
57  x_prime = -unit_normal(i) / _epsilon;
58  output(i) = -(x_prime * std::exp(x)) / Utility::pow<2>(std::exp(x) + 1);
59  }
60 
61  return output;
62 }
LevelSetOlssonPlane(const InputParameters &parameters)
Implementation of a level set function to represent a plane.
const Real & _epsilon
The interface thickness.
auto norm() const -> decltype(std::norm(Real()))
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
virtual Real value(Real, const Point &p) const override
const RealVectorValue & _normal
The normal vector to the plane.
static constexpr std::size_t dim
registerMooseObject("LevelSetApp", LevelSetOlssonPlane)
const RealVectorValue & _point
A point on the plane.
const std::vector< double > x
virtual RealGradient gradient(Real, const Point &p) const override
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
IntRange< T > make_range(T beg, T end)
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
static InputParameters validParams()