1#ifndef _RHEOLEF_SHERWIN_ICC
2#define _RHEOLEF_SHERWIN_ICC
31#include "rheolef/quadrature.h"
36#ifdef SHERWIN_USE_GINAC
37#include <ginac/ginac.h>
47template<
class T0,
class T,
class Container>
58 value.resize (order+1);
60 if (order == 0)
return;
61 value[1] = ((alpha+beta+2)*tilde_x + alpha - beta)/2;
62 for (
size_t r = 1; r < order; r++) {
63 T a = (beta*beta - alpha*alpha)/((alpha+beta+
T(2.*r))*(alpha+beta+
T(2.*r+2)));
64 T b = 2*(alpha+
T(1.*r))*(beta+
T(1.*r))/((alpha+beta+
T(2.*r))*(alpha+beta+
T(2.*r+1)));
65 T c = 2*
T(r+1.)*(alpha+beta+
T(r+1.))/((alpha+beta+
T(2.*r+1))*(alpha+beta+
T(2.*r+2)));
66 value[r+1] = ((tilde_x-a)*value[r] - b*value[r-1])/c;
74template<
class T0,
class T,
class Container>
86 typedef typename Container::value_type value_type;
88 value.resize (degree+1);
96 value [loc_idof] = (1-tilde_x)/2;
98 value [loc_idof] = (1+tilde_x)/2;
99 if (degree == 1)
return;
100 details::eval_jacobi (tilde_x, degree-2, alpha, beta, jacobi);
101 for (
size_type i = 1; i+1 <= degree; i++) {
103 value [loc_idof] = 0.25*(1-tilde_x)*(1+tilde_x)*jacobi [i-1];
106template<
class T,
class Container>
115 typedef typename Container::value_type value_type;
117 float_type eps = std::numeric_limits<float_type>::epsilon();
119 if (
d == 0)
return false;
120 T distance_to_corner = fabs(tilde_x[
d-1]-1);
121 if (distance_to_corner >= eps) {
125 for (
size_t i = 0; i < size_t(value.size()); ++i) {
126 value[i] = value_type(0);
130 size_t loc_idof = ilat2loc_inod (hat_K, degree, ilat);
134#ifdef SHERWIN_USE_GINAC
139eval_sherwin_basis_is_singular_point<GiNaC::ex,std::vector<GiNaC::ex> > (
140 const point_basic<GiNaC::ex>& tilde_x,
141 reference_element hat_K,
143 std::vector<GiNaC::ex>& value)
150template<
class T0,
class T,
class Container>
153eval_sherwin_basis_t (
154 const point_basic<T0>& tilde_x,
163 typedef typename Container::value_type
value_type;
165 value.resize ((degree+1)*(degree+2)/2);
171 value_type eta0 = 2*(1+tilde_x[0])/(1-tilde_x[1])-1,
177 value [loc_idof] = 0.25*(1-eta0)*(1-eta1);
179 value [loc_idof] = 0.25*(1+eta0)*(1-eta1);
181 value [loc_idof] = 0.5*(1+eta1);
184 if (degree <= 1)
return;
186 details::eval_jacobi (eta0, degree-2,
T(1),
T(1), jacobi_x);
187 value_type coef = 0.5*(1-eta1);
188 for (
size_type i = 1; i <= degree-1; ++i) {
190 coef *= 0.5*(1-eta1);
191 value [loc_idof] = 0.25*(1-eta0)*(1+eta0)*coef*jacobi_x[i-1];
194 details::eval_jacobi (eta1, degree-2,
T(1),
T(1), jacobi_y);
196 for (
size_type j = 1; j <= degree-1; ++j) {
198 value [loc_idof] = 0.25*(1+eta0)*(1-eta1)*coef*jacobi_y[j-1];
201 for (
size_type j = 1; j <= degree-1; ++j) {
203 value [loc_idof] = 0.25*(1-eta0)*(1-eta1)*coef*jacobi_y[j-1];
207 for (
size_type i = 1; i <= degree-1; ++i) {
208 coef *= 0.5*(1-eta1);
209 details::eval_jacobi (eta1, degree-2,
T(2*
int(i)+1),
T(1), jacobi_y);
210 for (
size_type j = 1; i+j <= degree-1; ++j) {
212 value [loc_idof] = 0.25*(1-eta0)*(1+eta0)*jacobi_x[i-1]*coef
213 *0.5*(1+eta1)*jacobi_y[j-1];
221eval_dubiner_basis_T (
222 const point_basic<T>& tilde_x,
224 const std::vector<size_t>& perm,
225 Eigen::Matrix<T,Eigen::Dynamic,1>& value,
226 std::vector<point_basic<size_t> >& power_index)
233template<
class T0,
class T,
class Container>
237 const point_basic<T0>& hat_x,
238 reference_element hat_K,
246 bool do_tilde =
true)
249 typedef typename Container::value_type value_type;
252 switch (hat_K.variant()) {
259 value_type tilde_x = do_tilde ? 2*hat_x[0] - 1: hat_x[0];
260 eval_sherwin_basis_e (tilde_x, degree, alpha, beta, jacobi_x, value);
265 point_basic<value_type> tilde_x
266 = do_tilde ? point_basic<value_type>(2*hat_x[0]-1, 2*hat_x[1]-1)
267 : point_basic<value_type>( hat_x[0], hat_x[1]);
268 eval_sherwin_basis_t (tilde_x, degree, alpha, beta, jacobi_x, jacobi_y, value);
275 point_basic<T> tilde_x
276 = do_tilde ? point_basic<T>(2*hat_x[0]-1, 2*hat_x[1]-1, 2*hat_x[2]-1) : hat_x;
277 eval_dubiner_basis_T (tilde_x, degree, perm, value, power_index);
281 Eigen::Matrix<T,Eigen::Dynamic,1> value0, value1;
282 std::vector<size_t> id_e (degree+1);
283 for (
size_type i = 0; i < id_e.size(); i++) { id_e [i] = i; }
284 std::vector<point_basic<size_t> > power_index_e;
285 eval_dubiner_basis_e (hat_x[0], degree, id_e, value0, power_index_e);
286 eval_dubiner_basis_e (hat_x[1], degree, id_e, value1, power_index_e);
287 for (
size_type i = 0; i <= degree; i++) {
288 for (
size_type j = 0; j <= degree; j++) {
292 power_index[perm[loc_idof]] = point_basic<size_t>(i,j);
293 value [perm[loc_idof]] = value0[loc_idof_e]*value1[loc_jdof_e];
298 Eigen::Matrix<T,Eigen::Dynamic,1> value0, value1, value2;
299 std::vector<size_t> id_e (degree+1);
300 for (
size_type i = 0; i < id_e.size(); i++) { id_e [i] = i; }
301 std::vector<point_basic<size_t> > power_index_e;
302 eval_dubiner_basis_e (hat_x[0], degree, id_e, value0, power_index_e);
303 eval_dubiner_basis_e (hat_x[1], degree, id_e, value1, power_index_e);
304 eval_dubiner_basis_e (hat_x[2], degree, id_e, value2, power_index_e);
305 for (
size_type i = 0; i <= degree; i++) {
306 for (
size_type j = 0; j <= degree; j++) {
307 for (
size_type k = 0; k <= degree; k++) {
312 power_index[perm[loc_idof]] = point_basic<size_t>(i,j,k);
313 value [perm[loc_idof]] = value0[loc_idof_e]*value1[loc_jdof_e]*value2[loc_kdof_e];
318 Eigen::Matrix<T,Eigen::Dynamic,1> value01, value2;
319 std::vector<size_t> id_e (degree+1), id_t ((degree+1)*(degree+2)/2);
320 for (
size_type iloc = 0; iloc < id_e.size(); iloc ++) { id_e [iloc ] = iloc ; }
321 for (
size_type iloc = 0; iloc < id_t.size(); iloc ++) { id_t [iloc ] = iloc ; }
322 point_basic<T> tilde_x
323 = do_tilde ? point_basic<T>(2*hat_x[0]-1, 2*hat_x[1]-1)
324 : point_basic<
T>( hat_x[0], hat_x[1]);
325 std::vector<point_basic<size_t> > power_index_e, power_index_t;
326 eval_dubiner_basis_t (tilde_x, degree, id_t, value01, power_index_t);
327 eval_dubiner_basis_e (hat_x[2], degree, id_e, value2, power_index_e);
328 for (
size_type i = 0; i <= degree; i++) {
329 for (
size_type j = 0; i+j <= degree; j++) {
330 for (
size_type k = 0; k <= degree; k++) {
334 power_index[perm[loc_idof]] = point_basic<size_t>(i,j,k);
335 value [perm[loc_idof]] = value01[loc_ijdof_t]*value2[loc_kdof_e];
341 error_macro (
"unsupported element: "<<hat_K.name());
basis_option - finite element method options
field::size_type size_type
static size_type ilat2loc_inod(size_type order, const point_basic< size_type > &ilat)
static size_type ilat2loc_inod(size_type order, const point_basic< size_type > &ilat)
static size_type ilat2loc_inod(size_type order, const point_basic< size_type > &ilat)
static size_type ilat2loc_inod(size_type order, const point_basic< size_type > &ilat)
static size_type ilat2loc_inod(size_type order, const point_basic< size_type > &ilat)
see the reference_element page for the full documentation
static const variant_type H
static const variant_type q
static const variant_type e
size_type dimension() const
static const variant_type p
std::vector< int >::size_type size_type
static size_type n_node(variant_type variant, size_type order)
static const variant_type T
static const variant_type P
static const variant_type t
typename float_traits< value_type >::type float_type
#define error_macro(message)
This file is part of Rheolef.
bool eval_sherwin_basis_is_singular_point(const point_basic< T > &tilde_x, reference_element hat_K, size_t degree, Container &value)