NiHu  2.0
telles_1987.hpp
Go to the documentation of this file.
1 
7 #ifndef NIHU_TELLES_1987_HPP_INCLUDED
8 #define NIHU_TELLES_1987_HPP_INCLUDED
9 
10 #include "core/quadrature.hpp"
11 
12 #include <cmath>
13 
14 namespace NiHu
15 {
16 
43 template <class QuadDerived>
44 QuadDerived telles_transform(
46  typename quadrature_traits<QuadDerived>::domain_t::xi_t const &eta_bar,
47 #ifdef _MSC_VER
49 #else
51 #endif
52  )
53 {
54  typedef quadrature_traits<QuadDerived> traits_t;
55  typedef typename traits_t::domain_t domain_t;
56  int const n_dims = domain_t::dimension;
57  typedef typename domain_t::xi_t xi_t;
58  typedef typename domain_t::scalar_t scalar_t;
59 
60  QuadDerived result = q.derived();
61 
62  /* Distance dependent parametrization (see (27) in [1] */
63  scalar_t r_bar;
64  if (d < 0.05)
65  r_bar = 0;
66  else if (d <= 1.3)
67  r_bar = 0.85 + 0.24 * std::log(d);
68  else if (d <= 3.618)
69  r_bar = 0.893 + 0.0832 * std::log(d);
70  else
71  r_bar = 1;
72 
73  /* Go through the dimensions */
74  for (int i_dim = 0; i_dim < n_dims; ++i_dim)
75  {
76  scalar_t const& e = eta_bar(i_dim); // Shortcut notation
77  scalar_t f = (1 + 2*r_bar); // Helper quantity
78  // Intermediate quantities defined in (21)
79  scalar_t q = 1/(2*f)*((e*(3-2*r_bar) - 2*e*e*e/f)*1/f - e);
80  scalar_t p = 1/(3*f*f)*(4*r_bar*(1-r_bar) + 3*(1 - e*e));
81  scalar_t s = std::sqrt(q*q + p*p*p);
82 
83  // The singular point in gamma domain
84  scalar_t gamma_bar = std::cbrt(-q+s) + std::cbrt(-q-s) + e/f;
85 
86  scalar_t Q = 1 + 3*gamma_bar*gamma_bar;
87  // Polynomial coefficients as defined in eq. (21)
88  scalar_t a = (1 - r_bar) / Q;
89  scalar_t b = -3*(1 - r_bar) * gamma_bar / Q;
90  scalar_t c = (3*gamma_bar*gamma_bar + r_bar) / Q;
91  scalar_t d = -b;
92 
93  /* Go through all quadrature points and scale them */
94  for (auto it = result.begin(); it != result.end(); ++it)
95  {
96  xi_t &xi = it->get_xi();
97  scalar_t x = xi(i_dim);
98  /* Update the base point */
99  xi(i_dim) = a*x*x*x + b*x*x + c*x + d;
100  /* Evaluate jacobian */
101  scalar_t jac = 3*a*x*x + 2*b*x + c;
102  /* Update weight */
103  it->set_w(it->get_w() * jac);
104  }
105  }
106 
107 
108  return result;
109 }
110 
111 } // end of namespace NiHu
112 
113 #endif /* NIHU_TELLES_1987_HPP_INCLUDED */
NiHu::quadrature_traits
Definition: quadrature.hpp:145
quadrature.hpp
implementation of class NiHu::quadrature_elem, NiHu::quadrature_base
NiHu::telles_transform
QuadDerived telles_transform(quadrature_base< QuadDerived > const &q, typename quadrature_traits< QuadDerived >::domain_t::xi_t const &eta_bar, typename quadrature_traits< QuadDerived >::domain_t::scalar_t const &d=typename quadrature_traits< QuadDerived >::domain_t::scalar_t())
Telles third order polynomial transform.
Definition: telles_1987.hpp:44
NiHu::quadrature_base
CRTP base class of all quadratures.
Definition: quadrature.hpp:162