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 component)
const 185 const Point<dim> p = p_ - coordinate_system_offset;
187 const std_cxx11::array<double, dim> sg = sgradient(sp, component);
190 const double cos_theta = std::cos(sp[1]);
191 const double sin_theta = std::sin(sp[1]);
192 const double cos_phi = std::cos(sp[2]);
193 const double sin_phi = std::sin(sp[2]);
196 set_unit_vectors(cos_theta, sin_theta,
198 unit_r, unit_theta, unit_phi);
204 res += unit_r * sg[0];
207 if (sg[1] * sin_phi != 0.)
211 res += unit_theta * sg[1] / (sp[0] * sin_phi);
218 res += unit_phi * sg[2] / sp[0];
229 const unsigned int component)
const 231 const Point<dim> p = p_ - coordinate_system_offset;
233 const std_cxx11::array<double, dim> sg = sgradient(sp, component);
234 const std_cxx11::array<double, 6> sh = shessian(sp, component);
237 const double cos_theta = std::cos(sp[1]);
238 const double sin_theta = std::sin(sp[1]);
239 const double cos_phi = std::cos(sp[2]);
240 const double sin_phi = std::sin(sp[2]);
241 const double r = sp[0];
244 set_unit_vectors(cos_theta, sin_theta,
246 unit_r, unit_theta, unit_phi);
248 const double sin_phi2 = sin_phi*sin_phi;
249 const double r2 = r*r;
253 const double c_utheta2 = sg[0]/r +
255 (cos_phi*sg[2])/(r2*sin_phi)+sh[1]/(r2*sin_phi2) :
257 const double c_utheta_ur = ((sin_phi != 0.) ?
258 (r*sh[3]-sg[1])/(r2*sin_phi) :
260 const double c_utheta_uphi = ((sin_phi != 0.) ?
261 (sh[5]*sin_phi-cos_phi*sg[1])/(r2*sin_phi2) :
263 const double c_ur2 = sh[0];
264 const double c_ur_uphi = (r*sh[4]-sg[2])/r2;
265 const double c_uphi2 = (sh[2]+r*sg[0])/r2;
270 add_outer_product(res,
274 add_outer_product(res,
279 add_outer_product(res,
284 add_outer_product(res,
288 add_outer_product(res,
293 add_outer_product(res,
314 const unsigned int )
const 324 std_cxx11::array<double, dim>
326 const unsigned int )
const 330 return std_cxx11::array<double,dim>();
336 std_cxx11::array<double, 6>
338 const unsigned int )
const 342 return std_cxx11::array<double, 6>();
352 DEAL_II_NAMESPACE_CLOSE
virtual SymmetricTensor< 2, dim > hessian(const Point< dim > &p, const unsigned int component=0) 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)
std_cxx11::array< double, dim > to_spherical(const Point< dim > &point)
static ::ExceptionBase & ExcDivideByZero()
virtual Tensor< 1, dim > gradient(const Point< dim > &p, const unsigned int component=0) const
virtual std_cxx11::array< double, 6 > shessian(const std_cxx11::array< double, dim > &sp, const unsigned int component) const
#define Assert(cond, exc)
virtual double svalue(const std_cxx11::array< double, dim > &sp, const unsigned int component) const
virtual std_cxx11::array< double, dim > sgradient(const std_cxx11::array< double, dim > &sp, const unsigned int component) const
static ::ExceptionBase & ExcNotImplemented()