29#ifndef OOMPH_SHAPE_HEADER
30#define OOMPH_SHAPE_HEADER
35#include <oomph-lib-config.h>
134 Shape(
const unsigned& N,
const unsigned& M)
162 warning_stream <<
"The assignment operator, =, makes a shallow copy."
164 <<
"This can have unexpected consequences, so we"
166 <<
"now recommend using the explicitly named function "
168 <<
"Shape::shallow_copy_from(.)." << std::endl
169 <<
"If you want to suppress" << std::endl
170 <<
"this warning then set the static boolean:"
172 <<
"Shape::Suppress_warning_about_assignment"
174 <<
" to true." << std::endl;
190 warning_stream <<
"The assignment operator, =, makes a shallow copy."
192 <<
"This can have unexpected consequences, so we"
194 <<
"now recommend using the explicitly named function "
196 <<
"Shape::shallow_copy_from(.)." << std::endl
197 <<
"If you want to suppress" << std::endl
198 <<
"this warning then set the static boolean:"
200 <<
"Shape::Suppress_warning_about_assignment"
202 <<
" to true." << std::endl;
223 shape.Is_psi_copied =
true;
253 void resize(
const unsigned& N,
const unsigned& M = 1)
260 error_stream <<
"Cannot resize an object whose storage has been copied."
262 <<
"This could lead to a dangling pointer in the copy."
328 inline const double&
operator()(
const unsigned&
i,
const unsigned&
j)
const
390 const unsigned&
k)
const
420 DShape(
const unsigned& N,
const unsigned& P)
432 DShape(
const unsigned& N,
const unsigned& M,
const unsigned& P)
465 warning_stream <<
"The assignment operator, =, makes a shallow copy."
467 <<
"This can have unexpected consequences, so we"
469 <<
"now recommend using the explicitly named function "
471 <<
"DShape::shallow_copy_from(.)." << std::endl
472 <<
"If you want to suppress" << std::endl
473 <<
"this warning then set the static boolean:"
475 <<
"DShape::Suppress_warning_about_assignment"
477 <<
" to true." << std::endl;
494 warning_stream <<
"The assignment operator, =, makes a shallow copy."
496 <<
"This can have unexpected consequences, so we"
498 <<
"now recommend using the explicitly named function "
500 <<
"DShape::shallow_copy_from(.)." << std::endl
501 <<
"If you want to suppress" << std::endl
502 <<
"this warning then set the static boolean:"
504 <<
"DShape::Suppress_warning_about_assignment"
506 <<
" to true." << std::endl;
522 Index1 = dshape.nindex1();
523 Index2 = dshape.nindex2();
524 Index3 = dshape.nindex3();
528 dshape.Is_dpsi_copied =
true;
557 void resize(
const unsigned& N,
const unsigned& P,
const unsigned& M = 1)
564 error_stream <<
"Cannot resize an object whose storage has been copied."
566 <<
"This could lead to a dangling pointer in the copy."
597 inline const double&
operator()(
const unsigned&
i,
const unsigned&
k)
const
619 const unsigned&
k)
const
649 unsigned offset(
const unsigned long&
i,
const unsigned long&
j)
const
684 namespace OneDimLagrange
689 template<
unsigned NNODE_1D>
693 error_stream <<
"One dimensional Lagrange shape functions "
694 <<
"have not been defined "
695 <<
"for " <<
NNODE_1D <<
" nodes." << std::endl;
703 template<
unsigned NNODE_1D>
707 error_stream <<
"One dimensional Lagrange shape function derivatives "
708 <<
"have not been defined "
709 <<
"for " <<
NNODE_1D <<
" nodes." << std::endl;
718 template<
unsigned NNODE_1D>
722 error_stream <<
"One dimensional Lagrange shape function "
723 <<
"second derivatives "
724 <<
"have not been defined "
725 <<
"for " <<
NNODE_1D <<
" nodes." << std::endl;
736 Psi[0] = 0.5 * (1.0 -
s);
737 Psi[1] = 0.5 * (1.0 +
s);
763 Psi[0] = 0.5 *
s * (
s - 1.0);
764 Psi[1] = 1.0 -
s *
s;
765 Psi[2] = 0.5 *
s * (
s + 1.0);
796 double t3 = 0.5625 *
t2;
797 double t4 = 0.5625 *
t1;
798 double t5 = 0.625E-1 *
s;
799 double t7 = 0.16875E1 *
t2;
800 double t8 = 0.16875E1 *
s;
801 Psi[0] = -
t3 +
t4 +
t5 - 0.625E-1;
802 Psi[1] =
t7 -
t4 -
t8 + 0.5625;
803 Psi[2] = -
t7 -
t4 +
t8 + 0.5625;
804 Psi[3] =
t3 +
t4 -
t5 - 0.625E-1;
814 double t2 = 0.16875E1 *
t1;
815 double t3 = 0.1125E1 *
s;
816 double t5 = 0.50625E1 *
t1;
817 DPsi[0] = -
t2 +
t3 + 0.625E-1;
818 DPsi[1] =
t5 -
t3 - 0.16875E1;
819 DPsi[2] = -
t5 -
t3 + 0.16875E1;
820 DPsi[3] =
t2 +
t3 - 0.625E-1;
830 double t2 = 0.16875E1 *
t1;
831 double t5 = 0.50625E1 *
t1;
832 DPsi[0] = -
t2 + 0.1125E1;
833 DPsi[1] =
t5 - 0.1125E1;
834 DPsi[2] = -
t5 - 0.1125E1;
835 DPsi[3] =
t2 + 0.1125E1;
844 namespace OneDimDiscontinuousGalerkin
849 template<
unsigned NNODE_1D>
856 error_stream <<
"One dimensional Lagrange shape functions "
857 <<
"have not been defined "
858 <<
"for " <<
NNODE_1D <<
" nodes." << std::endl;
868 template<
unsigned NNODE_1D>
875 error_stream <<
"One dimensional Lagrange shape function derivatives "
876 <<
"have not been defined "
877 <<
"for " <<
NNODE_1D <<
" nodes." << std::endl;
888 template<
unsigned NNODE_1D>
895 error_stream <<
"One dimensional Lagrange shape function "
896 <<
"second derivatives "
897 <<
"have not been defined "
898 <<
"for " <<
NNODE_1D <<
" nodes." << std::endl;
939 Psi[1] = 0.5 * (1.0 -
s);
940 Psi[2] = 0.5 * (1.0 +
s);
968 Psi[1] = 0.5 *
s * (
s - 1.0);
969 Psi[2] = 1.0 -
s *
s;
970 Psi[3] = 0.5 *
s * (
s + 1.0);
1001 namespace OneDimDiscontinuousGalerkinMixedOrderBasis
1006 template<
unsigned NNODE_1D>
1013 error_stream <<
"One dimensional Lagrange shape functions "
1014 <<
"have not been defined "
1015 <<
"for " <<
NNODE_1D <<
" nodes." << std::endl;
1025 template<
unsigned NNODE_1D>
1032 error_stream <<
"One dimensional Lagrange shape function derivatives "
1033 <<
"have not been defined "
1034 <<
"for " <<
NNODE_1D <<
" nodes." << std::endl;
1045 template<
unsigned NNODE_1D>
1052 error_stream <<
"One dimensional Lagrange shape function "
1053 <<
"second derivatives "
1054 <<
"have not been defined "
1055 <<
"for " <<
NNODE_1D <<
" nodes." << std::endl;
1068 Psi[0] = 0.5 * (1.0 -
s);
1069 Psi[1] = 0.5 * (1.0 +
s);
1095 Psi[0] = 0.5 * (1.0 -
s);
1097 Psi[2] = 0.5 * (1.0 +
s);
1124 Psi[0] = 0.5 * (1.0 -
s);
1127 Psi[3] = 0.5 * (1.0 +
s);
1158 namespace OneDimDiscontinuousGalerkinMixedOrderTest
1163 template<
unsigned NNODE_1D>
1170 error_stream <<
"One dimensional Lagrange shape functions "
1171 <<
"have not been defined "
1172 <<
"for " <<
NNODE_1D <<
" nodes." << std::endl;
1182 template<
unsigned NNODE_1D>
1189 error_stream <<
"One dimensional Lagrange shape function derivatives "
1190 <<
"have not been defined "
1191 <<
"for " <<
NNODE_1D <<
" nodes." << std::endl;
1202 template<
unsigned NNODE_1D>
1209 error_stream <<
"One dimensional Lagrange shape function "
1210 <<
"second derivatives "
1211 <<
"have not been defined "
1212 <<
"for " <<
NNODE_1D <<
" nodes." << std::endl;
1313 namespace OneDimHermite
1320 inline void shape(
const double&
s,
double Psi[2][2])
1323 Psi[0][0] = 0.25 * (
s *
s *
s - 3.0 *
s + 2.0);
1324 Psi[0][1] = 0.25 * (
s *
s *
s -
s *
s -
s + 1.0);
1326 Psi[1][0] = 0.25 * (2.0 + 3.0 *
s -
s *
s *
s);
1327 Psi[1][1] = 0.25 * (
s *
s *
s +
s *
s -
s - 1.0);
1332 inline void dshape(
const double&
s,
double DPsi[2][2])
1335 DPsi[0][0] = 0.75 * (
s *
s - 1.0);
1336 DPsi[0][1] = 0.25 * (3.0 *
s *
s - 2.0 *
s - 1.0);
1338 DPsi[1][0] = 0.75 * (1.0 -
s *
s);
1339 DPsi[1][1] = 0.25 * (3.0 *
s *
s + 2.0 *
s - 1.0);
1343 inline void d2shape(
const double&
s,
double DPsi[2][2])
1346 DPsi[0][0] = 1.5 *
s;
1347 DPsi[0][1] = 0.5 * (3.0 *
s - 1.0);
1349 DPsi[1][0] = -1.5 *
s;
1350 DPsi[1][1] = 0.5 * (3.0 *
s + 1.0);
1358 template<
unsigned NNODE_1D>
1384 using namespace Orthpoly;
1398 (*this)[
i] = (1.0 -
s *
s) * dlegendre(
p,
s) /
1399 (
p * (
p + 1) * legendre(
p,
z[
i]) * (
z[
i] -
s));
1405 template<
unsigned NNODE_1D>
1408 template<
unsigned NNODE_1D>
1412 template<
unsigned NNODE_1D>
1441 (*this)[
i] = -(1.0 +
p) *
p / 4.0;
1445 (*this)[
i] = (1.0 +
p) *
p / 4.0;
1482 (*this)[0] = 0.5 * (1.0 -
s);
1483 (*this)[1] = 0.5 * (1.0 +
s);
1484 for (
unsigned i = 2;
i < p_order;
i++)
1502 for (
unsigned i = 2;
i < p_order;
i++)
1504 (*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,...
void operator=(DShape &dshape)
Assignment operator, shallow copy (not recommended so warning given)
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.
static bool Suppress_warning_about_assignment
Boolean used to suppress warning about assignment operator.
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)
Assignment operator, shallow copy (not reccomended so warning given)
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 shallow_copy_from(DShape *const &dshape_pt)
This function 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,...
bool Is_dpsi_copied
Boolean to indicate whether the data has been copied.
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 shallow_copy_from(DShape &dshape)
This function does a shallow copy (resets the pointer to the data)
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.
bool Is_dpsi_a_copy
Boolean to indicate whether the data is a copy.
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....
An OomphLibWarning object which should be created as a temporary object to issue a warning....
A Class for shape functions. In simple cases, the shape functions have only one index that can be tho...
void shallow_copy_from(Shape &shape)
This function makes a shallow copy (sets the pointer to the allocated data to be from another Shape o...
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)
void operator=(Shape &shape)
Assignment operator, shallow copy (not recommended so warning given)
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.
static bool Suppress_warning_about_assignment
Boolean used to suppress warning about assignment operator.
double & operator()(const unsigned &i, const unsigned &j)
Overload the round bracket operator, allowing for two indices.
bool Is_psi_a_copy
Boolean to indicate whether the data is a copy.
void shallow_copy_from(Shape *const &shape_pt)
This function make a shallow copy (sets the pointer to the allocated data to be from another Shape ob...
unsigned Index2
Size of the second index of the shape function.
bool Is_psi_copied
Boolean to indicate whether the data has been copied.
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)
Assignment operator, shallow copy (not recommended so warning given)
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).