16 #include <deal.II/base/function_spherical.h> 17 #include <deal.II/base/geometric_utilities.h> 18 #include <deal.II/base/point.h> 23 DEAL_II_NAMESPACE_OPEN
101 set_unit_vectors(
const double cos_theta,
102 const double sin_theta,
103 const double cos_phi,
104 const double sin_phi,
109 unit_r[0] = cos_theta * sin_phi;
110 unit_r[1] = sin_theta * sin_phi;
113 unit_theta[0] = -sin_theta;
114 unit_theta[1] = cos_theta;
117 unit_phi[0] = cos_theta * cos_phi;
118 unit_phi[1] = sin_theta * cos_phi;
119 unit_phi[2] = -sin_phi;
133 for (
unsigned int i = 0; i < dim; i++)
134 for (
unsigned int j = i; j < dim; j++)
135 out[i][j] += (in1[i] * in2[j] + in1[j] * in2[i]) * val;
147 for (
unsigned int i = 0; i < dim; i++)
148 for (
unsigned int j = i; j < dim; j++)
149 out[i][j] += val * in[i] * in[j];
157 const unsigned int n_components)
159 , coordinate_system_offset(p)
169 const unsigned int component)
const 171 const Point<dim> p = p_ - coordinate_system_offset;
172 const std::array<double, dim> sp =
174 return svalue(sp, component);
182 const unsigned int )
const 195 constexpr
int dim = 3;
196 const Point<dim> p = p_ - coordinate_system_offset;
197 const std::array<double, dim> sp =
199 const std::array<double, dim> sg = sgradient(sp, component);
202 const double cos_theta = std::cos(sp[1]);
203 const double sin_theta = std::sin(sp[1]);
204 const double cos_phi = std::cos(sp[2]);
205 const double sin_phi = std::sin(sp[2]);
209 cos_theta, sin_theta, cos_phi, sin_phi, unit_r, unit_theta, unit_phi);
215 res += unit_r * sg[0];
218 if (sg[1] * sin_phi != 0.)
221 res += unit_theta * sg[1] / (sp[0] * sin_phi);
227 res += unit_phi * sg[2] / sp[0];
238 const unsigned int )
const 251 constexpr
int dim = 3;
252 const Point<dim> p = p_ - coordinate_system_offset;
253 const std::array<double, dim> sp =
255 const std::array<double, dim> sg = sgradient(sp, component);
256 const std::array<double, 6> sh = shessian(sp, component);
259 const double cos_theta = std::cos(sp[1]);
260 const double sin_theta = std::sin(sp[1]);
261 const double cos_phi = std::cos(sp[2]);
262 const double sin_phi = std::sin(sp[2]);
263 const double r = sp[0];
267 cos_theta, sin_theta, cos_phi, sin_phi, unit_r, unit_theta, unit_phi);
269 const double sin_phi2 = sin_phi * sin_phi;
270 const double r2 = r * r;
273 const double c_utheta2 =
274 sg[0] / r + ((sin_phi != 0.) ? (cos_phi * sg[2]) / (r2 * sin_phi) +
275 sh[1] / (r2 * sin_phi2) :
277 const double c_utheta_ur =
278 ((sin_phi != 0.) ? (r * sh[3] - sg[1]) / (r2 * sin_phi) : 0.);
279 const double c_utheta_uphi =
280 ((sin_phi != 0.) ? (sh[5] * sin_phi - cos_phi * sg[1]) / (r2 * sin_phi2) :
282 const double c_ur2 = sh[0];
283 const double c_ur_uphi = (r * sh[4] - sg[2]) / r2;
284 const double c_uphi2 = (sh[2] + r * sg[0]) / r2;
289 add_outer_product(res, c_utheta2, unit_theta);
291 add_outer_product(res, c_utheta_ur, unit_theta, unit_r);
293 add_outer_product(res, c_utheta_uphi, unit_theta, unit_phi);
295 add_outer_product(res, c_ur2, unit_r);
297 add_outer_product(res, c_ur_uphi, unit_r, unit_phi);
299 add_outer_product(res, c_uphi2, unit_phi);
308 Spherical<dim>::memory_consumption()
const 310 return sizeof(Spherical<dim>);
318 const unsigned int )
const 327 std::array<double, dim>
329 const unsigned int )
const 332 return std::array<double, dim>();
338 std::array<double, 6>
340 const unsigned int )
const 343 return std::array<double, 6>();
355 DEAL_II_NAMESPACE_CLOSE
virtual double value(const Point< dim > &point, const unsigned int component=0) const override
virtual std::array< double, 6 > shessian(const std::array< double, dim > &sp, const unsigned int component) const
Spherical(const Point< dim > ¢er=Point< dim >(), const unsigned int n_components=1)
#define AssertThrow(cond, exc)
static ::ExceptionBase & ExcDivideByZero()
virtual std::array< double, dim > sgradient(const std::array< double, dim > &sp, const unsigned int component) const
virtual SymmetricTensor< 2, dim > hessian(const Point< dim > &p, const unsigned int component=0) const override
virtual double svalue(const std::array< double, dim > &sp, const unsigned int component) const
virtual Tensor< 1, dim > gradient(const Point< dim > &p, const unsigned int component=0) const override
std::array< double, dim > to_spherical(const Point< dim > &point)
#define Assert(cond, exc)
static ::ExceptionBase & ExcNotImplemented()