29#ifndef OOMPH_SHAPE_HEADER
30#define OOMPH_SHAPE_HEADER
35#include <oomph-lib-config.h>
145 if ((shape.Index1 !=
Index1) || (shape.Index2 !=
Index2))
148 error_stream <<
"Cannot assign Shape object:" << std::endl
149 <<
"Indices do not match "
151 <<
", RHS: " << shape.Index1 <<
" " << shape.Index2
169 error_stream <<
"Cannot assign Shape object:" << std::endl
170 <<
"Indices do not match "
189 void resize(
const unsigned& N,
const unsigned& M = 1)
250 inline const double&
operator()(
const unsigned&
i,
const unsigned&
j)
const
302 const unsigned&
k)
const
332 DShape(
const unsigned& N,
const unsigned& P)
340 DShape(
const unsigned& N,
const unsigned& M,
const unsigned& P)
360 if ((dshape.Index1 !=
Index1) || (dshape.Index2 !=
Index2) ||
361 (dshape.Index3 !=
Index3))
364 error_stream <<
"Cannot assign DShape object:" << std::endl
365 <<
"Indices do not match "
367 <<
", RHS: " << dshape.Index1 <<
" " << dshape.Index2
368 <<
" " << dshape.Index3 << std::endl;
386 error_stream <<
"Cannot assign Shape object:" << std::endl
387 <<
"Indices do not match "
410 void resize(
const unsigned& N,
const unsigned& P,
const unsigned& M = 1)
435 inline const double&
operator()(
const unsigned&
i,
const unsigned&
k)
const
457 const unsigned&
k)
const
487 unsigned offset(
const unsigned long&
i,
const unsigned long&
j)
const
558 namespace OneDimLagrange
563 template<
unsigned NNODE_1D>
567 error_stream <<
"One dimensional Lagrange shape functions "
568 <<
"have not been defined "
569 <<
"for " <<
NNODE_1D <<
" nodes." << std::endl;
577 template<
unsigned NNODE_1D>
581 error_stream <<
"One dimensional Lagrange shape function derivatives "
582 <<
"have not been defined "
583 <<
"for " <<
NNODE_1D <<
" nodes." << std::endl;
592 template<
unsigned NNODE_1D>
596 error_stream <<
"One dimensional Lagrange shape function "
597 <<
"second derivatives "
598 <<
"have not been defined "
599 <<
"for " <<
NNODE_1D <<
" nodes." << std::endl;
610 Psi[0] = 0.5 * (1.0 -
s);
611 Psi[1] = 0.5 * (1.0 +
s);
637 Psi[0] = 0.5 *
s * (
s - 1.0);
638 Psi[1] = 1.0 -
s *
s;
639 Psi[2] = 0.5 *
s * (
s + 1.0);
670 double t3 = 0.5625 *
t2;
671 double t4 = 0.5625 *
t1;
672 double t5 = 0.625E-1 *
s;
673 double t7 = 0.16875E1 *
t2;
674 double t8 = 0.16875E1 *
s;
675 Psi[0] = -
t3 +
t4 +
t5 - 0.625E-1;
676 Psi[1] =
t7 -
t4 -
t8 + 0.5625;
677 Psi[2] = -
t7 -
t4 +
t8 + 0.5625;
678 Psi[3] =
t3 +
t4 -
t5 - 0.625E-1;
688 double t2 = 0.16875E1 *
t1;
689 double t3 = 0.1125E1 *
s;
690 double t5 = 0.50625E1 *
t1;
691 DPsi[0] = -
t2 +
t3 + 0.625E-1;
692 DPsi[1] =
t5 -
t3 - 0.16875E1;
693 DPsi[2] = -
t5 -
t3 + 0.16875E1;
694 DPsi[3] =
t2 +
t3 - 0.625E-1;
704 double t2 = 0.16875E1 *
t1;
705 double t5 = 0.50625E1 *
t1;
706 DPsi[0] = -
t2 + 0.1125E1;
707 DPsi[1] =
t5 - 0.1125E1;
708 DPsi[2] = -
t5 - 0.1125E1;
709 DPsi[3] =
t2 + 0.1125E1;
718 namespace OneDimDiscontinuousGalerkin
723 template<
unsigned NNODE_1D>
730 error_stream <<
"One dimensional Lagrange shape functions "
731 <<
"have not been defined "
732 <<
"for " <<
NNODE_1D <<
" nodes." << std::endl;
742 template<
unsigned NNODE_1D>
749 error_stream <<
"One dimensional Lagrange shape function derivatives "
750 <<
"have not been defined "
751 <<
"for " <<
NNODE_1D <<
" nodes." << std::endl;
762 template<
unsigned NNODE_1D>
769 error_stream <<
"One dimensional Lagrange shape function "
770 <<
"second derivatives "
771 <<
"have not been defined "
772 <<
"for " <<
NNODE_1D <<
" nodes." << std::endl;
813 Psi[1] = 0.5 * (1.0 -
s);
814 Psi[2] = 0.5 * (1.0 +
s);
842 Psi[1] = 0.5 *
s * (
s - 1.0);
843 Psi[2] = 1.0 -
s *
s;
844 Psi[3] = 0.5 *
s * (
s + 1.0);
875 namespace OneDimDiscontinuousGalerkinMixedOrderBasis
880 template<
unsigned NNODE_1D>
887 error_stream <<
"One dimensional Lagrange shape functions "
888 <<
"have not been defined "
889 <<
"for " <<
NNODE_1D <<
" nodes." << std::endl;
899 template<
unsigned NNODE_1D>
906 error_stream <<
"One dimensional Lagrange shape function derivatives "
907 <<
"have not been defined "
908 <<
"for " <<
NNODE_1D <<
" nodes." << std::endl;
919 template<
unsigned NNODE_1D>
926 error_stream <<
"One dimensional Lagrange shape function "
927 <<
"second derivatives "
928 <<
"have not been defined "
929 <<
"for " <<
NNODE_1D <<
" nodes." << std::endl;
942 Psi[0] = 0.5 * (1.0 -
s);
943 Psi[1] = 0.5 * (1.0 +
s);
969 Psi[0] = 0.5 * (1.0 -
s);
971 Psi[2] = 0.5 * (1.0 +
s);
998 Psi[0] = 0.5 * (1.0 -
s);
1001 Psi[3] = 0.5 * (1.0 +
s);
1032 namespace OneDimDiscontinuousGalerkinMixedOrderTest
1037 template<
unsigned NNODE_1D>
1044 error_stream <<
"One dimensional Lagrange shape functions "
1045 <<
"have not been defined "
1046 <<
"for " <<
NNODE_1D <<
" nodes." << std::endl;
1056 template<
unsigned NNODE_1D>
1063 error_stream <<
"One dimensional Lagrange shape function derivatives "
1064 <<
"have not been defined "
1065 <<
"for " <<
NNODE_1D <<
" nodes." << std::endl;
1076 template<
unsigned NNODE_1D>
1083 error_stream <<
"One dimensional Lagrange shape function "
1084 <<
"second derivatives "
1085 <<
"have not been defined "
1086 <<
"for " <<
NNODE_1D <<
" nodes." << std::endl;
1187 namespace OneDimHermite
1194 inline void shape(
const double&
s,
double Psi[2][2])
1197 Psi[0][0] = 0.25 * (
s *
s *
s - 3.0 *
s + 2.0);
1198 Psi[0][1] = 0.25 * (
s *
s *
s -
s *
s -
s + 1.0);
1200 Psi[1][0] = 0.25 * (2.0 + 3.0 *
s -
s *
s *
s);
1201 Psi[1][1] = 0.25 * (
s *
s *
s +
s *
s -
s - 1.0);
1206 inline void dshape(
const double&
s,
double DPsi[2][2])
1209 DPsi[0][0] = 0.75 * (
s *
s - 1.0);
1210 DPsi[0][1] = 0.25 * (3.0 *
s *
s - 2.0 *
s - 1.0);
1212 DPsi[1][0] = 0.75 * (1.0 -
s *
s);
1213 DPsi[1][1] = 0.25 * (3.0 *
s *
s + 2.0 *
s - 1.0);
1217 inline void d2shape(
const double&
s,
double DPsi[2][2])
1220 DPsi[0][0] = 1.5 *
s;
1221 DPsi[0][1] = 0.5 * (3.0 *
s - 1.0);
1223 DPsi[1][0] = -1.5 *
s;
1224 DPsi[1][1] = 0.5 * (3.0 *
s + 1.0);
1232 template<
unsigned NNODE_1D>
1258 using namespace Orthpoly;
1272 (*this)[
i] = (1.0 -
s *
s) * dlegendre(
p,
s) /
1273 (
p * (
p + 1) * legendre(
p,
z[
i]) * (
z[
i] -
s));
1279 template<
unsigned NNODE_1D>
1282 template<
unsigned NNODE_1D>
1286 template<
unsigned NNODE_1D>
1315 (*this)[
i] = -(1.0 +
p) *
p / 4.0;
1319 (*this)[
i] = (1.0 +
p) *
p / 4.0;
1356 (*this)[0] = 0.5 * (1.0 -
s);
1357 (*this)[1] = 0.5 * (1.0 +
s);
1358 for (
unsigned i = 2;
i < p_order;
i++)
1376 for (
unsigned i = 2;
i < p_order;
i++)
1378 (*this)[
i] = (0.5 * (1.0 -
s)) * (0.5 * (1.0 +
s)) *
A Class for the derivatives of shape functions The class design is essentially the same as Shape,...
double & operator()(const unsigned &i, const unsigned &j, const unsigned &k)
Overload the round bracket operator, with 3 indices.
const double & operator()(const unsigned &i, const unsigned &j, const unsigned &k) const
Overload the round bracket operator (const version)
unsigned long nindex3() const
Return the range of index 3 of the derivatives of the shape functions.
unsigned long nindex2() const
Return the range of index 2 of the derivatives of the shape functions.
unsigned offset(const unsigned long &i, const unsigned long &j) const
Caculate the offset in flat-packed C-style, column-major format, required for a given i,...
double & raw_direct_access(const unsigned long &i)
Direct access to internal storage of data in flat-packed C-style column-major format....
unsigned Index2
Size of the second index of the shape function.
const double & operator()(const unsigned &i, const unsigned &k) const
Overload the round bracket operator (const version)
~DShape()
Destructor, clean up the memory allocated by this object.
void operator=(DShape *const &dshape_pt)
The assignment operator does a shallow copy (resets the pointer to the data)
const double & raw_direct_access(const unsigned long &i) const
Direct access to internal storage of data in flat-packed C-style column-major format....
void operator=(const DShape &dshape)
The assignment operator does a shallow copy (resets the pointer to the data)
unsigned long nindex1() const
Return the range of index 1 of the derivatives of the shape functions.
DShape()
Default constructor - just assigns a null pointers and zero index sizes.
double * Allocated_storage
Pointer that addresses the storage allocated by the object on construction. This will be the same as ...
void resize(const unsigned &N, const unsigned &P, const unsigned &M=1)
Change the size of the storage. Note that (for some strange reason) index2 is the "optional" index,...
unsigned Index1
Size of the first index of the shape function.
unsigned Index3
Size of the third index of the shape function.
DShape(const unsigned &N, const unsigned &M, const unsigned &P)
Constructor with three paramters: a two-index shape function.
void range_check(const unsigned &i, const unsigned &j, const unsigned &k) const
Private function that checks whether the indices are in range.
DShape(const unsigned &N, const unsigned &P)
Constructor with two parameters: a single-index shape function.
DShape(const DShape &dshape)=delete
Broken copy constructor.
double * DPsi
Pointer that addresses the storage that will be used to read and set the shape-function derivatives....
double & operator()(const unsigned &i, const unsigned &k)
Overload the round bracket operator for access to the data.
OneDimensionalLegendreDShape(const double &s)
Class that returns the shape functions associated with legendre.
OneDimensionalLegendreShape(const double &s)
Constructor.
static double nodal_position(const unsigned &n)
static Vector< double > z
static bool Nodes_calculated
static void calculate_nodal_positions()
Static function used to populate the stored positions.
OneDimensionalModalDShape(const unsigned p_order, const double &s)
Non-templated class that returns modal hierachical shape functions based on Legendre polynomials.
OneDimensionalModalShape(const unsigned p_order, const double &s)
Constructor.
An OomphLibError object which should be thrown when an run-time error is encountered....
A shape function with a deep copy constructor. This allows for use with stl operations (e....
ShapeWithDeepCopy()
Default constructor.
ShapeWithDeepCopy(const unsigned &N)
Constructor for a single-index set of shape functions.
~ShapeWithDeepCopy()
Destructor, clear up the memory allocated by the object.
ShapeWithDeepCopy(const unsigned &N, const unsigned &M)
Constructor for a two-index set of shape functions.
void operator=(const ShapeWithDeepCopy &old_shape)=delete
Broken assignment operator.
ShapeWithDeepCopy(const ShapeWithDeepCopy &old_shape)
Deep copy constructor.
A Class for shape functions. In simple cases, the shape functions have only one index that can be tho...
const double & operator[](const unsigned &i) const
Overload the bracket operator (const version)
const double & operator()(const unsigned &i, const unsigned &j) const
Overload the round bracket operator, allowing for two indices (const version)
double * Allocated_storage
Pointer that addresses the storage allocated by the object on construction. This will be the same as ...
unsigned nindex1() const
Return the range of index 1 of the shape function object.
const double & operator()(const unsigned &i) const
Overload the round bracket operator (const version)
double & operator()(const unsigned &i)
Overload the round bracket operator to provide access to values.
unsigned Index1
Size of the first index of the shape function.
double & operator[](const unsigned &i)
Overload the bracket operator to provide access to values.
void resize(const unsigned &N, const unsigned &M=1)
Change the size of the storage.
double & operator()(const unsigned &i, const unsigned &j)
Overload the round bracket operator, allowing for two indices.
void operator=(const Shape &shape)
The assignment operator does a shallow copy (resets the pointer to the data)
unsigned Index2
Size of the second index of the shape function.
Shape(const unsigned &N, const unsigned &M)
Constructor for a two-index set of shape functions.
double * Psi
Pointer that addresses the storage that will be used to read and set the shape functions....
void operator=(Shape *const &shape_pt)
The assignment operator does a shallow copy (resets the pointer to the data)
unsigned nindex2() const
Return the range of index 2 of the shape function object.
Shape(const Shape &shape)=delete
Broken copy constructor.
Shape(const unsigned &N)
Constructor for a single-index set of shape functions.
void range_check(const unsigned &i, const unsigned &j) const
Private function that checks whether the index is in range.
Shape()
Default constructor - just assigns a null pointers and zero index sizes.
~Shape()
Destructor, clear up the memory allocated by the object.
TAdvectionDiffusionReactionElement<NREAGENT,DIM,NNODE_1D> elements are isoparametric triangular DIM-d...
void dshape< 4 >(const double &s, double *DPsi)
Derivatives of 1D shape functions specialised to cubic order (4 Nodes)
void d2shape< 2 >(const double &s, double *DPsi)
Second Derivatives of 1D shape functions, specialised to linear order (2 Nodes)
void dshape< 3 >(const double &s, double *DPsi)
Derivatives of 1D shape functions specialised to quadratic order (3 Nodes)
void shape< 2 >(const double &s, double *Psi)
1D shape functions specialised to linear order (2 Nodes)
void d2shape< 3 >(const double &s, double *DPsi)
Second Derivatives of 1D shape functions, specialised to quadratic order (3 Nodes)
void d2shape< 4 >(const double &s, double *DPsi)
Second derivatives of 1D shape functions specialised to cubic order (4 nodes)
void shape< 3 >(const double &s, double *Psi)
1D shape functions specialised to quadratic order (3 Nodes)
void dshape(const double &s, double *DPsi)
Definition for derivatives of 1D Lagrange shape functions. The value of all the shape function deriva...
void shape< 4 >(const double &s, double *Psi)
1D shape functions specialised to cubic order (4 Nodes)
void d2shape(const double &s, double *DPsi)
Definition for second derivatives of 1D Lagrange shape functions. The value of all the shape function...
void dshape< 2 >(const double &s, double *DPsi)
Derivatives of 1D shape functions specialised to linear order (2 Nodes)
void shape(const double &s, double *Psi)
Definition for 1D Lagrange shape functions. The value of all the shape functions at the local coordin...
void d2shape(const double &s, double *DPsi)
Definition for second derivatives of 1D Lagrange shape functions. The value of all the shape function...
void d2shape< 3 >(const double &s, double *DPsi)
Second Derivatives of 1D shape functions, specialised to quadratic order (3 Nodes)
void dshape< 3 >(const double &s, double *DPsi)
Derivatives of 1D shape functions specialised to quadratic order (3 Nodes)
void shape< 3 >(const double &s, double *Psi)
1D shape functions specialised to quadratic order (3 Nodes)
void dshape(const double &s, double *DPsi)
Definition for derivatives of 1D Lagrange shape functions. The value of all the shape function deriva...
void dshape< 2 >(const double &s, double *DPsi)
Derivatives of 1D shape functions specialised to linear order (2 Nodes)
void d2shape< 4 >(const double &s, double *DPsi)
Second derivatives of 1D shape functions specialised to cubic order (4 nodes)
void dshape< 4 >(const double &s, double *DPsi)
Derivatives of 1D shape functions specialised to cubic order (4 Nodes)
void shape(const double &s, double *Psi)
Definition for 1D Lagrange shape functions. The value of all the shape functions at the local coordin...
void shape< 2 >(const double &s, double *Psi)
1D shape functions specialised to linear order (2 Nodes)
void d2shape< 2 >(const double &s, double *DPsi)
Second Derivatives of 1D shape functions, specialised to linear order (2 Nodes)
void shape< 4 >(const double &s, double *Psi)
1D shape functions specialised to cubic order (4 Nodes)
void dshape< 3 >(const double &s, double *DPsi)
Derivatives of 1D shape functions specialised to quadratic order (3 Nodes)
void dshape< 4 >(const double &s, double *DPsi)
Derivatives of 1D shape functions specialised to cubic order (4 Nodes)
void shape< 3 >(const double &s, double *Psi)
1D shape functions specialised to quadratic order (3 Nodes)
void dshape(const double &s, double *DPsi)
Definition for derivatives of 1D Lagrange shape functions. The value of all the shape function deriva...
void d2shape< 3 >(const double &s, double *DPsi)
Second Derivatives of 1D shape functions, specialised to quadratic order (3 Nodes)
void dshape< 2 >(const double &s, double *DPsi)
Derivatives of 1D shape functions specialised to linear order (2 Nodes)
void shape< 2 >(const double &s, double *Psi)
1D shape functions specialised to linear order (2 Nodes)
void d2shape(const double &s, double *DPsi)
Definition for second derivatives of 1D Lagrange shape functions. The value of all the shape function...
void shape< 4 >(const double &s, double *Psi)
1D shape functions specialised to cubic order (4 Nodes)
void d2shape< 4 >(const double &s, double *DPsi)
Second derivatives of 1D shape functions specialised to cubic order (4 nodes)
void shape(const double &s, double *Psi)
Definition for 1D Lagrange shape functions. The value of all the shape functions at the local coordin...
void d2shape< 2 >(const double &s, double *DPsi)
Second Derivatives of 1D shape functions, specialised to linear order (2 Nodes)
void dshape(const double &s, double DPsi[2][2])
Derivatives of 1D Hermite shape functions.
void d2shape(const double &s, double DPsi[2][2])
Second derivatives of the Hermite shape functions.
void shape(const double &s, double Psi[2][2])
Constructor sets the values of the shape functions at the position s.
void shape(const double &s, double *Psi)
Definition for 1D Lagrange shape functions. The value of all the shape functions at the local coordin...
void d2shape< 2 >(const double &s, double *DPsi)
Second Derivatives of 1D shape functions, specialised to linear order (2 Nodes)
void dshape< 3 >(const double &s, double *DPsi)
Derivatives of 1D shape functions specialised to quadratic order (3 Nodes)
void d2shape(const double &s, double *DPsi)
Definition for second derivatives of 1D Lagrange shape functions. The value of all the shape function...
void dshape< 2 >(const double &s, double *DPsi)
Derivatives of 1D shape functions specialised to linear order (2 Nodes)
void d2shape< 3 >(const double &s, double *DPsi)
Second Derivatives of 1D shape functions, specialised to quadratic order (3 Nodes)
void d2shape< 4 >(const double &s, double *DPsi)
Second Derivatives of 1D shape functions specialised to cubic order (4 Nodes)
void dshape< 4 >(const double &s, double *DPsi)
Derivatives of 1D shape functions specialised to cubic order (4 Nodes)
void shape< 3 >(const double &s, double *Psi)
1D shape functions specialised to quadratic order (3 Nodes)
void shape< 4 >(const double &s, double *Psi)
1D shape functions specialised to cubic order (4 Nodes)
void shape< 2 >(const double &s, double *Psi)
1D shape functions specialised to linear order (2 Nodes)
void dshape(const double &s, double *DPsi)
Definition for derivatives of 1D Lagrange shape functions. The value of all the shape function deriva...
double dlegendre(const unsigned &p, const double &x)
Calculates first derivative of Legendre polynomial of degree p at x using three term recursive formul...
double ddlegendre(const unsigned &p, const double &x)
Calculates second derivative of Legendre polynomial of degree p at x using three term recursive formu...
double legendre(const unsigned &p, const double &x)
Calculates Legendre polynomial of degree p at x using the three term recurrence relation .
void gll_nodes(const unsigned &Nnode, Vector< double > &x)
Calculates the Gauss Lobatto Legendre abscissas for degree p = NNode-1.
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).