41 template<
unsigned DIM>
46 const unsigned& which_one)
49 unsigned n_dof = ndof();
52 if ((which_one == 0) || (which_one == 1))
55 press_mass_diag.assign(n_dof, 0.0);
59 if ((which_one == 0) || (which_one == 2))
62 veloc_mass_diag.assign(n_dof, 0.0);
69 unsigned n_master = 1;
72 double hang_weight = 1.0;
75 unsigned n_node = nnode();
84 for (
unsigned i = 0;
i < DIM;
i++)
87 u_nodal_index[
i] = this->u_index_nst(
i);
94 unsigned n_pres = this->npres_nst();
101 int p_index = this->p_nodal_index_nst();
105 bool pressure_dof_is_hanging[n_pres];
111 for (
unsigned l = 0; l < n_pres; l++)
114 pressure_dof_is_hanging[l] =
115 this->pressure_node_pt(l)->is_hanging(p_index);
122 for (
unsigned l = 0; l < n_pres; l++)
125 pressure_dof_is_hanging[l] =
false;
130 unsigned n_intpt = integral_pt()->nweight();
136 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
139 double w = integral_pt()->weight(ipt);
142 double J = J_eulerian_at_knot(ipt);
145 for (
unsigned i = 0;
i < DIM + 1;
i++)
148 s[
i] = integral_pt()->knot(ipt,
i);
155 if ((which_one == 0) || (which_one == 2))
158 shape_at_knot(ipt, psi);
161 for (
unsigned l = 0; l < n_node; l++)
164 bool is_node_hanging = node_pt(l)->is_hanging();
170 hang_info_pt = node_pt(l)->hanging_pt();
173 n_master = hang_info_pt->
nmaster();
183 for (
unsigned m = 0; m < n_master; m++)
186 for (
unsigned i = 0;
i < DIM;
i++)
192 local_eqn = this->local_hang_eqn(
202 local_eqn = this->nodal_local_eqn(l, u_nodal_index[
i]);
212 veloc_mass_diag[local_eqn] += pow(psi[l] * hang_weight, 2) *
W;
220 if ((which_one == 0) || (which_one == 1))
223 this->pshape_nst(
s, psi_p);
226 for (
unsigned l = 0; l < n_pres; l++)
229 if (pressure_dof_is_hanging[l])
232 hang_info_pt = this->pressure_node_pt(l)->hanging_pt(p_index);
235 n_master = hang_info_pt->
nmaster();
245 for (
unsigned m = 0; m < n_master; m++)
248 if (pressure_dof_is_hanging[l])
261 local_eqn = this->p_local_eqn(l);
271 press_mass_diag[local_eqn] += pow(psi_p[l] * hang_weight, 2) *
W;
285 template<
unsigned DIM>
290 const unsigned& flag)
293 OOMPH_CURRENT_FUNCTION,
294 OOMPH_EXCEPTION_LOCATION);
297 if (ndof() == 0)
return;
300 unsigned n_node = nnode();
303 unsigned n_pres = this->npres_nst();
306 unsigned u_nodal_index[DIM];
307 for (
unsigned i = 0;
i < DIM;
i++)
309 u_nodal_index[
i] = this->u_index_nst(
i);
315 int p_index = this->p_nodal_index_nst();
319 bool pressure_dof_is_hanging[n_pres];
324 for (
unsigned l = 0; l < n_pres; ++l)
326 pressure_dof_is_hanging[l] =
327 this->pressure_node_pt(l)->is_hanging(p_index);
335 "Pressure advection diffusion does not work in this case\n",
336 OOMPH_CURRENT_FUNCTION,
337 OOMPH_EXCEPTION_LOCATION);
339 for (
unsigned l = 0; l < n_pres; ++l)
341 pressure_dof_is_hanging[l] =
false;
347 DShape dpsidx(n_node, DIM);
350 Shape psip(n_pres), testp(n_pres);
351 DShape dpsip(n_pres, DIM);
352 DShape dtestp(n_pres, DIM);
355 unsigned n_intpt = integral_pt()->nweight();
362 double scaled_re = this->re() * this->density_ratio();
365 int local_eqn = 0, local_unknown = 0;
368 HangInfo *hang_info_pt = 0, *hang_info2_pt = 0;
371 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
374 for (
unsigned i = 0;
i < DIM;
i++)
s[
i] = integral_pt()->knot(ipt,
i);
377 double w = integral_pt()->weight(ipt);
381 double J = this->dshape_eulerian_at_knot(ipt, psif, dpsidx);
384 this->dpshape_and_dptest_eulerian_nst(
s, psip, dpsip, testp, dtestp);
396 for (
unsigned l = 0; l < n_pres; l++)
398 for (
unsigned i = 0;
i < DIM;
i++)
400 interpolated_dpdx[
i] += this->p_nst(l) * dpsip(l,
i);
407 for (
unsigned l = 0; l < n_node; l++)
410 for (
unsigned i = 0;
i < DIM;
i++)
413 double u_value = nodal_value(l, u_nodal_index[
i]);
414 interpolated_u[
i] += u_value * psif[l];
415 interpolated_x[
i] += nodal_position(l,
i) * psif[l];
421 if (this->Press_adv_diff_source_fct_pt != 0)
423 source = this->Press_adv_diff_source_fct_pt(interpolated_x);
428 unsigned n_master = 1;
429 double hang_weight = 1.0;
433 for (
unsigned l = 0; l < n_pres; l++)
436 if (pressure_dof_is_hanging[l])
440 hang_info_pt = this->pressure_node_pt(l)->hanging_pt(p_index);
443 n_master = hang_info_pt->
nmaster();
452 for (
unsigned m = 0; m < n_master; m++)
456 if (pressure_dof_is_hanging[l])
466 local_eqn = this->p_local_eqn(l);
473 residuals[local_eqn] -= source * testp[l] *
W * hang_weight;
474 for (
unsigned k = 0; k < DIM; k++)
476 residuals[local_eqn] +=
477 interpolated_dpdx[k] *
478 (scaled_re * interpolated_u[k] * testp[l] + dtestp(l, k)) *
W *
486 unsigned n_master2 = 1;
487 double hang_weight2 = 1.0;
490 for (
unsigned l2 = 0; l2 < n_pres; l2++)
493 if (pressure_dof_is_hanging[l2])
496 this->pressure_node_pt(l2)->hanging_pt(p_index);
499 n_master2 = hang_info2_pt->nmaster();
508 for (
unsigned m2 = 0; m2 < n_master2; m2++)
512 if (pressure_dof_is_hanging[l2])
515 local_unknown = this->local_hang_eqn(
516 hang_info2_pt->master_node_pt(m2), p_index);
518 hang_weight2 = hang_info2_pt->master_weight(m2);
522 local_unknown = this->p_local_eqn(l2);
527 if (local_unknown >= 0)
529 if ((
int(eqn_number(local_eqn)) !=
530 this->Pinned_fp_pressure_eqn) &&
531 (
int(eqn_number(local_unknown)) !=
532 this->Pinned_fp_pressure_eqn))
534 for (
unsigned k = 0; k < DIM; k++)
536 jacobian(local_eqn, local_unknown) +=
538 (scaled_re * interpolated_u[k] * testp[l] +
540 W * hang_weight * hang_weight2;
545 if ((
int(eqn_number(local_eqn)) ==
546 this->Pinned_fp_pressure_eqn) &&
547 (int(eqn_number(local_unknown)) ==
548 this->Pinned_fp_pressure_eqn))
550 jacobian(local_eqn, local_unknown) = 1.0;
564 this->Pressure_advection_diffusion_robin_element_pt.size();
565 for (
unsigned e = 0;
e < nrobin;
e++)
567 this->Pressure_advection_diffusion_robin_element_pt[
e]
568 ->fill_in_generic_residual_contribution_fp_press_adv_diff_robin_bc(
569 residuals, jacobian, flag);
580 template<
unsigned DIM>
585 const unsigned& flag)
588 if (ndof() == 0)
return;
591 unsigned n_node = nnode();
594 unsigned n_pres = this->npres_nst();
597 unsigned u_nodal_index[DIM];
600 for (
unsigned i = 0;
i < DIM;
i++)
603 u_nodal_index[
i] = this->u_index_nst(
i);
608 int p_index = this->p_nodal_index_nst();
612 bool pressure_dof_is_hanging[n_pres];
618 for (
unsigned l = 0; l < n_pres; ++l)
621 pressure_dof_is_hanging[l] =
622 this->pressure_node_pt(l)->is_hanging(p_index);
629 for (
unsigned l = 0; l < n_pres; ++l)
632 pressure_dof_is_hanging[l] =
false;
643 DShape dpsifdx(n_node, DIM + 1);
646 DShape dtestfdx(n_node, DIM + 1);
655 unsigned n_intpt = integral_pt()->nweight();
664 double scaled_re = this->re() * this->density_ratio();
667 double scaled_re_st = this->re_st() * this->density_ratio();
670 double scaled_dre_st_dre_st = this->density_ratio();
673 double scaled_re_inv_fr = this->re_invfr() * this->density_ratio();
676 double visc_ratio = this->viscosity_ratio();
685 int local_unknown = 0;
694 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
697 for (
unsigned i = 0;
i < DIM + 1;
i++)
700 s[
i] = integral_pt()->knot(ipt,
i);
704 double w = integral_pt()->weight(ipt);
707 double J = this->dshape_and_dtest_eulerian_at_knot_nst(
708 ipt, psif, dpsifdx, testf, dtestfdx);
711 this->pshape_nst(
s, psip, testp);
717 double interpolated_t = 0.0;
720 double interpolated_p = 0.0;
738 for (
unsigned l = 0; l < n_pres; l++)
741 interpolated_p += this->p_nst(l) * psip[l];
748 for (
unsigned l = 0; l < n_node; l++)
751 interpolated_t += this->nodal_position(l, DIM) * psif(l);
754 for (
unsigned i = 0;
i < DIM;
i++)
757 double u_value = this->nodal_value(l, u_nodal_index[
i]);
760 interpolated_u[
i] += u_value * psif[l];
763 interpolated_x[
i] += this->nodal_position(l,
i) * psif[l];
766 interpolated_dudt[
i] += u_value * dpsifdx(l, DIM);
769 for (
unsigned j = 0; j < DIM; j++)
772 interpolated_dudx(
i, j) += u_value * dpsifdx(l, j);
778 if (!(this->ALE_is_disabled))
781 for (
unsigned l = 0; l < n_node; l++)
784 for (
unsigned i = 0;
i < DIM;
i++)
787 mesh_velocity[
i] += this->nodal_position(l,
i) * dpsifdx(l, DIM);
796 this->get_body_force_nst(
797 interpolated_t, ipt,
s, interpolated_x, body_force);
800 double source = this->get_source_nst(interpolated_t, ipt, interpolated_x);
809 unsigned n_master = 1;
812 double hang_weight = 1.0;
815 for (
unsigned l = 0; l < n_node; l++)
818 bool is_node_hanging = node_pt(l)->is_hanging();
824 hang_info_pt = node_pt(l)->hanging_pt();
827 n_master = hang_info_pt->
nmaster();
837 for (
unsigned m = 0; m < n_master; m++)
840 for (
unsigned i = 0;
i < DIM;
i++)
856 local_eqn = this->nodal_local_eqn(l, u_nodal_index[
i]);
866 residuals[local_eqn] +=
867 body_force[
i] * testf[l] *
W * hang_weight;
870 residuals[local_eqn] +=
871 scaled_re_inv_fr * testf[l] * G[
i] *
W * hang_weight;
874 residuals[local_eqn] +=
875 interpolated_p * dtestfdx(l,
i) *
W * hang_weight;
878 residuals[local_eqn] -= (scaled_re_st * interpolated_dudt[
i] *
879 testf[l] *
W * hang_weight);
882 if (!(this->ALE_is_disabled))
885 for (
unsigned k = 0; k < DIM; k++)
888 residuals[local_eqn] +=
889 (scaled_re_st * mesh_velocity[k] * interpolated_dudx(
i, k) *
890 testf[l] *
W * hang_weight);
895 for (
unsigned k = 0; k < DIM; k++)
898 residuals[local_eqn] -=
899 (scaled_re * interpolated_u[k] * interpolated_dudx(
i, k) *
900 testf[l] *
W * hang_weight);
904 for (
unsigned k = 0; k < DIM; k++)
910 residuals[local_eqn] -=
911 ((interpolated_dudx(
i, k) +
912 this->Gamma[
i] * interpolated_dudx(k,
i)) *
913 visc_ratio * dtestfdx(l, k) *
W * hang_weight);
923 unsigned n_master2 = 1;
926 double hang_weight2 = 1.0;
929 for (
unsigned l2 = 0; l2 < n_node; l2++)
932 bool is_node2_hanging = node_pt(l2)->is_hanging();
935 if (is_node2_hanging)
938 hang_info2_pt = node_pt(l2)->hanging_pt();
941 n_master2 = hang_info2_pt->
nmaster();
951 for (
unsigned m2 = 0; m2 < n_master2; m2++)
954 for (
unsigned i2 = 0; i2 < DIM; i2++)
957 if (is_node2_hanging)
960 local_unknown = this->local_hang_eqn(
971 this->nodal_local_eqn(l2, u_nodal_index[i2]);
978 if (local_unknown >= 0)
981 jacobian(local_eqn, local_unknown) -=
982 (visc_ratio * this->Gamma[
i] * dpsifdx(l2,
i) *
983 dtestfdx(l, i2) *
W * hang_weight * hang_weight2);
986 jacobian(local_eqn, local_unknown) -=
987 (scaled_re * psif[l2] * interpolated_dudx(
i, i2) *
988 testf[l] *
W * hang_weight * hang_weight2);
1000 mass_matrix(local_eqn, local_unknown) +=
1001 (scaled_re_st * psif[l2] * testf[l] *
W *
1002 hang_weight * hang_weight2);
1006 jacobian(local_eqn, local_unknown) -=
1007 (scaled_re_st * dpsifdx(l2, DIM) * testf[l] *
W *
1008 hang_weight * hang_weight2);
1011 for (
unsigned k = 0; k < DIM; k++)
1014 jacobian(local_eqn, local_unknown) -=
1015 (scaled_re * interpolated_u[k] * dpsifdx(l2, k) *
1016 testf[l] *
W * hang_weight * hang_weight2);
1020 if (!(this->ALE_is_disabled))
1023 for (
unsigned k = 0; k < DIM; k++)
1026 jacobian(local_eqn, local_unknown) +=
1027 (scaled_re_st * mesh_velocity[k] *
1028 dpsifdx(l2, k) * testf[l] *
W * hang_weight *
1034 for (
unsigned k = 0; k < DIM; k++)
1037 jacobian(local_eqn, local_unknown) -=
1038 (visc_ratio * dpsifdx(l2, k) * dtestfdx(l, k) *
1039 W * hang_weight * hang_weight2);
1048 for (
unsigned l2 = 0; l2 < n_pres; l2++)
1051 if (pressure_dof_is_hanging[l2])
1056 this->pressure_node_pt(l2)->hanging_pt(p_index);
1059 n_master2 = hang_info2_pt->
nmaster();
1069 for (
unsigned m2 = 0; m2 < n_master2; m2++)
1072 if (pressure_dof_is_hanging[l2])
1075 local_unknown = this->local_hang_eqn(
1085 local_unknown = this->p_local_eqn(l2);
1092 if (local_unknown >= 0)
1094 jacobian(local_eqn, local_unknown) +=
1095 (psip[l2] * dtestfdx(l,
i) *
W * hang_weight *
1106 if (this->ReynoldsStrouhal_is_stored_as_external_data)
1109 unsigned data_index = 0;
1112 unsigned value_index = 0;
1117 this->external_local_eqn(data_index, value_index);
1120 if (local_unknown >= 0)
1123 jacobian(local_eqn, local_unknown) -=
1124 (scaled_dre_st_dre_st * interpolated_dudt[
i] * testf[l] *
1128 if (!this->ALE_is_disabled)
1131 for (
unsigned k = 0; k < DIM; k++)
1134 jacobian(local_eqn, local_unknown) +=
1135 (scaled_dre_st_dre_st * mesh_velocity[k] *
1136 interpolated_dudx(
i, k) * testf[l] *
W *
1152 for (
unsigned l = 0; l < n_pres; l++)
1155 if (pressure_dof_is_hanging[l])
1158 hang_info_pt = this->pressure_node_pt(l)->hanging_pt(p_index);
1161 n_master = hang_info_pt->
nmaster();
1171 for (
unsigned m = 0; m < n_master; m++)
1174 if (pressure_dof_is_hanging[l])
1187 local_eqn = this->p_local_eqn(l);
1197 residuals[local_eqn] -= source * testp[l] *
W * hang_weight;
1200 for (
unsigned k = 0; k < DIM; k++)
1203 residuals[local_eqn] +=
1204 interpolated_dudx(k, k) * testp[l] *
W * hang_weight;
1214 unsigned n_master2 = 1;
1217 double hang_weight2 = 1.0;
1220 for (
unsigned l2 = 0; l2 < n_node; l2++)
1223 bool is_node2_hanging = node_pt(l2)->is_hanging();
1226 if (is_node2_hanging)
1229 hang_info2_pt = node_pt(l2)->hanging_pt();
1232 n_master2 = hang_info2_pt->
nmaster();
1242 for (
unsigned m2 = 0; m2 < n_master2; m2++)
1245 for (
unsigned i2 = 0; i2 < DIM; i2++)
1248 if (is_node2_hanging)
1251 local_unknown = this->local_hang_eqn(
1262 this->nodal_local_eqn(l2, u_nodal_index[i2]);
1269 if (local_unknown >= 0)
1272 jacobian(local_eqn, local_unknown) +=
1273 (dpsifdx(l2, i2) * testp[l] *
W * hang_weight *
1293 template<
unsigned DIM>
1296 dresidual_dnodal_coordinates)
1299 throw OomphLibError(
"Space-time version has not been implemented yet!",
1300 OOMPH_CURRENT_FUNCTION,
1301 OOMPH_EXCEPTION_LOCATION);
A Class for the derivatives of shape functions The class design is essentially the same as Shape,...
Class that contains data for hanging nodes.
double const & master_weight(const unsigned &i) const
Return weight for dofs on i-th master node.
Node *const & master_node_pt(const unsigned &i) const
Return a pointer to the i-th master node.
unsigned nmaster() const
Return the number of master nodes.
An OomphLibError object which should be thrown when an run-time error is encountered....
An OomphLibWarning object which should be created as a temporary object to issue a warning....
////////////////////////////////////////////////////////////////// //////////////////////////////////...
Refineable version of Taylor Hood elements. These classes can be written in total generality.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
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,...
void fill_in_generic_residual_contribution_nst(Vector< double > &residuals, DenseMatrix< double > &jacobian, DenseMatrix< double > &mass_matrix, const unsigned &compute_jacobian_flag)
Add the elements contribution to elemental residual vector and/or Jacobian matrix....
void fill_in_generic_pressure_advection_diffusion_contribution_nst(Vector< double > &residuals, DenseMatrix< double > &jacobian, const unsigned &compute_jacobian_flag)
Compute the residuals for the associated pressure advection diffusion problem. Used by the Fp precond...
A Class for shape functions. In simple cases, the shape functions have only one index that can be tho...
//////////////////////////////////////////////////////////////////// ////////////////////////////////...