Dune Core Modules (2.6.0)

pk2dlocalcoefficients.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3
4#ifndef DUNE_PK2DLOCALCOEFFICIENTS_HH
5#define DUNE_PK2DLOCALCOEFFICIENTS_HH
6
7#include <cstddef>
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)/2};
25
26 public:
29 {
30 fill_default();
31 }
32
34 Pk2DLocalCoefficients (int variant) : li(N)
35 {
36 fill_default();
37 bool flip[3];
38 for (int i = 0; i < 3; ++i)
39 flip[i] = variant & (1<<i);
40 for (int i=0; i<N; i++)
41 if (li[i].codim()==1 && flip[li[i].subEntity()])
42 li[i].index(k-2-li[i].index());
43 }
44
54 template<class VertexMap>
55 explicit Pk2DLocalCoefficients(const VertexMap &vertexmap) : li(N)
56 {
57 fill_default();
58 bool flip[3];
59 flip[0] = vertexmap[0] > vertexmap[1];
60 flip[1] = vertexmap[0] > vertexmap[2];
61 flip[2] = vertexmap[1] > vertexmap[2];
62 for (std::size_t i=0; i<N; i++)
63 if (li[i].codim()==1 && flip[li[i].subEntity()])
64 li[i].index(k-2-li[i].index());
65 }
66
68 std::size_t size () const
69 {
70 return N;
71 }
72
74 const LocalKey& localKey (std::size_t i) const
75 {
76 return li[i];
77 }
78
79 private:
80 std::vector<LocalKey> li;
81
82 void fill_default ()
83 {
84 if (k==0)
85 {
86 li[0] = LocalKey(0,0,0);
87 return;
88 }
89 int n=0;
90 int c=0;
91 for (unsigned int j=0; j<=k; j++)
92 for (unsigned int i=0; i<=k-j; i++)
93 {
94 if (i==0 && j==0)
95 {
96 li[n++] = LocalKey(0,2,0);
97 continue;
98 }
99 if (i==k && j==0)
100 {
101 li[n++] = LocalKey(1,2,0);
102 continue;
103 }
104 if (i==0 && j==k)
105 {
106 li[n++] = LocalKey(2,2,0);
107 continue;
108 }
109 if (j==0)
110 {
111 li[n++] = LocalKey(0,1,i-1);
112 continue;
113 }
114 if (i==0)
115 {
116 li[n++] = LocalKey(1,1,j-1);
117 continue;
118 }
119 if (i+j==k)
120 {
121 li[n++] = LocalKey(2,1,j-1);
122 continue;
123 }
124 li[n++] = LocalKey(0,0,c++);
125 }
126 }
127 };
128
129}
130
131#endif
Describe position of one degree of freedom.
Definition: localkey.hh:21
Layout map for P0 elements.
Definition: pk2dlocalcoefficients.hh:23
Pk2DLocalCoefficients()
Standard constructor.
Definition: pk2dlocalcoefficients.hh:28
std::size_t size() const
number of coefficients
Definition: pk2dlocalcoefficients.hh:68
const LocalKey & localKey(std::size_t i) const
get i'th index
Definition: pk2dlocalcoefficients.hh:74
Pk2DLocalCoefficients(const VertexMap &vertexmap)
Definition: pk2dlocalcoefficients.hh:55
Pk2DLocalCoefficients(int variant)
constructor for eight variants with order on edges flipped
Definition: pk2dlocalcoefficients.hh:34
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)