35 template<
unsigned DIM>
46 template<
unsigned DIM>
51 if ((strain.
ncol() != DIM) || (strain.
nrow() != DIM))
53 std::ostringstream error_message;
54 error_message <<
"Strain matrix is " << strain.
ncol() <<
" x "
55 << strain.
nrow() <<
", but dimension of the equations is "
58 error_message.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
63 const unsigned n_node = nnode();
66 const unsigned n_position_type = this->nnodal_position_type();
69 Shape psi(n_node, n_position_type);
70 DShape dpsidxi(n_node, n_position_type, DIM);
73 (void)dshape_lagrangian(
s, psi, dpsidxi);
79 for (
unsigned i = 0;
i < DIM;
i++)
81 for (
unsigned j = 0; j < DIM; j++)
83 interpolated_G(
i, j) = 0.0;
91 for (
unsigned l = 0; l < n_node; l++)
94 for (
unsigned k = 0; k < n_position_type; k++)
97 for (
unsigned i = 0;
i < DIM;
i++)
100 interpolated_xi[
i] +=
101 this->lagrangian_position_gen(l, k,
i) * psi(l, k);
104 for (
unsigned j = 0; j < DIM; j++)
106 interpolated_G(j,
i) +=
107 this->nodal_position_gen(l, k,
i) * dpsidxi(l, k, j);
117 get_isotropic_growth(ipt,
s, interpolated_xi, gamma);
122 double diag_entry = pow(gamma, 2.0 /
double(DIM));
124 for (
unsigned i = 0;
i < DIM;
i++)
126 for (
unsigned j = 0; j < DIM; j++)
130 g(
i, j) = diag_entry;
144 for (
unsigned i = 0;
i < DIM;
i++)
147 for (
unsigned j =
i; j < DIM; j++)
152 for (
unsigned k = 0; k < DIM; k++)
154 G(
i, j) += interpolated_G(
i, k) * interpolated_G(j, k);
158 for (
unsigned j = 0; j <
i; j++)
165 for (
unsigned i = 0;
i < DIM;
i++)
167 for (
unsigned j = 0; j < DIM; j++)
169 strain(
i, j) = 0.5 * (G(
i, j) - g(
i, j));
178 template<
unsigned DIM>
182 const unsigned& flag)
190 "PVDEquations cannot be used with incompressible constitutive laws.",
191 OOMPH_CURRENT_FUNCTION,
192 OOMPH_EXCEPTION_LOCATION);
197 if (this->Solid_ic_pt != 0)
199 this->fill_in_residuals_for_solid_ic(residuals);
204 const unsigned n_node = this->nnode();
207 const unsigned n_position_type = this->nnodal_position_type();
210 Shape psi(n_node, n_position_type);
211 DShape dpsidxi(n_node, n_position_type, DIM);
214 const unsigned n_intpt = this->integral_pt()->nweight();
220 double lambda_sq = this->lambda_sq();
223 double time_factor = 0.0;
226 time_factor = this->node_pt(0)->position_time_stepper_pt()->weight(2, 0);
233 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
236 for (
unsigned i = 0;
i < DIM; ++
i)
238 s[
i] = this->integral_pt()->knot(ipt,
i);
242 double w = this->integral_pt()->weight(ipt);
245 double J = this->dshape_lagrangian_at_knot(ipt, psi, dpsidxi);
255 for (
unsigned i = 0;
i < DIM;
i++)
259 for (
unsigned j = 0; j < DIM; j++)
261 interpolated_G(
i, j) = 0.0;
269 for (
unsigned l = 0; l < n_node; l++)
272 for (
unsigned k = 0; k < n_position_type; k++)
274 double psi_ = psi(l, k);
276 for (
unsigned i = 0;
i < DIM;
i++)
279 interpolated_xi[
i] += this->lagrangian_position_gen(l, k,
i) * psi_;
282 if ((lambda_sq > 0.0) && (this->Unsteady))
284 accel[
i] += this->dnodal_position_gen_dt(2, l, k,
i) * psi_;
288 for (
unsigned j = 0; j < DIM; j++)
290 interpolated_G(j,
i) +=
291 this->nodal_position_gen(l, k,
i) * dpsidxi(l, k, j);
299 this->get_isotropic_growth(ipt,
s, interpolated_xi, gamma);
304 this->body_force(interpolated_xi, b);
309 double diag_entry = pow(gamma, 2.0 /
double(DIM));
311 for (
unsigned i = 0;
i < DIM;
i++)
313 for (
unsigned j = 0; j < DIM; j++)
317 g(
i, j) = diag_entry;
328 double W = gamma * w * J;
334 for (
unsigned i = 0;
i < DIM;
i++)
337 for (
unsigned j =
i; j < DIM; j++)
342 for (
unsigned k = 0; k < DIM; k++)
344 G(
i, j) += interpolated_G(
i, k) * interpolated_G(j, k);
348 for (
unsigned j = 0; j <
i; j++)
356 get_stress(g, G, sigma);
359 for (
unsigned i = 0;
i < DIM;
i++)
361 for (
unsigned j = 0; j < DIM; j++)
363 sigma(
i, j) += this->prestress(
i, j, interpolated_xi);
374 n_node, n_position_type, DIM, DIM, DIM, 0.0);
384 for (
unsigned ll = 0; ll < n_node; ll++)
386 for (
unsigned kk = 0; kk < n_position_type; kk++)
388 for (
unsigned ii = 0; ii < DIM; ii++)
390 for (
unsigned aa = 0; aa < DIM; aa++)
392 for (
unsigned bb = aa; bb < DIM; bb++)
394 d_G_dX(ll, kk, ii, aa, bb) =
395 interpolated_G(aa, ii) * dpsidxi(ll, kk, bb) +
396 interpolated_G(bb, ii) * dpsidxi(ll, kk, aa);
405 this->get_d_stress_dG_upper(g, G, sigma, d_stress_dG);
412 for (
unsigned l = 0; l < n_node; l++)
415 for (
unsigned k = 0; k < n_position_type; k++)
418 const unsigned offset5 = dpsidxi.
offset(l, k);
421 for (
unsigned i = 0;
i < DIM;
i++)
424 local_eqn = this->position_local_eqn(l, k,
i);
433 sum += (lambda_sq * accel[
i] - b[
i]) * psi(l, k);
436 for (
unsigned a = 0; a < DIM; a++)
438 unsigned count = offset5;
439 for (
unsigned b = 0; b < DIM; b++)
442 sum += sigma(a, b) * interpolated_G(a,
i) *
447 residuals[local_eqn] +=
W * sum;
453 const unsigned offset1 = d_G_dX.
offset(l, k,
i);
456 for (
unsigned ll = 0; ll < n_node; ll++)
459 for (
unsigned kk = 0; kk < n_position_type; kk++)
462 for (
unsigned ii = 0; ii < DIM; ii++)
465 int local_unknown = this->position_local_eqn(ll, kk, ii);
468 if (local_unknown >= 0)
471 const unsigned offset2 = d_G_dX.
offset(ll, kk, ii);
472 const unsigned offset4 = dpsidxi.
offset(ll, kk);
477 unsigned count1 = offset1;
478 for (
unsigned a = 0; a < DIM; a++)
483 for (
unsigned b = a; b < DIM; b++)
486 if (a == b) factor *= 0.5;
489 unsigned offset3 = d_stress_dG.
offset(a, b);
490 unsigned count2 = offset2;
491 unsigned count3 = offset3;
493 for (
unsigned aa = 0; aa < DIM; aa++)
502 for (
unsigned bb = aa; bb < DIM; bb++)
517 jacobian(local_eqn, local_unknown) += sum *
W;
521 if ((
i == ii) && (local_unknown >= local_eqn))
528 lambda_sq * time_factor * psi(ll, kk) * psi(l, k);
531 unsigned count4 = offset4;
532 for (
unsigned a = 0; a < DIM; a++)
535 const double factor =
539 unsigned count5 = offset5;
540 for (
unsigned b = 0; b < DIM; b++)
542 sum += sigma(a, b) * factor *
548 jacobian(local_eqn, local_unknown) += sum *
W;
550 if (local_eqn != local_unknown)
552 jacobian(local_unknown, local_eqn) += sum *
W;
574 template<
unsigned DIM>
582 outfile << this->tecplot_zone_string(n_plot);
585 unsigned num_plot_points = this->nplot_points(n_plot);
586 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
589 this->get_s_plot(iplot, n_plot,
s);
592 this->interpolated_x(
s, x);
593 this->interpolated_xi(
s, xi);
599 this->get_isotropic_growth(ipt,
s, xi, gamma);
602 for (
unsigned i = 0;
i < DIM;
i++)
604 outfile << x[
i] <<
" ";
608 for (
unsigned i = 0;
i < DIM;
i++)
610 outfile << xi[
i] <<
" ";
615 outfile << std::endl;
620 this->write_tecplot_zone_footer(outfile, n_plot);
621 outfile << std::endl;
628 template<
unsigned DIM>
642 fprintf(file_pt,
"ZONE I=%i, J=%i\n", n_plot, n_plot);
645 for (
unsigned l2 = 0; l2 < n_plot; l2++)
647 s[1] = -1.0 + l2 * 2.0 / (n_plot - 1);
648 for (
unsigned l1 = 0; l1 < n_plot; l1++)
650 s[0] = -1.0 + l1 * 2.0 / (n_plot - 1);
653 this->interpolated_x(
s, x);
654 this->interpolated_xi(
s, xi);
660 this->get_isotropic_growth(ipt,
s, xi, gamma);
663 for (
unsigned i = 0;
i < DIM;
i++)
666 fprintf(file_pt,
"%g ", x[
i]);
669 for (
unsigned i = 0;
i < DIM;
i++)
672 fprintf(file_pt,
"%g ", xi[
i]);
677 fprintf(file_pt,
"%g \n", gamma);
681 fprintf(file_pt,
"\n");
689 fprintf(file_pt,
"ZONE I=%i, J=%i, K=%i \n", n_plot, n_plot, n_plot);
692 for (
unsigned l3 = 0; l3 < n_plot; l3++)
694 s[2] = -1.0 + l3 * 2.0 / (n_plot - 1);
695 for (
unsigned l2 = 0; l2 < n_plot; l2++)
697 s[1] = -1.0 + l2 * 2.0 / (n_plot - 1);
698 for (
unsigned l1 = 0; l1 < n_plot; l1++)
700 s[0] = -1.0 + l1 * 2.0 / (n_plot - 1);
703 this->interpolated_x(
s, x);
704 this->interpolated_xi(
s, xi);
710 this->get_isotropic_growth(ipt,
s, xi, gamma);
713 for (
unsigned i = 0;
i < DIM;
i++)
716 fprintf(file_pt,
"%g ", x[
i]);
719 for (
unsigned i = 0;
i < DIM;
i++)
722 fprintf(file_pt,
"%g ", xi[
i]);
727 fprintf(file_pt,
"%g \n", gamma);
732 fprintf(file_pt,
"\n");
737 std::ostringstream error_message;
738 error_message <<
"No output routine for PVDEquations<" << DIM
739 <<
"> elements -- write it yourself!" << std::endl;
741 OOMPH_CURRENT_FUNCTION,
742 OOMPH_EXCEPTION_LOCATION);
750 template<
unsigned DIM>
752 const unsigned& n_plot)
760 outfile << this->tecplot_zone_string(n_plot);
763 unsigned num_plot_points = this->nplot_points(n_plot);
764 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
767 this->get_s_plot(iplot, n_plot,
s);
770 this->interpolated_x(
s, x);
771 this->interpolated_xi(
s, xi);
777 this->get_isotropic_growth(ipt,
s, xi, gamma);
780 for (
unsigned i = 0;
i < DIM;
i++)
782 outfile << x[
i] <<
" ";
786 for (
unsigned i = 0;
i < DIM;
i++)
788 outfile << xi[
i] <<
" ";
792 outfile << gamma <<
" ";
795 this->get_strain(
s, stress_or_strain);
796 for (
unsigned i = 0;
i < DIM;
i++)
798 for (
unsigned j = 0; j <=
i; j++)
800 outfile << stress_or_strain(j,
i) <<
" ";
805 this->get_stress(
s, stress_or_strain);
806 for (
unsigned i = 0;
i < DIM;
i++)
808 for (
unsigned j = 0; j <=
i; j++)
810 outfile << stress_or_strain(j,
i) <<
" ";
815 outfile << std::endl;
820 this->write_tecplot_zone_footer(outfile, n_plot);
821 outfile << std::endl;
828 template<
unsigned DIM>
836 unsigned n_intpt = this->integral_pt()->nweight();
842 const unsigned n_node = this->nnode();
845 const unsigned n_position_type = this->nnodal_position_type();
848 Shape psi(n_node, n_position_type);
849 DShape dpsidxi(n_node, n_position_type, DIM);
852 double lambda_sq = this->lambda_sq();
855 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
858 for (
unsigned i = 0;
i < DIM;
i++)
860 s[
i] = this->integral_pt()->knot(ipt,
i);
864 double w = this->integral_pt()->weight(ipt);
867 double J = this->dshape_lagrangian_at_knot(ipt, psi, dpsidxi);
874 for (
unsigned l = 0; l < n_node; l++)
877 for (
unsigned k = 0; k < n_position_type; k++)
880 for (
unsigned i = 0;
i < DIM;
i++)
883 interpolated_xi[
i] +=
884 this->lagrangian_position_gen(l, k,
i) * psi(l, k);
889 veloc[
i] += this->dnodal_position_gen_dt(l, k,
i) * psi(l, k);
897 this->get_isotropic_growth(ipt,
s, interpolated_xi, gamma);
901 double W = gamma * w * J;
907 this->get_stress(
s, sigma);
910 for (
unsigned i = 0;
i < DIM;
i++)
912 for (
unsigned j = 0; j < DIM; j++)
914 sigma(
i, j) += prestress(
i, j, interpolated_xi);
919 this->get_strain(
s, strain);
922 double local_pot_en = 0;
926 for (
unsigned i = 0;
i < DIM;
i++)
928 for (
unsigned j = 0; j < DIM; j++)
930 local_pot_en += sigma(
i, j) * strain(
i, j);
932 veloc_sq += veloc[
i] * veloc[
i];
935 pot_en += 0.5 * local_pot_en *
W;
936 kin_en += lambda_sq * 0.5 * veloc_sq *
W;
950 template<
unsigned DIM>
955 unsigned n_node = this->nnode();
958 unsigned n_position_type = this->nnodal_position_type();
961 Shape psi(n_node, n_position_type);
962 DShape dpsidxi(n_node, n_position_type, DIM);
965 (void)this->dshape_lagrangian(
s, psi, dpsidxi);
969 this->interpolated_xi(
s, xi);
975 this->get_isotropic_growth(ipt,
s, xi, gamma);
980 double diag_entry = pow(gamma, 2.0 /
double(DIM));
982 for (
unsigned i = 0;
i < DIM;
i++)
984 for (
unsigned j = 0; j < DIM; j++)
988 g(
i, j) = diag_entry;
1003 for (
unsigned i = 0;
i < DIM;
i++)
1005 for (
unsigned j = 0; j < DIM; j++)
1007 interpolated_G(
i, j) = 0.0;
1012 for (
unsigned l = 0; l < n_node; l++)
1015 for (
unsigned k = 0; k < n_position_type; k++)
1018 for (
unsigned i = 0;
i < DIM;
i++)
1021 for (
unsigned j = 0; j < DIM; j++)
1023 interpolated_G(j,
i) +=
1024 this->nodal_position_gen(l, k,
i) * dpsidxi(l, k, j);
1033 for (
unsigned i = 0;
i < DIM;
i++)
1038 for (
int j = (DIM - 1); j >=
static_cast<int>(
i); j--)
1043 for (
unsigned k = 0; k < DIM; k++)
1045 G(
i, j) += interpolated_G(
i, k) * interpolated_G(j, k);
1049 for (
int j = (
i - 1); j >= 0; j--)
1056 get_stress(g, G, sigma);
1070 template<
unsigned DIM>
1078 get_stress(
s, sigma);
1082 this->interpolated_xi(
s, xi);
1085 for (
unsigned i = 0;
i < DIM;
i++)
1087 for (
unsigned j = 0; j < DIM; j++)
1089 sigma(
i, j) += this->prestress(
i, j, xi);
1095 get_deformed_covariant_basis_vectors(
s, lower_deformed_basis);
1099 for (
unsigned i = 0;
i < DIM;
i++)
1101 for (
unsigned j = 0; j < DIM; j++)
1103 lower_metric(
i, j) = 0.0;
1104 for (
unsigned k = 0; k < DIM; k++)
1106 lower_metric(
i, j) +=
1107 lower_deformed_basis(
i, k) * lower_deformed_basis(j, k);
1118 for (
unsigned k = 0; k < DIM; k++)
1120 for (
unsigned l = 0; l < DIM; l++)
1122 rhs[l] = lower_deformed_basis(l, k);
1125 lower_metric.
solve(rhs, aux);
1127 for (
unsigned l = 0; l < DIM; l++)
1129 upper_deformed_basis(l, k) = aux[l];
1146 for (
unsigned i = 0;
i < DIM;
i++)
1149 for (
unsigned j = 0; j < DIM; j++)
1151 principal_stress_vector(j,
i) = 0.0;
1155 for (
unsigned j = 0; j < DIM; j++)
1157 for (
unsigned k = 0; k < DIM; k++)
1159 principal_stress_vector(j,
i) +=
1160 upper_deformed_basis(k,
i) * ev(j, k);
1167 for (
unsigned i = 0;
i < DIM;
i++)
1170 for (
unsigned j = 0; j < DIM; j++)
1172 norm[
i] += pow(principal_stress_vector(
i, j), 2);
1174 norm[
i] = sqrt(norm[
i]);
1180 for (
unsigned i = 0;
i < DIM;
i++)
1182 for (
unsigned j = 0; j < DIM; j++)
1184 principal_stress_vector(j,
i) =
1185 ev(j,
i) / norm[j] * principal_stress[j];
1196 template<
unsigned DIM>
1201 unsigned n_node = nnode();
1204 unsigned n_position_type = this->nnodal_position_type();
1207 Shape psi(n_node, n_position_type);
1208 DShape dpsidxi(n_node, n_position_type, DIM);
1212 (void)dshape_lagrangian(
s, psi, dpsidxi);
1216 for (
unsigned i = 0;
i < DIM;
i++)
1218 for (
unsigned j = 0; j < DIM; j++)
1220 def_covariant_basis(
i, j) = 0.0;
1225 for (
unsigned l = 0; l < n_node; l++)
1228 for (
unsigned k = 0; k < n_position_type; k++)
1231 for (
unsigned i = 0;
i < DIM;
i++)
1234 for (
unsigned j = 0; j < DIM; j++)
1236 def_covariant_basis(j,
i) +=
1237 nodal_position_gen(l, k,
i) * dpsidxi(l, k, j);
1254 template<
unsigned DIM>
1269 template<
unsigned DIM>
1275 const unsigned& flag)
1283 throw OomphLibError(
"The constitutive law requires the use of the "
1284 "incompressible formulation by setting the element's "
1285 "member function set_incompressible()",
1286 OOMPH_CURRENT_FUNCTION,
1287 OOMPH_EXCEPTION_LOCATION);
1293 if (this->Solid_ic_pt != 0)
1295 this->get_residuals_for_solid_ic(residuals);
1300 const unsigned n_node = this->nnode();
1303 const unsigned n_position_type = this->nnodal_position_type();
1306 const unsigned n_solid_pres = this->npres_solid();
1309 Shape psi(n_node, n_position_type);
1310 DShape dpsidxi(n_node, n_position_type, DIM);
1313 Shape psisp(n_solid_pres);
1316 const unsigned n_intpt = this->integral_pt()->nweight();
1322 double lambda_sq = this->lambda_sq();
1325 double time_factor = 0.0;
1328 time_factor = this->node_pt(0)->position_time_stepper_pt()->weight(2, 0);
1332 int local_eqn = 0, local_unknown = 0;
1335 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
1338 for (
unsigned i = 0;
i < DIM; ++
i)
1340 s[
i] = this->integral_pt()->knot(ipt,
i);
1344 double w = this->integral_pt()->weight(ipt);
1347 double J = this->dshape_lagrangian_at_knot(ipt, psi, dpsidxi);
1350 solid_pshape_at_knot(ipt, psisp);
1362 for (
unsigned i = 0;
i < DIM;
i++)
1366 for (
unsigned j = 0; j < DIM; j++)
1368 interpolated_G(
i, j) = 0.0;
1373 for (
unsigned l = 0; l < n_node; l++)
1376 for (
unsigned k = 0; k < n_position_type; k++)
1379 for (
unsigned i = 0;
i < DIM;
i++)
1382 interpolated_xi[
i] +=
1383 this->lagrangian_position_gen(l, k,
i) * psi(l, k);
1388 if ((lambda_sq > 0.0) && (this->Unsteady))
1390 accel[
i] += this->dnodal_position_gen_dt(2, l, k,
i) * psi(l, k);
1394 for (
unsigned j = 0; j < DIM; j++)
1396 interpolated_G(j,
i) +=
1397 this->nodal_position_gen(l, k,
i) * dpsidxi(l, k, j);
1405 this->get_isotropic_growth(ipt,
s, interpolated_xi, gamma);
1409 this->body_force(interpolated_xi, b);
1414 double diag_entry = pow(gamma, 2.0 /
double(DIM));
1416 for (
unsigned i = 0;
i < DIM;
i++)
1418 for (
unsigned j = 0; j < DIM; j++)
1422 g(
i, j) = diag_entry;
1433 double W = gamma * w * J;
1436 double interpolated_solid_p = 0.0;
1437 for (
unsigned l = 0; l < n_solid_pres; l++)
1439 interpolated_solid_p += solid_p(l) * psisp[l];
1447 for (
unsigned i = 0;
i < DIM;
i++)
1450 for (
unsigned j =
i; j < DIM; j++)
1455 for (
unsigned k = 0; k < DIM; k++)
1457 G(
i, j) += interpolated_G(
i, k) * interpolated_G(j, k);
1461 for (
unsigned j = 0; j <
i; j++)
1471 double gen_dil = 0.0;
1472 double inv_kappa = 0.0;
1483 n_node, n_position_type, DIM, DIM, DIM, 0.0);
1486 if ((flag == 1) || (flag == 3))
1493 for (
unsigned ll = 0; ll < n_node; ll++)
1495 for (
unsigned kk = 0; kk < n_position_type; kk++)
1497 for (
unsigned ii = 0; ii < DIM; ii++)
1499 for (
unsigned aa = 0; aa < DIM; aa++)
1501 for (
unsigned bb = aa; bb < DIM; bb++)
1503 d_G_dX(ll, kk, ii, aa, bb) =
1504 interpolated_G(aa, ii) * dpsidxi(ll, kk, bb) +
1505 interpolated_G(bb, ii) * dpsidxi(ll, kk, aa);
1519 get_stress(g, G, sigma_dev, Gup, detG);
1522 for (
unsigned a = 0; a < DIM; a++)
1524 for (
unsigned b = 0; b < DIM; b++)
1526 sigma(a, b) = sigma_dev(a, b) - interpolated_solid_p * Gup(a, b);
1531 if ((flag == 1) || (flag == 3))
1535 this->get_d_stress_dG_upper(
1536 g, G, sigma, detG, interpolated_solid_p, d_stress_dG, d_detG_dG);
1544 get_stress(g, G, sigma_dev, Gup, gen_dil, inv_kappa);
1547 for (
unsigned a = 0; a < DIM; a++)
1549 for (
unsigned b = 0; b < DIM; b++)
1551 sigma(a, b) = sigma_dev(a, b) - interpolated_solid_p * Gup(a, b);
1556 if ((flag == 1) || (flag == 3))
1560 this->get_d_stress_dG_upper(g,
1565 interpolated_solid_p,
1572 for (
unsigned i = 0;
i < DIM;
i++)
1574 for (
unsigned j = 0; j < DIM; j++)
1576 sigma(
i, j) += this->prestress(
i, j, interpolated_xi);
1584 for (
unsigned l = 0; l < n_node; l++)
1587 for (
unsigned k = 0; k < n_position_type; k++)
1590 const unsigned offset5 = dpsidxi.
offset(l, k);
1593 for (
unsigned i = 0;
i < DIM;
i++)
1596 local_eqn = this->position_local_eqn(l, k,
i);
1605 sum += (lambda_sq * accel[
i] - b[
i]) * psi(l, k);
1608 for (
unsigned a = 0; a < DIM; a++)
1610 unsigned count = offset5;
1611 for (
unsigned b = 0; b < DIM; b++)
1614 sum += sigma(a, b) * interpolated_G(a,
i) *
1619 residuals[local_eqn] +=
W * sum;
1625 for (
unsigned ll = 0; ll < n_node; ll++)
1628 for (
unsigned kk = 0; kk < n_position_type; kk++)
1631 int local_unknown = this->position_local_eqn(ll, kk,
i);
1634 if (local_unknown >= 0)
1636 mass_matrix(local_eqn, local_unknown) +=
1637 lambda_sq * psi(l, k) * psi(ll, kk) *
W;
1644 if ((flag == 1) || (flag == 3))
1647 const unsigned offset1 = d_G_dX.
offset(l, k,
i);
1650 for (
unsigned ll = 0; ll < n_node; ll++)
1653 for (
unsigned kk = 0; kk < n_position_type; kk++)
1656 for (
unsigned ii = 0; ii < DIM; ii++)
1659 int local_unknown = this->position_local_eqn(ll, kk, ii);
1662 if (local_unknown >= 0)
1665 const unsigned offset2 = d_G_dX.
offset(ll, kk, ii);
1666 const unsigned offset4 = dpsidxi.
offset(ll, kk);
1671 unsigned count1 = offset1;
1672 for (
unsigned a = 0; a < DIM; a++)
1677 for (
unsigned b = a; b < DIM; b++)
1680 if (a == b) factor *= 0.5;
1683 unsigned offset3 = d_stress_dG.
offset(a, b);
1684 unsigned count2 = offset2;
1685 unsigned count3 = offset3;
1687 for (
unsigned aa = 0; aa < DIM; aa++)
1696 for (
unsigned bb = aa; bb < DIM; bb++)
1711 jacobian(local_eqn, local_unknown) += sum *
W;
1715 if ((
i == ii) && (local_unknown >= local_eqn))
1722 lambda_sq * time_factor * psi(ll, kk) * psi(l, k);
1725 unsigned count4 = offset4;
1726 for (
unsigned a = 0; a < DIM; a++)
1729 const double factor =
1733 unsigned count5 = offset5;
1734 for (
unsigned b = 0; b < DIM; b++)
1736 sum += sigma(a, b) * factor *
1743 jacobian(local_eqn, local_unknown) += sum *
W;
1745 if (local_eqn != local_unknown)
1747 jacobian(local_unknown, local_eqn) += sum *
W;
1760 for (
unsigned l2 = 0; l2 < n_solid_pres; l2++)
1762 local_unknown = this->solid_p_local_eqn(l2);
1765 if (local_unknown >= 0)
1768 for (
unsigned a = 0; a < DIM; a++)
1770 for (
unsigned b = 0; b < DIM; b++)
1772 jacobian(local_eqn, local_unknown) -=
1773 psisp[l2] * Gup(a, b) * interpolated_G(a,
i) *
1774 dpsidxi(l, k, b) *
W;
1789 for (
unsigned l = 0; l < n_solid_pres; l++)
1791 local_eqn = this->solid_p_local_eqn(l);
1802 residuals[local_eqn] += (detG - gamma) * psisp[l] *
W;
1806 if ((flag == 1) || (flag == 3))
1809 for (
unsigned ll = 0; ll < n_node; ll++)
1812 for (
unsigned kk = 0; kk < n_position_type; kk++)
1815 for (
unsigned ii = 0; ii < DIM; ii++)
1818 int local_unknown = this->position_local_eqn(ll, kk, ii);
1821 if (local_unknown >= 0)
1824 const unsigned offset = d_G_dX.
offset(ll, kk, ii);
1828 unsigned count = offset;
1829 for (
unsigned aa = 0; aa < DIM; aa++)
1836 for (
unsigned bb = aa; bb < DIM; bb++)
1838 sum += d_detG_dG(aa, bb) *
1843 jacobian(local_eqn, local_unknown) += sum *
W;
1857 residuals[local_eqn] +=
1858 (inv_kappa * interpolated_solid_p + gen_dil) * psisp[l] *
W;
1861 if ((flag == 1) || (flag == 3))
1864 for (
unsigned ll = 0; ll < n_node; ll++)
1867 for (
unsigned kk = 0; kk < n_position_type; kk++)
1870 for (
unsigned ii = 0; ii < DIM; ii++)
1873 int local_unknown = this->position_local_eqn(ll, kk, ii);
1876 if (local_unknown >= 0)
1879 const unsigned offset = d_G_dX.
offset(ll, kk, ii);
1883 unsigned count = offset;
1884 for (
unsigned aa = 0; aa < DIM; aa++)
1891 for (
unsigned bb = aa; bb < DIM; bb++)
1893 sum += d_gen_dil_dG(aa, bb) *
1898 jacobian(local_eqn, local_unknown) += sum *
W;
1909 for (
unsigned l2 = 0; l2 < n_solid_pres; l2++)
1911 local_unknown = this->solid_p_local_eqn(l2);
1913 if (local_unknown >= 0)
1915 jacobian(local_eqn, local_unknown) +=
1916 inv_kappa * psisp[l2] * psisp[l] *
W;
1933 template<
unsigned DIM>
1935 const unsigned& n_plot)
1943 outfile << this->tecplot_zone_string(n_plot);
1946 unsigned num_plot_points = this->nplot_points(n_plot);
1947 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
1950 this->get_s_plot(iplot, n_plot,
s);
1953 this->interpolated_x(
s, x);
1954 this->interpolated_xi(
s, xi);
1960 this->get_isotropic_growth(ipt,
s, xi, gamma);
1963 for (
unsigned i = 0;
i < DIM;
i++)
1965 outfile << x[
i] <<
" ";
1969 for (
unsigned i = 0;
i < DIM;
i++)
1971 outfile << xi[
i] <<
" ";
1975 outfile << gamma <<
" ";
1977 outfile << interpolated_solid_p(
s) <<
" ";
1982 this->write_tecplot_zone_footer(outfile, n_plot);
1989 template<
unsigned DIM>
1991 const unsigned& n_plot)
2003 fprintf(file_pt,
"ZONE I=%i, J=%i\n", n_plot, n_plot);
2006 for (
unsigned l2 = 0; l2 < n_plot; l2++)
2008 s[1] = -1.0 + l2 * 2.0 / (n_plot - 1);
2009 for (
unsigned l1 = 0; l1 < n_plot; l1++)
2011 s[0] = -1.0 + l1 * 2.0 / (n_plot - 1);
2014 this->interpolated_x(
s, x);
2015 this->interpolated_xi(
s, xi);
2021 this->get_isotropic_growth(ipt,
s, xi, gamma);
2024 for (
unsigned i = 0;
i < DIM;
i++)
2027 fprintf(file_pt,
"%g ", x[
i]);
2030 for (
unsigned i = 0;
i < DIM;
i++)
2033 fprintf(file_pt,
"%g ", xi[
i]);
2037 fprintf(file_pt,
"%g ", gamma);
2042 fprintf(file_pt,
"%g \n", interpolated_solid_p(
s));
2053 fprintf(file_pt,
"ZONE I=%i, J=%i, K=%i \n", n_plot, n_plot, n_plot);
2056 for (
unsigned l3 = 0; l3 < n_plot; l3++)
2058 s[2] = -1.0 + l3 * 2.0 / (n_plot - 1);
2059 for (
unsigned l2 = 0; l2 < n_plot; l2++)
2061 s[1] = -1.0 + l2 * 2.0 / (n_plot - 1);
2062 for (
unsigned l1 = 0; l1 < n_plot; l1++)
2064 s[0] = -1.0 + l1 * 2.0 / (n_plot - 1);
2067 this->interpolated_x(
s, x);
2068 this->interpolated_xi(
s, xi);
2074 this->get_isotropic_growth(ipt,
s, xi, gamma);
2077 for (
unsigned i = 0;
i < DIM;
i++)
2080 fprintf(file_pt,
"%g ", x[
i]);
2083 for (
unsigned i = 0;
i < DIM;
i++)
2086 fprintf(file_pt,
"%g ", xi[
i]);
2090 fprintf(file_pt,
"%g ", gamma);
2095 fprintf(file_pt,
"%g \n", interpolated_solid_p(
s));
2102 std::ostringstream error_message;
2103 error_message <<
"No output routine for PVDEquationsWithPressure<"
2104 << DIM <<
"> elements. Write it yourself!" << std::endl;
2106 OOMPH_CURRENT_FUNCTION,
2107 OOMPH_EXCEPTION_LOCATION);
2115 template<
unsigned DIM>
2117 const unsigned& n_plot)
2125 outfile << this->tecplot_zone_string(n_plot);
2128 unsigned num_plot_points = this->nplot_points(n_plot);
2129 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
2132 this->get_s_plot(iplot, n_plot,
s);
2135 this->interpolated_x(
s, x);
2136 this->interpolated_xi(
s, xi);
2142 this->get_isotropic_growth(ipt,
s, xi, gamma);
2145 for (
unsigned i = 0;
i < DIM;
i++)
2147 outfile << x[
i] <<
" ";
2151 for (
unsigned i = 0;
i < DIM;
i++)
2153 outfile << xi[
i] <<
" ";
2157 outfile << gamma <<
" ";
2160 outfile << interpolated_solid_p(
s) <<
" ";
2163 this->get_strain(
s, stress_or_strain);
2164 for (
unsigned i = 0;
i < DIM;
i++)
2166 for (
unsigned j = 0; j <=
i; j++)
2168 outfile << stress_or_strain(j,
i) <<
" ";
2173 this->get_stress(
s, stress_or_strain);
2174 for (
unsigned i = 0;
i < DIM;
i++)
2176 for (
unsigned j = 0; j <=
i; j++)
2178 outfile << stress_or_strain(j,
i) <<
" ";
2183 outfile << std::endl;
2188 this->write_tecplot_zone_footer(outfile, n_plot);
2189 outfile << std::endl;
2197 template<
unsigned DIM>
2202 mass_diag.assign(this->ndof(), 0.0);
2205 unsigned n_node = this->nnode();
2208 const unsigned n_position_type = this->nnodal_position_type();
2211 Shape psi(n_node, n_position_type);
2212 DShape dpsidxi(n_node, n_position_type, DIM);
2215 unsigned n_intpt = this->integral_pt()->nweight();
2221 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
2224 double w = this->integral_pt()->weight(ipt);
2227 double J = this->dshape_lagrangian_at_knot(ipt, psi, dpsidxi);
2233 for (
unsigned l = 0; l < n_node; l++)
2236 for (
unsigned k = 0; k < n_position_type; k++)
2239 for (
unsigned i = 0;
i < DIM;
i++)
2242 local_eqn = this->position_local_eqn(l, k,
i);
2248 mass_diag[local_eqn] += pow(psi(l, k), 2) *
W;
2266 template<
unsigned DIM>
2271 unsigned n_node = this->nnode();
2274 unsigned n_position_type = this->nnodal_position_type();
2277 unsigned n_solid_pres = this->npres_solid();
2280 Shape psi(n_node, n_position_type);
2281 DShape dpsidxi(n_node, n_position_type, DIM);
2284 Shape psisp(n_solid_pres);
2287 solid_pshape(
s, psisp);
2290 (void)this->dshape_lagrangian(
s, psi, dpsidxi);
2294 this->interpolated_xi(
s, xi);
2300 this->get_isotropic_growth(ipt,
s, xi, gamma);
2305 double diag_entry = pow(gamma, 2.0 /
double(DIM));
2307 for (
unsigned i = 0;
i < DIM;
i++)
2309 for (
unsigned j = 0; j < DIM; j++)
2313 g(
i, j) = diag_entry;
2328 for (
unsigned i = 0;
i < DIM;
i++)
2330 for (
unsigned j = 0; j < DIM; j++)
2332 interpolated_G(
i, j) = 0.0;
2337 for (
unsigned l = 0; l < n_node; l++)
2340 for (
unsigned k = 0; k < n_position_type; k++)
2343 for (
unsigned i = 0;
i < DIM;
i++)
2346 for (
unsigned j = 0; j < DIM; j++)
2348 interpolated_G(j,
i) +=
2349 this->nodal_position_gen(l, k,
i) * dpsidxi(l, k, j);
2359 for (
unsigned i = 0;
i < DIM;
i++)
2364 for (
int j = (DIM - 1); j >=
static_cast<int>(
i); j--)
2369 for (
unsigned k = 0; k < DIM; k++)
2371 G(
i, j) += interpolated_G(
i, k) * interpolated_G(j, k);
2375 for (
int j = (
i - 1); j >= 0; j--)
2383 double interpolated_solid_p = 0.0;
2384 for (
unsigned l = 0; l < n_solid_pres; l++)
2386 interpolated_solid_p += solid_p(l) * psisp[l];
2393 double gen_dil = 0.0;
2394 double inv_kappa = 0.0;
2402 get_stress(g, G, sigma_dev, Gup, detG);
2409 get_stress(g, G, sigma_dev, Gup, gen_dil, inv_kappa);
2413 for (
unsigned i = 0;
i < DIM;
i++)
2415 for (
unsigned j = 0; j < DIM; j++)
2417 sigma(
i, j) = -interpolated_solid_p * Gup(
i, j) + sigma_dev(
i, j);
2433 1, 0, 1, 0, 0, 0, 1, 0, 1};
2446 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0,
2447 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1};
2454 0, 2, 6, 8, 18, 20, 24, 26};
2479 1, 1, 1, 1, 0, 0, 0, 0, 0, 0};
virtual bool requires_incompressibility_constraint()=0
Pure virtual function in which the user must declare if the constitutive equation requires an incompr...
A Class for the derivatives of shape functions The class design is essentially the same as Shape,...
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....
Class of matrices containing doubles, and stored as a DenseMatrix<double>, but with solving functiona...
void eigenvalues_by_jacobi(Vector< double > &eigen_val, DenseMatrix< double > &eigen_vect) const
Determine eigenvalues and eigenvectors, using Jacobi rotations. Only for symmetric matrices....
unsigned long nrow() const
Return the number of rows of the matrix.
unsigned long ncol() const
Return the number of columns of the matrix.
void solve(DoubleVector &rhs)
Complete LU solve (replaces matrix by its LU decomposition and overwrites RHS with solution)....
An OomphLibError object which should be thrown when an run-time error is encountered....
A base class for elements that solve the equations of solid mechanics, based on the principle of virt...
void get_energy(double &pot_en, double &kin_en)
Get potential (strain) and kinetic energy.
static double Default_lambda_sq_value
Static default value for timescale ratio (1.0 – for natural scaling)
void get_principal_stress(const Vector< double > &s, DenseMatrix< double > &principal_stress_vector, Vector< double > &principal_stress)
Compute principal stress vectors and (scalar) principal stresses at specified local coordinate....
void get_deformed_covariant_basis_vectors(const Vector< double > &s, DenseMatrix< double > &def_covariant_basis)
Return the deformed covariant basis vectors at specified local coordinate: def_covariant_basis(i,...
void get_strain(const Vector< double > &s, DenseMatrix< double > &strain) const
Return the strain tensor.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
void get_stress(const Vector< double > &s, DenseMatrix< double > &sigma)
Return the 2nd Piola Kirchoff stress tensor, as calculated from the constitutive law at specified loc...
void output(std::ostream &outfile)
Output: x,y,[z],xi0,xi1,[xi2],p,gamma.
virtual void fill_in_generic_residual_contribution_pvd_with_pressure(Vector< double > &residuals, DenseMatrix< double > &jacobian, DenseMatrix< double > &mass_matrix, const unsigned &flag)
Returns the residuals for the discretised principle of virtual displacements, formulated in the incom...
void extended_output(std::ostream &outfile, const unsigned &n_plot)
Output: x,y,[z],xi0,xi1,[xi2],gamma and the strain and stress components.
void get_mass_matrix_diagonal(Vector< double > &mass_diag)
Compute the diagonal of the displacement mass matrix for LSC preconditioner.
A class for elements that solve the equations of solid mechanics, based on the principle of virtual d...
virtual void fill_in_generic_contribution_to_residuals_pvd(Vector< double > &residuals, DenseMatrix< double > &jacobian, const unsigned &flag)
Compute element residual Vector only (if flag=and/or element Jacobian matrix.
void extended_output(std::ostream &outfile, const unsigned &n_plot)
Output: x,y,[z],xi0,xi1,[xi2],gamma and the strain and stress components.
void output(std::ostream &outfile)
Output: x,y,[z],xi0,xi1,[xi2],gamma.
void get_stress(const Vector< double > &s, DenseMatrix< double > &sigma)
Return the 2nd Piola Kirchoff stress tensor, as calculated from the constitutive law at specified loc...
//////////////////////////////////////////////////////////////////////// ////////////////////////////...
/////////////////////////////////////////////////////////////////////////// /////////////////////////...
/////////////////////////////////////////////////////////////// /////////////////////////////////////...
T & raw_direct_access(const unsigned long &i)
Direct access to internal storage of data in flat-packed C-style column-major format....
unsigned offset(const unsigned long &i, const unsigned long &j, const unsigned long &k) const
Caculate the offset in flat-packed Cy-style, column-major format, required for a given i,...
////////////////////////////////////////////////////////////////// //////////////////////////////////...
T & raw_direct_access(const unsigned long &i)
Direct access to internal storage of data in flat-packed C-style column-major format....
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,...
A Class for shape functions. In simple cases, the shape functions have only one index that can be tho...
An Element that solves the solid mechanics equations in an (near) incompressible formulation with qua...
ConstitutiveLaw * Constitutive_law_pt
Create constitutive law (for smoothing by nonlinear elasticity)
//////////////////////////////////////////////////////////////////// ////////////////////////////////...