33 #ifndef __H__UG__LIB_DISC__LOCAL_SHAPE_FUNCTION_SET__CROUZEIX_RAVIART__
34 #define __H__UG__LIB_DISC__LOCAL_SHAPE_FUNCTION_SET__CROUZEIX_RAVIART__
44 template <
typename TRefElem>
52 static const size_t nsh = TRefElem::numSides;
58 for(
size_t i = 0; i <
nsh; ++i)
91 template <
typename TRefElem>
104 public BaseLSFS<CrouzeixRaviartLSFS<ReferenceTriangle>, 2>
116 case 0: pos[0] = 0.5;
117 pos[1] = 0.0;
return true;
118 case 1: pos[0] = 0.5;
119 pos[1] = 0.5;
return true;
120 case 2: pos[0] = 0.0;
121 pos[1] = 0.5;
return true;
122 default:
UG_THROW(
"CrouzeixRaviartLSFS: shape function "<<i<<
123 " not found. Only "<<nsh<<
" shapes present.");
132 case 0:
return 1-2*x[1];
133 case 1:
return -1+2*x[0]+2*x[1];
134 case 2:
return 1-2*x[0];
135 default:
UG_THROW(
"CrouzeixRaviartLSFS: shape function "<<i<<
136 " not found. Only "<<nsh<<
" shapes present.");
151 default:
UG_THROW(
"CrouzeixRaviartLSFS: shape function "<<i<<
152 " not found. Only "<<nsh<<
" shapes present.");
168 public BaseLSFS<CrouzeixRaviartLSFS<ReferenceQuadrilateral>, 2>
180 case 0: pos[0] = 0.5;
181 pos[1] = 0.0;
return true;
182 case 1: pos[0] = 1.0;
183 pos[1] = 0.5;
return true;
184 case 2: pos[0] = 0.5;
185 pos[1] = 1.0;
return true;
186 case 3: pos[0] = 0.0;
187 pos[1] = 0.5;
return true;
189 default:
UG_THROW(
"CrouzeixRaviartLSFS: shape function "<<i<<
190 " not found. Only "<<nsh<<
" shapes present.");
199 case 0:
return 0.75+x[0]-2*x[1]-x[0]*x[0]+x[1]*x[1];
200 case 1:
return -0.25+x[1]+x[0]*x[0]-x[1]*x[1];
201 case 2:
return -0.25+x[0]-x[0]*x[0]+x[1]*x[1];
202 case 3:
return 0.75-2*x[0]+x[1]+x[0]*x[0]-x[1]*x[1];
203 default:
UG_THROW(
"CrouzeixRaviartLSFS: shape function "<<i<<
204 " not found. Only "<<nsh<<
" shapes present.");
213 case 0: g[0] = 1-2*x[0];
214 g[1] = -2.0+2*x[1];
return;
215 case 1: g[0] = 2.0*x[0];
216 g[1] = 1-2.0*x[1];
return;
217 case 2: g[0] = 1-2.0*x[0];
218 g[1] = 2*x[1];
return;
219 case 3: g[0] = -2+2*x[0];
220 g[1] = 1-2*x[1];
return;
221 default:
UG_THROW(
"CrouzeixRaviartLSFS: shape function "<<i<<
222 " not found. Only "<<nsh<<
" shapes present.");
237 public BaseLSFS<CrouzeixRaviartLSFS<ReferenceTetrahedron>, 3>
249 case 0: pos[0] = 1.0/3.0;
251 pos[2] = 0.0;
return true;
252 case 1: pos[0] = 1.0/3.0;
254 pos[2] = 1.0/3.0;
return true;
255 case 2: pos[0] = 0.0;
257 pos[2] = 1.0/3.0;
return true;
258 case 3: pos[0] = 1.0/3.0;
260 pos[2] = 1.0/3.0;
return true;
262 default:
UG_THROW(
"CrouzeixRaviartLSFS: shape function "<<i<<
263 " not found. Only "<<nsh<<
" shapes present.");
272 case 0:
return 1 - 3*x[2];;
273 case 1:
return -2 + 3*x[0]+3*x[1]+3*x[2];
274 case 2:
return 1 - 3*x[0];
275 case 3:
return 1 - 3*x[1];
276 default:
UG_THROW(
"CrouzeixRaviartLSFS: shape function "<<i<<
277 " not found. Only "<<nsh<<
" shapes present.");
298 default:
UG_THROW(
"CrouzeixRaviartLSFS: shape function "<<i<<
299 " not found. Only "<<nsh<<
" shapes present.");
315 public BaseLSFS<CrouzeixRaviartLSFS<ReferenceHexahedron>, 3>
327 case 0: pos[0] = 0.5;
329 pos[2] = 0.0;
return true;
330 case 1: pos[0] = 0.5;
332 pos[2] = 0.5;
return true;
333 case 2: pos[0] = 1.0;
335 pos[2] = 0.5;
return true;
336 case 3: pos[0] = 0.5;
338 pos[2] = 0.5;
return true;
339 case 4: pos[0] = 0.0;
341 pos[2] = 0.5;
return true;
342 case 5: pos[0] = 0.5;
344 pos[2] = 1.0;
return true;
346 default:
UG_THROW(
"CrouzeixRaviartLSFS: shape function "<<i<<
347 " not found. Only "<<nsh<<
" shapes present.");
356 case 0:
return 1.0/3.0*(2 + 2*x[0] + 2*x[1] - 7*x[2]-2*x[0]*x[0]-2*x[1]*x[1]+4*x[2]*x[2]);
357 case 1:
return 1.0/3.0*(2+2*x[0]-7*x[1]+2*x[2]-2*x[0]*x[0]+4*x[1]*x[1]-2*x[2]*x[2]);
358 case 2:
return 1.0/3.0*(-1-x[0]+2*x[1]+2*x[2]+4*x[0]*x[0]-2*x[1]*x[1]-2*x[2]*x[2]);
359 case 3:
return 1.0/3.0*(-1+2*x[0]-x[1]+2*x[2]-2*x[0]*x[0]+4*x[1]*x[1]-2*x[2]*x[2]);
360 case 4:
return 1.0/3.0*(2-7*x[0]+2*x[1]+2*x[2]+4*x[0]*x[0]-2*x[1]*x[1]-2*x[2]*x[2]);
361 case 5:
return 1.0/3.0*(-1+2*x[0]+2*x[1]-x[2]-2*x[0]*x[0]-2*x[1]*x[1]+4*x[2]*x[2]);
362 default:
UG_THROW(
"CrouzeixRaviartLSFS: shape function "<<i<<
363 " not found. Only "<<nsh<<
" shapes present.");
372 case 0: g[0] = 1.0/3.0*(2-4*x[0]);
373 g[1] = 1.0/3.0*(2-4*x[1]);
374 g[2] = 1.0/3.0*(-7+8*x[2]);
return;
375 case 1: g[0] = 1.0/3.0*(2-4*x[0]);
376 g[1] = 1.0/3.0*(-7+8*x[1]);
377 g[2] = 1.0/3.0*(2-4*x[2]);
return;
378 case 2: g[0] = 1.0/3.0*(-1+8*x[0]);
379 g[1] = 1.0/3.0*(2-4*x[1]);
380 g[2] = 1.0/3.0*(2-4*x[2]);
return;
381 case 3: g[0] = 1.0/3.0*(2-4*x[0]);
382 g[1] = 1.0/3.0*(-1+8*x[1]);
383 g[2] = 1.0/3.0*(2-4*x[2]);
return;
384 case 4: g[0] = 1.0/3.0*(-7+8*x[0]);
385 g[1] = 1.0/3.0*(2-4*x[1]);
386 g[2] = 1.0/3.0*(2-4*x[2]);
return;
387 case 5: g[0] = 1.0/3.0*(2-4*x[0]);
388 g[1] = 1.0/3.0*(2-4*x[1]);
389 g[2] = 1.0/3.0*(-1+8*x[2]);
return;
390 default:
UG_THROW(
"CrouzeixRaviartLSFS: shape function "<<i<<
391 " not found. Only "<<nsh<<
" shapes present.");
406 public BaseLSFS<CrouzeixRaviartLSFS<ReferencePrism>, 3>
418 case 0: pos[0] = 1.0/3.0;
420 pos[2] = 0.0;
return true;
421 case 1: pos[0] = 0.5;
423 pos[2] = 0.5;
return true;
424 case 2: pos[0] = 0.5;
426 pos[2] = 0.5;
return true;
427 case 3: pos[0] = 0.0;
429 pos[2] = 0.5;
return true;
430 case 4: pos[0] = 1.0/3.0;
432 pos[2] = 1.0;
return true;
433 default:
UG_THROW(
"CrouzeixRaviartLSFS: shape function "<<i<<
434 " not found. Only "<<nsh<<
" shapes present.");
443 case 0:
return 1+x[0]-x[1]-3*x[2]-2*(x[0]*x[0]-x[1]*x[1]-x[2]*x[2]);
444 case 1:
return 1.0/3.0*(2-2*x[0]-4*x[1]+4*x[2]+4*(x[0]*x[0]-x[1]*x[1]-x[2]*x[2]));
445 case 2:
return 1.0/3.0*(-4+4*x[0]+8*x[1]+4*x[2]+4*(x[0]*x[0]-x[1]*x[1]-x[2]*x[2]));
446 case 3:
return 1.0/3.0*(2-8*x[0]+2*x[1]+4*x[2]+4*(x[0]*x[0]-x[1]*x[1]-x[2]*x[2]));
447 case 4:
return x[0]-x[1]-x[2]-2*(x[0]*x[0]-x[1]*x[1]-x[2]*x[2]);
448 default:
UG_THROW(
"CrouzeixRaviartLSFS: shape function "<<i<<
449 " not found. Only "<<nsh<<
" shapes present.");
458 case 0: g[0] = 1-4*x[0];
460 g[2] = -3+4*x[2];
return;
461 case 1: g[0] = 1.0/3.0*(-2+8*x[0]);
462 g[1] = 1.0/3.0*(-4-8*x[1]);
463 g[2] = 1.0/3.0*(4-8*x[2]);
return;
464 case 2: g[0] = 1.0/3.0*(4+8*x[0]);
465 g[1] = 1.0/3.0*(8-8*x[1]);
466 g[2] = 1.0/3.0*(4-8*x[2]);
return;
467 case 3: g[0] = 1.0/3.0*(-8+8*x[0]);
468 g[1] = 1.0/3.0*(2-8*x[1]);
469 g[2] = 1.0/3.0*(4-8*x[2]);
return;
470 case 4: g[0] = 1-4*x[0];
472 g[2] = -1+4*x[2];
return;
473 default:
UG_THROW(
"CrouzeixRaviartLSFS: shape function "<<i<<
474 " not found. Only "<<nsh<<
" shapes present.");
490 public BaseLSFS<CrouzeixRaviartLSFS<ReferencePyramid>, 3>
502 case 0: pos[0] = 0.5;
504 pos[2] = 0.0;
return true;
505 case 1: pos[0] = 1.0/3.0;
507 pos[2] = 1.0/3.0;
return true;
508 case 2: pos[0] = 2.0/3.0;
510 pos[2] = 1.0/3.0;
return true;
511 case 3: pos[0] = 1.0/3.0;
513 pos[2] = 1.0/3.0;
return true;
514 case 4: pos[0] = 0.0;
516 pos[2] = 1.0/3.0;
return true;
517 default:
UG_THROW(
"CrouzeixRaviartLSFS: shape function "<<i<<
518 " not found. Only "<<nsh<<
" shapes present.");
527 case 0:
return 1-3*x[2];
528 case 1:
return 0.75+1.5*x[0]-3*x[1]-0.75*x[2]-2.25*(x[0]*x[0]-x[1]*x[1]-x[2]*x[2]);
529 case 2:
return -0.75+1.5*x[1]+2.25*x[2]+2.25*(x[0]*x[0]-x[1]*x[1]-x[2]*x[2]);
530 case 3:
return -0.75+1.5*x[0]+0.75*x[2]-2.25*(x[0]*x[0]-x[1]*x[1]-x[2]*x[2]);
531 case 4:
return 0.75-3*x[0]+1.5*x[1]+0.75*x[2]+2.25*(x[0]*x[0]-x[1]*x[1]-x[2]*x[2]);
532 default:
UG_THROW(
"CrouzeixRaviartLSFS: shape function "<<i<<
533 " not found. Only "<<nsh<<
" shapes present.");
545 case 1: g[0] = 1.5-4.5*x[0];
547 g[2] = -0.75+4.5*x[2];
return;
548 case 2: g[0] = 4.5*x[0];
550 g[2] = 2.25-4.5*x[2];
return;
551 case 3: g[0] = 1.5-4.5*x[0];
553 g[2] = 0.75+4.5*x[2];
return;
554 case 4: g[0] = -3+4.5*x[0];
556 g[2] = 0.75-4.5*x[2];
return;
557 default:
UG_THROW(
"CrouzeixRaviartLSFS: shape function "<<i<<
558 " not found. Only "<<nsh<<
" shapes present.");
static interface for trial spaces
Definition: local_shape_function_set.h:176
Crouzeix - Raviart Set.
Definition: crouzeix_raviart.h:46
const LocalDoF & local_dof(size_t dof) const
returns the dof storage
Definition: crouzeix_raviart.h:77
static const size_t nsh
Number of shape functions.
Definition: crouzeix_raviart.h:52
bool exact_position_available() const
returns if the local dof position are exact
Definition: crouzeix_raviart.h:80
ReferenceObjectID roid() const
returns the type of reference element
Definition: crouzeix_raviart.h:63
LocalDoF m_vLocalDoF[nsh]
association to elements
Definition: crouzeix_raviart.h:87
CrouzeixRaviartBase()
constructor
Definition: crouzeix_raviart.h:56
static const int dim
dimension of reference element
Definition: crouzeix_raviart.h:49
bool continuous() const
returns if space constructs continuous functions
Definition: crouzeix_raviart.h:83
size_t num_dof() const
returns the total number of DoFs on the finite element
Definition: crouzeix_raviart.h:66
size_t num_dof(ReferenceObjectID type) const
returns the number of DoFs on a sub-geometric object type
Definition: crouzeix_raviart.h:70
size_t num_sh() const
Definition: crouzeix_raviart.h:67
number shape(const size_t i, const MathVector< dim > &x) const
evaluates the shape function
Definition: crouzeix_raviart.h:352
void grad(MathVector< dim > &g, const size_t i, const MathVector< dim > &x) const
evaluates the gradient of the shape function
Definition: crouzeix_raviart.h:368
bool position(size_t i, MathVector< dim > &pos) const
local position of DoF i
Definition: crouzeix_raviart.h:323
void grad(MathVector< dim > &g, const size_t i, const MathVector< dim > &x) const
evaluates the gradient of the shape function
Definition: crouzeix_raviart.h:454
number shape(const size_t i, const MathVector< dim > &x) const
evaluates the shape function
Definition: crouzeix_raviart.h:439
bool position(size_t i, MathVector< dim > &pos) const
local position of DoF i
Definition: crouzeix_raviart.h:414
bool position(size_t i, MathVector< dim > &pos) const
local position of DoF i
Definition: crouzeix_raviart.h:498
number shape(const size_t i, const MathVector< dim > &x) const
evaluates the shape function
Definition: crouzeix_raviart.h:523
void grad(MathVector< dim > &g, const size_t i, const MathVector< dim > &x) const
evaluates the gradient of the shape function
Definition: crouzeix_raviart.h:538
void grad(MathVector< dim > &g, const size_t i, const MathVector< dim > &x) const
evaluates the gradient of the shape function
Definition: crouzeix_raviart.h:209
bool position(size_t i, MathVector< dim > &pos) const
local position of DoF i
Definition: crouzeix_raviart.h:176
number shape(const size_t i, const MathVector< dim > &x) const
evaluates the shape function
Definition: crouzeix_raviart.h:195
void grad(MathVector< dim > &g, const size_t i, const MathVector< dim > &x) const
evaluates the gradient of the shape function
Definition: crouzeix_raviart.h:282
number shape(const size_t i, const MathVector< dim > &x) const
evaluates the shape function
Definition: crouzeix_raviart.h:268
bool position(size_t i, MathVector< dim > &pos) const
local position of DoF i
Definition: crouzeix_raviart.h:245
number shape(const size_t i, const MathVector< dim > &x) const
evaluates the shape function
Definition: crouzeix_raviart.h:128
void grad(MathVector< dim > &g, const size_t i, const MathVector< dim > &x) const
evaluates the gradient of the shape function
Definition: crouzeix_raviart.h:141
bool position(size_t i, MathVector< dim > &pos) const
local position of DoF i
Definition: crouzeix_raviart.h:112
Lagrange Shape Function Set without virtual functions and fixed order.
Definition: crouzeix_raviart.h:92
Definition: local_dof_set.h:58
reference element for a hexahedron
Definition: reference_element.h:648
static const int dim
dimension of reference element
Definition: reference_element.h:654
Definition: reference_element.h:595
Definition: reference_element.h:546
Definition: reference_element.h:445
Definition: reference_element.h:494
static const int dim
dimension of reference element
Definition: reference_element.h:500
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
int ReferenceElementDimension(ReferenceObjectID roid)
returns the reference element dimension at run-time
Definition: reference_element_util.h:40