16 #include <deal.II/base/point.h> 17 #include <deal.II/base/function_spherical.h> 18 #include <deal.II/base/geometric_utilities.h> 23 DEAL_II_NAMESPACE_OPEN
101 void 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)
160 coordinate_system_offset(p)
171 const unsigned int component)
const 173 const Point<dim> p = p_ - coordinate_system_offset;
175 return svalue(sp, component);
183 const unsigned int )
const 195 const unsigned int component)
const 197 constexpr
int dim = 3;
198 const Point<dim> p = p_ - coordinate_system_offset;
200 const std::array<double, dim> sg = sgradient(sp, component);
203 const double cos_theta = std::cos(sp[1]);
204 const double sin_theta = std::sin(sp[1]);
205 const double cos_phi = std::cos(sp[2]);
206 const double sin_phi = std::sin(sp[2]);
209 set_unit_vectors(cos_theta, sin_theta,
211 unit_r, unit_theta, unit_phi);
217 res += unit_r * sg[0];
220 if (sg[1] * sin_phi != 0.)
224 res += unit_theta * sg[1] / (sp[0] * sin_phi);
231 res += unit_phi * sg[2] / sp[0];
242 const unsigned int )
const 253 const unsigned int component)
const 256 constexpr
int dim = 3;
257 const Point<dim> p = p_ - coordinate_system_offset;
259 const std::array<double, dim> sg = sgradient(sp, component);
260 const std::array<double, 6> sh = shessian(sp, component);
263 const double cos_theta = std::cos(sp[1]);
264 const double sin_theta = std::sin(sp[1]);
265 const double cos_phi = std::cos(sp[2]);
266 const double sin_phi = std::sin(sp[2]);
267 const double r = sp[0];
270 set_unit_vectors(cos_theta, sin_theta,
272 unit_r, unit_theta, unit_phi);
274 const double sin_phi2 = sin_phi*sin_phi;
275 const double r2 = r*r;
279 const double c_utheta2 = sg[0]/r +
281 (cos_phi*sg[2])/(r2*sin_phi)+sh[1]/(r2*sin_phi2) :
283 const double c_utheta_ur = ((sin_phi != 0.) ?
284 (r*sh[3]-sg[1])/(r2*sin_phi) :
286 const double c_utheta_uphi = ((sin_phi != 0.) ?
287 (sh[5]*sin_phi-cos_phi*sg[1])/(r2*sin_phi2) :
289 const double c_ur2 = sh[0];
290 const double c_ur_uphi = (r*sh[4]-sg[2])/r2;
291 const double c_uphi2 = (sh[2]+r*sg[0])/r2;
296 add_outer_product(res,
300 add_outer_product(res,
305 add_outer_product(res,
310 add_outer_product(res,
314 add_outer_product(res,
319 add_outer_product(res,
330 Spherical<dim>::memory_consumption ()
const 332 return sizeof(Spherical<dim>);
340 const unsigned int )
const 350 std::array<double, dim>
352 const unsigned int )
const 356 return std::array<double,dim>();
362 std::array<double, 6>
364 const unsigned int )
const 368 return std::array<double, 6>();
380 DEAL_II_NAMESPACE_CLOSE
virtual SymmetricTensor< 2, dim > hessian(const Point< dim > &p, const unsigned int component=0) const
virtual std::array< double, 6 > shessian(const std::array< double, dim > &sp, const unsigned int component) const
virtual double value(const Point< dim > &point, const unsigned int component=0) const
Spherical(const Point< dim > ¢er=Point< dim >(), const unsigned int n_components=1)
#define AssertThrow(cond, exc)
static ::ExceptionBase & ExcDivideByZero()
virtual Tensor< 1, dim > gradient(const Point< dim > &p, const unsigned int component=0) const
virtual std::array< double, dim > sgradient(const std::array< double, dim > &sp, const unsigned int component) const
virtual double svalue(const std::array< double, dim > &sp, const unsigned int component) const
std::array< double, dim > to_spherical(const Point< dim > &point)
#define Assert(cond, exc)
static ::ExceptionBase & ExcNotImplemented()