local_basis.hh 30.3 KB
Newer Older
1 2
#ifndef DUNE_DORIE_RAVIART_THOMAS_VOLUME_BASIS_HH
#define DUNE_DORIE_RAVIART_THOMAS_VOLUME_BASIS_HH
3 4 5 6 7 8 9 10 11

#include <dune/localfunctions/common/localbasis.hh>
#include <dune/localfunctions/lagrange/pk.hh>
#include <dune/localfunctions/lagrange/qk.hh>

#include <dune/geometry/type.hh>

#include <dune/common/exceptions.hh>
#include <dune/common/power.hh>
12
#include <dune/common/typetraits.hh>
13

14 15
#include <dune/pdelab/finiteelementmap/qkdg.hh>

16 17 18 19 20
#include <vector>

namespace Dune{
namespace Dorie{

21
/*-------------------------------------------------------------------------*//**
22 23
 * @brief      Class for local basis of the volume raviart thomas finite element
 *             @f$\mathcal{RT}_k^{vol}\f$.
24 25
 * @details    This class is used to reconstruct fluxes from local operators
 *             that solve fluxes in the residual vector. In particular, this
26 27 28
 *             volume raviart thomas \f$\mathcal{RT}_k^{vol}\f$ is equivalent to 
 *             the usual raviart thomas element but excluding the degrees of
 *             freedom located on the faces (codim = 1).
29 30 31
 *
 * @author     Santiago Ospina De Los Ríos implemented it in DORiE out of source
 *             files sent by Marian Piatkowski.
32 33
 * @date       2018
 * @see        Dune::Dorie::RaviartThomasVolumeLocalFiniteElement.
34 35 36 37 38 39 40
 *
 * @tparam     DF    The domain field.
 * @tparam     RF    The range field.
 * @tparam     k     The order.
 * @tparam     d     The dimension.
 * @tparam     gt    The geometry type.
 */
41
template<class DF, class RF, int k, int d, Dune::GeometryType::BasicType gt>
42
class RaviartThomasVolumeLocalBasis
43
{
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
  //! Identify when there is no implementation of this class.
  static_assert(Dune::AlwaysFalse<DF>::value, 
    "Volume Raviart Thomas basis function is not implemented!");

#ifdef DOXYGEN /* Documentation of the code */

  //! Order of the polynomials.
  static constexpr int k;
  //! World dimension.
  static constexpr int dim;
  //! Number of shape functions
  static constexpr int volsize;

  /*-----------------------------------------------------------------------*//**
   * @brief      Traits of local basis. 
   * @details    It follows the traits structure for local basis defined by
   *             dune-localfunctions (Dune::LocalBasisTraits).
   */
  struct Traits {};

  /*-----------------------------------------------------------------------*//**
   * @brief      Number of shape functions (i.e. degrees of freedom).
   *
   * @return     The number of shape functions.
   */
  constexpr unsigned int size() const;

  /*-----------------------------------------------------------------------*//**
   * @brief      Evaluates the each local base function (in the vector out) in
   *             the position in.
   *
   * @param[in]  in    Position to evaluate the base function in local
   *                   coordinates.
   * @param      out   Vector of values. Each value represents one local base
   *                   function evaluated in the position in.
   */
  inline void evaluateFunction(const typename Traits::DomainType& in,
                               std::vector<typename Traits::RangeType>& out) const;

  /*-----------------------------------------------------------------------*//**
   * @brief      Evaluates the jacobian of each local base function (in the
   *             vector out) in the position in.
   *
   * @param[in]  in    Position to evaluate the base function in local
   *                   coordinates.
   * @param      out   Vector of jacobians. Each entry i in the vector
   *                   represents the jacobian of the local base function i
   *                   evaluated in the position in.
   */
  inline void
  evaluateJacobian(const typename Traits::DomainType& in,
                   std::vector<typename Traits::JacobianType>& out) const;

  /*-----------------------------------------------------------------------*//**
   * @brief      Evaluate partial derivatives of any order of all shape
   *             functions.
   *
   * @param[in]  order  Order of the partial derivatives, in the classic
   *                    multi-index notation.
   * @param[in]  in     Position to evaluate the base function in local
   *                    coordinates.
   * @param      out    The desired partial derivatives.
   */
  void partial(const std::array<unsigned int,dim>& order,
               const typename Traits::DomainType& in,
               std::vector<typename Traits::RangeType>& out) const;

/*-------------------------------------------------------------------------*//**
 * @brief Polynomial order of the shape functions for quadrature
 *
 * @return     The order.
 */
  constexpr unsigned int order() const;
#endif /* Documentation of the code */
118 119
};

120 121 122 123 124
#ifndef DOXYGEN /* Actual code */

// This classes only implement the parts needed for the flux reconstruction.
// Never use them to generate a grid function space in dune-pdelab!

125
template<class DF, class RF>
126
class RaviartThomasVolumeLocalBasis<DF,RF,0,2,Dune::GeometryType::simplex>
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
{
  static constexpr int k = 0;
  static constexpr int dim = 2;
  static constexpr int volsize = (dim == 2) ? dim*k*(k+1)/2 
                                            : dim*k*(k+1)*(k+2)/6;

public:

  using Traits = LocalBasisTraits<DF,dim,Dune::FieldVector<DF,dim>,
                                  RF,dim,Dune::FieldVector<RF,dim>,
                                  Dune::FieldMatrix<RF,dim,dim> >;

  constexpr unsigned int size() const
  {
    return volsize;
  }

  inline void evaluateFunction(const typename Traits::DomainType& in,
                               std::vector<typename Traits::RangeType>& out) const
  {}

  inline void
  evaluateJacobian(const typename Traits::DomainType& in,
                   std::vector<typename Traits::JacobianType>& out) const
  {}

  void partial(const std::array<unsigned int,dim>& order,
               const typename Traits::DomainType& in,
               std::vector<typename Traits::RangeType>& out) const
  {}

  constexpr unsigned int order() const
  {
    return k;
  }
};

template<class DF, class RF>
165
class RaviartThomasVolumeLocalBasis<DF,RF,0,3,Dune::GeometryType::simplex>
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
{
  static constexpr int k = 0;
  static constexpr int dim = 3;
  static constexpr int volsize = (dim == 2) ? dim*k*(k+1)/2 
                                            : dim*k*(k+1)*(k+2)/6;

public:

  using Traits = LocalBasisTraits<DF,dim,Dune::FieldVector<DF,dim>,
                                  RF,dim,Dune::FieldVector<RF,dim>,
                                  Dune::FieldMatrix<RF,dim,dim> >;


  constexpr unsigned int size() const
  {
    return volsize;
  }

  inline void evaluateFunction(const typename Traits::DomainType& in,
                               std::vector<typename Traits::RangeType>& out) const
  {}

  inline void
  evaluateJacobian(const typename Traits::DomainType& in,
                   std::vector<typename Traits::JacobianType>& out) const
  {}

  void partial(const std::array<unsigned int,dim>& order,
               const typename Traits::DomainType& in,
               std::vector<typename Traits::RangeType>& out) const
  {}

  constexpr unsigned int order() const
  {
    return k;
  }
};

template<class DF, class RF>
205
class RaviartThomasVolumeLocalBasis<DF,RF,1,2,Dune::GeometryType::simplex>
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
{
  static constexpr int k = 1;
  static constexpr int dim = 2;
  static constexpr int volsize = (dim == 2) ? dim*k*(k+1)/2 
                                            : dim*k*(k+1)*(k+2)/6;

public:

  using Traits = LocalBasisTraits<DF,dim,Dune::FieldVector<DF,dim>,
                                  RF,dim,Dune::FieldVector<RF,dim>,
                                  Dune::FieldMatrix<RF,dim,dim> >;

  constexpr unsigned int size() const
  {
    return volsize;
  }

  inline void evaluateFunction(const typename Traits::DomainType& in,
                               std::vector<typename Traits::RangeType>& out) const
  {
    out.resize(volsize);

    out[0][0] = 1.0; out[1][0] = 0.0;
    out[0][1] = 0.0; out[1][1] = 1.0;
  }

  inline void
  evaluateJacobian(const typename Traits::DomainType& in,
                   std::vector<typename Traits::JacobianType>& out) const
  {
    DUNE_THROW(Dune::NotImplemented,
237
      "evaluateJacobian for RaviartThomasVolumeLocalBasis not implemented!");
238 239 240 241 242 243 244
  }

  void partial(const std::array<unsigned int,dim>& order,
               const typename Traits::DomainType& in,
               std::vector<typename Traits::RangeType>& out) const
  {
    DUNE_THROW(Dune::NotImplemented,
245
      "partial for RaviartThomasVolumeLocalBasis not implemented!");
246 247 248 249 250 251 252 253 254
  }

  constexpr unsigned int order() const
  {
    return k;
  }
};

template<class DF, class RF>
255
class RaviartThomasVolumeLocalBasis<DF,RF,1,3,Dune::GeometryType::simplex>
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
{
  static constexpr int k = 1;
  static constexpr int dim = 3;
  static constexpr int volsize = (dim == 2) ? dim*k*(k+1)/2 
                                            : dim*k*(k+1)*(k+2)/6;

public:

  using Traits = LocalBasisTraits<DF,dim,Dune::FieldVector<DF,dim>,
                                  RF,dim,Dune::FieldVector<RF,dim>,
                                  Dune::FieldMatrix<RF,dim,dim> >;

  constexpr unsigned int size() const
  {
    return volsize;
  }

  inline void evaluateFunction(const typename Traits::DomainType& in,
                               std::vector<typename Traits::RangeType>& out) const
  {
    out.resize(volsize);

    out[0][0] = 1.0; out[1][0] = 0.0; out[2][0] = 0.0;
    out[0][1] = 0.0; out[1][1] = 1.0; out[2][1] = 0.0;
    out[0][2] = 0.0; out[1][2] = 0.0; out[2][2] = 1.0;
  }

  inline void
  evaluateJacobian(const typename Traits::DomainType& in,
                   std::vector<typename Traits::JacobianType>& out) const
  {
    DUNE_THROW(Dune::NotImplemented,
288
      "evaluateJacobian for RaviartThomasVolumeLocalBasis not implemented!");
289 290 291 292 293 294 295
  }

  void partial(const std::array<unsigned int,dim>& order,
               const typename Traits::DomainType& in,
               std::vector<typename Traits::RangeType>& out) const
  {
    DUNE_THROW(Dune::NotImplemented,
296
      "partial for RaviartThomasVolumeLocalBasis not implemented!");
297 298 299 300 301 302 303 304 305
  }

  constexpr unsigned int order() const
  {
    return k;
  }
};

template<class DF, class RF>
306
class RaviartThomasVolumeLocalBasis<DF,RF,2,2,Dune::GeometryType::simplex>
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340
{
  static constexpr int k = 2;
  static constexpr int dim = 2;
  static constexpr int volsize = (dim == 2) ? dim*k*(k+1)/2 
                                            : dim*k*(k+1)*(k+2)/6;

public:

  using Traits = LocalBasisTraits<DF,dim,Dune::FieldVector<DF,dim>,
                                  RF,dim,Dune::FieldVector<RF,dim>,
                                  Dune::FieldMatrix<RF,dim,dim> >;

  constexpr unsigned int size() const
  {
    return volsize;
  }

  inline void evaluateFunction(const typename Traits::DomainType& in,
                               std::vector<typename Traits::RangeType>& out) const
  {
    out.resize(volsize);

    out[0][0] = 1.0; out[1][0] = in[0]; out[2][0] = in[1];
    out[0][1] = 0.0; out[1][1] = 0.0;   out[2][1] = 0.0;

    out[3][0] = 0.0; out[4][0] = 0.0;   out[5][0] = 0.0;
    out[3][1] = 1.0; out[4][1] = in[0]; out[5][1] = in[1];
  }

  inline void
  evaluateJacobian(const typename Traits::DomainType& in,
                   std::vector<typename Traits::JacobianType>& out) const
  {
    DUNE_THROW(Dune::NotImplemented,
341
      "evaluateJacobian for RaviartThomasVolumeLocalBasis not implemented!");
342 343 344 345 346 347 348
  }

  void partial(const std::array<unsigned int,dim>& order,
               const typename Traits::DomainType& in,
               std::vector<typename Traits::RangeType>& out) const
  {
    DUNE_THROW(Dune::NotImplemented,
349
      "partial for RaviartThomasVolumeLocalBasis not implemented!");
350 351 352 353 354 355 356 357 358
  }

  constexpr unsigned int order() const
  {
    return k;
  }
};

template<class DF, class RF>
359
class RaviartThomasVolumeLocalBasis<DF,RF,2,3,Dune::GeometryType::simplex>
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399
{
  static constexpr int k = 2;
  static constexpr int dim = 3;
  static constexpr int volsize = (dim == 2) ? dim*k*(k+1)/2 
                                            : dim*k*(k+1)*(k+2)/6;

public:

  using Traits = LocalBasisTraits<DF,dim,Dune::FieldVector<DF,dim>,
                                  RF,dim,Dune::FieldVector<RF,dim>,
                                  Dune::FieldMatrix<RF,dim,dim> >;

  constexpr unsigned int size() const
  {
    return volsize;
  }

  inline void evaluateFunction(const typename Traits::DomainType& in,
                               std::vector<typename Traits::RangeType>& out) const
  {
    out.resize(volsize);

    out[0][0] = 1.0; out[1][0] = in[0]; out[2][0] = in[1]; out[3][0] = in[2];
    out[0][1] = 0.0; out[1][1] = 0.0;   out[2][1] = 0.0;   out[3][1] = 0.0;
    out[0][2] = 0.0; out[1][2] = 0.0;   out[2][2] = 0.0;   out[3][2] = 0.0;

    out[4][0] = 0.0; out[5][0] = 0.0;   out[6][0] = 0.0;   out[7][0] = 0.0;
    out[4][1] = 1.0; out[5][1] = in[0]; out[6][1] = in[1]; out[7][1] = in[2];
    out[4][2] = 0.0; out[5][2] = 0.0;   out[6][2] = 0.0;   out[7][2] = 0.0;

    out[8][0] = 0.0; out[9][0] = 0.0;   out[10][0] = 0.0;   out[11][0] = 0.0;
    out[8][1] = 0.0; out[9][1] = 0.0;   out[10][1] = 0.0;   out[11][1] = 0.0;
    out[8][2] = 1.0; out[9][2] = in[0]; out[10][2] = in[1]; out[11][2] = in[2];
  }

  inline void
  evaluateJacobian(const typename Traits::DomainType& in,
                   std::vector<typename Traits::JacobianType>& out) const
  {
    DUNE_THROW(Dune::NotImplemented,
400
      "evaluateJacobian for RaviartThomasVolumeLocalBasis not implemented!");
401 402 403 404 405 406 407
  }

  void partial(const std::array<unsigned int,dim>& order,
               const typename Traits::DomainType& in,
               std::vector<typename Traits::RangeType>& out) const
  {
    DUNE_THROW(Dune::NotImplemented,
408
      "partial for RaviartThomasVolumeLocalBasis not implemented!");
409 410 411 412 413 414 415 416 417 418 419
  }

  constexpr unsigned int order() const
  {
    return k;
  }
};

//********************** now cubes **********************//

template<class DF, class RF>
420
class RaviartThomasVolumeLocalBasis<DF,RF,0,2,Dune::GeometryType::cube>
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457
{
  static constexpr int k = 0;
  static constexpr int dim = 2;
  static constexpr int volsize = dim*Dune::StaticPower<k+1,dim-1>::power*k;

public:

  using Traits = LocalBasisTraits<DF,dim,Dune::FieldVector<DF,dim>,
                                  RF,dim,Dune::FieldVector<RF,dim>,
                                  Dune::FieldMatrix<RF,dim,dim> >;

  constexpr unsigned int size() const
  {
    return volsize;
  }

  inline void evaluateFunction(const typename Traits::DomainType& in,
                               std::vector<typename Traits::RangeType>& out) const
  {}

  inline void
  evaluateJacobian(const typename Traits::DomainType& in,
                   std::vector<typename Traits::JacobianType>& out) const
  {}

  void partial(const std::array<unsigned int,dim>& order,
               const typename Traits::DomainType& in,
               std::vector<typename Traits::RangeType>& out) const
  {}

  constexpr unsigned int order() const
  {
    return k;
  }
};

template<class DF, class RF>
458
class RaviartThomasVolumeLocalBasis<DF,RF,0,3,Dune::GeometryType::cube>
459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495
{
  static constexpr int k = 0;
  static constexpr int dim = 3;
  static constexpr int volsize = dim*Dune::StaticPower<k+1,dim-1>::power*k;

public:

  using Traits = LocalBasisTraits<DF,dim,Dune::FieldVector<DF,dim>,
                                  RF,dim,Dune::FieldVector<RF,dim>,
                                  Dune::FieldMatrix<RF,dim,dim> >;

  constexpr unsigned int size() const
  {
    return volsize;
  }

  inline void evaluateFunction(const typename Traits::DomainType& in,
                               std::vector<typename Traits::RangeType>& out) const
  {}

  inline void
  evaluateJacobian(const typename Traits::DomainType& in,
                   std::vector<typename Traits::JacobianType>& out) const
  {}

  void partial(const std::array<unsigned int,dim>& order,
               const typename Traits::DomainType& in,
               std::vector<typename Traits::RangeType>& out) const
  {}

  constexpr unsigned int order() const
  {
    return k;
  }
};

template<class DF, class RF>
496
class RaviartThomasVolumeLocalBasis<DF,RF,1,2,Dune::GeometryType::cube>
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526
{
  static constexpr int k = 1;
  static constexpr int dim = 2;
  static constexpr int volsize = dim*Dune::StaticPower<k+1,dim-1>::power*k;

public:

  using Traits = LocalBasisTraits<DF,dim,Dune::FieldVector<DF,dim>,
                                  RF,dim,Dune::FieldVector<RF,dim>,
                                  Dune::FieldMatrix<RF,dim,dim> >;

  constexpr unsigned int size() const
  {
    return volsize;
  }

  inline void evaluateFunction(const typename Traits::DomainType& in,
                               std::vector<typename Traits::RangeType>& out) const
  {
    out.resize(volsize);

    out[0][0] = 1.0; out[1][0] = in[1]; out[2][0] = 0.0; out[3][0] = 0.0;
    out[0][1] = 0.0; out[1][1] = 0.0;   out[2][1] = 1.0; out[3][1] = in[0];
  }

  inline void
  evaluateJacobian(const typename Traits::DomainType& in,
                   std::vector<typename Traits::JacobianType>& out) const
  {
    DUNE_THROW(Dune::NotImplemented,
527
      "evaluateJacobian for RaviartThomasVolumeLocalBasis not implemented!");
528 529 530 531 532 533 534
  }

  void partial(const std::array<unsigned int,dim>& order,
               const typename Traits::DomainType& in,
               std::vector<typename Traits::RangeType>& out) const
  {
    DUNE_THROW(Dune::NotImplemented,
535
      "partial for RaviartThomasVolumeLocalBasis not implemented!");
536 537 538 539 540 541 542 543 544
  }

  constexpr unsigned int order() const
  {
    return k;
  }
};

template<class DF, class RF>
545
class RaviartThomasVolumeLocalBasis<DF,RF,1,3,Dune::GeometryType::cube>
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587
{
  static constexpr int k = 1;
  static constexpr int dim = 3;
  static constexpr int volsize = dim*Dune::StaticPower<k+1,dim-1>::power*k;

public:

  using Traits = LocalBasisTraits<DF,dim,Dune::FieldVector<DF,dim>,
                                  RF,dim,Dune::FieldVector<RF,dim>,
                                  Dune::FieldMatrix<RF,dim,dim> >;

  constexpr unsigned int size() const
  {
    return volsize;
  }

  inline void evaluateFunction(const typename Traits::DomainType& in,
                               std::vector<typename Traits::RangeType>& out) const
  {
    out.resize(volsize);

    out[0] = {1.0,         0.0, 0.0};
    out[1] = {in[1],       0.0, 0.0};
    out[2] = {in[2],       0.0, 0.0};
    out[3] = {in[1]*in[2], 0.0, 0.0};

    out[4] = {0.0, 1.0,         0.0};
    out[5] = {0.0, in[0],       0.0};
    out[6] = {0.0, in[2],       0.0};
    out[7] = {0.0, in[0]*in[2], 0.0};

    out[8] =  {0.0, 0.0, 1.0        };
    out[9] =  {0.0, 0.0, in[0]      };
    out[10] = {0.0, 0.0, in[1]      };
    out[11] = {0.0, 0.0, in[0]*in[1]};
  }

  inline void
  evaluateJacobian(const typename Traits::DomainType& in,
                   std::vector<typename Traits::JacobianType>& out) const
  {
    DUNE_THROW(Dune::NotImplemented,
588
      "evaluateJacobian for RaviartThomasVolumeLocalBasis not implemented!");
589 590 591 592 593 594 595
  }

  void partial(const std::array<unsigned int,dim>& order,
               const typename Traits::DomainType& in,
               std::vector<typename Traits::RangeType>& out) const
  {
    DUNE_THROW(Dune::NotImplemented,
596
      "partial for RaviartThomasVolumeLocalBasis not implemented!");
597 598 599 600 601 602 603 604 605
  }

  constexpr unsigned int order() const
  {
    return k;
  }
};

template<class DF, class RF>
606
class RaviartThomasVolumeLocalBasis<DF,RF,2,2,Dune::GeometryType::cube>
607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645
{
  static constexpr int k = 2;
  static constexpr int dim = 2;
  static constexpr int volsize = dim*Dune::StaticPower<k+1,dim-1>::power*k;

public:

  using Traits = LocalBasisTraits<DF,dim,Dune::FieldVector<DF,dim>,
                                  RF,dim,Dune::FieldVector<RF,dim>,
                                  Dune::FieldMatrix<RF,dim,dim> >;

  constexpr unsigned int size() const
  {
    return volsize;
  }

  inline void evaluateFunction(const typename Traits::DomainType& in,
                               std::vector<typename Traits::RangeType>& out) const
  {
    out.resize(volsize);

    out[0][0] = 1.0; out[1][0] = in[1]; out[2][0] = in[1]*in[1];
    out[0][1] = 0.0; out[1][1] = 0.0;   out[2][1] = 0.0;

    out[3][0] = 0.0; out[4][0] = 0.0;   out[5][0] = 0.0;
    out[3][1] = 1.0; out[4][1] = in[0]; out[5][1] = in[0]*in[0];

    out[6][0] = in[0]; out[7][0] = in[0]*in[1]; out[8][0] = in[0]*in[1]*in[1];
    out[6][1] = 0.0;   out[7][1] = 0.0;         out[8][1] = 0.0;

    out[9][0] = 0.0;   out[10][0] = 0.0;         out[11][0] = 0.0;
    out[9][1] = in[1]; out[10][1] = in[1]*in[0]; out[11][1] = in[1]*in[0]*in[0];
  }

  inline void
  evaluateJacobian(const typename Traits::DomainType& in,
                   std::vector<typename Traits::JacobianType>& out) const
  {
    DUNE_THROW(Dune::NotImplemented,
646
      "evaluateJacobian for RaviartThomasVolumeLocalBasis not implemented!");
647 648 649 650 651 652 653
  }

  void partial(const std::array<unsigned int,dim>& order,
               const typename Traits::DomainType& in,
               std::vector<typename Traits::RangeType>& out) const
  {
    DUNE_THROW(Dune::NotImplemented,
654
      "partial for RaviartThomasVolumeLocalBasis not implemented!");
655 656 657 658 659 660 661 662 663
  }

  constexpr unsigned int order() const
  {
    return k;
  }
};

template<class DF, class RF>
664
class RaviartThomasVolumeLocalBasis<DF,RF,2,3,Dune::GeometryType::cube>
665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688
{
  static constexpr int k = 2;
  static constexpr int dim = 3;
  static constexpr int volsize = dim*Dune::StaticPower<k+1,dim-1>::power*k;

public:

  using Traits = LocalBasisTraits<DF,dim,Dune::FieldVector<DF,dim>,
                                  RF,dim,Dune::FieldVector<RF,dim>,
                                  Dune::FieldMatrix<RF,dim,dim> >;

  constexpr unsigned int size() const
  {
    return volsize;
  }

  inline void evaluateFunction(const typename Traits::DomainType& in,
                               std::vector<typename Traits::RangeType>& out) const
  {
    out.resize(volsize);

    // x-direction fastest, y-direction middle, z-direction slowest
    std::size_t global_iter = 0.0;

689 690 691
    for(std::size_t i2=0; i2<k+1; ++i2)
      for(std::size_t i1=0; i1<k+1; ++i1)
        for(std::size_t i0=0; i0<k; ++i0) // reduced
692 693 694 695 696
        {
          out[global_iter] = {poly_km1.p(i0,in[0])*poly_k.p(i1,in[1])*poly_k.p(i2,in[2]), 0.0, 0.0};
          global_iter++;
        }

697 698 699
    for(std::size_t i2=0; i2<k+1; ++i2)
      for(std::size_t i1=0; i1<k; ++i1) // reduced
        for(std::size_t i0=0; i0<k+1; ++i0)
700 701 702 703 704
        {
          out[global_iter] = {0.0, poly_k.p(i0,in[0])*poly_km1.p(i1,in[1])*poly_k.p(i2,in[2]), 0.0};
          global_iter++;
        }

705 706 707
    for(std::size_t i2=0; i2<k; ++i2) // reduced
      for(std::size_t i1=0; i1<k+1; ++i1)
        for(std::size_t i0=0; i0<k+1; ++i0)
708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809
        {
          out[global_iter] = {0.0, 0.0, poly_k.p(i0,in[0])*poly_k.p(i1,in[1])*poly_km1.p(i2,in[2])};
          global_iter++;
        }

#if 0
    // x-direction fastest, y-direction middle, z-direction slowest
    out[0] =  {1.0,            0.0, 0.0};
    out[1] =  {in[0],           0.0, 0.0};
    out[2] =  {in[1],           0.0, 0.0};
    out[3] =  {in[0]*in[1],      0.0, 0.0};
    out[4] =  {in[1]*in[1],      0.0, 0.0};
    out[5] =  {in[0]*in[1]*in[1], 0.0, 0.0};
    //--------------------------------------------
    out[6] =  {in[2],                0.0, 0.0};
    out[7] =  {in[0]*in[2],           0.0, 0.0};
    out[8] =  {in[1]*in[2],           0.0, 0.0};
    out[9] =  {in[0]*in[1]*in[2],      0.0, 0.0};
    out[10] = {in[1]*in[1]*in[2],      0.0, 0.0};
    out[11] = {in[0]*in[1]*in[1]*in[2], 0.0, 0.0};
    //--------------------------------------------
    out[12] = {in[2]*in[2],                0.0, 0.0};
    out[13] = {in[0]*in[2]*in[2],           0.0, 0.0};
    out[14] = {in[1]*in[2]*in[2],           0.0, 0.0};
    out[15] = {in[0]*in[1]*in[2]*in[2],      0.0, 0.0};
    out[16] = {in[1]*in[1]*in[2]*in[2],      0.0, 0.0};
    out[17] = {in[0]*in[1]*in[1]*in[2]*in[2], 0.0, 0.0};

    out[18] = {0.0, 1.0,            0.0};
    out[19] = {0.0, in[0],           0.0};
    out[20] = {0.0, in[0]*in[0],      0.0};
    out[21] = {0.0, in[1],           0.0};
    out[22] = {0.0, in[0]*in[1],      0.0};
    out[23] = {0.0, in[0]*in[0]*in[1], 0.0};
    //--------------------------------------------
    out[24] = {0.0, in[2],                0.0};
    out[25] = {0.0, in[0]*in[2],           0.0};
    out[26] = {0.0, in[0]*in[0]*in[2],      0.0};
    out[27] = {0.0, in[1]*in[2],           0.0};
    out[28] = {0.0, in[0]*in[1]*in[2],      0.0};
    out[29] = {0.0, in[0]*in[0]*in[1]*in[2], 0.0};
    //--------------------------------------------
    out[30] = {0.0, in[2]*in[2],                0.0};
    out[31] = {0.0, in[0]*in[2]*in[2],           0.0};
    out[32] = {0.0, in[0]*in[0]*in[2]*in[2],      0.0};
    out[33] = {0.0, in[1]*in[2]*in[2],           0.0};
    out[34] = {0.0, in[0]*in[1]*in[2]*in[2],      0.0};
    out[35] = {0.0, in[0]*in[0]*in[1]*in[2]*in[2], 0.0};

    out[36] = {0.0, 0.0, 1.0};
    out[37] = {0.0, 0.0, in[0]};
    out[38] = {0.0, 0.0, in[0]*in[0]};
    out[39] = {0.0, 0.0, in[1]};
    out[40] = {0.0, 0.0, in[0]*in[1]};
    out[41] = {0.0, 0.0, in[0]*in[0]*in[1]};
    out[42] = {0.0, 0.0, in[1]*in[1]};
    out[43] = {0.0, 0.0, in[0]*in[1]*in[1]};
    out[44] = {0.0, 0.0, in[0]*in[0]*in[1]*in[1]};
    //--------------------------------------------
    out[45] = {0.0, 0.0, in[2]};
    out[46] = {0.0, 0.0, in[0]*in[2]};
    out[47] = {0.0, 0.0, in[0]*in[0]*in[2]};
    out[48] = {0.0, 0.0, in[1]*in[2]};
    out[49] = {0.0, 0.0, in[0]*in[1]*in[2]};
    out[50] = {0.0, 0.0, in[0]*in[0]*in[1]*in[2]};
    out[51] = {0.0, 0.0, in[1]*in[1]*in[2]};
    out[52] = {0.0, 0.0, in[0]*in[1]*in[1]*in[2]};
    out[53] = {0.0, 0.0, in[0]*in[0]*in[1]*in[1]*in[2]};
#endif

#if 0
    out[0][0] = 1.0; out[1][0] = in[1]; out[2][0] = in[1]*in[1]; out[3][0] = in[2]; out[4][0] = in[2]*in[2]; out[5][0] = in[1]*in[2]; out[6][0] = in[1]*in[2]*in[2]; out[7][0] = in[1]*in[1]*in[2]; out[8][0] = in[1]*in[1]*in[2]*in[2];
    out[0][1] = 0.0; out[1][1] = 0.0;  out[2][1] = 0.0;       out[3][1] = 0.0;  out[4][1] = 0.0;       out[5][1] = 0.0;       out[6][1] = 0.0;            out[7][1] = 0.0;            out[8][1] = 0.0;
    out[0][2] = 0.0; out[1][2] = 0.0;  out[2][2] = 0.0;       out[3][2] = 0.0;  out[4][2] = 0.0;       out[5][2] = 0.0;       out[6][2] = 0.0;            out[7][2] = 0.0;            out[8][2] = 0.0;

    out[9][0] = 0.0; out[10][0] = 0.0;  out[11][0] = 0.0;       out[12][0] = 0.0;  out[13][0] = 0.0;       out[14][0] = 0.0;       out[15][0] = 0.0;            out[16][0] = 0.0;            out[17][0] = 0.0;
    out[9][1] = 1.0; out[10][1] = in[0]; out[11][1] = in[0]*in[0]; out[12][1] = in[2]; out[13][1] = in[2]*in[2]; out[14][1] = in[0]*in[2]; out[15][1] = in[0]*in[2]*in[2]; out[16][1] = in[0]*in[0]*in[2]; out[17][1] = in[0]*in[0]*in[2]*in[2];
    out[9][2] = 0.0; out[10][2] = 0.0;  out[11][2] = 0.0;       out[12][2] = 0.0;  out[13][2] = 0.0;       out[14][2] = 0.0;       out[15][2] = 0.0;            out[16][2] = 0.0;            out[17][2] = 0.0;

    out[18][0] = 0.0; out[19][0] = 0.0;  out[20][0] = 0.0;       out[21][0] = 0.0;  out[22][0] = 0.0;       out[23][0] = 0.0;       out[24][0] = 0.0;            out[25][0] = 0.0;            out[26][0] = 0.0;
    out[18][1] = 0.0; out[19][1] = 0.0;  out[20][1] = 0.0;       out[21][1] = 0.0;  out[22][1] = 0.0;       out[23][1] = 0.0;       out[24][1] = 0.0;            out[25][1] = 0.0;            out[26][1] = 0.0;
    out[18][2] = 1.0; out[19][2] = in[0]; out[20][2] = in[0]*in[0]; out[21][2] = in[1]; out[22][2] = in[1]*in[1]; out[23][2] = in[0]*in[1]; out[24][2] = in[0]*in[1]*in[1]; out[25][2] = in[0]*in[0]*in[1]; out[26][2] = in[0]*in[0]*in[1]*in[1];

    out[27][0] = in[0]; out[28][0] = in[0]*in[1]; out[29][0] = in[0]*in[1]*in[1]; out[30][0] = in[0]*in[2]; out[31][0] = in[0]*in[2]*in[2]; out[32][0] = in[0]*in[1]*in[2]; out[33][0] = in[0]*in[1]*in[2]*in[2]; out[34][0] = in[0]*in[1]*in[1]*in[2]; out[35][0] = in[0]*in[1]*in[1]*in[2]*in[2];
    out[27][1] = 0.0;  out[28][1] = 0.0;       out[29][1] = 0.0;            out[30][1] = 0.0;       out[31][1] = 0.0;            out[32][1] = 0.0;            out[33][1] = 0.0;                 out[34][1] = 0.0;                 out[35][1] = 0.0;
    out[27][2] = 0.0;  out[28][2] = 0.0;       out[29][2] = 0.0;            out[30][2] = 0.0;       out[31][2] = 0.0;            out[32][2] = 0.0;            out[33][2] = 0.0;                 out[34][2] = 0.0;                 out[35][2] = 0.0;

    out[36][0] = 0.0;  out[37][0] = 0.0;       out[38][0] = 0.0;            out[39][0] = 0.0;       out[40][0] = 0.0;            out[41][0] = 0.0;            out[42][0] = 0.0;                 out[43][0] = 0.0;                 out[44][0] = 0.0;
    out[36][1] = in[1]; out[37][1] = in[1]*in[0]; out[38][1] = in[1]*in[0]*in[0]; out[39][1] = in[1]*in[2]; out[40][1] = in[1]*in[2]*in[2]; out[41][1] = in[1]*in[0]*in[2]; out[42][1] = in[1]*in[0]*in[2]*in[2]; out[43][1] = in[1]*in[0]*in[0]*in[2]; out[44][1] = in[1]*in[0]*in[0]*in[2]*in[2];
    out[36][2] = 0.0;  out[37][2] = 0.0;       out[38][2] = 0.0;            out[39][2] = 0.0;       out[40][2] = 0.0;            out[41][2] = 0.0;            out[42][2] = 0.0;                 out[43][2] = 0.0;                 out[44][2] = 0.0;

    out[45][0] = 0.0;  out[46][0] = 0.0;       out[47][0] = 0.0;            out[48][0] = 0.0;       out[49][0] = 0.0;            out[50][0] = 0.0;            out[51][0] = 0.0;                 out[52][0] = 0.0;                 out[53][0] = 0.0;
    out[45][1] = 0.0;  out[46][1] = 0.0;       out[47][1] = 0.0;            out[48][1] = 0.0;       out[49][1] = 0.0;            out[50][1] = 0.0;            out[51][1] = 0.0;                 out[52][1] = 0.0;                 out[53][1] = 0.0;
    out[45][2] = in[2]; out[46][2] = in[2]*in[0]; out[47][2] = in[2]*in[0]*in[0]; out[48][2] = in[2]*in[1]; out[49][2] = in[2]*in[1]*in[1]; out[50][2] = in[2]*in[0]*in[1]; out[51][2] = in[2]*in[0]*in[1]*in[1]; out[52][2] = in[2]*in[0]*in[0]*in[1]; out[53][2] = in[2]*in[0]*in[0]*in[1]*in[1];
#endif
  }

  inline void
  evaluateJacobian(const typename Traits::DomainType& in,
                   std::vector<typename Traits::JacobianType>& out) const
  {
    DUNE_THROW(Dune::NotImplemented,
810
      "evaluateJacobian for RaviartThomasVolumeLocalBasis not implemented!");
811 812
  }

813
  void partial(const std::array<unsigned int,dim>& order_,
814 815 816 817
               const typename Traits::DomainType& in,
               std::vector<typename Traits::RangeType>& out) const
  {
    DUNE_THROW(Dune::NotImplemented,
818
      "partial for RaviartThomasVolumeLocalBasis not implemented!");
819 820 821 822 823 824 825
  }

  constexpr unsigned int order() const
  {
    return k;
  }
private:
826 827
  Dune::QkStuff::GaussLobattoLagrangePolynomials<DF,RF,k>   poly_k;
  Dune::QkStuff::GaussLobattoLagrangePolynomials<DF,RF,k-1> poly_km1;
828 829
};

830 831
#endif /* Actual code */

832 833 834
} // namespace Dorie
} // namespace Dune

835
#endif // DUNE_DORIE_RAVIART_THOMAS_VOLUME_BASIS_HH