Dune Core Modules (2.6.0)

pk3dlocalcoefficients.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_PK3DLOCALCOEFFICIENTS_HH
4#define DUNE_PK3DLOCALCOEFFICIENTS_HH
5
6#include <cstddef>
7#include <iostream>
8#include <vector>
9
10#include <dune/localfunctions/common/localkey.hh>
11
12namespace Dune
13{
14
21 template<unsigned int k>
23 {
24 enum {N = (k+1)*(k+2)*(k+3)/6};
25
26 public:
29 {
30 const unsigned int vertexmap[4] = {0, 1, 2, 3};
31 generate_local_keys(vertexmap);
32 }
33
40 Pk3DLocalCoefficients (const unsigned int vertexmap[4]) : li(N)
41 {
42 generate_local_keys(vertexmap);
43 }
44
46 std::size_t size () const
47 {
48 return N;
49 }
50
52 const LocalKey& localKey (std::size_t i) const
53 {
54 return li[i];
55 }
56
57 private:
58 std::vector<LocalKey> li;
59
60 void generate_local_keys(const unsigned int vertexmap[4])
61 {
62 if (k==0)
63 {
64 li[0] = LocalKey(0,0,0);
65 return;
66 }
67 unsigned int subindex[16];
68 unsigned int codim_count[4] = {0};
69 for (unsigned int m = 1; m < 16; ++m)
70 {
71 unsigned int codim = !(m&1) + !(m&2) + !(m&4) + !(m&8);
72 subindex[m] = codim_count[codim]++;
73 }
74
75 int a1 = (3*k + 12)*k + 11;
76 int a2 = -3*k - 6;
77 unsigned int dof_count[16] = {0};
78 unsigned int i[4];
79 for (i[3] = 0; i[3] <= k; ++i[3])
80 for (i[2] = 0; i[2] <= k - i[3]; ++i[2])
81 for (i[1] = 0; i[1] <= k - i[2] - i[3]; ++i[1])
82 {
83 i[0] = k - i[1] - i[2] - i[3];
84 unsigned int j[4];
85 unsigned int entity = 0;
86 unsigned int codim = 0;
87 for (unsigned int m = 0; m < 4; ++m)
88 {
89 j[m] = i[vertexmap[m]];
90 entity += !!j[m] << m;
91 codim += !j[m];
92 }
93 int local_index = j[3]*(a1 + (a2 + j[3])*j[3])/6
94 + j[2]*(2*(k - j[3]) + 3 - j[2])/2 + j[1];
95 li[local_index] = LocalKey(subindex[entity], codim, dof_count[entity]++);
96 }
97 }
98 };
99
100}
101
102#endif
Describe position of one degree of freedom.
Definition: localkey.hh:21
Please doc me!
Definition: pk3dlocalcoefficients.hh:23
std::size_t size() const
number of coefficients
Definition: pk3dlocalcoefficients.hh:46
Pk3DLocalCoefficients()
Standard constructor.
Definition: pk3dlocalcoefficients.hh:28
Pk3DLocalCoefficients(const unsigned int vertexmap[4])
Definition: pk3dlocalcoefficients.hh:40
const LocalKey & localKey(std::size_t i) const
get i'th index
Definition: pk3dlocalcoefficients.hh:52
Dune namespace.
Definition: alignedallocator.hh:10
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 24, 23:30, 2024)