29 #ifndef OOMPH_QSPECTRAL_ELEMENT_HEADER
30 #define OOMPH_QSPECTRAL_ELEMENT_HEADER
34 #include <oomph-lib-config.h>
48 static std::map<unsigned, Vector<double>>
z;
54 if (
z.find(order) ==
z.end())
70 using namespace Orthpoly;
72 unsigned p = order - 1;
74 for (
unsigned i = 0;
i < order;
i++)
100 unsigned p = order - 1;
104 for (
unsigned i = 0;
i < order;
i++)
106 unsigned rootnum = 0;
107 for (
unsigned j = 0;
j < order;
j++)
118 if (
i == rootnum &&
i == 0)
120 (*this)[
i] = -(1.0 +
p) *
p / 4.0;
122 else if (
i == rootnum &&
i ==
p)
124 (*this)[
i] = (1.0 +
p) *
p / 4.0;
126 else if (
i == rootnum)
172 if (Spectral_data_pt != 0)
174 delete Spectral_data_pt;
175 Spectral_data_pt = 0;
184 return (*Spectral_data_pt)[
i];
201 unsigned n_spectral = nspectral();
204 for (
unsigned n = 0;
n < n_spectral;
n++)
207 Node* cast_node_pt =
dynamic_cast<Node*
>(spectral_data_pt(
n));
210 std::stringstream conversion;
211 conversion <<
" of Node " <<
n << current_string;
218 Data* data_pt = spectral_data_pt(
n);
219 std::stringstream conversion;
220 conversion <<
" of Data " <<
n << current_string;
230 const bool& store_local_dof_pt)
236 unsigned n_spectral = nspectral();
240 unsigned local_eqn_number = ndof();
243 unsigned max_n_value = spectral_data_pt(0)->nvalue();
246 for (
unsigned n = 1;
n < n_spectral;
n++)
248 unsigned n_value = spectral_data_pt(
n)->nvalue();
249 if (n_value > max_n_value)
251 max_n_value = n_value;
257 Spectral_local_eqn.
resize(
261 std::set<Data*> set_of_node_pt;
262 unsigned n_node = nnode();
263 for (
unsigned n = 0;
n < n_node;
n++)
265 set_of_node_pt.insert(node_pt(
n));
269 std::deque<unsigned long> global_eqn_number_queue;
272 for (
unsigned n = 0;
n < n_spectral;
n++)
278 Node* cast_node_pt =
dynamic_cast<Node*
>(spectral_data_pt(
n));
279 if ((cast_node_pt) &&
280 (set_of_node_pt.find(cast_node_pt) != set_of_node_pt.end()))
283 unsigned n_value = cast_node_pt->
nvalue();
285 for (
unsigned j = 0;
j < n_value;
j++)
287 Spectral_local_eqn(
n,
j) =
288 nodal_local_eqn(get_node_number(cast_node_pt),
j);
291 set_of_node_pt.erase(cast_node_pt);
296 Data*
const data_pt = spectral_data_pt(
n);
297 unsigned n_value = data_pt->
nvalue();
299 for (
unsigned j = 0;
j < n_value;
j++)
309 global_eqn_number_queue.push_back(eqn_number);
311 if (store_local_dof_pt)
317 Spectral_local_eqn(
n,
j) = local_eqn_number;
331 add_global_eqn_numbers(global_eqn_number_queue,
334 if (store_local_dof_pt)
344 if (Spectral_data_pt == 0)
350 return Spectral_data_pt->size();
361 template<
unsigned DIM,
unsigned NNODE_1D>
370 template<
unsigned NNODE_1D>
387 this->set_n_node(NNODE_1D);
388 Spectral_order.resize(1, NNODE_1D);
389 Nodal_spectral_order.resize(1, NNODE_1D);
391 this->set_dimension(1);
393 this->set_integration_scheme(&integral);
420 unsigned n_node_1d = nnode_1d();
425 nod_pt = this->node_pt(0);
428 nod_pt = this->node_pt(n_node_1d - 1);
431 std::ostringstream error_message;
432 error_message <<
"Vertex node number is " <<
j
433 <<
" but must be from 0 to 1\n";
452 this->local_coordinate_of_node(
n, s_fraction);
454 s_fraction[0] = 0.5 * (s_fraction[0] + 1.0);
487 return FiniteElement::invert_jacobian<1>(jacobian, inverse_jacobian);
504 void output(FILE* file_pt,
const unsigned& n_plot)
510 void output(std::ostream& outfile);
513 void output(std::ostream& outfile,
const unsigned& n_plot);
519 const unsigned& nplot,
521 const bool& use_equally_spaced_interior_sample_points =
false)
const
526 if (use_equally_spaced_interior_sample_points)
529 double dx_new = range /
double(nplot);
530 double range_new =
double(nplot - 1) * dx_new;
531 s[0] = -1.0 + 0.5 * dx_new + range_new * (1.0 +
s[0]) / range;
544 std::ostringstream header;
545 header <<
"ZONE I=" << nplot <<
"\n";
555 for (
unsigned i = 0;
i <
DIM;
i++)
567 void build_face_element(
const int& face_index,
575 template<
unsigned NNODE_1D>
585 for (
unsigned i = 0;
i < NNODE_1D;
i++)
594 template<
unsigned NNODE_1D>
607 for (
unsigned l = 0; l < NNODE_1D; l++)
610 dpsids(l, 0) = dpsi1ds[l];
618 template<
unsigned NNODE_1D>
624 std::ostringstream error_message;
626 <<
"\nd2shpe_local currently not implemented for this element\n";
648 template<
unsigned NNODE_1D>
665 this->set_n_node(NNODE_1D * NNODE_1D);
666 Spectral_order.resize(2, NNODE_1D);
667 Nodal_spectral_order.resize(2, NNODE_1D);
669 this->set_dimension(2);
671 this->set_integration_scheme(&integral);
698 unsigned n_node_1d = nnode_1d();
703 nod_pt = this->node_pt(0);
706 nod_pt = this->node_pt(n_node_1d - 1);
709 nod_pt = this->node_pt(n_node_1d * (n_node_1d - 1));
712 nod_pt = this->node_pt(n_node_1d * n_node_1d - 1);
715 std::ostringstream error_message;
716 error_message <<
"Vertex node number is " <<
j
717 <<
" but must be from 0 to 3\n";
731 unsigned n0 =
n % NNODE_1D;
732 unsigned n1 =
unsigned(
double(
n) /
double(NNODE_1D));
740 this->local_coordinate_of_node(
n, s_fraction);
742 s_fraction[0] = 0.5 * (s_fraction[0] + 1.0);
743 s_fraction[1] = 0.5 * (s_fraction[1] + 1.0);
778 return FiniteElement::invert_jacobian<2>(jacobian, inverse_jacobian);
795 void output(FILE* file_pt,
const unsigned& n_plot)
801 void output(std::ostream& outfile);
804 void output(std::ostream& outfile,
const unsigned& n_plot);
810 const unsigned& nplot,
812 const bool& use_equally_spaced_interior_sample_points =
false)
const
816 unsigned i0 =
i % nplot;
817 unsigned i1 = (
i - i0) / nplot;
821 if (use_equally_spaced_interior_sample_points)
824 double dx_new = range /
double(nplot);
825 double range_new =
double(nplot - 1) * dx_new;
826 s[0] = -1.0 + 0.5 * dx_new + range_new * (1.0 +
s[0]) / range;
827 s[1] = -1.0 + 0.5 * dx_new + range_new * (1.0 +
s[1]) / range;
842 std::ostringstream header;
843 header <<
"ZONE I=" << nplot <<
", J=" << nplot <<
"\n";
853 for (
unsigned i = 0;
i <
DIM;
i++)
867 void build_face_element(
const int& face_index,
875 template<
unsigned NNODE_1D>
885 for (
unsigned i = 0;
i < NNODE_1D;
i++)
887 for (
unsigned j = 0;
j < NNODE_1D;
j++)
889 psi(NNODE_1D *
i +
j) = psi2[
i] * psi1[
j];
897 template<
unsigned NNODE_1D>
912 for (
unsigned i = 0;
i < NNODE_1D;
i++)
914 for (
unsigned j = 0;
j < NNODE_1D;
j++)
917 dpsids(index, 0) = psi2[
i] * dpsi1ds[
j];
918 dpsids(index, 1) = dpsi2ds[
i] * psi1[
j];
919 psi[index] = psi2[
i] * psi1[
j];
933 template<
unsigned NNODE_1D>
939 std::ostringstream error_message;
941 <<
"\nd2shpe_local currently not implemented for this element\n";
963 template<
unsigned NNODE_1D>
980 this->set_n_node(NNODE_1D * NNODE_1D * NNODE_1D);
981 Spectral_order.resize(3, NNODE_1D);
982 Nodal_spectral_order.resize(3, NNODE_1D);
984 this->set_dimension(3);
986 this->set_integration_scheme(&integral);
1013 unsigned n_node_1d = nnode_1d();
1018 nod_pt = this->node_pt(0);
1021 nod_pt = this->node_pt(n_node_1d - 1);
1024 nod_pt = this->node_pt(n_node_1d * (n_node_1d - 1));
1027 nod_pt = this->node_pt(n_node_1d * n_node_1d - 1);
1030 nod_pt = this->node_pt(n_node_1d * n_node_1d * (n_node_1d - 1));
1033 nod_pt = this->node_pt(n_node_1d * n_node_1d * (n_node_1d - 1) +
1037 nod_pt = this->node_pt(n_node_1d * n_node_1d * n_node_1d - n_node_1d);
1040 nod_pt = this->node_pt(n_node_1d * n_node_1d * n_node_1d - 1);
1043 std::ostringstream error_message;
1044 error_message <<
"Vertex node number is " <<
j
1045 <<
" but must be from 0 to 7\n";
1059 unsigned n0 =
n % NNODE_1D;
1060 unsigned n1 =
unsigned(
double(
n) /
double(NNODE_1D)) % NNODE_1D;
1061 unsigned n2 =
unsigned(
double(
n) /
double(NNODE_1D * NNODE_1D));
1070 this->local_coordinate_of_node(
n, s_fraction);
1072 s_fraction[0] = 0.5 * (s_fraction[0] + 1.0);
1073 s_fraction[1] = 0.5 * (s_fraction[1] + 1.0);
1074 s_fraction[2] = 0.5 * (s_fraction[2] + 1.0);
1113 return FiniteElement::invert_jacobian<3>(jacobian, inverse_jacobian);
1129 void output(FILE* file_pt,
const unsigned& n_plot)
1135 void output(std::ostream& outfile);
1138 void output(std::ostream& outfile,
const unsigned& nplot);
1144 const unsigned& nplot,
1146 const bool& use_equally_spaced_interior_sample_points =
false)
const
1150 unsigned i01 =
i % (nplot * nplot);
1151 unsigned i0 = i01 % nplot;
1152 unsigned i1 = (i01 - i0) / nplot;
1153 unsigned i2 = (
i - i01) / (nplot * nplot);
1158 if (use_equally_spaced_interior_sample_points)
1161 double dx_new = range /
double(nplot);
1162 double range_new =
double(nplot - 1) * dx_new;
1163 s[0] = -1.0 + 0.5 * dx_new + range_new * (1.0 +
s[0]) / range;
1164 s[1] = -1.0 + 0.5 * dx_new + range_new * (1.0 +
s[1]) / range;
1165 s[2] = -1.0 + 0.5 * dx_new + range_new * (1.0 +
s[2]) / range;
1181 std::ostringstream header;
1182 header <<
"ZONE I=" << nplot <<
", J=" << nplot <<
", K=" << nplot
1184 return header.str();
1193 for (
unsigned i = 0;
i <
DIM;
i++)
1209 void build_face_element(
const int& face_index,
1217 template<
unsigned NNODE_1D>
1228 for (
unsigned i = 0;
i < NNODE_1D;
i++)
1230 for (
unsigned j = 0;
j < NNODE_1D;
j++)
1232 for (
unsigned k = 0;
k < NNODE_1D;
k++)
1234 psi(NNODE_1D * NNODE_1D *
i + NNODE_1D *
j +
k) =
1235 psi3[
i] * psi2[
j] * psi1[
k];
1244 template<
unsigned NNODE_1D>
1263 for (
unsigned i = 0;
i < NNODE_1D;
i++)
1265 for (
unsigned j = 0;
j < NNODE_1D;
j++)
1267 for (
unsigned k = 0;
k < NNODE_1D;
k++)
1270 dpsids(index, 0) = psi3[
i] * psi2[
j] * dpsi1ds[
k];
1271 dpsids(index, 1) = psi3[
i] * dpsi2ds[
j] * psi1[
k];
1272 dpsids(index, 2) = dpsi3ds[
i] * psi2[
j] * psi1[
k];
1273 psi[index] = psi3[
i] * psi2[
j] * psi1[
k];
1291 template<
unsigned NNODE_1D>
1297 std::ostringstream error_message;
1299 <<
"\nd2shpe_local currently not implemented for this element\n";
1321 template<
unsigned DIM>
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
float * p
Definition: Tutorial_Map_using.cpp:9
Base class for all brick elements.
Definition: Qelements.h:1233
long & eqn_number(const unsigned &i)
Return the equation number of the i-th stored variable.
Definition: nodes.h:367
virtual void describe_dofs(std::ostream &out, const std::string ¤t_string) const
Definition: nodes.cc:939
static long Is_pinned
Static "Magic number" to indicate pinned values.
Definition: nodes.h:183
double * value_pt(const unsigned &i) const
Definition: nodes.h:324
unsigned nvalue() const
Return number of values stored in data object (incl pinned ones).
Definition: nodes.h:483
static long Is_unclassified
Definition: nodes.h:192
void resize(const unsigned long &n)
Definition: matrices.h:498
Definition: elements.h:4338
Definition: elements.h:1313
virtual void output(std::ostream &outfile)
Definition: elements.h:3050
virtual void describe_local_dofs(std::ostream &out, const std::string ¤t_string) const
Definition: elements.cc:1709
virtual void assign_all_generic_local_eqn_numbers(const bool &store_local_dof_pt)
Definition: elements.h:2164
static std::deque< double * > Dof_pt_deque
Definition: elements.h:231
Base class for all line elements.
Definition: Qelements.h:466
Definition: Qspectral_elements.h:94
OneDLegendreDShapeParam(const unsigned &order, const double &s)
Definition: Qspectral_elements.h:97
Class that returns the shape functions associated with legendre.
Definition: Qspectral_elements.h:46
static void calculate_nodal_positions(const unsigned &order)
Static function used to populate the stored positions.
Definition: Qspectral_elements.h:51
static std::map< unsigned, Vector< double > > z
Definition: Qspectral_elements.h:48
static double nodal_position(const unsigned &order, const unsigned &n)
Definition: Qspectral_elements.h:60
OneDLegendreShapeParam(const unsigned &order, const double &s)
Constructor.
Definition: Qspectral_elements.h:67
Class that returns the shape functions associated with legendre.
Definition: shape.h:1234
static double nodal_position(const unsigned &n)
Definition: shape.h:1250
static void calculate_nodal_positions()
Static function used to populate the stored positions.
Definition: shape.h:1241
Definition: oomph_definitions.h:222
double invert_jacobian_mapping(const DenseMatrix< double > &jacobian, DenseMatrix< double > &inverse_jacobian) const
Definition: Qspectral_elements.h:484
static GaussLobattoLegendre< 1, NNODE_1D > integral
Assign the static integral.
Definition: Qspectral_elements.h:380
std::string tecplot_zone_string(const unsigned &nplot) const
Definition: Qspectral_elements.h:542
double s_min() const
Min. value of local coordinate.
Definition: Qspectral_elements.h:400
double local_one_d_fraction_of_node(const unsigned &n1d, const unsigned &i)
The local one-d fraction is the same.
Definition: Qspectral_elements.h:458
unsigned nplot_points(const unsigned &nplot) const
Definition: Qspectral_elements.h:551
Node * vertex_node_pt(const unsigned &j) const
Pointer to the j-th vertex node in the element.
Definition: Qspectral_elements.h:418
QSpectralElement()
Constructor.
Definition: Qspectral_elements.h:384
void local_coordinate_of_node(const unsigned &n, Vector< double > &s) const
Get local coordinates of node j in the element; vector sets its own size.
Definition: Qspectral_elements.h:443
void output(FILE *file_pt)
C-style output.
Definition: Qspectral_elements.h:498
unsigned nnode_1d() const
Number of nodes along each element edge.
Definition: Qspectral_elements.h:492
void local_fraction_of_node(const unsigned &n, Vector< double > &s_fraction)
Get the local fractino of node j in the element.
Definition: Qspectral_elements.h:450
void output(FILE *file_pt, const unsigned &n_plot)
C_style output at n_plot points.
Definition: Qspectral_elements.h:504
double s_max() const
Max. value of local coordinate.
Definition: Qspectral_elements.h:406
void get_s_plot(const unsigned &i, const unsigned &nplot, Vector< double > &s, const bool &use_equally_spaced_interior_sample_points=false) const
Definition: Qspectral_elements.h:517
unsigned nvertex_node() const
Number of vertex nodes in the element.
Definition: Qspectral_elements.h:412
void output(FILE *file_pt)
C-style output.
Definition: Qspectral_elements.h:789
void output(FILE *file_pt, const unsigned &n_plot)
C_style output at n_plot points.
Definition: Qspectral_elements.h:795
void local_coordinate_of_node(const unsigned &n, Vector< double > &s) const
Get local coordinates of node j in the element; vector sets its own size.
Definition: Qspectral_elements.h:728
std::string tecplot_zone_string(const unsigned &nplot) const
Definition: Qspectral_elements.h:840
double invert_jacobian_mapping(const DenseMatrix< double > &jacobian, DenseMatrix< double > &inverse_jacobian) const
Definition: Qspectral_elements.h:775
Node * vertex_node_pt(const unsigned &j) const
Pointer to the j-th vertex node in the element.
Definition: Qspectral_elements.h:696
void get_s_plot(const unsigned &i, const unsigned &nplot, Vector< double > &s, const bool &use_equally_spaced_interior_sample_points=false) const
Definition: Qspectral_elements.h:808
QSpectralElement()
Constructor.
Definition: Qspectral_elements.h:662
void local_fraction_of_node(const unsigned &n, Vector< double > &s_fraction)
Get the local fractino of node j in the element.
Definition: Qspectral_elements.h:738
unsigned nplot_points(const unsigned &nplot) const
Definition: Qspectral_elements.h:849
unsigned nnode_1d() const
Number of nodes along each element edge.
Definition: Qspectral_elements.h:783
unsigned nvertex_node() const
Number of vertex nodes in the element.
Definition: Qspectral_elements.h:690
double s_max() const
Max. value of local coordinate.
Definition: Qspectral_elements.h:684
double s_min() const
Min. value of local coordinate.
Definition: Qspectral_elements.h:678
static GaussLobattoLegendre< 2, NNODE_1D > integral
Assign the static integral.
Definition: Qspectral_elements.h:658
double local_one_d_fraction_of_node(const unsigned &n1d, const unsigned &i)
The local one-d fraction is the same.
Definition: Qspectral_elements.h:747
void output(FILE *file_pt, const unsigned &n_plot)
C_style output at n_plot points.
Definition: Qspectral_elements.h:1129
QSpectralElement()
Constructor.
Definition: Qspectral_elements.h:977
void output(FILE *file_pt)
C-style output.
Definition: Qspectral_elements.h:1123
Node * vertex_node_pt(const unsigned &j) const
Pointer to the j-th vertex node in the element.
Definition: Qspectral_elements.h:1011
void get_s_plot(const unsigned &i, const unsigned &nplot, Vector< double > &s, const bool &use_equally_spaced_interior_sample_points=false) const
Definition: Qspectral_elements.h:1142
static GaussLobattoLegendre< 3, NNODE_1D > integral
Assign the static integral.
Definition: Qspectral_elements.h:973
void local_fraction_of_node(const unsigned &n, Vector< double > &s_fraction)
Get the local fractino of node j in the element.
Definition: Qspectral_elements.h:1068
void local_coordinate_of_node(const unsigned &n, Vector< double > &s) const
Get local coordinates of node j in the element; vector sets its own size.
Definition: Qspectral_elements.h:1056
double s_min() const
Min. value of local coordinate.
Definition: Qspectral_elements.h:993
double local_one_d_fraction_of_node(const unsigned &n1d, const unsigned &i)
The local one-d fraction is the same.
Definition: Qspectral_elements.h:1078
double invert_jacobian_mapping(const DenseMatrix< double > &jacobian, DenseMatrix< double > &inverse_jacobian) const
Definition: Qspectral_elements.h:1110
double s_max() const
Max. value of local coordinate.
Definition: Qspectral_elements.h:999
unsigned nvertex_node() const
Number of vertex nodes in the element.
Definition: Qspectral_elements.h:1005
unsigned nnode_1d() const
Number of nodes along each element edge.
Definition: Qspectral_elements.h:1117
std::string tecplot_zone_string(const unsigned &nplot) const
Definition: Qspectral_elements.h:1179
unsigned nplot_points(const unsigned &nplot) const
Definition: Qspectral_elements.h:1189
Definition: Qspectral_elements.h:363
Base class for all quad elements.
Definition: Qelements.h:821
Definition: Qspectral_elements.h:1323
RefineableQSpectralElement()
Empty constuctor.
Definition: Qspectral_elements.h:1326
Definition: Qspectral_elements.h:153
Vector< Data * > * Spectral_data_pt
Additional Storage for shared spectral data.
Definition: Qspectral_elements.h:156
DenseMatrix< int > Spectral_local_eqn
Local equation numbers for the spectral degrees of freedom.
Definition: Qspectral_elements.h:165
virtual void assign_all_generic_local_eqn_numbers(const bool &store_local_dof_pt)
Definition: Qspectral_elements.h:229
virtual void describe_local_dofs(std::ostream &out, const std::string ¤t_string) const
Definition: Qspectral_elements.h:195
unsigned nspectral() const
Definition: Qspectral_elements.h:342
virtual ~SpectralElement()
Definition: Qspectral_elements.h:170
Data * spectral_data_pt(const unsigned &i) const
Definition: Qspectral_elements.h:182
Vector< unsigned > Nodal_spectral_order
Vector that represents the nodal spectral order.
Definition: Qspectral_elements.h:162
SpectralElement()
Definition: Qspectral_elements.h:168
Vector< unsigned > Spectral_order
Vector that represents the spectral order in each dimension.
Definition: Qspectral_elements.h:159
RealScalar s
Definition: level1_cplx_impl.h:130
char char char int int * k
Definition: level2_impl.h:374
#define DIM
Definition: linearised_navier_stokes_elements.h:44
Real fabs(const Real &a)
Definition: boostmultiprec.cpp:117
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
void shape(const double &s, double *Psi)
Definition: shape.h:564
double dlegendre(const unsigned &p, const double &x)
Definition: orthpoly.h:121
const double eps
Definition: orthpoly.h:52
double ddlegendre(const unsigned &p, const double &x)
Definition: orthpoly.h:144
double legendre(const unsigned &p, const double &x)
Definition: orthpoly.h:57
void gll_nodes(const unsigned &Nnode, Vector< double > &x)
Calculates the Gauss Lobatto Legendre abscissas for degree p = NNode-1.
Definition: orthpoly.cc:33
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
void output(std::ostream &outfile)
Output with default number of plot points.
Definition: gen_axisym_advection_diffusion_elements.h:161
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86
std::ofstream out("Result.txt")
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2