45 template<
unsigned NNODE_1D>
52 template<
unsigned NNODE_1D>
65 if(std::fabs(s[0] + 1.0) < tol)
70 else if(std::fabs(s[0] - 1.0) < tol)
72 index[0] = NNODE_1D-1;
78 double float_index = 0.5*(1.0 + s[0])*(NNODE_1D-1);
80 index[0] =
static_cast<int>(std::floor(float_index));
83 double excess = float_index - index[0];
87 if((excess > tol) && ((1.0 - excess) > tol))
93 if((1.0 - excess) <= tol) {index[0] += 1;}
96 return node_pt(index[0]);
103 template <
unsigned NNODE_1D>
108 double Psi[NNODE_1D];
110 OneDimLagrange::shape<NNODE_1D>(s[0],Psi);
114 for(
unsigned i=0;
i<NNODE_1D;
i++) {psi[
i] = Psi[
i];}
120 template <
unsigned NNODE_1D>
125 double Psi[NNODE_1D];
126 double DPsi[NNODE_1D];
128 OneDimLagrange::shape<NNODE_1D>(s[0],Psi);
129 OneDimLagrange::dshape<NNODE_1D>(s[0],DPsi);
132 for(
unsigned l=0;l<NNODE_1D;l++)
135 dpsids(l,0) = DPsi[l];
143 template <
unsigned NNODE_1D>
148 double Psi[NNODE_1D];
149 double DPsi[NNODE_1D];
150 double D2Psi[NNODE_1D];
152 OneDimLagrange::shape<NNODE_1D>(s[0],Psi);
153 OneDimLagrange::dshape<NNODE_1D>(s[0],DPsi);
154 OneDimLagrange::d2shape<NNODE_1D>(s[0],D2Psi);
157 for(
unsigned l=0;l<NNODE_1D;l++)
160 dpsids(l,0) = DPsi[l];
161 d2psids(l,0) = D2Psi[l];
168 template <
unsigned NNODE_1D>
171 output(outfile, NNODE_1D);
177 template <
unsigned NNODE_1D>
179 const unsigned &n_plot)
185 outfile <<
"ZONE I=" << n_plot << std::endl;
188 unsigned n_dim = this->nodal_dimension();
191 for(
unsigned l=0;l<n_plot;l++)
193 s[0] = -1.0 + l*2.0/(n_plot-1);
195 for (
unsigned i=0;
i<n_dim;
i++)
197 outfile << interpolated_x(s,
i) <<
" " ;
199 outfile << std::endl;
201 outfile << std::endl;
209 template <
unsigned NNODE_1D>
212 output(file_pt, NNODE_1D);
218 template <
unsigned NNODE_1D>
226 fprintf(file_pt,
"ZONE I=%i\n",n_plot);
229 unsigned n_dim = this->nodal_dimension();
232 for(
unsigned l=0;l<n_plot;l++)
234 s[0] = -1.0 + l*2.0/(n_plot-1);
237 for (
unsigned i=0;
i<n_dim;
i++)
240 fprintf(file_pt,
"%g ",interpolated_x(s,
i));
243 fprintf(file_pt,
"\n");
246 fprintf(file_pt,
"\n");
255 template<
unsigned NNODE_1D>
262 template<
unsigned NNODE_1D>
271 for(
unsigned i=0;
i<2;
i++)
274 if(std::fabs(s[
i] + 1.0) < tol)
279 else if(std::fabs(s[
i] - 1.0) < tol)
281 index[
i] = NNODE_1D-1;
287 double float_index = 0.5*(1.0 + s[
i])*(NNODE_1D-1);
289 index[
i] =
static_cast<int>(std::floor(float_index));
292 double excess = float_index - index[
i];
296 if((excess > tol) && ((1.0 - excess) > tol))
302 if((1.0 - excess) <= tol) {index[
i] += 1;}
306 return node_pt(index[0] + NNODE_1D*index[1]);
315 template <
unsigned NNODE_1D>
320 double Psi[2][NNODE_1D];
322 OneDimLagrange::shape<NNODE_1D>(s[0],Psi[0]);
323 OneDimLagrange::shape<NNODE_1D>(s[1],Psi[1]);
329 for(
unsigned i=0;
i<NNODE_1D;
i++)
331 for(
unsigned j=0;j<NNODE_1D;j++)
334 psi[index] = Psi[1][
i]*Psi[0][j];
344 template <
unsigned NNODE_1D>
349 double Psi[2][NNODE_1D];
350 double DPsi[2][NNODE_1D];
354 OneDimLagrange::shape<NNODE_1D>(s[0],Psi[0]);
355 OneDimLagrange::shape<NNODE_1D>(s[1],Psi[1]);
356 OneDimLagrange::dshape<NNODE_1D>(s[0],DPsi[0]);
357 OneDimLagrange::dshape<NNODE_1D>(s[1],DPsi[1]);
360 for(
unsigned i=0;
i<NNODE_1D;
i++)
362 for(
unsigned j=0;j<NNODE_1D;j++)
365 dpsids(index,0) = Psi[1][
i]*DPsi[0][j];
366 dpsids(index,1) = DPsi[1][
i]* Psi[0][j];
367 psi[index] = Psi[1][
i]* Psi[0][j];
381 template <
unsigned NNODE_1D>
386 double Psi[2][NNODE_1D];
387 double DPsi[2][NNODE_1D];
388 double D2Psi[2][NNODE_1D];
393 OneDimLagrange::shape<NNODE_1D>(s[0],Psi[0]);
394 OneDimLagrange::shape<NNODE_1D>(s[1],Psi[1]);
395 OneDimLagrange::dshape<NNODE_1D>(s[0],DPsi[0]);
396 OneDimLagrange::dshape<NNODE_1D>(s[1],DPsi[1]);
397 OneDimLagrange::d2shape<NNODE_1D>(s[0],D2Psi[0]);
398 OneDimLagrange::d2shape<NNODE_1D>(s[1],D2Psi[1]);
401 for(
unsigned i=0;
i<NNODE_1D;
i++)
403 for(
unsigned j=0;j<NNODE_1D;j++)
406 psi[index] = Psi[1][
i]*Psi[0][j];
408 dpsids(index,0) = Psi[1][
i]*DPsi[0][j];
409 dpsids(index,1) = DPsi[1][
i]* Psi[0][j];
412 d2psids(index,0) = Psi[1][
i]*D2Psi[0][j];
413 d2psids(index,1) = D2Psi[1][
i]* Psi[0][j];
414 d2psids(index,2) = DPsi[1][
i]* DPsi[0][j];
427 template <
unsigned NNODE_1D>
430 output(outfile, NNODE_1D);
436 template <
unsigned NNODE_1D>
438 const unsigned &n_plot)
444 outfile <<
"ZONE I=" << n_plot <<
", J=" << n_plot << std::endl;
447 unsigned n_dim = this->nodal_dimension();
450 for(
unsigned l2=0;l2<n_plot;l2++)
452 s[1] = -1.0 + l2*2.0/(n_plot-1);
453 for(
unsigned l1=0;l1<n_plot;l1++)
455 s[0] = -1.0 + l1*2.0/(n_plot-1);
458 for (
unsigned i=0;
i<n_dim;
i++)
460 outfile << interpolated_x(s,
i) <<
" " ;
462 outfile << std::endl;
465 outfile << std::endl;
474 template <
unsigned NNODE_1D>
477 output(file_pt, NNODE_1D);
483 template <
unsigned NNODE_1D>
490 unsigned n_dim = this->nodal_dimension();
494 fprintf(file_pt,
"ZONE I=%i, J=%i\n",n_plot,n_plot);
497 for(
unsigned l2=0;l2<n_plot;l2++)
499 s[1] = -1.0 + l2*2.0/(n_plot-1);
500 for(
unsigned l1=0;l1<n_plot;l1++)
502 s[0] = -1.0 + l1*2.0/(n_plot-1);
505 for (
unsigned i=0;
i<n_dim;
i++)
508 fprintf(file_pt,
"%g ",interpolated_x(s,
i));
512 fprintf(file_pt,
"\n");
516 fprintf(file_pt,
"\n");
526 template<
unsigned NNODE_1D>
532 template<
unsigned NNODE_1D>
541 for(
unsigned i=0;
i<3;
i++)
544 if(std::fabs(s[
i] + 1.0) < tol)
549 else if(std::fabs(s[
i] - 1.0) < tol)
551 index[
i] = NNODE_1D-1;
557 double float_index = 0.5*(1.0 + s[
i])*(NNODE_1D-1);
559 index[
i] =
static_cast<int>(std::floor(float_index));
562 double excess = float_index - index[
i];
565 if((excess > tol) && ((1.0 - excess) > tol))
571 if((1.0 - excess) <= tol) {index[
i] += 1;}
575 return node_pt(index[0] + NNODE_1D*index[1] + NNODE_1D*NNODE_1D*index[2]);
583 template <
unsigned NNODE_1D>
588 double Psi[3][NNODE_1D];
591 OneDimLagrange::shape<NNODE_1D>(s[0],Psi[0]);
592 OneDimLagrange::shape<NNODE_1D>(s[1],Psi[1]);
593 OneDimLagrange::shape<NNODE_1D>(s[2],Psi[2]);
600 for(
unsigned i=0;
i<NNODE_1D;
i++)
602 for(
unsigned j=0;j<NNODE_1D;j++)
604 for(
unsigned k=0;k<NNODE_1D;k++)
607 psi[index] = Psi[2][
i]*Psi[1][j]*Psi[0][k];
618 template <
unsigned NNODE_1D>
623 double Psi[3][NNODE_1D];
624 double DPsi[3][NNODE_1D];
629 OneDimLagrange::shape<NNODE_1D>(s[0],Psi[0]);
630 OneDimLagrange::shape<NNODE_1D>(s[1],Psi[1]);
631 OneDimLagrange::shape<NNODE_1D>(s[2],Psi[2]);
632 OneDimLagrange::dshape<NNODE_1D>(s[0],DPsi[0]);
633 OneDimLagrange::dshape<NNODE_1D>(s[1],DPsi[1]);
634 OneDimLagrange::dshape<NNODE_1D>(s[2],DPsi[2]);
638 for(
unsigned i=0;
i<NNODE_1D;
i++)
640 for(
unsigned j=0;j<NNODE_1D;j++)
642 for(
unsigned k=0;k<NNODE_1D;k++)
645 dpsids(index,0) = Psi[2][
i] * Psi[1][j] * DPsi[0][k];
646 dpsids(index,1) = Psi[2][
i] * DPsi[1][j] * Psi[0][k];
647 dpsids(index,2) = DPsi[2][
i] * Psi[1][j] * Psi[0][k];
649 psi[index] = Psi[2][
i]*Psi[1][j]*Psi[0][k];
666 template <
unsigned NNODE_1D>
671 double Psi[3][NNODE_1D];
672 double DPsi[3][NNODE_1D];
673 double D2Psi[3][NNODE_1D];
678 OneDimLagrange::shape<NNODE_1D>(s[0],Psi[0]);
679 OneDimLagrange::shape<NNODE_1D>(s[1],Psi[1]);
680 OneDimLagrange::shape<NNODE_1D>(s[2],Psi[2]);
681 OneDimLagrange::dshape<NNODE_1D>(s[0],DPsi[0]);
682 OneDimLagrange::dshape<NNODE_1D>(s[1],DPsi[1]);
683 OneDimLagrange::dshape<NNODE_1D>(s[2],DPsi[2]);
684 OneDimLagrange::d2shape<NNODE_1D>(s[0],D2Psi[0]);
685 OneDimLagrange::d2shape<NNODE_1D>(s[1],D2Psi[1]);
686 OneDimLagrange::d2shape<NNODE_1D>(s[2],D2Psi[2]);
689 for(
unsigned i=0;
i<NNODE_1D;
i++)
691 for(
unsigned j=0;j<NNODE_1D;j++)
693 for(
unsigned k=0;k<NNODE_1D;k++)
696 psi[index] = Psi[2][
i]*Psi[1][j]*Psi[0][k];
698 dpsids(index,0) = Psi[2][
i]*Psi[1][j]*DPsi[0][k];
699 dpsids(index,1) = Psi[2][
i]*DPsi[1][j]*Psi[0][k];
700 dpsids(index,2) = DPsi[2][
i]* Psi[1][j]*Psi[0][k];
703 d2psids(index,0) = Psi[2][
i]*Psi[1][j]*D2Psi[0][k];
704 d2psids(index,1) = Psi[2][
i]*D2Psi[1][j]*Psi[0][k];
705 d2psids(index,2) = D2Psi[2][
i]* Psi[1][j]*Psi[0][k];
708 d2psids(index,3) = Psi[2][
i]*DPsi[1][j]*DPsi[0][k];
709 d2psids(index,4) = DPsi[2][
i]*Psi[1][j]*DPsi[0][k];
710 d2psids(index,5) = DPsi[2][
i]*DPsi[1][j]*Psi[0][k];
721 template <
unsigned NNODE_1D>
724 output(outfile, NNODE_1D);
730 template <
unsigned NNODE_1D>
732 const unsigned &n_plot)
738 outfile <<
"ZONE I=" << n_plot <<
", J=" << n_plot
739 <<
", K=" << n_plot << std::endl;
742 unsigned n_dim = this->nodal_dimension();
745 for(
unsigned l3=0;l3<n_plot;l3++)
747 s[2] = -1.0 + l3*2.0/(n_plot-1);
748 for(
unsigned l2=0;l2<n_plot;l2++)
750 s[1] = -1.0 + l2*2.0/(n_plot-1);
751 for(
unsigned l1=0;l1<n_plot;l1++)
753 s[0] = -1.0 + l1*2.0/(n_plot-1);
756 for (
unsigned i=0;
i<n_dim;
i++)
758 outfile << interpolated_x(s,
i) <<
" " ;
760 outfile << std::endl;
764 outfile << std::endl;
773 template <
unsigned NNODE_1D>
776 output(file_pt, NNODE_1D);
782 template <
unsigned NNODE_1D>
789 fprintf(file_pt,
"ZONE I=%i, J=%i, K=%i\n",n_plot,n_plot,n_plot);
792 unsigned n_dim = this->nodal_dimension();
795 for(
unsigned l3=0;l3<n_plot;l3++)
797 s[2] = -1.0 + l3*2.0/(n_plot-1);
798 for(
unsigned l2=0;l2<n_plot;l2++)
800 s[1] = -1.0 + l2*2.0/(n_plot-1);
801 for(
unsigned l1=0;l1<n_plot;l1++)
803 s[0] = -1.0 + l1*2.0/(n_plot-1);
806 for (
unsigned i=0;
i<n_dim;
i++)
808 fprintf(file_pt,
"%g ",interpolated_x(s,
i));
810 fprintf(file_pt,
"\n");
814 fprintf(file_pt,
"\n");
Nodes are derived from Data, but, in addition, have a definite (Eulerian) position in a space of a gi...
static const double Node_location_tolerance
Default value for the tolerance to be used when locating nodes via local coordinates.
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 output(std::ostream &outfile)
Output with default number of plot points.
static Gauss< 1, NNODE_1D > Default_integration_scheme
Default integration rule: Gaussian integration of same 'order' as the element.
Node * get_node_at_local_coordinate(const Vector< double > &s) const
Get the node at the specified local coordinate.