3 #ifndef DUNE_REFINED_SIMPLEX_LOCALBASIS_HH
4 #define DUNE_REFINED_SIMPLEX_LOCALBASIS_HH
10 #include <dune/common/fvector.hh>
11 #include <dune/common/exceptions.hh>
16 template<
class D,
int dim>
22 DUNE_THROW(Dune::NotImplemented,
"RefinedSimplexLocalBasis not implemented for dim > 3.");
51 static int getSubElement(
const FieldVector<D,2>& global)
55 else if (global[0] <= 1.0)
58 DUNE_THROW(InvalidStateException,
"no subelement defined");
67 static void getSubElement(
const FieldVector<D,1>& global,
69 FieldVector<D,1>& local)
71 if (global[0] <= 0.5) {
73 local[0] = 2.0 * global[0];
78 local[0] = 2.0 * global[0] - 1.0;
116 static int getSubElement(
const FieldVector<D,2>& global)
118 if (global[0] + global[1] <= 0.5)
120 else if (global[0] >= 0.5)
122 else if (global[1] >= 0.5)
134 static void getSubElement(
const FieldVector<D,2>& global,
136 FieldVector<D,2>& local)
138 if (global[0] + global[1] <= 0.5) {
140 local[0] = 2*global[0];
141 local[1] = 2*global[1];
143 }
else if (global[0] >= 0.5) {
145 local[0] = 2*global[0]-1;
146 local[1] = 2*global[1];
148 }
else if (global[1] >= 0.5) {
150 local[0] = 2*global[0];
151 local[1] = 2*global[1]-1;
156 local[0] = -2 * global[0] + 1;
157 local[1] = -2 * global[1] + 1;
212 static int getSubElement(
const FieldVector<D,3>& global)
214 if (global[0] + global[1] + global[2] <= 0.5)
216 else if (global[0] >= 0.5)
218 else if (global[1] >= 0.5)
220 else if (global[2] >= 0.5)
222 else if ((global[0] + global[1] <= 0.5) and (global[1] + global[2] <= 0.5))
224 else if ((global[0] + global[1] >= 0.5) and (global[1] + global[2] <= 0.5))
226 else if ((global[0] + global[1] <= 0.5) and (global[1] + global[2] >= 0.5))
228 else if ((global[0] + global[1] >= 0.5) and (global[1] + global[2] >= 0.5))
231 DUNE_THROW(InvalidStateException,
"no subelement defined");
240 static void getSubElement(
const FieldVector<D,3>& global,
242 FieldVector<D,3>& local)
244 if (global[0] + global[1] + global[2] <= 0.5) {
249 }
else if (global[0] >= 0.5) {
255 }
else if (global[1] >= 0.5) {
261 }
else if (global[2] >= 0.5) {
267 }
else if ((global[0] + global[1] <= 0.5) and (global[1] + global[2] <= 0.5)) {
269 local[0] = 2.0 * global[1];
270 local[1] = 2.0 * (0.5 - global[0] - global[1]);
271 local[2] = 2.0 * (-0.5 + global[0] + global[1] + global[2]);
283 }
else if ((global[0] + global[1] >= 0.5) and (global[1] + global[2] <= 0.5)) {
285 local[0] = 2.0 * (0.5 - global[0]);
286 local[1] = 2.0 * (0.5 - global[1] - global[2]);
287 local[2] = 2.0 * global[2];
297 }
else if ((global[0] + global[1] <= 0.5) and (global[1] + global[2] >= 0.5)) {
299 local[0] = 2.0 * (0.5 - global[0] - global[1]);
300 local[1] = 2.0 * global[0];
301 local[2] = 2.0 * (-0.5 + global[1] + global[2]);
312 }
else if ((global[0] + global[1] >= 0.5) and (global[1] + global[2] >= 0.5)) {
314 local[0] = 2.0 * (-0.5 + global[1] + global[2]);
315 local[1] = 2.0 * (0.5 - global[1]);
316 local[2] = 2.0 * (-0.5 + global[0] + global[1]);
330 DUNE_THROW(InvalidStateException,
"no subelement defined");