Reference documentation for deal.II version 9.3.3
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
function_level_set.cc
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2019 - 2021 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.md at
12// the top level directory of deal.II.
13//
14// ---------------------------------------------------------------------
15
18
20
21namespace Functions
22{
23 namespace LevelSet
24 {
25 template <int dim>
26 Sphere<dim>::Sphere(const Point<dim> &center, const double radius)
27 : center(center)
28 , radius(radius)
29 {
30 Assert(radius > 0, ExcMessage("Radius must be positive."))
31 }
32
33
34
35 template <int dim>
36 double
38 const unsigned int component) const
39 {
40 AssertIndexRange(component, this->n_components);
41 (void)component;
42
43 return point.distance(center) - radius;
44 }
45
46
47
48 template <int dim>
51 const unsigned int component) const
52 {
53 AssertIndexRange(component, this->n_components);
54 (void)component;
55
56 const Tensor<1, dim> center_to_point = point - center;
57 const Tensor<1, dim> grad = center_to_point / center_to_point.norm();
58 return grad;
59 }
60
61
62
63 template <int dim>
66 const unsigned int component) const
67 {
68 AssertIndexRange(component, this->n_components);
69 (void)component;
70
71 const Tensor<1, dim> center_to_point = point - center;
72 const double distance = center_to_point.norm();
73
74 const SymmetricTensor<2, dim> hess =
75 unit_symmetric_tensor<dim>() / distance -
76 symmetrize(outer_product(center_to_point, center_to_point)) /
77 std::pow(distance, 3);
78
79 return hess;
80 }
81
82
83
84 template <int dim>
86 : point_in_plane(point)
87 , normal(normal)
88 {
89 Assert(normal.norm() > 0, ExcMessage("Plane normal must not be 0."))
90 }
91
92
93
94 template <int dim>
95 double
97 const unsigned int component) const
98 {
99 AssertIndexRange(component, this->n_components);
100 (void)component;
101
102 return normal * (point - point_in_plane);
103 }
104
105
106
107 template <int dim>
109 Plane<dim>::gradient(const Point<dim> &, const unsigned int component) const
110 {
111 AssertIndexRange(component, this->n_components);
112 (void)component;
113
114 return normal;
115 }
116
117
118
119 template <int dim>
121 Plane<dim>::hessian(const Point<dim> &, const unsigned int component) const
122 {
123 AssertIndexRange(component, this->n_components);
124 (void)component;
125
127 }
128
129 } // namespace LevelSet
130} // namespace Functions
131
132#include "function_level_set.inst"
133
double value(const Point< dim > &point, const unsigned int component=0) const override
Plane(const Point< dim > &point, const Tensor< 1, dim > &normal)
Tensor< 1, dim > gradient(const Point< dim > &, const unsigned int component=0) const override
SymmetricTensor< 2, dim > hessian(const Point< dim > &, const unsigned int component=0) const override
const Tensor< 1, dim > normal
SymmetricTensor< 2, dim > hessian(const Point< dim > &point, const unsigned int component=0) const override
Tensor< 1, dim > gradient(const Point< dim > &point, const unsigned int component=0) const override
double value(const Point< dim > &point, const unsigned int component=0) const override
Sphere(const Point< dim > &center=Point< dim >(), const double radius=1)
Definition: point.h:111
numbers::NumberTraits< Number >::real_type distance(const Point< dim, Number > &p) const
numbers::NumberTraits< Number >::real_type norm() const
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:402
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:403
Point< 3 > center
#define Assert(cond, exc)
Definition: exceptions.h:1465
#define AssertIndexRange(index, range)
Definition: exceptions.h:1690
static ::ExceptionBase & ExcMessage(std::string arg1)
Point< spacedim > point(const gp_Pnt &p, const double tolerance=1e-10)
Definition: utilities.cc:188
::VectorizedArray< Number, width > pow(const ::VectorizedArray< Number, width > &, const Number p)
constexpr SymmetricTensor< 2, dim, Number > symmetrize(const Tensor< 2, dim, Number > &t)
constexpr SymmetricTensor< 4, dim, Number > outer_product(const SymmetricTensor< 2, dim, Number > &t1, const SymmetricTensor< 2, dim, Number > &t2)