33 #ifndef __H__UG__LIB_DISC__LOCAL_SHAPE_FUNCTION_SET__MINI__MINI_BUBBLE__
34 #define __H__UG__LIB_DISC__LOCAL_SHAPE_FUNCTION_SET__MINI__MINI_BUBBLE__
36 #include "../common/lagrange1d.h"
37 #include "../local_finite_element_provider.h"
38 #include "../local_dof_set.h"
50 template <
typename TRefElem>
55 template <
typename TRefElem>
73 nsh = rRefElem.num(0)+1;
76 for(
size_t i = 0; i<
nsh-1; ++i)
86 for(
size_t i = 0; i<
nsh-1; ++i)
103 if (d ==
refDim)
return 1;
134 public BaseLSFS<MiniBubbleLSFS<ReferenceEdge>, 1>
138 static const size_t order = 1;
144 static const size_t nsh = 3;
164 inline size_t num_sh()
const {
return nsh;}
171 case 0: pos[0] = 0;
return true;
172 case 1: pos[0] = 1;
return true;
173 case 2: pos[0] = 0.5;
return true;
174 default:
UG_THROW(
"MiniBubbleLSFS: shape function "<<i<<
175 " not found. Only "<<nsh<<
" shapes present.");
186 case 0:
return 1-x[0];
188 case 2:
return 2.0*x[0]*(1-x[0]);
189 default:
UG_THROW(
"MiniBubbleLSFS: shape function "<<i<<
190 " not found. Only "<<nsh<<
" shapes present.");
203 case 2: g[0] = 2.0-4.0*x[0];
204 default:
UG_THROW(
"MiniBubbleLSFS: shape function "<<i<<
205 " not found. Only "<<nsh<<
" shapes present.");
220 public BaseLSFS<MiniBubbleLSFS<ReferenceTriangle>, 2>
224 static const size_t order = 2;
230 static const size_t nsh = 4;
249 inline size_t num_sh()
const {
return nsh;}
256 case 0: pos[0] = 0.0;
257 pos[1] = 0.0;
return true;
258 case 1: pos[0] = 0.1;
259 pos[1] = 0.0;
return true;
260 case 2: pos[0] = 0.0;
261 pos[1] = 0.1;
return true;
262 case 3: pos[0] = 1.0/3.0;
263 pos[1] = 1.0/3.0;
return true;
264 default:
UG_THROW(
"MiniLSFS: shape function "<<i<<
265 " not found. Only "<<nsh<<
" shapes present.");
276 case 0:
return (1.0-x[0]-x[1]);
279 case 3:
return 27.0*x[0]*x[1]*(1.0-x[0]-x[1]);
280 default:
UG_THROW(
"MiniLSFS: shape function "<<i<<
281 " not found. Only "<<nsh<<
" shapes present.");
298 case 3: g[0] = 27*x[1]*(1.0-x[1]-2.0*x[0]);
299 g[1] = 27*x[0]*(1.0-x[0]-2.0*x[1]);
300 std::cout <<
"MiniGrad: " << g[0] <<
","<< g[1] <<
"at"<< x[0]<<
","<< x[1]<< std::endl;
302 default:
UG_THROW(
"MiniLSFS: shape function "<<i<<
303 " not found. Only "<<nsh<<
" shapes present.");
319 public BaseLSFS<MiniBubbleLSFS<ReferenceQuadrilateral>, 2>
327 static const size_t order = 2;
333 static const size_t nsh = 5;
353 inline size_t num_sh()
const {
return nsh;}
360 case 0: pos[0] = 0.0;
361 pos[1] = 0.0;
return true;
362 case 1: pos[0] = 1.0;
363 pos[1] = 0.0;
return true;
364 case 2: pos[0] = 1.0;
365 pos[1] = 1.0;
return true;
366 case 3: pos[0] = 0.0;
367 pos[1] = 1.0;
return true;
368 case 4: pos[0] = 0.5;
369 pos[1] = 0.5;
return true;
370 case 5: pos[0] = SQRT_FIVTH;
371 pos[1] = SQRT_FIVTH;
return true;
373 default:
UG_THROW(
"MiniLSFS: shape function "<<i<<
374 " not found. Only "<<nsh<<
" shapes present.");
385 case 0:
return (1.0-x[0])*(1.0-x[1]);
386 case 1:
return x[0]*(1.0-x[1]);
387 case 2:
return x[0]*x[1];
388 case 3:
return x[1]*(1.0-x[0]);
391 case 4:
return x[0]*(1.0-x[0])*x[1]*(1.0-x[1]);
392 case 5:
return (1.0-x[0]*x[0])*(1.0-x[1]*x[1])*(x[0]+x[1])/(0.8*0.8*2.0)*SQRT_FIVTH;
394 default:
UG_THROW(
"MiniLSFS: shape function "<<i<<
395 " not found. Only "<<nsh<<
" shapes present.");
406 case 0: g[0] = -(1.0-x[1]);
407 g[1] = -(1.0-x[0]);
return;
408 case 1: g[0] = (1.0-x[1]);
409 g[1] = -(0.0+x[0]);
return;
410 case 2: g[0] = (0.0+x[1]);
411 g[1] = (0.0+x[0]);
return;
412 case 3: g[0] = -(0.0+x[1]);
413 g[1] = (1.0-x[0]);
return;
415 case 4: g[0] = (1.0-2.0*x[0])*x[1]*(1.0-x[1]);
416 g[1] = x[0]*(1.0-x[0])*(1.0-2.0*x[1]);
return;
418 case 5: g[0] =(x[1]*x[1]-1.0)*(3.0*x[0]*x[0]+2.0*x[0]*x[1]-1.0)/(0.8*0.8*2.0)*SQRT_FIVTH;
419 g[1] =(x[0]*x[0]-1.0)*(3.0*x[1]*x[1]+2.0*x[1]*x[0]-1.0)/(0.8*0.8*2.0)*SQRT_FIVTH;
return;
421 default:
UG_THROW(
"MiniLSFS: shape function "<<i<<
422 " not found. Only "<<nsh<<
" shapes present.");
437 public BaseLSFS<MiniBubbleLSFS<ReferenceTetrahedron>, 3>
441 static const size_t order = 1;
447 static const size_t nsh = 4+1;
467 inline size_t num_sh()
const {
return nsh;}
474 case 0: pos[0] = 0.0; pos[1] = 0.0; pos[2] = 0.0;
return true;
475 case 1: pos[0] = 1.0; pos[1] = 0.0; pos[2] = 0.0;
return true;
476 case 2: pos[0] = 0.0; pos[1] = 1.0; pos[2] = 0.0;
return true;
477 case 3: pos[0] = 0.0; pos[1] = 0.0; pos[2] = 1.0;
return true;
478 case 4: pos[0] = 0.25; pos[1] = 0.25; pos[2] = 0.25;
return true;
479 default:
UG_THROW(
"MiniLSFS: shape function "<<i<<
480 " not found. Only "<<nsh<<
" shapes present.");
493 case 0:
return (1.0-x[0]-x[1]-x[2]);
497 case 4:
return x[0]*x[1]*x[2]*(1.0-x[0]-x[1]-x[2]);
498 default:
UG_THROW(
"MiniLSFS: shape function "<<i<<
499 " not found. Only "<<nsh<<
" shapes present.");
507 number prod = x[0]*x[1]*x[2];
508 number lambda4 = (1.0-x[0]-x[1]-x[2]);
524 case 4: g[0] = -prod + lambda4*x[1]*x[2];
525 g[1] = -prod + lambda4*x[0]*x[2];
526 g[2] = -prod + lambda4*x[0]*x[2];
return;
528 default:
UG_THROW(
"MiniLSFS: shape function "<<i<<
529 " not found. Only "<<nsh<<
" shapes present.");
543 public BaseLSFS<MiniBubbleLSFS<ReferenceHexahedron>, 3>
547 static const size_t order = 6;
553 static const size_t nsh = 8+1;
573 inline size_t num_sh()
const {
return nsh;}
584 pos = refElem.
corner(i);
return true;
587 pos[0] = 0.5; pos[1] = 0.5; pos[2] = 0.5;
return true;
590 UG_THROW(
"MiniLSFS: shape function "<<i<<
" not found. Only "<<nsh<<
" shapes present.");
602 case 0:
return((1.0-x[0])*(1.0-x[1])*(1.0-x[2]));
603 case 1:
return((x[0])*(1.0-x[1])*(1.0-x[2]));
604 case 2:
return((x[0])*(x[1])*(1.0-x[2]));
605 case 3:
return((1.0-x[0])*(x[1])*(1.0-x[2]));
606 case 4:
return((1.0-x[0])*(1.0-x[1])*(x[2]));
607 case 5:
return((x[0])*(1.0-x[1])*(x[2]));
608 case 6:
return((x[0])*(x[1])*(x[2]));
609 case 7:
return((1.0-x[0])*(x[1])*(x[2]));
611 case 8:
return 64.0*x[0]*(1-x[0])*x[1]*(1-x[1])*x[2]*(1-x[2]);
612 default:
UG_THROW(
"MiniLSFS: shape function "<<i<<
613 " not found. Only "<<nsh<<
" shapes present.");
626 value[0] = -(1.0-x[1])*(1.0-x[2]);
627 value[1] = -(1.0-x[0])*(1.0-x[2]);
628 value[2] = -(1.0-x[0])*(1.0-x[1]);
631 value[0] = (1.0-x[1])*(1.0-x[2]);
632 value[1] = -(x[0])*(1.0-x[2]);
633 value[2] = -(x[0])*(1.0-x[1]);
636 value[0] = (x[1])*(1.0-x[2]);
637 value[1] = (x[0])*(1.0-x[2]);
638 value[2] = -x[0]*x[1];
641 value[0] = -(x[1])*(1.0-x[2]);
642 value[1] = (1.0-x[0])*(1.0-x[2]);
643 value[2] = -(1.0-x[0])*(x[1]);
646 value[0] = -(1.0-x[1])*(x[2]);
647 value[1] = -(1.0-x[0])*(x[2]);
648 value[2] = (1.0-x[0])*(1.0-x[1]);
651 value[0] = (1.0-x[1])*x[2];
652 value[1] = -(x[0])*x[2];
653 value[2] = (x[0])*(1.0-x[1]);
656 value[0] = (x[1])*x[2];
657 value[1] = (x[0])*x[2];
658 value[2] = x[0]*x[1];
661 value[0] = -(x[1])*x[2];
662 value[1] = (1.0-x[0])*x[2];
663 value[2] = (1.0-x[0])*x[1];
666 value[0] = 64.0*(1.0-2.0*x[0])*x[1]*(1-x[1])*x[2]*(1-x[2]);
667 value[1] = 64.0*(1.0-2.0*x[1])*x[0]*(1-x[0])*x[2]*(1-x[2]);
668 value[2] = 64.0*(1.0-2.0*x[2])*x[0]*(1-x[0])*x[1]*(1-x[1]);
671 default:
UG_THROW(
"MiniLSFS: Invalid shape fct index: "<<i);
static interface for trial spaces
Definition: local_shape_function_set.h:176
const MathVector< dim > & corner(size_t i) const
coordinates of reference corner (i = 0 ... num(0))
Definition: reference_element.h:192
Definition: local_dof_set.h:58
Definition: local_dof_set.h:120
MiniBubble Set (2D only!)
Definition: mini.h:57
size_t nsh
number of shapes
Definition: mini.h:111
const LocalDoF & local_dof(size_t dof) const
returns the dof storage
Definition: mini.h:108
MiniBubbleLDS()
constructor
Definition: mini.h:64
size_t num_dof(ReferenceObjectID type) const
returns the number of DoFs on a sub-geometric object type
Definition: mini.h:99
size_t num_dof() const
returns the total number of DoFs on the finite element
Definition: mini.h:96
bool exact_position_available() const
returns if the local dof position are exact
Definition: mini.h:111
std::vector< LocalDoF > m_vLocalDoF
association to elements
Definition: mini.h:121
ReferenceObjectID roid() const
returns the type of reference element
Definition: mini.h:93
static const int refDim
dimension of reference element
Definition: mini.h:60
bool position(size_t i, MathVector< dim > &pos) const
local position of DoF i
Definition: mini.h:167
void grad(MathVector< dim > &g, const size_t i, const MathVector< dim > &x) const
evaluates the gradient of the shape function
Definition: mini.h:195
MathVector< dim > grad_type
Gradient type.
Definition: mini.h:151
number shape_type
Shape type.
Definition: mini.h:148
MiniBubbleLSFS()
Constructor.
Definition: mini.h:158
size_t num_sh() const
Definition: mini.h:164
number shape(const size_t i, const MathVector< dim > &x) const
evaluates the shape function
Definition: mini.h:180
bool continuous() const
returns if space constructs continuous functions
Definition: mini.h:161
ReferenceEdge reference_element_type
Reference Element type.
Definition: mini.h:154
MathVector< dim > grad_type
Gradient type.
Definition: mini.h:560
void grad(MathVector< dim > &value, const size_t i, const MathVector< dim > &x) const
evaluates the gradient of the shape function
Definition: mini.h:619
MiniBubbleLSFS()
Constructor.
Definition: mini.h:567
bool position(size_t i, MathVector< dim > &pos) const
local position of DoF i
Definition: mini.h:577
size_t num_sh() const
Definition: mini.h:573
number shape(const size_t i, const MathVector< dim > &x) const
evaluates the shape function
Definition: mini.h:596
number shape_type
Shape type.
Definition: mini.h:557
ReferenceHexahedron reference_element_type
Reference Element type.
Definition: mini.h:563
bool continuous() const
returns if space constructs continuous functions
Definition: mini.h:570
static const double SQRT_FIVTH
Definition: mini.h:323
MiniBubbleLSFS()
Constructor.
Definition: mini.h:347
bool continuous() const
returns if space constructs continuous functions
Definition: mini.h:350
ReferenceQuadrilateral reference_element_type
Reference Element type.
Definition: mini.h:343
static const double SQRT_FIVE
Definition: mini.h:322
number shape(const size_t i, const MathVector< dim > &x) const
evaluates the shape function
Definition: mini.h:379
number shape_type
Shape type.
Definition: mini.h:337
size_t num_sh() const
Definition: mini.h:353
bool position(size_t i, MathVector< dim > &pos) const
local position of DoF i
Definition: mini.h:356
void grad(MathVector< dim > &g, const size_t i, const MathVector< dim > &x) const
evaluates the gradient of the shape function
Definition: mini.h:400
MathVector< dim > grad_type
Gradient type.
Definition: mini.h:340
number shape(const size_t i, const MathVector< dim > &x) const
evaluates the shape function
Definition: mini.h:485
bool position(size_t i, MathVector< dim > &pos) const
local position of DoF i
Definition: mini.h:470
ReferenceTetrahedron reference_element_type
Reference Element type.
Definition: mini.h:457
number shape_type
Shape type.
Definition: mini.h:451
MiniBubbleLSFS()
Constructor.
Definition: mini.h:461
bool continuous() const
returns if space constructs continuous functions
Definition: mini.h:464
MathVector< dim > grad_type
Gradient type.
Definition: mini.h:454
size_t num_sh() const
Definition: mini.h:467
void grad(MathVector< dim > &g, const size_t i, const MathVector< dim > &x) const
evaluates the gradient of the shape function
Definition: mini.h:504
MathVector< dim > grad_type
Gradient type.
Definition: mini.h:236
number shape_type
Shape type.
Definition: mini.h:233
bool continuous() const
returns if space constructs continuous functions
Definition: mini.h:246
bool position(size_t i, MathVector< dim > &pos) const
local position of DoF i
Definition: mini.h:252
size_t num_sh() const
Definition: mini.h:249
void grad(MathVector< dim > &g, const size_t i, const MathVector< dim > &x) const
evaluates the gradient of the shape function
Definition: mini.h:286
ReferenceTriangle reference_element_type
Reference Element type.
Definition: mini.h:239
MiniBubbleLSFS()
Constructor.
Definition: mini.h:243
number shape(const size_t i, const MathVector< dim > &x) const
evaluates the shape function
Definition: mini.h:270
Lagrange Shape Function Set without virtual functions and fixed order.
Definition: mini.h:51
static TClass & get()
returns a singleton based on the identifier
Definition: provider.h:54
Definition: reference_element.h:345
reference element for a hexahedron
Definition: reference_element.h:648
Definition: reference_element.h:445
Definition: reference_element.h:494
Definition: reference_element.h:394
#define UG_THROW(msg)
Definition: error.h:57
double number
Definition: types.h:124
ReferenceObjectID
these ids are used to identify the shape of a geometric object.
Definition: grid_base_objects.h:74
@ ROID_HEXAHEDRON
Definition: grid_base_objects.h:81
int ReferenceElementDimension(ReferenceObjectID roid)
returns the reference element dimension at run-time
Definition: reference_element_util.h:40