40 template<
unsigned NNODE_1D>
47 template<
unsigned NNODE_1D>
60 if (std::fabs(
s[0] + 1.0) < tol)
65 else if (std::fabs(
s[0] - 1.0) < tol)
67 index[0] = NNODE_1D - 1;
73 double float_index = 0.5 * (1.0 +
s[0]) * (NNODE_1D - 1);
75 index[0] =
static_cast<int>(std::floor(float_index));
78 double excess = float_index - index[0];
82 if ((excess > tol) && ((1.0 - excess) > tol))
88 if ((1.0 - excess) <= tol)
94 return node_pt(index[0]);
101 template<
unsigned NNODE_1D>
105 double Psi[NNODE_1D];
107 OneDimLagrange::shape<NNODE_1D>(
s[0], Psi);
111 for (
unsigned i = 0;
i < NNODE_1D;
i++)
120 template<
unsigned NNODE_1D>
126 double Psi[NNODE_1D];
127 double DPsi[NNODE_1D];
129 OneDimLagrange::shape<NNODE_1D>(
s[0], Psi);
130 OneDimLagrange::dshape<NNODE_1D>(
s[0], DPsi);
133 for (
unsigned l = 0; l < NNODE_1D; l++)
136 dpsids(l, 0) = DPsi[l];
144 template<
unsigned NNODE_1D>
151 double Psi[NNODE_1D];
152 double DPsi[NNODE_1D];
153 double D2Psi[NNODE_1D];
155 OneDimLagrange::shape<NNODE_1D>(
s[0], Psi);
156 OneDimLagrange::dshape<NNODE_1D>(
s[0], DPsi);
157 OneDimLagrange::d2shape<NNODE_1D>(
s[0], D2Psi);
160 for (
unsigned l = 0; l < NNODE_1D; l++)
163 dpsids(l, 0) = DPsi[l];
164 d2psids(l, 0) = D2Psi[l];
171 template<
unsigned NNODE_1D>
174 output(outfile, NNODE_1D);
180 template<
unsigned NNODE_1D>
182 const unsigned& n_plot)
188 outfile <<
"ZONE I=" << n_plot << std::endl;
191 unsigned n_dim = this->nodal_dimension();
194 for (
unsigned l = 0; l < n_plot; l++)
196 s[0] = -1.0 + l * 2.0 / (n_plot - 1);
198 for (
unsigned i = 0;
i < n_dim;
i++)
200 outfile << interpolated_x(
s,
i) <<
" ";
202 outfile << std::endl;
204 outfile << std::endl;
211 template<
unsigned NNODE_1D>
214 output(file_pt, NNODE_1D);
220 template<
unsigned NNODE_1D>
228 fprintf(file_pt,
"ZONE I=%i\n", n_plot);
231 unsigned n_dim = this->nodal_dimension();
234 for (
unsigned l = 0; l < n_plot; l++)
236 s[0] = -1.0 + l * 2.0 / (n_plot - 1);
239 for (
unsigned i = 0;
i < n_dim;
i++)
242 fprintf(file_pt,
"%g ", interpolated_x(
s,
i));
245 fprintf(file_pt,
"\n");
248 fprintf(file_pt,
"\n");
257 template<
unsigned NNODE_1D>
264 template<
unsigned NNODE_1D>
273 for (
unsigned i = 0;
i < 2;
i++)
276 if (std::fabs(
s[
i] + 1.0) < tol)
281 else if (std::fabs(
s[
i] - 1.0) < tol)
283 index[
i] = NNODE_1D - 1;
289 double float_index = 0.5 * (1.0 +
s[
i]) * (NNODE_1D - 1);
291 index[
i] =
static_cast<int>(std::floor(float_index));
294 double excess = float_index - index[
i];
298 if ((excess > tol) && ((1.0 - excess) > tol))
304 if ((1.0 - excess) <= tol)
311 return node_pt(index[0] + NNODE_1D * index[1]);
319 template<
unsigned NNODE_1D>
323 double Psi[2][NNODE_1D];
325 OneDimLagrange::shape<NNODE_1D>(
s[0], Psi[0]);
326 OneDimLagrange::shape<NNODE_1D>(
s[1], Psi[1]);
332 for (
unsigned i = 0;
i < NNODE_1D;
i++)
334 for (
unsigned j = 0; j < NNODE_1D; j++)
337 psi[index] = Psi[1][
i] * Psi[0][j];
347 template<
unsigned NNODE_1D>
353 double Psi[2][NNODE_1D];
354 double DPsi[2][NNODE_1D];
358 OneDimLagrange::shape<NNODE_1D>(
s[0], Psi[0]);
359 OneDimLagrange::shape<NNODE_1D>(
s[1], Psi[1]);
360 OneDimLagrange::dshape<NNODE_1D>(
s[0], DPsi[0]);
361 OneDimLagrange::dshape<NNODE_1D>(
s[1], DPsi[1]);
364 for (
unsigned i = 0;
i < NNODE_1D;
i++)
366 for (
unsigned j = 0; j < NNODE_1D; j++)
369 dpsids(index, 0) = Psi[1][
i] * DPsi[0][j];
370 dpsids(index, 1) = DPsi[1][
i] * Psi[0][j];
371 psi[index] = Psi[1][
i] * Psi[0][j];
385 template<
unsigned NNODE_1D>
392 double Psi[2][NNODE_1D];
393 double DPsi[2][NNODE_1D];
394 double D2Psi[2][NNODE_1D];
399 OneDimLagrange::shape<NNODE_1D>(
s[0], Psi[0]);
400 OneDimLagrange::shape<NNODE_1D>(
s[1], Psi[1]);
401 OneDimLagrange::dshape<NNODE_1D>(
s[0], DPsi[0]);
402 OneDimLagrange::dshape<NNODE_1D>(
s[1], DPsi[1]);
403 OneDimLagrange::d2shape<NNODE_1D>(
s[0], D2Psi[0]);
404 OneDimLagrange::d2shape<NNODE_1D>(
s[1], D2Psi[1]);
407 for (
unsigned i = 0;
i < NNODE_1D;
i++)
409 for (
unsigned j = 0; j < NNODE_1D; j++)
412 psi[index] = Psi[1][
i] * Psi[0][j];
414 dpsids(index, 0) = Psi[1][
i] * DPsi[0][j];
415 dpsids(index, 1) = DPsi[1][
i] * Psi[0][j];
418 d2psids(index, 0) = Psi[1][
i] * D2Psi[0][j];
419 d2psids(index, 1) = D2Psi[1][
i] * Psi[0][j];
420 d2psids(index, 2) = DPsi[1][
i] * DPsi[0][j];
431 template<
unsigned NNODE_1D>
434 output(outfile, NNODE_1D);
440 template<
unsigned NNODE_1D>
442 const unsigned& n_plot)
448 outfile <<
"ZONE I=" << n_plot <<
", J=" << n_plot << std::endl;
451 unsigned n_dim = this->nodal_dimension();
454 for (
unsigned l2 = 0; l2 < n_plot; l2++)
456 s[1] = -1.0 + l2 * 2.0 / (n_plot - 1);
457 for (
unsigned l1 = 0; l1 < n_plot; l1++)
459 s[0] = -1.0 + l1 * 2.0 / (n_plot - 1);
462 for (
unsigned i = 0;
i < n_dim;
i++)
464 outfile << interpolated_x(
s,
i) <<
" ";
466 outfile << std::endl;
469 outfile << std::endl;
476 template<
unsigned NNODE_1D>
479 output(file_pt, NNODE_1D);
485 template<
unsigned NNODE_1D>
492 unsigned n_dim = this->nodal_dimension();
496 fprintf(file_pt,
"ZONE I=%i, J=%i\n", n_plot, n_plot);
499 for (
unsigned l2 = 0; l2 < n_plot; l2++)
501 s[1] = -1.0 + l2 * 2.0 / (n_plot - 1);
502 for (
unsigned l1 = 0; l1 < n_plot; l1++)
504 s[0] = -1.0 + l1 * 2.0 / (n_plot - 1);
507 for (
unsigned i = 0;
i < n_dim;
i++)
510 fprintf(file_pt,
"%g ", interpolated_x(
s,
i));
513 fprintf(file_pt,
"\n");
517 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)
578 return node_pt(index[0] + NNODE_1D * index[1] +
579 NNODE_1D * NNODE_1D * index[2]);
586 template<
unsigned NNODE_1D>
590 double Psi[3][NNODE_1D];
593 OneDimLagrange::shape<NNODE_1D>(
s[0], Psi[0]);
594 OneDimLagrange::shape<NNODE_1D>(
s[1], Psi[1]);
595 OneDimLagrange::shape<NNODE_1D>(
s[2], Psi[2]);
602 for (
unsigned i = 0;
i < NNODE_1D;
i++)
604 for (
unsigned j = 0; j < NNODE_1D; j++)
606 for (
unsigned k = 0; k < NNODE_1D; k++)
609 psi[index] = Psi[2][
i] * Psi[1][j] * Psi[0][k];
620 template<
unsigned NNODE_1D>
626 double Psi[3][NNODE_1D];
627 double DPsi[3][NNODE_1D];
632 OneDimLagrange::shape<NNODE_1D>(
s[0], Psi[0]);
633 OneDimLagrange::shape<NNODE_1D>(
s[1], Psi[1]);
634 OneDimLagrange::shape<NNODE_1D>(
s[2], Psi[2]);
635 OneDimLagrange::dshape<NNODE_1D>(
s[0], DPsi[0]);
636 OneDimLagrange::dshape<NNODE_1D>(
s[1], DPsi[1]);
637 OneDimLagrange::dshape<NNODE_1D>(
s[2], DPsi[2]);
641 for (
unsigned i = 0;
i < NNODE_1D;
i++)
643 for (
unsigned j = 0; j < NNODE_1D; j++)
645 for (
unsigned k = 0; k < NNODE_1D; k++)
648 dpsids(index, 0) = Psi[2][
i] * Psi[1][j] * DPsi[0][k];
649 dpsids(index, 1) = Psi[2][
i] * DPsi[1][j] * Psi[0][k];
650 dpsids(index, 2) = DPsi[2][
i] * Psi[1][j] * Psi[0][k];
652 psi[index] = Psi[2][
i] * Psi[1][j] * Psi[0][k];
669 template<
unsigned NNODE_1D>
676 double Psi[3][NNODE_1D];
677 double DPsi[3][NNODE_1D];
678 double D2Psi[3][NNODE_1D];
683 OneDimLagrange::shape<NNODE_1D>(
s[0], Psi[0]);
684 OneDimLagrange::shape<NNODE_1D>(
s[1], Psi[1]);
685 OneDimLagrange::shape<NNODE_1D>(
s[2], Psi[2]);
686 OneDimLagrange::dshape<NNODE_1D>(
s[0], DPsi[0]);
687 OneDimLagrange::dshape<NNODE_1D>(
s[1], DPsi[1]);
688 OneDimLagrange::dshape<NNODE_1D>(
s[2], DPsi[2]);
689 OneDimLagrange::d2shape<NNODE_1D>(
s[0], D2Psi[0]);
690 OneDimLagrange::d2shape<NNODE_1D>(
s[1], D2Psi[1]);
691 OneDimLagrange::d2shape<NNODE_1D>(
s[2], D2Psi[2]);
694 for (
unsigned i = 0;
i < NNODE_1D;
i++)
696 for (
unsigned j = 0; j < NNODE_1D; j++)
698 for (
unsigned k = 0; k < NNODE_1D; k++)
701 psi[index] = Psi[2][
i] * Psi[1][j] * Psi[0][k];
703 dpsids(index, 0) = Psi[2][
i] * Psi[1][j] * DPsi[0][k];
704 dpsids(index, 1) = Psi[2][
i] * DPsi[1][j] * Psi[0][k];
705 dpsids(index, 2) = DPsi[2][
i] * Psi[1][j] * Psi[0][k];
708 d2psids(index, 0) = Psi[2][
i] * Psi[1][j] * D2Psi[0][k];
709 d2psids(index, 1) = Psi[2][
i] * D2Psi[1][j] * Psi[0][k];
710 d2psids(index, 2) = D2Psi[2][
i] * Psi[1][j] * Psi[0][k];
713 d2psids(index, 3) = Psi[2][
i] * DPsi[1][j] * DPsi[0][k];
714 d2psids(index, 4) = DPsi[2][
i] * Psi[1][j] * DPsi[0][k];
715 d2psids(index, 5) = DPsi[2][
i] * DPsi[1][j] * Psi[0][k];
726 template<
unsigned NNODE_1D>
729 output(outfile, NNODE_1D);
735 template<
unsigned NNODE_1D>
737 const unsigned& n_plot)
743 outfile <<
"ZONE I=" << n_plot <<
", J=" << n_plot <<
", K=" << n_plot
747 unsigned n_dim = this->nodal_dimension();
750 for (
unsigned l3 = 0; l3 < n_plot; l3++)
752 s[2] = -1.0 + l3 * 2.0 / (n_plot - 1);
753 for (
unsigned l2 = 0; l2 < n_plot; l2++)
755 s[1] = -1.0 + l2 * 2.0 / (n_plot - 1);
756 for (
unsigned l1 = 0; l1 < n_plot; l1++)
758 s[0] = -1.0 + l1 * 2.0 / (n_plot - 1);
761 for (
unsigned i = 0;
i < n_dim;
i++)
763 outfile << interpolated_x(
s,
i) <<
" ";
765 outfile << std::endl;
769 outfile << std::endl;
776 template<
unsigned NNODE_1D>
779 output(file_pt, NNODE_1D);
785 template<
unsigned NNODE_1D>
792 fprintf(file_pt,
"ZONE I=%i, J=%i, K=%i\n", n_plot, n_plot, n_plot);
795 unsigned n_dim = this->nodal_dimension();
798 for (
unsigned l3 = 0; l3 < n_plot; l3++)
800 s[2] = -1.0 + l3 * 2.0 / (n_plot - 1);
801 for (
unsigned l2 = 0; l2 < n_plot; l2++)
803 s[1] = -1.0 + l2 * 2.0 / (n_plot - 1);
804 for (
unsigned l1 = 0; l1 < n_plot; l1++)
806 s[0] = -1.0 + l1 * 2.0 / (n_plot - 1);
809 for (
unsigned i = 0;
i < n_dim;
i++)
811 fprintf(file_pt,
"%g ", interpolated_x(
s,
i));
813 fprintf(file_pt,
"\n");
817 fprintf(file_pt,
"\n");
A Class for the derivatives of shape functions The class design is essentially the same as Shape,...
static const double Node_location_tolerance
Default value for the tolerance to be used when locating nodes via local coordinates.
Nodes are derived from Data, but, in addition, have a definite (Eulerian) position in a space of a gi...
static Gauss< 1, NNODE_1D > Default_integration_scheme
Default integration rule: Gaussian integration of same 'order' as the element.
/////////////////////////////////////////////////////////////////////// /////////////////////////////...
A Class for shape functions. In simple cases, the shape functions have only one index that can be tho...
void output()
Doc the command line arguments.
void shape(const double &s, double *Psi)
Definition for 1D Lagrange shape functions. The value of all the shape functions at the local coordin...
//////////////////////////////////////////////////////////////////// ////////////////////////////////...