36 template<
unsigned DIM>
44 template<
unsigned DIM>
48 template<
unsigned DIM>
53 template<
unsigned DIM>
58 template<
unsigned DIM>
68 template<
unsigned DIM>
71 Vector<double>& press_mass_diag,
72 Vector<double>& veloc_mass_diag,
73 const unsigned& which_one)
76 unsigned n_dof = ndof();
79 if ((which_one == 0) || (which_one == 1))
82 press_mass_diag.assign(n_dof, 0.0);
86 if ((which_one == 0) || (which_one == 2))
89 veloc_mass_diag.assign(n_dof, 0.0);
93 unsigned n_node = nnode();
96 Vector<double>
s(DIM + 1, 0.0);
99 Vector<unsigned> u_nodal_index(DIM, 0.0);
102 for (
unsigned i = 0;
i < DIM;
i++)
105 u_nodal_index[
i] = this->u_index_nst(
i);
112 unsigned n_pres = npres_nst();
118 unsigned n_intpt = integral_pt()->nweight();
124 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
127 double w = integral_pt()->weight(ipt);
130 double J = J_eulerian_at_knot(ipt);
133 for (
unsigned i = 0;
i < DIM + 1;
i++)
136 s[
i] = integral_pt()->knot(ipt,
i);
143 if ((which_one == 0) || (which_one == 2))
146 shape_at_knot(ipt, psi);
149 for (
unsigned l = 0; l < n_node; l++)
152 for (
unsigned i = 0;
i < DIM;
i++)
155 local_eqn = nodal_local_eqn(l, u_nodal_index[
i]);
161 veloc_mass_diag[local_eqn] += pow(psi[l], 2) *
W;
168 if ((which_one == 0) || (which_one == 1))
171 pshape_nst(
s, psi_p);
174 for (
unsigned l = 0; l < n_pres; l++)
177 local_eqn = p_local_eqn(l);
183 press_mass_diag[local_eqn] += pow(psi_p[l], 2) *
W;
194 template<
unsigned DIM>
198 norm.resize(DIM + 1, 0.0);
201 Vector<double>
s(DIM + 1, 0.0);
204 unsigned n_intpt = integral_pt()->nweight();
207 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
210 for (
unsigned i = 0;
i < DIM + 1;
i++)
212 s[
i] = integral_pt()->knot(ipt,
i);
216 double w = integral_pt()->weight(ipt);
219 double J = J_eulerian(
s);
225 for (
unsigned i = 0;
i < DIM;
i++)
228 norm[
i] += pow(interpolated_u_nst(
s,
i), 2) *
W;
232 norm[DIM] += pow(interpolated_p_nst(
s), 2) *
W;
242 template<
unsigned DIM>
244 std::ostream& outfile,
257 double interpolated_t = 0.0;
260 Vector<double>
s(DIM + 1, 0.0);
263 Vector<double> x(DIM, 0.0);
266 unsigned n_intpt = integral_pt()->nweight();
269 Vector<double> exact_soln(DIM + 1, 0.0);
272 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
275 for (
unsigned i = 0;
i < DIM + 1;
i++)
277 s[
i] = integral_pt()->knot(ipt,
i);
281 for (
unsigned i = 0;
i < DIM;
i++)
284 x[
i] = interpolated_x(
s,
i);
288 interpolated_t = interpolated_x(
s, DIM);
291 (*exact_soln_pt)(interpolated_t, x, exact_soln);
294 double w = integral_pt()->weight(ipt);
297 double J = J_eulerian(
s);
303 for (
unsigned i = 0;
i < DIM;
i++)
306 norm += exact_soln[
i] * exact_soln[
i] *
W;
309 error += pow(exact_soln[
i] - interpolated_u_nst(
s,
i), 2) *
W;
314 norm += pow(exact_soln[DIM], 2) *
W;
317 error += pow(exact_soln[DIM] - interpolated_p_nst(
s), 2) *
W;
328 outfile << tecplot_zone_string(n_plot);
331 unsigned num_plot_points = nplot_points(n_plot);
334 for (
unsigned i_plot = 0; i_plot < num_plot_points; i_plot++)
337 get_s_plot(i_plot, n_plot,
s);
340 for (
unsigned i = 0;
i < DIM;
i++)
343 x[
i] = interpolated_x(
s,
i);
347 interpolated_t = interpolated_x(
s, DIM);
350 (*exact_soln_pt)(interpolated_t, x, exact_soln);
353 for (
unsigned i = 0;
i < DIM;
i++)
356 outfile << x[
i] <<
" ";
360 outfile << interpolated_t <<
" ";
363 for (
unsigned i = 0;
i < DIM;
i++)
366 outfile << exact_soln[
i] - interpolated_u_nst(
s,
i) <<
" ";
370 outfile << exact_soln[DIM] - interpolated_p_nst(
s) <<
" ";
373 outfile << std::endl;
377 write_tecplot_zone_footer(outfile, n_plot);
386 template<
unsigned DIM>
388 std::ostream& outfile,
391 Vector<double>& error,
392 Vector<double>& norm)
395 error.resize(DIM + 1, 0.0);
398 norm.resize(DIM + 1, 0.0);
401 double interpolated_t = 0.0;
404 Vector<double>
s(DIM + 1, 0.0);
407 Vector<double> x(DIM, 0.0);
410 unsigned n_intpt = integral_pt()->nweight();
413 Vector<double> exact_soln(DIM + 1, 0.0);
416 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
419 for (
unsigned i = 0;
i < DIM + 1;
i++)
421 s[
i] = integral_pt()->knot(ipt,
i);
425 for (
unsigned i = 0;
i < DIM;
i++)
428 x[
i] = interpolated_x(
s,
i);
432 interpolated_t = interpolated_x(
s, DIM);
435 (*exact_soln_pt)(interpolated_t, x, exact_soln);
438 double w = integral_pt()->weight(ipt);
441 double J = J_eulerian(
s);
447 for (
unsigned i = 0;
i < DIM;
i++)
450 norm[
i] += exact_soln[
i] * exact_soln[
i] *
W;
453 error[
i] += pow(exact_soln[
i] - interpolated_u_nst(
s,
i), 2) *
W;
458 norm[DIM] += pow(exact_soln[DIM], 2) *
W;
461 error[DIM] += pow(exact_soln[DIM] - interpolated_p_nst(
s), 2) *
W;
472 outfile << tecplot_zone_string(n_plot);
475 unsigned num_plot_points = nplot_points(n_plot);
478 for (
unsigned i_plot = 0; i_plot < num_plot_points; i_plot++)
481 get_s_plot(i_plot, n_plot,
s);
484 for (
unsigned i = 0;
i < DIM;
i++)
487 x[
i] = interpolated_x(
s,
i);
491 interpolated_t = interpolated_x(
s, DIM);
494 (*exact_soln_pt)(interpolated_t, x, exact_soln);
497 for (
unsigned i = 0;
i < DIM;
i++)
500 outfile << x[
i] <<
" ";
504 outfile << interpolated_t <<
" ";
507 for (
unsigned i = 0;
i < DIM;
i++)
510 outfile << exact_soln[
i] - interpolated_u_nst(
s,
i) <<
" ";
514 outfile << exact_soln[DIM] - interpolated_p_nst(
s) <<
" ";
517 outfile << std::endl;
521 write_tecplot_zone_footer(outfile, n_plot);
530 template<
unsigned DIM>
544 double interpolated_t = 0.0;
547 Vector<double>
s(DIM + 1, 0.0);
550 Vector<double> x(DIM, 0.0);
553 unsigned n_intpt = integral_pt()->nweight();
556 Vector<double> exact_soln(DIM + 1, 0.0);
559 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
562 for (
unsigned i = 0;
i < DIM + 1;
i++)
564 s[
i] = integral_pt()->knot(ipt,
i);
568 for (
unsigned i = 0;
i < DIM;
i++)
571 x[
i] = interpolated_x(
s,
i);
575 interpolated_t = interpolated_x(
s, DIM);
578 (*exact_soln_pt)(interpolated_t, x, exact_soln);
581 double w = integral_pt()->weight(ipt);
584 double J = J_eulerian(
s);
590 for (
unsigned i = 0;
i < DIM;
i++)
593 norm += exact_soln[
i] * exact_soln[
i] *
W;
596 error += pow(exact_soln[
i] - interpolated_u_nst(
s,
i), 2) *
W;
606 template<
unsigned DIM>
619 Vector<double>
s(DIM + 1, 0.0);
622 Vector<double> x(DIM, 0.0);
625 unsigned n_intpt = integral_pt()->nweight();
628 Vector<double> exact_soln(DIM + 1, 0.0);
631 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
634 for (
unsigned i = 0;
i < DIM + 1;
i++)
636 s[
i] = integral_pt()->knot(ipt,
i);
640 for (
unsigned i = 0;
i < DIM;
i++)
643 x[
i] = interpolated_x(
s,
i);
647 (*exact_soln_pt)(x, exact_soln);
650 double w = integral_pt()->weight(ipt);
653 double J = J_eulerian(
s);
659 for (
unsigned i = 0;
i < DIM;
i++)
662 norm += exact_soln[
i] * exact_soln[
i] *
W;
665 error += pow(exact_soln[
i] - interpolated_u_nst(
s,
i), 2) *
W;
676 template<
unsigned DIM>
678 std::ostream& outfile,
690 double interpolated_t = 0.0;
693 Vector<double>
s(DIM + 1, 0.0);
696 Vector<double> x(DIM, 0.0);
699 unsigned n_intpt = integral_pt()->nweight();
702 outfile <<
"ZONE" << std::endl;
705 Vector<double> exact_soln(DIM + 1, 0.0);
708 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
711 for (
unsigned i = 0;
i < DIM + 1;
i++)
713 s[
i] = integral_pt()->knot(ipt,
i);
717 for (
unsigned i = 0;
i < DIM;
i++)
720 x[
i] = interpolated_x(
s,
i);
724 interpolated_t = interpolated_x(
s, DIM);
727 (*exact_soln_pt)(x, exact_soln);
730 double w = integral_pt()->weight(ipt);
733 double J = J_eulerian(
s);
739 for (
unsigned i = 0;
i < DIM;
i++)
742 norm += exact_soln[
i] * exact_soln[
i] *
W;
745 error += pow(exact_soln[
i] - interpolated_u_nst(
s,
i), 2) *
W;
749 for (
unsigned i = 0;
i < DIM;
i++)
752 outfile << x[
i] <<
" ";
756 outfile << interpolated_t <<
" ";
759 for (
unsigned i = 0;
i < DIM;
i++)
762 outfile << exact_soln[
i] - interpolated_u_nst(
s,
i) <<
" ";
766 outfile << std::endl;
776 template<
unsigned DIM>
778 std::ostream& outfile,
779 const unsigned& n_plot,
783 double interpolated_t = 0.0;
786 Vector<double>
s(DIM + 1, 0.0);
789 Vector<double> x(DIM, 0.0);
792 outfile << tecplot_zone_string(n_plot);
795 Vector<double> exact_soln;
798 unsigned num_plot_points = nplot_points(n_plot);
801 for (
unsigned i_plot = 0; i_plot < num_plot_points; i_plot++)
804 get_s_plot(i_plot, n_plot,
s);
807 for (
unsigned i = 0;
i < DIM;
i++)
810 x[
i] = interpolated_x(
s,
i);
814 interpolated_t = interpolated_x(
s, DIM);
817 (*exact_soln_pt)(x, exact_soln);
820 for (
unsigned i = 0;
i < DIM;
i++)
823 outfile << x[
i] <<
" ";
827 outfile << interpolated_t <<
" ";
830 for (
unsigned i = 0;
i < exact_soln.size();
i++)
833 outfile << exact_soln[
i] <<
" ";
837 outfile << std::endl;
841 write_tecplot_zone_footer(outfile, n_plot);
850 template<
unsigned DIM>
852 std::ostream& outfile,
853 const unsigned& n_plot,
858 double interpolated_t = 0.0;
861 Vector<double>
s(DIM + 1, 0.0);
864 Vector<double> x(DIM, 0.0);
867 outfile << tecplot_zone_string(n_plot);
870 Vector<double> exact_soln;
873 unsigned num_plot_points = nplot_points(n_plot);
876 for (
unsigned i_plot = 0; i_plot < num_plot_points; i_plot++)
879 get_s_plot(i_plot, n_plot,
s);
882 for (
unsigned i = 0;
i < DIM;
i++)
885 x[
i] = interpolated_x(
s,
i);
889 interpolated_t = interpolated_x(
s, DIM);
892 (*exact_soln_pt)(interpolated_t, x, exact_soln);
895 for (
unsigned i = 0;
i < DIM;
i++)
898 outfile << x[
i] <<
" ";
902 outfile << interpolated_t <<
" ";
905 for (
unsigned i = 0;
i < exact_soln.size();
i++)
908 outfile << exact_soln[
i] <<
" ";
912 outfile << std::endl;
916 write_tecplot_zone_footer(outfile, n_plot);
927 template<
unsigned DIM>
929 const unsigned& n_plot,
933 unsigned n_node = nnode();
939 Vector<double>
s(DIM + 1, 0.0);
942 outfile << tecplot_zone_string(n_plot);
945 unsigned num_plot_points = nplot_points(n_plot);
948 for (
unsigned i_plot = 0; i_plot < num_plot_points; i_plot++)
951 get_s_plot(i_plot, n_plot,
s);
954 for (
unsigned i = 0;
i < DIM + 1;
i++)
957 outfile << interpolated_x(
s,
i) <<
" ";
961 for (
unsigned i = 0;
i < DIM;
i++)
964 outfile << interpolated_u_nst(
s,
i) <<
" ";
968 outfile << std::endl;
972 write_tecplot_zone_footer(outfile, n_plot);
981 template<
unsigned DIM>
983 const unsigned& n_plot)
986 unsigned n_node = nnode();
992 Vector<double>
s(DIM + 1, 0.0);
995 outfile << tecplot_zone_string(n_plot);
998 unsigned num_plot_points = nplot_points(n_plot);
1001 for (
unsigned i_plot = 0; i_plot < num_plot_points; i_plot++)
1004 get_s_plot(i_plot, n_plot,
s);
1007 for (
unsigned i = 0;
i < DIM + 1;
i++)
1010 outfile << interpolated_x(
s,
i) <<
" ";
1014 for (
unsigned i = 0;
i < DIM;
i++)
1017 outfile << interpolated_u_nst(
s,
i) <<
" ";
1021 outfile << interpolated_p_nst(
s) <<
" ";
1024 outfile << std::endl;
1028 outfile << std::endl;
1031 write_tecplot_zone_footer(outfile, n_plot);
1040 template<
unsigned DIM>
1042 const unsigned& n_plot)
1045 Vector<double>
s(DIM + 1, 0.0);
1048 fprintf(file_pt,
"%s", tecplot_zone_string(n_plot).c_str());
1051 unsigned num_plot_points = nplot_points(n_plot);
1054 for (
unsigned i_plot = 0; i_plot < num_plot_points; i_plot++)
1057 get_s_plot(i_plot, n_plot,
s);
1060 for (
unsigned i = 0;
i < DIM + 1;
i++)
1063 fprintf(file_pt,
"%g ", interpolated_x(
s,
i));
1067 for (
unsigned i = 0;
i < DIM;
i++)
1070 fprintf(file_pt,
"%g ", interpolated_u_nst(
s,
i));
1074 fprintf(file_pt,
"%g \n", interpolated_p_nst(
s));
1078 fprintf(file_pt,
"\n");
1081 write_tecplot_zone_footer(file_pt, n_plot);
1090 template<
unsigned DIM>
1092 const unsigned& n_plot)
1095 Vector<double>
s(DIM + 1, 0.0);
1098 outfile << tecplot_zone_string(n_plot);
1101 unsigned n_node = nnode();
1107 DShape dpsifdx(n_node, DIM);
1110 unsigned num_plot_points = nplot_points(n_plot);
1113 for (
unsigned i_plot = 0; i_plot < num_plot_points; i_plot++)
1116 get_s_plot(i_plot, n_plot,
s);
1119 dshape_eulerian(
s, psif, dpsifdx);
1122 Vector<double> mesh_velocity(DIM, 0.0);
1125 Vector<double> du_dt(DIM, 0.0);
1128 Vector<double> du_dt_ALE(DIM, 0.0);
1131 DenseMatrix<double> interpolated_dudx(DIM, DIM, 0.0);
1137 for (
unsigned i = 0;
i < DIM;
i++)
1140 unsigned u_nodal_index = u_index_nst(
i);
1143 for (
unsigned l = 0; l < n_node; l++)
1146 double u_value = nodal_value(l, u_nodal_index);
1149 du_dt[
i] += u_value * dpsifdx(l, DIM);
1152 mesh_velocity[
i] += nodal_position(l,
i) * dpsifdx(l, DIM);
1155 for (
unsigned j = 0; j < DIM; j++)
1158 interpolated_dudx(
i, j) += u_value * dpsifdx(l, j);
1167 for (
unsigned i = 0;
i < DIM;
i++)
1170 du_dt_ALE[
i] = du_dt[
i];
1173 for (
unsigned k = 0; k < DIM; k++)
1176 du_dt_ALE[
i] -= mesh_velocity[k] * interpolated_dudx(
i, k);
1181 for (
unsigned i = 0;
i < DIM + 1;
i++)
1184 outfile << interpolated_x(
s,
i) <<
" ";
1188 for (
unsigned i = 0;
i < DIM;
i++)
1191 outfile << interpolated_u_nst(
s,
i) <<
" ";
1195 outfile << interpolated_p_nst(
s) <<
" ";
1198 for (
unsigned i = 0;
i < DIM;
i++)
1201 outfile << du_dt_ALE[
i] <<
" ";
1205 outfile << dissipation(
s) <<
" ";
1208 outfile << std::endl;
1212 write_tecplot_zone_footer(outfile, n_plot);
1222 template<
unsigned DIM>
1224 std::ostream& outfile,
const unsigned& n_plot)
1227 Vector<double>
s(DIM + 1, 0.0);
1230 Vector<double> vorticity;
1236 vorticity.resize(1);
1242 vorticity.resize(3);
1248 "Can't output vorticity in 1D - in fact, what ";
1249 error_message +=
"do you mean\nby the 1D Navier-Stokes equations?\n";
1250 throw OomphLibError(
1251 error_message, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
1255 outfile << tecplot_zone_string(n_plot);
1258 unsigned num_plot_points = nplot_points(n_plot);
1261 for (
unsigned i_plot = 0; i_plot < num_plot_points; i_plot++)
1264 get_s_plot(i_plot, n_plot,
s);
1267 for (
unsigned i = 0;
i < DIM + 1;
i++)
1270 outfile << interpolated_x(
s,
i) <<
" ";
1274 get_vorticity(
s, vorticity);
1280 outfile << vorticity[0];
1286 outfile << vorticity[0] <<
" " << vorticity[1] <<
" " << vorticity[2]
1291 outfile << std::endl;
1295 outfile << std::endl;
1298 write_tecplot_zone_footer(outfile, n_plot);
1304 template<
unsigned DIM>
1311 unsigned n_intpt = integral_pt()->nweight();
1314 Vector<double>
s(DIM + 1, 0.0);
1317 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
1320 for (
unsigned i = 0;
i < DIM + 1;
i++)
1323 s[
i] = integral_pt()->knot(ipt,
i);
1327 double w = integral_pt()->weight(ipt);
1330 double J = J_eulerian(
s);
1333 DenseMatrix<double> strainrate(DIM, DIM);
1336 strain_rate(
s, strainrate);
1339 double local_diss = 0.0;
1342 for (
unsigned i = 0;
i < DIM;
i++)
1345 for (
unsigned j = 0; j < DIM; j++)
1348 local_diss += 2.0 * strainrate(
i, j) * strainrate(
i, j);
1353 diss += local_diss * w * J;
1365 template<
unsigned DIM>
1367 const Vector<double>&
s,
const Vector<double>&
N, Vector<double>& traction)
1370 DenseMatrix<double> strainrate(DIM, DIM);
1373 strain_rate(
s, strainrate);
1376 double press = interpolated_p_nst(
s);
1379 for (
unsigned i = 0;
i < DIM;
i++)
1382 traction[
i] = -press *
N[
i];
1385 for (
unsigned j = 0; j < DIM; j++)
1388 traction[
i] += 2.0 * strainrate(
i, j) *
N[j];
1399 template<
unsigned DIM>
1401 const Vector<double>&
s,
1402 const Vector<double>&
N,
1403 Vector<double>& traction_p,
1404 Vector<double>& traction_visc_n,
1405 Vector<double>& traction_visc_t)
1408 Vector<double> traction_visc(DIM);
1411 DenseMatrix<double> strainrate(DIM, DIM);
1414 strain_rate(
s, strainrate);
1417 double press = interpolated_p_nst(
s);
1420 for (
unsigned i = 0;
i < DIM;
i++)
1423 traction_p[
i] = -press *
N[
i];
1426 for (
unsigned j = 0; j < DIM; j++)
1429 traction_visc[
i] += 2.0 * strainrate(
i, j) *
N[j];
1433 traction_visc_n[
i] = traction_visc[
i] *
N[
i];
1436 traction_visc_t[
i] = traction_visc[
i] - traction_visc_n[
i];
1443 template<
unsigned DIM>
1445 const Vector<double>&
s)
const
1448 DenseMatrix<double> strainrate(DIM, DIM);
1449 strain_rate(
s, strainrate);
1452 double local_diss = 0.0;
1453 for (
unsigned i = 0;
i < DIM;
i++)
1455 for (
unsigned j = 0; j < DIM; j++)
1457 local_diss += 2.0 * strainrate(
i, j) * strainrate(
i, j);
1467 template<
unsigned DIM>
1469 const Vector<double>&
s, DenseMatrix<double>& strainrate)
const
1472 if ((strainrate.ncol() != DIM) || (strainrate.nrow() != DIM))
1474 std::ostringstream error_message;
1475 error_message <<
"The strain rate has incorrect dimensions "
1476 << strainrate.ncol() <<
" x " << strainrate.nrow()
1477 <<
" not " << DIM << std::endl;
1478 throw OomphLibError(
1479 error_message.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
1484 DenseMatrix<double> dudx(DIM);
1487 unsigned n_node = nnode();
1493 DShape dpsidx(n_node, DIM + 1);
1496 dshape_eulerian(
s, psi, dpsidx);
1499 dudx.initialise(0.0);
1502 for (
unsigned i = 0;
i < DIM;
i++)
1505 unsigned u_nodal_index = u_index_nst(
i);
1508 for (
unsigned j = 0; j < DIM; j++)
1511 for (
unsigned l = 0; l < n_node; l++)
1514 dudx(
i, j) += nodal_value(l, u_nodal_index) * dpsidx(l, j);
1520 for (
unsigned i = 0;
i < DIM;
i++)
1523 for (
unsigned j = 0; j < DIM; j++)
1526 strainrate(
i, j) = 0.5 * (dudx(
i, j) + dudx(j,
i));
1540 if (vorticity.size() != 1)
1542 std::ostringstream error_message;
1543 error_message <<
"Computation of vorticity in 2D requires a 1D vector\n"
1544 <<
"which contains the only non-zero component of the\n"
1545 <<
"vorticity vector. You've passed a vector of size "
1546 << vorticity.size() << std::endl;
1549 error_message.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
1560 unsigned n_node = nnode();
1566 DShape dpsidx(n_node, DIM + 1);
1569 dshape_eulerian(
s, psi, dpsidx);
1575 for (
unsigned i = 0;
i < DIM;
i++)
1578 unsigned u_nodal_index = u_index_nst(
i);
1581 for (
unsigned j = 0; j < DIM; j++)
1584 for (
unsigned l = 0; l < n_node; l++)
1587 dudx(
i, j) += nodal_value(l, u_nodal_index) * dpsidx(l, j);
1593 vorticity[0] = dudx(1, 0) - dudx(0, 1);
1602 double& vorticity)
const
1608 get_vorticity(
s, vort);
1611 vorticity = vort[0];
1622 template<
unsigned DIM>
1626 double kin_en = 0.0;
1629 unsigned n_intpt = integral_pt()->nweight();
1635 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
1638 for (
unsigned i = 0;
i < DIM + 1;
i++)
1640 s[
i] = integral_pt()->knot(ipt,
i);
1644 double w = integral_pt()->weight(ipt);
1647 double J = J_eulerian(
s);
1650 double veloc_squared = 0.0;
1651 for (
unsigned i = 0;
i < DIM;
i++)
1653 veloc_squared += interpolated_u_nst(
s,
i) * interpolated_u_nst(
s,
i);
1656 kin_en += 0.5 * veloc_squared * w * J;
1667 template<
unsigned DIM>
1671 double d_kin_en_dt = 0.0;
1674 const unsigned n_intpt = integral_pt()->nweight();
1677 const unsigned n_node = this->nnode();
1681 DShape dpsidx(n_node, DIM + 1);
1684 unsigned u_index[DIM];
1685 for (
unsigned i = 0;
i < DIM;
i++)
1687 u_index[
i] = this->u_index_nst(
i);
1691 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
1694 double J = dshape_eulerian_at_knot(ipt, psi, dpsidx);
1697 double w = integral_pt()->weight(ipt);
1700 Vector<double> interpolated_u(DIM, 0.0);
1701 Vector<double> interpolated_dudt(DIM, 0.0);
1704 for (
unsigned l = 0; l < n_node; l++)
1707 for (
unsigned i = 0;
i < DIM;
i++)
1709 interpolated_u[
i] += nodal_value(l, u_index[
i]) * psi(l);
1710 interpolated_dudt[
i] += du_dt_nst(l, u_index[
i]) * psi(l);
1715 if (!ALE_is_disabled)
1717 Vector<double> mesh_velocity(DIM, 0.0);
1718 DenseMatrix<double> interpolated_dudx(DIM, DIM, 0.0);
1721 for (
unsigned l = 0; l < n_node; l++)
1723 for (
unsigned i = 0;
i < DIM;
i++)
1725 mesh_velocity[
i] += this->dnodal_position_dt(l,
i) * psi(l);
1727 for (
unsigned j = 0; j < DIM; j++)
1729 interpolated_dudx(
i, j) +=
1730 this->nodal_value(l, u_index[
i]) * dpsidx(l, j);
1736 for (
unsigned i = 0;
i < DIM;
i++)
1738 for (
unsigned k = 0; k < DIM; k++)
1740 interpolated_dudt[
i] -= mesh_velocity[k] * interpolated_dudx(
i, k);
1748 for (
unsigned i = 0;
i < DIM;
i++)
1750 sum += interpolated_u[
i] * interpolated_dudt[
i];
1753 d_kin_en_dt += sum * w * J;
1764 template<
unsigned DIM>
1768 double press_int = 0;
1771 unsigned n_intpt = integral_pt()->nweight();
1774 Vector<double>
s(DIM + 1, 0.0);
1777 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
1780 for (
unsigned i = 0;
i < DIM + 1;
i++)
1782 s[
i] = integral_pt()->knot(ipt,
i);
1786 double w = integral_pt()->weight(ipt);
1789 double J = J_eulerian(
s);
1795 double press = interpolated_p_nst(
s);
1798 press_int += press *
W;
1810 template<
unsigned DIM>
1813 Vector<double>& residuals,
1814 DenseMatrix<double>& jacobian,
1815 const unsigned& flag)
1817 OomphLibWarning(
"I'm not sure this is correct yet...",
1818 OOMPH_CURRENT_FUNCTION,
1819 OOMPH_EXCEPTION_LOCATION);
1822 if (ndof() == 0)
return;
1825 unsigned n_node = nnode();
1828 unsigned n_pres = npres_nst();
1832 DShape dpsidx(n_node, DIM + 1);
1836 Shape testp(n_pres);
1837 DShape dpsip(n_pres, DIM);
1838 DShape dtestp(n_pres, DIM);
1841 unsigned n_intpt = integral_pt()->nweight();
1844 Vector<double>
s(DIM + 1, 0.0);
1848 double scaled_re = re() * density_ratio();
1852 int local_unknown = 0;
1855 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
1858 for (
unsigned i = 0;
i < DIM + 1;
i++)
1860 s[
i] = integral_pt()->knot(ipt,
i);
1864 double w = integral_pt()->weight(ipt);
1868 double J = this->dshape_eulerian_at_knot(ipt, psif, dpsidx);
1871 this->dpshape_and_dptest_eulerian_nst(
s, psip, dpsip, testp, dtestp);
1877 Vector<double> x(DIM + 1, 0.0);
1880 Vector<double> interpolated_u(DIM, 0.0);
1881 Vector<double> interpolated_dpdx(DIM, 0.0);
1884 for (
unsigned l = 0; l < n_pres; l++)
1886 for (
unsigned i = 0;
i < DIM;
i++)
1888 interpolated_dpdx[
i] += p_nst(l) * dpsip(l,
i);
1893 for (
unsigned i = 0;
i < DIM;
i++)
1895 interpolated_u[
i] = interpolated_u_nst(
s,
i);
1899 for (
unsigned i = 0;
i < DIM + 1;
i++)
1901 x[
i] = interpolated_x(
s,
i);
1905 double source = 0.0;
1906 if (Press_adv_diff_source_fct_pt != 0)
1908 source = Press_adv_diff_source_fct_pt(x);
1912 for (
unsigned l = 0; l < n_pres; l++)
1914 local_eqn = p_local_eqn(l);
1919 residuals[local_eqn] -= source * testp[l] *
W;
1921 for (
unsigned k = 0; k < DIM; k++)
1923 residuals[local_eqn] +=
1924 interpolated_dpdx[k] *
1925 (scaled_re * interpolated_u[k] * testp[l] + dtestp(l, k)) *
W;
1932 for (
unsigned l2 = 0; l2 < n_pres; l2++)
1934 local_unknown = p_local_eqn(l2);
1937 if (local_unknown >= 0)
1939 if ((
int(eqn_number(local_eqn)) != Pinned_fp_pressure_eqn) &&
1940 (
int(eqn_number(local_unknown)) != Pinned_fp_pressure_eqn))
1942 for (
unsigned k = 0; k < DIM; k++)
1944 jacobian(local_eqn, local_unknown) +=
1946 (scaled_re * interpolated_u[k] * testp[l] +
1953 if ((
int(eqn_number(local_eqn)) == Pinned_fp_pressure_eqn) &&
1954 (int(eqn_number(local_unknown)) ==
1955 Pinned_fp_pressure_eqn))
1958 jacobian(local_eqn, local_unknown) = 1.0;
1970 unsigned nrobin = Pressure_advection_diffusion_robin_element_pt.size();
1971 for (
unsigned e = 0;
e < nrobin;
e++)
1973 Pressure_advection_diffusion_robin_element_pt[
e]
1974 ->fill_in_generic_residual_contribution_fp_press_adv_diff_robin_bc(
1975 residuals, jacobian, flag);
1985 template<
unsigned DIM>
1988 DenseMatrix<double>& jacobian,
1989 DenseMatrix<double>& mass_matrix,
1990 const unsigned& flag)
1993 if (ndof() == 0)
return;
1996 unsigned n_node = nnode();
1999 unsigned n_pres = npres_nst();
2002 unsigned u_nodal_index[DIM];
2005 for (
unsigned i = 0;
i < DIM;
i++)
2008 u_nodal_index[
i] = u_index_nst(
i);
2015 Shape testf(n_node);
2018 DShape dpsifdx(n_node, DIM + 1);
2021 DShape dtestfdx(n_node, DIM + 1);
2027 Shape testp(n_pres);
2030 unsigned n_intpt = integral_pt()->nweight();
2033 Vector<double>
s(DIM + 1, 0.0);
2039 double scaled_re = re() * density_ratio();
2042 double scaled_re_st = re() * st() * density_ratio();
2045 double scaled_dre_st_dst = re() * density_ratio();
2048 double scaled_re_inv_fr = re_invfr() * density_ratio();
2051 double visc_ratio = viscosity_ratio();
2054 Vector<double> G = g();
2060 int local_unknown = 0;
2063 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
2066 for (
unsigned i = 0;
i < DIM + 1;
i++)
2069 s[
i] = integral_pt()->knot(ipt,
i);
2073 double w = integral_pt()->weight(ipt);
2076 double J = dshape_and_dtest_eulerian_at_knot_nst(
2077 ipt, psif, dpsifdx, testf, dtestfdx);
2080 pshape_nst(
s, psip, testp);
2086 double interpolated_t = 0.0;
2089 double interpolated_p = 0.0;
2092 Vector<double> interpolated_x(DIM, 0.0);
2095 Vector<double> interpolated_u(DIM, 0.0);
2098 Vector<double> interpolated_dudt(DIM, 0.0);
2101 Vector<double> mesh_velocity(DIM, 0.0);
2104 DenseMatrix<double> interpolated_dudx(DIM, DIM, 0.0);
2107 for (
unsigned l = 0; l < n_pres; l++)
2110 interpolated_p += p_nst(l) * psip[l];
2117 for (
unsigned l = 0; l < n_node; l++)
2120 interpolated_t += raw_nodal_position(l, DIM) * psif(l);
2123 for (
unsigned i = 0;
i < DIM;
i++)
2126 double u_value = raw_nodal_value(l, u_nodal_index[
i]);
2129 interpolated_u[
i] += u_value * psif[l];
2132 interpolated_x[
i] += raw_nodal_position(l,
i) * psif[l];
2135 interpolated_dudt[
i] += u_value * dpsifdx(l, DIM);
2138 for (
unsigned j = 0; j < DIM; j++)
2141 interpolated_dudx(
i, j) += u_value * dpsifdx(l, j);
2147 if (!ALE_is_disabled)
2150 for (
unsigned l = 0; l < n_node; l++)
2153 for (
unsigned i = 0;
i < DIM;
i++)
2158 mesh_velocity[
i] += raw_nodal_position(l,
i) * dpsifdx(l, DIM);
2164 Vector<double> body_force(DIM, 0.0);
2167 get_body_force_nst(interpolated_t, ipt,
s, interpolated_x, body_force);
2170 double source = get_source_nst(interpolated_t, ipt, interpolated_x);
2179 for (
unsigned l = 0; l < n_node; l++)
2182 for (
unsigned i = 0;
i < DIM;
i++)
2185 local_eqn = nodal_local_eqn(l, u_nodal_index[
i]);
2191 residuals[local_eqn] += body_force[
i] * testf[l] *
W;
2194 residuals[local_eqn] += scaled_re_inv_fr * testf[l] * G[
i] *
W;
2197 residuals[local_eqn] += interpolated_p * dtestfdx(l,
i) *
W;
2200 residuals[local_eqn] -=
2201 scaled_re_st * interpolated_dudt[
i] * testf[l] *
W;
2204 if (!ALE_is_disabled)
2207 for (
unsigned k = 0; k < DIM; k++)
2210 residuals[local_eqn] +=
2211 (scaled_re_st * mesh_velocity[k] * interpolated_dudx(
i, k) *
2217 for (
unsigned k = 0; k < DIM; k++)
2220 residuals[local_eqn] -= (scaled_re * interpolated_u[k] *
2221 interpolated_dudx(
i, k) * testf[l] *
W);
2225 for (
unsigned k = 0; k < DIM; k++)
2231 residuals[local_eqn] -= ((interpolated_dudx(
i, k) +
2232 Gamma[
i] * interpolated_dudx(k,
i)) *
2233 visc_ratio * dtestfdx(l, k) *
W);
2243 for (
unsigned l2 = 0; l2 < n_node; l2++)
2246 for (
unsigned i2 = 0; i2 < DIM; i2++)
2249 local_unknown = nodal_local_eqn(l2, u_nodal_index[i2]);
2252 if (local_unknown >= 0)
2255 jacobian(local_eqn, local_unknown) -=
2256 (visc_ratio * Gamma[
i] * dpsifdx(l2,
i) *
2257 dtestfdx(l, i2) *
W);
2260 jacobian(local_eqn, local_unknown) -=
2261 (scaled_re * psif[l2] * interpolated_dudx(
i, i2) *
2274 mass_matrix(local_eqn, local_unknown) +=
2275 (scaled_re_st * psif[l2] * testf[l] *
W);
2279 jacobian(local_eqn, local_unknown) -=
2280 (scaled_re_st * dpsifdx(l2, DIM) * testf[l] *
W);
2283 if (!ALE_is_disabled)
2286 for (
unsigned k = 0; k < DIM; k++)
2289 jacobian(local_eqn, local_unknown) +=
2290 (scaled_re_st * mesh_velocity[k] * dpsifdx(l2, k) *
2296 for (
unsigned k = 0; k < DIM; k++)
2299 jacobian(local_eqn, local_unknown) -=
2300 (scaled_re * interpolated_u[k] * dpsifdx(l2, k) *
2305 for (
unsigned k = 0; k < DIM; k++)
2308 jacobian(local_eqn, local_unknown) -=
2309 (visc_ratio * dpsifdx(l2, k) * dtestfdx(l, k) *
W);
2317 for (
unsigned l2 = 0; l2 < n_pres; l2++)
2321 local_unknown = p_local_eqn(l2);
2324 if (local_unknown >= 0)
2327 jacobian(local_eqn, local_unknown) +=
2328 psip[l2] * dtestfdx(l,
i) *
W;
2337 if (Strouhal_is_stored_as_external_data)
2340 unsigned data_index = 0;
2343 unsigned value_index = 0;
2348 this->external_local_eqn(data_index, value_index);
2351 if (local_unknown >= 0)
2354 jacobian(local_eqn, local_unknown) -=
2355 (scaled_dre_st_dst * interpolated_dudt[
i] * testf[l] *
W);
2358 if (!ALE_is_disabled)
2361 for (
unsigned k = 0; k < DIM; k++)
2364 jacobian(local_eqn, local_unknown) +=
2365 (scaled_dre_st_dst * mesh_velocity[k] *
2366 interpolated_dudx(
i, k) * testf[l] *
W);
2380 for (
unsigned l = 0; l < n_pres; l++)
2383 local_eqn = p_local_eqn(l);
2389 residuals[local_eqn] -= source * testp[l] *
W;
2392 for (
unsigned k = 0; k < DIM; k++)
2395 residuals[local_eqn] += interpolated_dudx(k, k) * testp[l] *
W;
2405 for (
unsigned l2 = 0; l2 < n_node; l2++)
2408 for (
unsigned i2 = 0; i2 < DIM; i2++)
2411 local_unknown = nodal_local_eqn(l2, u_nodal_index[i2]);
2414 if (local_unknown >= 0)
2417 jacobian(local_eqn, local_unknown) +=
2418 dpsifdx(l2, i2) * testp[l] *
W;
2434 template<
unsigned DIM>
2437 double*
const& parameter_pt,
2438 Vector<double>& dres_dparam,
2439 DenseMatrix<double>& djac_dparam,
2440 DenseMatrix<double>& dmass_matrix_dparam,
2441 const unsigned& flag)
2444 throw OomphLibError(
"Not yet implemented\n",
2445 OOMPH_CURRENT_FUNCTION,
2446 OOMPH_EXCEPTION_LOCATION);
2453 template<
unsigned DIM>
2456 Vector<double>
const& Y,
2457 DenseMatrix<double>
const& C,
2458 DenseMatrix<double>& product)
2461 throw OomphLibError(
"Not yet implemented\n",
2462 OOMPH_CURRENT_FUNCTION,
2463 OOMPH_EXCEPTION_LOCATION);
2473 template<
unsigned DIM>
2475 RankThreeTensor<double>& dresidual_dnodal_coordinates)
2478 throw OomphLibError(
"Space-time update needs to be checked!",
2479 OOMPH_CURRENT_FUNCTION,
2480 OOMPH_EXCEPTION_LOCATION);
2489 const unsigned n_node = nnode();
2492 const unsigned n_pres = npres_nst();
2495 unsigned u_nodal_index[DIM];
2496 for (
unsigned i = 0;
i < DIM;
i++)
2498 u_nodal_index[
i] = u_index_nst(
i);
2503 Shape testf(n_node);
2504 DShape dpsifdx(n_node, DIM + 1);
2505 DShape dtestfdx(n_node, DIM + 1);
2508 Shape psip(n_pres), testp(n_pres);
2511 RankFourTensor<double> d_dpsifdx_dX(DIM, n_node, n_node, DIM);
2512 RankFourTensor<double> d_dtestfdx_dX(DIM, n_node, n_node, DIM);
2515 DenseMatrix<double> dJ_dX(DIM, n_node);
2518 RankFourTensor<double> d_dudx_dX(DIM, n_node, DIM, DIM);
2523 DenseMatrix<double> d_U_dX(DIM, n_node, 0.0);
2526 const unsigned n_intpt = integral_pt()->nweight();
2529 Vector<double>
s(DIM + 1, 0.0);
2533 double scaled_re = re() * density_ratio();
2534 double scaled_re_st = re_st() * density_ratio();
2535 double scaled_re_inv_fr = re_invfr() * density_ratio();
2536 double visc_ratio = viscosity_ratio();
2537 Vector<double> G = g();
2545 bool element_has_node_with_aux_node_update_fct =
false;
2546 for (
unsigned q = 0; q < n_node; q++)
2548 Node* nod_pt = node_pt(q);
2551 if (nod_pt->has_auxiliary_node_update_fct_pt())
2553 element_has_node_with_aux_node_update_fct =
true;
2556 Vector<double> u_ref(DIM);
2557 for (
unsigned i = 0;
i < DIM;
i++)
2559 u_ref[
i] = *(nod_pt->value_pt(u_nodal_index[
i]));
2563 for (
unsigned p = 0; p < DIM; p++)
2566 double backup = nod_pt->x(p);
2570 nod_pt->x(p) += eps_fd;
2573 nod_pt->perform_auxiliary_node_update_fct();
2577 (*(nod_pt->value_pt(u_nodal_index[p])) - u_ref[p]) / eps_fd;
2580 nod_pt->x(p) = backup;
2583 nod_pt->perform_auxiliary_node_update_fct();
2592 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
2595 for (
unsigned i = 0;
i < DIM + 1;
i++)
2597 s[
i] = integral_pt()->knot(ipt,
i);
2601 const double w = integral_pt()->weight(ipt);
2604 const double J = dshape_and_dtest_eulerian_at_knot_nst(ipt,
2614 pshape_nst(
s, psip, testp);
2617 double interpolated_t = 0.0;
2620 double interpolated_p = 0.0;
2623 Vector<double> interpolated_x(DIM, 0.0);
2626 Vector<double> interpolated_u(DIM, 0.0);
2629 Vector<double> interpolated_dudt(DIM, 0.0);
2632 Vector<double> mesh_velocity(DIM, 0.0);
2635 DenseMatrix<double> interpolated_dudx(DIM, DIM, 0.0);
2638 for (
unsigned l = 0; l < n_pres; l++)
2641 interpolated_p += p_nst(l) * psip[l];
2648 for (
unsigned l = 0; l < n_node; l++)
2651 interpolated_t += raw_nodal_position(l, DIM) * psif(l);
2654 for (
unsigned i = 0;
i < DIM;
i++)
2657 double u_value = raw_nodal_value(l, u_nodal_index[
i]);
2660 interpolated_u[
i] += u_value * psif[l];
2663 interpolated_x[
i] += raw_nodal_position(l,
i) * psif[l];
2666 interpolated_dudt[
i] += u_value * dpsifdx(l, DIM);
2669 for (
unsigned j = 0; j < DIM; j++)
2672 interpolated_dudx(
i, j) += u_value * dpsifdx(l, j);
2678 if (!ALE_is_disabled)
2681 for (
unsigned l = 0; l < n_node; l++)
2684 for (
unsigned i = 0;
i < DIM;
i++)
2687 mesh_velocity[
i] += raw_nodal_position(l,
i) * dpsifdx(l, DIM);
2694 for (
unsigned q = 0; q < n_node; q++)
2697 for (
unsigned p = 0; p < DIM; p++)
2699 for (
unsigned i = 0;
i < DIM;
i++)
2701 for (
unsigned k = 0; k < DIM; k++)
2705 for (
unsigned j = 0; j < n_node; j++)
2707 aux += raw_nodal_value(j, u_nodal_index[
i]) *
2708 d_dpsifdx_dX(p, q, j, k);
2712 d_dudx_dX(p, q,
i, k) = aux;
2719 Vector<double> body_force(DIM);
2722 get_body_force_nst(interpolated_t, ipt,
s, interpolated_x, body_force);
2725 const double source = get_source_nst(interpolated_t, ipt, interpolated_x);
2731 DenseMatrix<double> d_body_force_dx(DIM, DIM, 0.0);
2734 get_body_force_gradient_nst(
2735 interpolated_t, ipt,
s, interpolated_x, d_body_force_dx);
2738 Vector<double> source_gradient(DIM, 0.0);
2741 get_source_gradient_nst(
2742 interpolated_t, ipt, interpolated_x, source_gradient);
2746 const double pos_time_weight =
2747 (node_pt(0)->position_time_stepper_pt()->weight(1, 0));
2751 const double val_time_weight =
2752 node_pt(0)->time_stepper_pt()->weight(1, 0);
2761 for (
unsigned l = 0; l < n_node; l++)
2764 for (
unsigned i = 0;
i < DIM;
i++)
2768 local_eqn = nodal_local_eqn(l, u_nodal_index[
i]);
2774 for (
unsigned p = 0; p < DIM; p++)
2777 for (
unsigned q = 0; q < n_node; q++)
2783 double sum = body_force[
i] * testf[l];
2786 sum += scaled_re_inv_fr * testf[l] * G[
i];
2789 sum += interpolated_p * dtestfdx(l,
i);
2792 for (
unsigned k = 0; k < DIM; k++)
2798 sum -= (visc_ratio *
2799 (interpolated_dudx(
i, k) +
2800 Gamma[
i] * interpolated_dudx(k,
i)) *
2805 sum -= scaled_re_st * interpolated_dudt[
i] * testf[l];
2808 for (
unsigned k = 0; k < DIM; k++)
2811 sum -= scaled_re * interpolated_u[k] *
2812 interpolated_dudx(
i, k) * testf[l];
2816 if (!ALE_is_disabled)
2819 for (
unsigned k = 0; k < DIM; k++)
2822 sum += scaled_re_st * mesh_velocity[k] *
2823 interpolated_dudx(
i, k) * testf[l];
2829 dresidual_dnodal_coordinates(local_eqn, p, q) +=
2830 sum * dJ_dX(p, q) * w;
2836 sum = d_body_force_dx(
i, p) * psif(q) * testf(l);
2839 sum += interpolated_p * d_dtestfdx_dX(p, q, l,
i);
2842 for (
unsigned k = 0; k < DIM; k++)
2844 sum -= (visc_ratio * ((interpolated_dudx(
i, k) +
2845 Gamma[
i] * interpolated_dudx(k,
i)) *
2846 d_dtestfdx_dX(p, q, l, k) +
2847 (d_dudx_dX(p, q,
i, k) +
2848 Gamma[
i] * d_dudx_dX(p, q, k,
i)) *
2853 for (
unsigned k = 0; k < DIM; k++)
2855 double tmp = scaled_re * interpolated_u[k];
2856 if (!ALE_is_disabled)
2858 tmp -= scaled_re_st * mesh_velocity[k];
2860 sum -= tmp * d_dudx_dX(p, q,
i, k) * testf(l);
2863 if (!ALE_is_disabled)
2865 sum += scaled_re_st * pos_time_weight * psif(q) *
2866 interpolated_dudx(
i, p) * testf(l);
2870 dresidual_dnodal_coordinates(local_eqn, p, q) += sum * J * w;
2874 if (element_has_node_with_aux_node_update_fct)
2877 -visc_ratio * Gamma[
i] * dpsifdx(q,
i) * dtestfdx(l, p) -
2878 scaled_re * psif(q) * interpolated_dudx(
i, p) * testf(l);
2881 sum -= scaled_re_st * val_time_weight * psif(q) * testf(l);
2882 for (
unsigned k = 0; k < DIM; k++)
2884 sum -= visc_ratio * dpsifdx(q, k) * dtestfdx(l, k);
2885 double tmp = scaled_re * interpolated_u[k];
2886 if (!ALE_is_disabled)
2887 tmp -= scaled_re_st * mesh_velocity[k];
2888 sum -= tmp * dpsifdx(q, k) * testf(l);
2891 dresidual_dnodal_coordinates(local_eqn, p, q) +=
2892 sum * d_U_dX(p, q) * J * w;
2905 for (
unsigned l = 0; l < n_pres; l++)
2907 local_eqn = p_local_eqn(l);
2913 for (
unsigned p = 0; p < DIM; p++)
2916 for (
unsigned q = 0; q < n_node; q++)
2922 double aux = -source;
2925 for (
unsigned k = 0; k < DIM; k++)
2927 aux += interpolated_dudx(k, k);
2931 dresidual_dnodal_coordinates(local_eqn, p, q) +=
2932 aux * dJ_dX(p, q) * testp[l] * w;
2938 aux = -source_gradient[p] * psif(q);
2939 for (
unsigned k = 0; k < DIM; k++)
2941 aux += d_dudx_dX(p, q, k, k);
2944 dresidual_dnodal_coordinates(local_eqn, p, q) +=
2945 aux * testp[l] * J * w;
2949 if (element_has_node_with_aux_node_update_fct)
2951 aux = dpsifdx(q, p) * testp(l);
2952 dresidual_dnodal_coordinates(local_eqn, p, q) +=
2953 aux * d_U_dX(p, q) * J * w;
2973 3, 2, 3, 2, 2, 2, 3, 2, 3, 2, 2, 2, 2, 2,
2974 2, 2, 2, 2, 3, 2, 3, 2, 2, 2, 3, 2, 3};
2979 0, 2, 6, 8, 18, 20, 24, 26};
2990 template<
unsigned DIM>
2992 std::set<std::pair<Data*, unsigned>>& paired_load_data)
2995 unsigned u_index[DIM];
2998 for (
unsigned i = 0;
i < DIM;
i++)
3001 u_index[
i] = this->u_index_nst(
i);
3005 unsigned n_node = this->nnode();
3008 for (
unsigned n = 0; n < n_node; n++)
3012 for (
unsigned i = 0;
i < DIM;
i++)
3015 paired_load_data.insert(std::make_pair(this->node_pt(n), u_index[
i]));
3020 this->identify_pressure_data(paired_load_data);
3032 template<
unsigned DIM>
3034 std::set<std::pair<Data*, unsigned>>& paired_pressure_data)
3037 unsigned p_index =
static_cast<unsigned>(this->p_nodal_index_nst());
3040 unsigned n_pres = npres_nst();
3043 for (
unsigned l = 0; l < n_pres; l++)
3047 paired_pressure_data.insert(
3048 std::make_pair(this->node_pt(Pconv[l]), p_index));
3054 //=====start_of_setup=========================================================
3056 //============================================================================
3057 template<unsigned DIM>
3058 void QTaylorHoodSpaceTimeElement<DIM>::
3059 get_dof_numbers_for_unknowns(std::list<std::pair<unsigned long,unsigned> >&
3060 dof_lookup_list) const
3062 // Get the number of nodes in this element
3063 unsigned n_node=this->nnode();
3065 // Temporary pair (used to store dof lookup prior to being added to list)
3066 std::pair<unsigned,unsigned> dof_lookup;
3068 // Loop over the nodes
3069 for (unsigned n=0;n<n_node;n++)
3071 // Find the number of values at this node
3072 unsigned n_value=this->required_nvalue(n);
3074 // Loop over these values
3075 for (unsigned i_value=0;i_value<n_value;i_value++)
3077 // Determine the local eqn number associated with this value
3078 int local_eqn_number=this->nodal_local_eqn(n,i_value);
3080 // Ignore pinned values - far away degrees of freedom resulting
3081 // from hanging nodes can be ignored since these are be dealt
3082 // with by the element containing their master nodes
3083 if (local_eqn_number>=0)
3085 // Store dof lookup in temporary pair; the global equation number
3086 // is the first entry in pair
3087 dof_lookup.first=this->eqn_number(local_eqn_number);
3089 // Set dof numbers; this is used to distinguish between dof types
3090 // whether they be velocity dofs or the pressure dof
3091 dof_lookup.second=i_value;
3094 dof_lookup_list.push_front(dof_lookup);
3096 } // for (unsigned v=0;v<nv;v++)
3097 } // for (unsigned n=0;n<n_node;n++)
3098 } // End of get_dof_numbers_for_unknowns
3104 template class SpaceTimeNavierStokesEquations<2>;
3105 template class QTaylorHoodSpaceTimeElement<2>;
A Class for the derivatives of shape functions The class design is essentially the same as Shape,...
void initialise(const T &val)
Initialize all values in the matrix to val.
void(* SteadyExactSolutionFctPt)(const Vector< double > &, Vector< double > &)
Function pointer for function that computes vector-valued steady "exact solution" as .
void(* UnsteadyExactSolutionFctPt)(const double &, const Vector< double > &, Vector< double > &)
Function pointer for function that computes Vector-valued time-dependent function as .
static double Default_fd_jacobian_step
Double used for the default finite difference step in elemental jacobian calculations.
An OomphLibError object which should be thrown when an run-time error is encountered....
/////////////////////////////////////////////////////////////////////////// /////////////////////////...
void identify_load_data(std::set< std::pair< Data *, unsigned >> &paired_load_data)
Add to the set paired_load_data pairs containing.
void identify_pressure_data(std::set< std::pair< Data *, unsigned >> &paired_pressure_data)
Add to the set paired_pressure_data pairs containing.
A Class for shape functions. In simple cases, the shape functions have only one index that can be tho...
void get_pressure_and_velocity_mass_matrix_diagonal(Vector< double > &press_mass_diag, Vector< double > &veloc_mass_diag, const unsigned &which_one=0)
Compute the diagonal of the velocity/pressure mass matrices. If which one=0, both are computed,...
static Vector< double > Gamma
Vector to decide whether the stress-divergence form is used or not N.B. This needs to be public so th...
void get_traction(const Vector< double > &s, const Vector< double > &N, Vector< double > &traction)
Compute traction (on the viscous scale) exerted onto the fluid at local coordinate s....
void full_output(std::ostream &outfile)
Full output function: x,y,[z],u,v,[w],p,du/dt,dv/dt,[dw/dt],dissipation in tecplot format....
void compute_norm(Vector< double > &norm)
Compute the vector norm of the FEM solution.
void output_fct(std::ostream &outfile, const unsigned &nplot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
Output exact solution specified via function pointer at a given number of plot points....
static double Default_Physical_Constant_Value
Static default value for the physical constants (all initialised to zero)
void fill_in_contribution_to_hessian_vector_products(Vector< double > const &Y, DenseMatrix< double > const &C, DenseMatrix< double > &product)
Compute the hessian tensor vector products required to perform continuation of bifurcations analytica...
double kin_energy() const
Get integral of kinetic energy over element.
virtual void fill_in_generic_pressure_advection_diffusion_contribution_nst(Vector< double > &residuals, DenseMatrix< double > &jacobian, const unsigned &flag)
Compute the residuals for the associated pressure advection diffusion problem. Used by the Fp precond...
virtual void fill_in_generic_dresidual_contribution_nst(double *const ¶meter_pt, Vector< double > &dres_dparam, DenseMatrix< double > &djac_dparam, DenseMatrix< double > &dmass_matrix_dparam, const unsigned &flag)
Compute the derivatives of the residuals for the Navier-Stokes equations with respect to a parameter ...
static int Pressure_not_stored_at_node
Static "magic" number that indicates that the pressure is not stored at a node.
void output(std::ostream &outfile)
Output function: x,y,t,u,v,p in tecplot format. The default number of plot points is five.
double d_kin_energy_dt() const
Get integral of time derivative of kinetic energy over element.
double dissipation() const
Return integral of dissipation over element.
static Vector< double > Default_Gravity_vector
Static default value for the gravity vector.
virtual void fill_in_generic_residual_contribution_nst(Vector< double > &residuals, DenseMatrix< double > &jacobian, DenseMatrix< double > &mass_matrix, const unsigned &flag)
Compute the residuals for the Navier-Stokes equations. Flag=1 (or 0): do (or don't) compute the Jacob...
double pressure_integral() const
Integral of pressure over element.
void output_veloc(std::ostream &outfile, const unsigned &nplot, const unsigned &t)
Output function: x,y,t,u,v in tecplot format. Use n_plot points in each coordinate direction at times...
void compute_error(std::ostream &outfile, FiniteElement::UnsteadyExactSolutionFctPt exact_soln_pt, const double &time, double &error, double &norm)
Validate against exact solution at given time Solution is provided via function pointer....
virtual void get_dresidual_dnodal_coordinates(RankThreeTensor< double > &dresidual_dnodal_coordinates)
Compute derivatives of elemental residual vector with respect to nodal coordinates....
void get_vorticity(const Vector< double > &s, Vector< double > &vorticity) const
Compute the vorticity vector at local coordinate s.
void strain_rate(const Vector< double > &s, DenseMatrix< double > &strain_rate) const
Strain-rate tensor: 1/2 (du_i/dx_j+du_j/dx_i)
static double Default_Physical_Ratio_Value
Static default value for the physical ratios (all are initialised to one)
void output_vorticity(std::ostream &outfile, const unsigned &nplot)
Output function: x,y,t,omega in tecplot format. nplot points in each coordinate direction.
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn't been defined.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...