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();
1831 unsigned u_nodal_index[DIM];
1832 for (
unsigned i = 0;
i < DIM;
i++)
1834 u_nodal_index[
i] = u_index_nst(
i);
1839 DShape dpsidx(n_node, DIM + 1);
1843 Shape testp(n_pres);
1844 DShape dpsip(n_pres, DIM);
1845 DShape dtestp(n_pres, DIM);
1848 unsigned n_intpt = integral_pt()->nweight();
1851 Vector<double>
s(DIM + 1, 0.0);
1855 double scaled_re = re() * density_ratio();
1859 int local_unknown = 0;
1862 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
1865 for (
unsigned i = 0;
i < DIM + 1;
i++)
1867 s[
i] = integral_pt()->knot(ipt,
i);
1871 double w = integral_pt()->weight(ipt);
1875 double J = this->dshape_eulerian_at_knot(ipt, psif, dpsidx);
1878 this->dpshape_and_dptest_eulerian_nst(
s, psip, dpsip, testp, dtestp);
1884 Vector<double> x(DIM + 1, 0.0);
1887 Vector<double> interpolated_u(DIM, 0.0);
1888 Vector<double> interpolated_dpdx(DIM, 0.0);
1891 for (
unsigned l = 0; l < n_pres; l++)
1893 for (
unsigned i = 0;
i < DIM;
i++)
1895 interpolated_dpdx[
i] += p_nst(l) * dpsip(l,
i);
1900 for (
unsigned i = 0;
i < DIM;
i++)
1902 interpolated_u[
i] = interpolated_u_nst(
s,
i);
1906 for (
unsigned i = 0;
i < DIM + 1;
i++)
1908 x[
i] = interpolated_x(
s,
i);
1912 double source = 0.0;
1913 if (Press_adv_diff_source_fct_pt != 0)
1915 source = Press_adv_diff_source_fct_pt(x);
1919 for (
unsigned l = 0; l < n_pres; l++)
1921 local_eqn = p_local_eqn(l);
1926 residuals[local_eqn] -= source * testp[l] *
W;
1928 for (
unsigned k = 0; k < DIM; k++)
1930 residuals[local_eqn] +=
1931 interpolated_dpdx[k] *
1932 (scaled_re * interpolated_u[k] * testp[l] + dtestp(l, k)) *
W;
1939 for (
unsigned l2 = 0; l2 < n_pres; l2++)
1941 local_unknown = p_local_eqn(l2);
1944 if (local_unknown >= 0)
1946 if ((
int(eqn_number(local_eqn)) != Pinned_fp_pressure_eqn) &&
1947 (
int(eqn_number(local_unknown)) != Pinned_fp_pressure_eqn))
1949 for (
unsigned k = 0; k < DIM; k++)
1951 jacobian(local_eqn, local_unknown) +=
1953 (scaled_re * interpolated_u[k] * testp[l] +
1960 if ((
int(eqn_number(local_eqn)) == Pinned_fp_pressure_eqn) &&
1961 (int(eqn_number(local_unknown)) ==
1962 Pinned_fp_pressure_eqn))
1965 jacobian(local_eqn, local_unknown) = 1.0;
1977 unsigned nrobin = Pressure_advection_diffusion_robin_element_pt.size();
1978 for (
unsigned e = 0;
e < nrobin;
e++)
1980 Pressure_advection_diffusion_robin_element_pt[
e]
1981 ->fill_in_generic_residual_contribution_fp_press_adv_diff_robin_bc(
1982 residuals, jacobian, flag);
1992 template<
unsigned DIM>
1995 DenseMatrix<double>& jacobian,
1996 DenseMatrix<double>& mass_matrix,
1997 const unsigned& flag)
2000 if (ndof() == 0)
return;
2003 unsigned n_node = nnode();
2006 unsigned n_pres = npres_nst();
2009 unsigned u_nodal_index[DIM];
2012 for (
unsigned i = 0;
i < DIM;
i++)
2015 u_nodal_index[
i] = u_index_nst(
i);
2022 Shape testf(n_node);
2025 DShape dpsifdx(n_node, DIM + 1);
2028 DShape dtestfdx(n_node, DIM + 1);
2034 Shape testp(n_pres);
2037 unsigned n_intpt = integral_pt()->nweight();
2040 Vector<double>
s(DIM + 1, 0.0);
2046 double scaled_re = re() * density_ratio();
2049 double scaled_re_st = re() * st() * density_ratio();
2052 double scaled_dre_st_dst = re() * density_ratio();
2055 double scaled_re_inv_fr = re_invfr() * density_ratio();
2058 double visc_ratio = viscosity_ratio();
2061 Vector<double> G = g();
2067 int local_unknown = 0;
2070 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
2073 for (
unsigned i = 0;
i < DIM + 1;
i++)
2076 s[
i] = integral_pt()->knot(ipt,
i);
2080 double w = integral_pt()->weight(ipt);
2083 double J = dshape_and_dtest_eulerian_at_knot_nst(
2084 ipt, psif, dpsifdx, testf, dtestfdx);
2087 pshape_nst(
s, psip, testp);
2093 double interpolated_t = 0.0;
2096 double interpolated_p = 0.0;
2099 Vector<double> interpolated_x(DIM, 0.0);
2102 Vector<double> interpolated_u(DIM, 0.0);
2105 Vector<double> interpolated_dudt(DIM, 0.0);
2108 Vector<double> mesh_velocity(DIM, 0.0);
2111 DenseMatrix<double> interpolated_dudx(DIM, DIM, 0.0);
2114 for (
unsigned l = 0; l < n_pres; l++)
2117 interpolated_p += p_nst(l) * psip[l];
2124 for (
unsigned l = 0; l < n_node; l++)
2127 interpolated_t += raw_nodal_position(l, DIM) * psif(l);
2130 for (
unsigned i = 0;
i < DIM;
i++)
2133 double u_value = raw_nodal_value(l, u_nodal_index[
i]);
2136 interpolated_u[
i] += u_value * psif[l];
2139 interpolated_x[
i] += raw_nodal_position(l,
i) * psif[l];
2142 interpolated_dudt[
i] += u_value * dpsifdx(l, DIM);
2145 for (
unsigned j = 0; j < DIM; j++)
2148 interpolated_dudx(
i, j) += u_value * dpsifdx(l, j);
2154 if (!ALE_is_disabled)
2157 for (
unsigned l = 0; l < n_node; l++)
2160 for (
unsigned i = 0;
i < DIM;
i++)
2163 mesh_velocity[
i] += raw_nodal_position(l,
i) * dpsifdx(l, DIM);
2169 Vector<double> body_force(DIM, 0.0);
2172 get_body_force_nst(interpolated_t, ipt,
s, interpolated_x, body_force);
2175 double source = get_source_nst(interpolated_t, ipt, interpolated_x);
2184 for (
unsigned l = 0; l < n_node; l++)
2187 for (
unsigned i = 0;
i < DIM;
i++)
2190 local_eqn = nodal_local_eqn(l, u_nodal_index[
i]);
2196 residuals[local_eqn] += body_force[
i] * testf[l] *
W;
2199 residuals[local_eqn] += scaled_re_inv_fr * testf[l] * G[
i] *
W;
2202 residuals[local_eqn] += interpolated_p * dtestfdx(l,
i) *
W;
2205 residuals[local_eqn] -=
2206 scaled_re_st * interpolated_dudt[
i] * testf[l] *
W;
2209 if (!ALE_is_disabled)
2212 for (
unsigned k = 0; k < DIM; k++)
2215 residuals[local_eqn] +=
2216 (scaled_re_st * mesh_velocity[k] * interpolated_dudx(
i, k) *
2222 for (
unsigned k = 0; k < DIM; k++)
2225 residuals[local_eqn] -= (scaled_re * interpolated_u[k] *
2226 interpolated_dudx(
i, k) * testf[l] *
W);
2230 for (
unsigned k = 0; k < DIM; k++)
2236 residuals[local_eqn] -= ((interpolated_dudx(
i, k) +
2237 Gamma[
i] * interpolated_dudx(k,
i)) *
2238 visc_ratio * dtestfdx(l, k) *
W);
2248 for (
unsigned l2 = 0; l2 < n_node; l2++)
2251 for (
unsigned i2 = 0; i2 < DIM; i2++)
2254 local_unknown = nodal_local_eqn(l2, u_nodal_index[i2]);
2257 if (local_unknown >= 0)
2260 jacobian(local_eqn, local_unknown) -=
2261 (visc_ratio * Gamma[
i] * dpsifdx(l2,
i) *
2262 dtestfdx(l, i2) *
W);
2265 jacobian(local_eqn, local_unknown) -=
2266 (scaled_re * psif[l2] * interpolated_dudx(
i, i2) *
2279 mass_matrix(local_eqn, local_unknown) +=
2280 (scaled_re_st * psif[l2] * testf[l] *
W);
2284 jacobian(local_eqn, local_unknown) -=
2285 (scaled_re_st * dpsifdx(l2, DIM) * testf[l] *
W);
2288 if (!ALE_is_disabled)
2291 for (
unsigned k = 0; k < DIM; k++)
2294 jacobian(local_eqn, local_unknown) +=
2295 (scaled_re_st * mesh_velocity[k] * dpsifdx(l2, k) *
2301 for (
unsigned k = 0; k < DIM; k++)
2304 jacobian(local_eqn, local_unknown) -=
2305 (scaled_re * interpolated_u[k] * dpsifdx(l2, k) *
2310 for (
unsigned k = 0; k < DIM; k++)
2313 jacobian(local_eqn, local_unknown) -=
2314 (visc_ratio * dpsifdx(l2, k) * dtestfdx(l, k) *
W);
2322 for (
unsigned l2 = 0; l2 < n_pres; l2++)
2326 local_unknown = p_local_eqn(l2);
2329 if (local_unknown >= 0)
2332 jacobian(local_eqn, local_unknown) +=
2333 psip[l2] * dtestfdx(l,
i) *
W;
2342 if (Strouhal_is_stored_as_external_data)
2345 unsigned data_index = 0;
2348 unsigned value_index = 0;
2353 this->external_local_eqn(data_index, value_index);
2356 if (local_unknown >= 0)
2359 jacobian(local_eqn, local_unknown) -=
2360 (scaled_dre_st_dst * interpolated_dudt[
i] * testf[l] *
W);
2363 if (!ALE_is_disabled)
2366 for (
unsigned k = 0; k < DIM; k++)
2369 jacobian(local_eqn, local_unknown) +=
2370 (scaled_dre_st_dst * mesh_velocity[k] *
2371 interpolated_dudx(
i, k) * testf[l] *
W);
2385 for (
unsigned l = 0; l < n_pres; l++)
2388 local_eqn = p_local_eqn(l);
2394 residuals[local_eqn] -= source * testp[l] *
W;
2397 for (
unsigned k = 0; k < DIM; k++)
2400 residuals[local_eqn] += interpolated_dudx(k, k) * testp[l] *
W;
2410 for (
unsigned l2 = 0; l2 < n_node; l2++)
2413 for (
unsigned i2 = 0; i2 < DIM; i2++)
2416 local_unknown = nodal_local_eqn(l2, u_nodal_index[i2]);
2419 if (local_unknown >= 0)
2422 jacobian(local_eqn, local_unknown) +=
2423 dpsifdx(l2, i2) * testp[l] *
W;
2439 template<
unsigned DIM>
2442 double*
const& parameter_pt,
2443 Vector<double>& dres_dparam,
2444 DenseMatrix<double>& djac_dparam,
2445 DenseMatrix<double>& dmass_matrix_dparam,
2446 const unsigned& flag)
2449 throw OomphLibError(
"Not yet implemented\n",
2450 OOMPH_CURRENT_FUNCTION,
2451 OOMPH_EXCEPTION_LOCATION);
2458 template<
unsigned DIM>
2461 Vector<double>
const& Y,
2462 DenseMatrix<double>
const& C,
2463 DenseMatrix<double>& product)
2466 throw OomphLibError(
"Not yet implemented\n",
2467 OOMPH_CURRENT_FUNCTION,
2468 OOMPH_EXCEPTION_LOCATION);
2478 template<
unsigned DIM>
2480 RankThreeTensor<double>& dresidual_dnodal_coordinates)
2483 throw OomphLibError(
"Space-time update needs to be checked!",
2484 OOMPH_CURRENT_FUNCTION,
2485 OOMPH_EXCEPTION_LOCATION);
2494 const unsigned n_node = nnode();
2497 const unsigned n_pres = npres_nst();
2500 unsigned u_nodal_index[DIM];
2501 for (
unsigned i = 0;
i < DIM;
i++)
2503 u_nodal_index[
i] = u_index_nst(
i);
2508 Shape testf(n_node);
2509 DShape dpsifdx(n_node, DIM + 1);
2510 DShape dtestfdx(n_node, DIM + 1);
2513 Shape psip(n_pres), testp(n_pres);
2516 RankFourTensor<double> d_dpsifdx_dX(DIM, n_node, n_node, DIM);
2517 RankFourTensor<double> d_dtestfdx_dX(DIM, n_node, n_node, DIM);
2520 DenseMatrix<double> dJ_dX(DIM, n_node);
2523 RankFourTensor<double> d_dudx_dX(DIM, n_node, DIM, DIM);
2528 DenseMatrix<double> d_U_dX(DIM, n_node, 0.0);
2531 const unsigned n_intpt = integral_pt()->nweight();
2534 Vector<double>
s(DIM + 1, 0.0);
2538 double scaled_re = re() * density_ratio();
2539 double scaled_re_st = re_st() * density_ratio();
2540 double scaled_re_inv_fr = re_invfr() * density_ratio();
2541 double visc_ratio = viscosity_ratio();
2542 Vector<double> G = g();
2550 bool element_has_node_with_aux_node_update_fct =
false;
2551 for (
unsigned q = 0; q < n_node; q++)
2553 Node* nod_pt = node_pt(q);
2556 if (nod_pt->has_auxiliary_node_update_fct_pt())
2558 element_has_node_with_aux_node_update_fct =
true;
2561 Vector<double> u_ref(DIM);
2562 for (
unsigned i = 0;
i < DIM;
i++)
2564 u_ref[
i] = *(nod_pt->value_pt(u_nodal_index[
i]));
2568 for (
unsigned p = 0; p < DIM; p++)
2571 double backup = nod_pt->x(p);
2575 nod_pt->x(p) += eps_fd;
2578 nod_pt->perform_auxiliary_node_update_fct();
2582 (*(nod_pt->value_pt(u_nodal_index[p])) - u_ref[p]) / eps_fd;
2585 nod_pt->x(p) = backup;
2588 nod_pt->perform_auxiliary_node_update_fct();
2597 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
2600 for (
unsigned i = 0;
i < DIM + 1;
i++)
2602 s[
i] = integral_pt()->knot(ipt,
i);
2606 const double w = integral_pt()->weight(ipt);
2609 const double J = dshape_and_dtest_eulerian_at_knot_nst(ipt,
2619 pshape_nst(
s, psip, testp);
2622 double interpolated_t = 0.0;
2625 double interpolated_p = 0.0;
2628 Vector<double> interpolated_x(DIM, 0.0);
2631 Vector<double> interpolated_u(DIM, 0.0);
2634 Vector<double> interpolated_dudt(DIM, 0.0);
2637 Vector<double> mesh_velocity(DIM, 0.0);
2640 DenseMatrix<double> interpolated_dudx(DIM, DIM, 0.0);
2643 for (
unsigned l = 0; l < n_pres; l++)
2646 interpolated_p += p_nst(l) * psip[l];
2653 for (
unsigned l = 0; l < n_node; l++)
2656 interpolated_t += raw_nodal_position(l, DIM) * psif(l);
2659 for (
unsigned i = 0;
i < DIM;
i++)
2662 double u_value = raw_nodal_value(l, u_nodal_index[
i]);
2665 interpolated_u[
i] += u_value * psif[l];
2668 interpolated_x[
i] += raw_nodal_position(l,
i) * psif[l];
2671 interpolated_dudt[
i] += u_value * dpsifdx(l, DIM);
2674 for (
unsigned j = 0; j < DIM; j++)
2677 interpolated_dudx(
i, j) += u_value * dpsifdx(l, j);
2683 if (!ALE_is_disabled)
2686 for (
unsigned l = 0; l < n_node; l++)
2689 for (
unsigned i = 0;
i < DIM;
i++)
2692 mesh_velocity[
i] += raw_nodal_position(l,
i) * dpsifdx(l, DIM);
2699 for (
unsigned q = 0; q < n_node; q++)
2702 for (
unsigned p = 0; p < DIM; p++)
2704 for (
unsigned i = 0;
i < DIM;
i++)
2706 for (
unsigned k = 0; k < DIM; k++)
2710 for (
unsigned j = 0; j < n_node; j++)
2712 aux += raw_nodal_value(j, u_nodal_index[
i]) *
2713 d_dpsifdx_dX(p, q, j, k);
2717 d_dudx_dX(p, q,
i, k) = aux;
2724 Vector<double> body_force(DIM);
2727 get_body_force_nst(interpolated_t, ipt,
s, interpolated_x, body_force);
2730 const double source = get_source_nst(interpolated_t, ipt, interpolated_x);
2736 DenseMatrix<double> d_body_force_dx(DIM, DIM, 0.0);
2739 get_body_force_gradient_nst(
2740 interpolated_t, ipt,
s, interpolated_x, d_body_force_dx);
2743 Vector<double> source_gradient(DIM, 0.0);
2746 get_source_gradient_nst(
2747 interpolated_t, ipt, interpolated_x, source_gradient);
2751 const double pos_time_weight =
2752 (node_pt(0)->position_time_stepper_pt()->weight(1, 0));
2756 const double val_time_weight =
2757 node_pt(0)->time_stepper_pt()->weight(1, 0);
2766 for (
unsigned l = 0; l < n_node; l++)
2769 for (
unsigned i = 0;
i < DIM;
i++)
2773 local_eqn = nodal_local_eqn(l, u_nodal_index[
i]);
2779 for (
unsigned p = 0; p < DIM; p++)
2782 for (
unsigned q = 0; q < n_node; q++)
2788 double sum = body_force[
i] * testf[l];
2791 sum += scaled_re_inv_fr * testf[l] * G[
i];
2794 sum += interpolated_p * dtestfdx(l,
i);
2797 for (
unsigned k = 0; k < DIM; k++)
2803 sum -= (visc_ratio *
2804 (interpolated_dudx(
i, k) +
2805 Gamma[
i] * interpolated_dudx(k,
i)) *
2810 sum -= scaled_re_st * interpolated_dudt[
i] * testf[l];
2813 for (
unsigned k = 0; k < DIM; k++)
2816 sum -= scaled_re * interpolated_u[k] *
2817 interpolated_dudx(
i, k) * testf[l];
2821 if (!ALE_is_disabled)
2824 for (
unsigned k = 0; k < DIM; k++)
2827 sum += scaled_re_st * mesh_velocity[k] *
2828 interpolated_dudx(
i, k) * testf[l];
2834 dresidual_dnodal_coordinates(local_eqn, p, q) +=
2835 sum * dJ_dX(p, q) * w;
2841 sum = d_body_force_dx(
i, p) * psif(q) * testf(l);
2844 sum += interpolated_p * d_dtestfdx_dX(p, q, l,
i);
2847 for (
unsigned k = 0; k < DIM; k++)
2849 sum -= (visc_ratio * ((interpolated_dudx(
i, k) +
2850 Gamma[
i] * interpolated_dudx(k,
i)) *
2851 d_dtestfdx_dX(p, q, l, k) +
2852 (d_dudx_dX(p, q,
i, k) +
2853 Gamma[
i] * d_dudx_dX(p, q, k,
i)) *
2858 for (
unsigned k = 0; k < DIM; k++)
2860 double tmp = scaled_re * interpolated_u[k];
2861 if (!ALE_is_disabled)
2863 tmp -= scaled_re_st * mesh_velocity[k];
2865 sum -= tmp * d_dudx_dX(p, q,
i, k) * testf(l);
2868 if (!ALE_is_disabled)
2870 sum += scaled_re_st * pos_time_weight * psif(q) *
2871 interpolated_dudx(
i, p) * testf(l);
2875 dresidual_dnodal_coordinates(local_eqn, p, q) += sum * J * w;
2879 if (element_has_node_with_aux_node_update_fct)
2882 -visc_ratio * Gamma[
i] * dpsifdx(q,
i) * dtestfdx(l, p) -
2883 scaled_re * psif(q) * interpolated_dudx(
i, p) * testf(l);
2886 sum -= scaled_re_st * val_time_weight * psif(q) * testf(l);
2887 for (
unsigned k = 0; k < DIM; k++)
2889 sum -= visc_ratio * dpsifdx(q, k) * dtestfdx(l, k);
2890 double tmp = scaled_re * interpolated_u[k];
2891 if (!ALE_is_disabled)
2892 tmp -= scaled_re_st * mesh_velocity[k];
2893 sum -= tmp * dpsifdx(q, k) * testf(l);
2896 dresidual_dnodal_coordinates(local_eqn, p, q) +=
2897 sum * d_U_dX(p, q) * J * w;
2910 for (
unsigned l = 0; l < n_pres; l++)
2912 local_eqn = p_local_eqn(l);
2918 for (
unsigned p = 0; p < DIM; p++)
2921 for (
unsigned q = 0; q < n_node; q++)
2927 double aux = -source;
2930 for (
unsigned k = 0; k < DIM; k++)
2932 aux += interpolated_dudx(k, k);
2936 dresidual_dnodal_coordinates(local_eqn, p, q) +=
2937 aux * dJ_dX(p, q) * testp[l] * w;
2943 aux = -source_gradient[p] * psif(q);
2944 for (
unsigned k = 0; k < DIM; k++)
2946 aux += d_dudx_dX(p, q, k, k);
2949 dresidual_dnodal_coordinates(local_eqn, p, q) +=
2950 aux * testp[l] * J * w;
2954 if (element_has_node_with_aux_node_update_fct)
2956 aux = dpsifdx(q, p) * testp(l);
2957 dresidual_dnodal_coordinates(local_eqn, p, q) +=
2958 aux * d_U_dX(p, q) * J * w;
2977 3, 2, 3, 2, 2, 2, 3, 2, 3, 2, 2, 2, 2, 2,
2978 2, 2, 2, 2, 3, 2, 3, 2, 2, 2, 3, 2, 3};
2983 0, 2, 6, 8, 18, 20, 24, 26};
2994 template<
unsigned DIM>
2996 std::set<std::pair<Data*, unsigned>>& paired_load_data)
2999 unsigned u_index[DIM];
3002 for (
unsigned i = 0;
i < DIM;
i++)
3005 u_index[
i] = this->u_index_nst(
i);
3009 unsigned n_node = this->nnode();
3012 for (
unsigned n = 0; n < n_node; n++)
3016 for (
unsigned i = 0;
i < DIM;
i++)
3019 paired_load_data.insert(std::make_pair(this->node_pt(n), u_index[
i]));
3024 this->identify_pressure_data(paired_load_data);
3036 template<
unsigned DIM>
3038 std::set<std::pair<Data*, unsigned>>& paired_pressure_data)
3041 unsigned p_index =
static_cast<unsigned>(this->p_nodal_index_nst());
3044 unsigned n_pres = npres_nst();
3047 for (
unsigned l = 0; l < n_pres; l++)
3051 paired_pressure_data.insert(
3052 std::make_pair(this->node_pt(Pconv[l]), p_index));
3064 //============================================================================
3065 template<unsigned DIM>
3066 void QTaylorHoodSpaceTimeElement<DIM>::get_dof_numbers_for_unknowns(
3067 std::list<std::pair<unsigned long, unsigned> >& dof_lookup_list) const
3069 // Get the number of nodes in this element
3070 unsigned n_node=this->nnode();
3072 // Temporary pair (used to store dof lookup prior to being added to list)
3073 std::pair<unsigned,unsigned> dof_lookup;
3075 // Loop over the nodes
3076 for (unsigned n=0;n<n_node;n++)
3078 // Find the number of values at this node
3079 unsigned n_value=this->required_nvalue(n);
3081 // Loop over these values
3082 for (unsigned i_value=0;i_value<n_value;i_value++)
3084 // Determine the local eqn number associated with this value
3085 int local_eqn_number=this->nodal_local_eqn(n,i_value);
3087 // Ignore pinned values - far away degrees of freedom resulting
3088 // from hanging nodes can be ignored since these are be dealt
3089 // with by the element containing their master nodes
3090 if (local_eqn_number>=0)
3092 // Store dof lookup in temporary pair; the global equation number
3093 // is the first entry in pair
3094 dof_lookup.first=this->eqn_number(local_eqn_number);
3096 // Set dof numbers; dof number is the second entry in pair
3097 // DRAIG: Uncomment whichever one you want to use. Setting
3098 // all dof numbers to 0 means you don't distinguish between
3099 // velocity and pressure component; just aggregate everything.
3100 // In contrast, setting the dof number to i_value means the
3101 // dofs associated with the first velocity component, second
3102 // velocity component and the pressure are all separated
3103 dof_lookup.second=i_value;
3106 dof_lookup_list.push_front(dof_lookup);
3108 } // for (unsigned v=0;v<nv;v++)
3109 } // for (unsigned n=0;n<n_node;n++)
3110 } // End of get_dof_numbers_for_unknowns
3116 template class SpaceTimeNavierStokesEquations<2>;
3117 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.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...