69   const unsigned& which_one)
    73   if ((which_one==0)||(which_one==1)) 
    76      "Computation of diagonal of pressure mass matrix is not impmented yet.\n",
    77      OOMPH_CURRENT_FUNCTION,
    78      OOMPH_EXCEPTION_LOCATION);
    83   veloc_mass_diag.assign(
ndof(), 0.0);
    86   const unsigned n_node = 
nnode();
    89   const unsigned n_value = 3;
    93   for(
unsigned i=0; 
i<n_value; 
i++)
   108   for(
unsigned ipt=0; ipt<n_intpt; ipt++)
   127     for(
unsigned l=0;l<n_node;l++)
   137     for(
unsigned l=0; l<n_node; l++)
   140       for(
unsigned i=0; 
i<n_value; 
i++)
   148           veloc_mass_diag[local_eqn] += test[l]*test[l] * 
W;
   169                double& error, 
double& norm)
   183  outfile << 
"ZONE" << std::endl;
   189  for(
unsigned ipt=0;ipt<n_intpt;ipt++)
   193    for(
unsigned i=0;
i<2;
i++)
   211    (*exact_soln_pt)(time,x,exact_soln);
   214    for(
unsigned i=0;
i<3;
i++)
   216      norm+=exact_soln[
i]*exact_soln[
i]*
W;
   222    for(
unsigned i=0;
i<2;
i++)
   224      outfile << x[
i] << 
" ";
   228    for(
unsigned i=0;
i<3;
i++)
   233    outfile << std::endl;
   246   std::ostream &outfile,
   265  outfile << 
"ZONE" << std::endl;
   271  for(
unsigned ipt=0;ipt<n_intpt;ipt++)
   274    for(
unsigned i=0;
i<2;
i++)
   292    (*exact_soln_pt)(x,exact_soln);
   295    for(
unsigned i=0;
i<3;
i++)
   297      norm+=exact_soln[
i]*exact_soln[
i]*
W;
   303    for(
unsigned i=0;
i<2;
i++)
   305      outfile << x[
i] << 
" ";
   309    for(
unsigned i=0;
i<3;
i++)
   313    outfile << std::endl;   
   324   std::ostream &outfile,
   356  for(
unsigned ipt=0;ipt<n_intpt;ipt++)
   360    for(
unsigned i=0;
i<2;
i++)
   378    (*exact_soln_pt)(x,exact_soln);
   379    (*exact_soln_dr_pt)(x,exact_soln_dr);
   380    (*exact_soln_dtheta_pt)(x,exact_soln_dth);
   405            u_norm+=(1/(r*r))*exact_soln[2]*exact_soln[2]*
W;
   412            u_norm+=
cot(theta)*
cot(theta)*(1/(r*r))*exact_soln[2]*exact_soln[2]*
W;
   415            u_norm+=exact_soln_dr[2]*exact_soln_dr[2]*
W;
   417            u_norm+=(1/(r*r))*exact_soln_dth[2]*exact_soln_dth[2]*
W;
   453      p_norm+=exact_soln[3]*exact_soln[3]*
W;
   460    for(
unsigned i=0;
i<2;
i++)
   462      outfile << x[
i] << 
" ";
   466    outfile << u_error << 
"  " << u_norm << 
"  ";
   468    outfile << p_error << 
"  " << p_norm << 
"  ";
   469    outfile << std::endl; 
   497     for(
unsigned i=0;
i<Npts;
i++)
   500       s[1] = -1 + 2.0*
i/(Npts-1);
   507       outfile << x[0] << 
" ";
   508       outfile << x[1] << 
" ";
   513       outfile << shear << 
"  ";
   515       outfile << std::endl;
   538   for(
unsigned i=0;
i<Npts;
i++)
   541     s[0] = -1 + 2.0*
i/(Npts-1);
   551     outfile << theta << 
" ";
   561     outfile << shear << 
"  ";
   573       for (
unsigned j=0; j<3; j++)
   575       outfile << u_int << 
" ";
   580       outfile << std::endl;
   591      for (
unsigned j=0; j<3; j++)
   593      outfile << u_int << 
" ";
   598      outfile << std::endl;}
   612            const unsigned &nplot, 
   631  for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
   641    (*exact_soln_pt)(x,exact_soln);
   644    for(
unsigned i=0;
i<3;
i++)
   646      outfile << x[
i] << 
" ";
   650    for(
unsigned i=0;
i<exact_soln.size();
i++)
   652      outfile << exact_soln[
i] << 
" ";
   655    outfile << std::endl;
   672            const unsigned &nplot, 
   691  for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
   701    (*exact_soln_pt)(time,x,exact_soln);
   704    for(
unsigned i=0;
i<3;
i++)
   706      outfile << x[
i] << 
" ";
   710    for(
unsigned i=0;
i<exact_soln.size();
i++)
   712      outfile << exact_soln[
i] << 
" ";
   715    outfile << std::endl;
   731                                                   const unsigned& nplot, 
   736  unsigned n_node = 
nnode();
   751  for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
   761    for(
unsigned i=0;
i<3;
i++) 
   763      interpolated_x[
i]=0.0;
   764      interpolated_u[
i]=0.0;
   768      for(
unsigned l=0;l<n_node;l++) 
   770        interpolated_u[
i] += 
nodal_value(t,l,u_nodal_index)*psi[l];
   776    for(
unsigned i=0;
i<2;
i++) 
   778      outfile << interpolated_x[
i] << 
" ";
   782    for(
unsigned i=0;
i<3;
i++) 
   784      outfile << interpolated_u[
i] << 
" ";
   787    outfile << std::endl;   
   802                                             const unsigned &nplot)
   813  for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
   829    outfile << r*sin(theta) << 
" " << r*cos(theta) << 
" ";
   835    outfile << u_r*sin(theta) + u_theta*cos(theta) << 
" "    836            << u_r*cos(theta) - u_theta*sin(theta) << 
" ";
   842    for(
unsigned i=0;
i<3;
i++) 
   853    outfile << std::endl;   
   869                                             const unsigned &nplot)
   880  for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
   887    for(
unsigned i=0;
i<2;
i++) 
   893    for(
unsigned i=0;
i<3;
i++) 
   901  fprintf(file_pt,
"\n");
   916                                                  const unsigned &nplot)
   920                      OOMPH_CURRENT_FUNCTION,
   921                      OOMPH_EXCEPTION_LOCATION);
   936  unsigned n_node = 
nnode();
   944  for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
   960    for(
unsigned i=0;
i<3;
i++)
   965      for(
unsigned j=0;j<2;j++)
   967        interpolated_dudx(
i,j) = 0.0;
   975    for(
unsigned i=0;
i<3;
i++)
   980      for(
unsigned l=0;l<n_node;l++) 
   986        for(
unsigned j=0;j<2;j++)
   988          interpolated_dudx(
i,j) += 
nodal_value(l,u_nodal_index)*dpsifdx(l,j);
   995    for(
unsigned i=0;
i<3;
i++)
   998      for (
unsigned k=0;k<2;k++)
  1000        dudt_ALE[
i]-=mesh_veloc[k]*interpolated_dudx(
i,k);
  1006    for(
unsigned i=0;
i<2;
i++) 
  1012    for(
unsigned i=0;
i<3;
i++) 
  1021    for(
unsigned i=0;
i<3;
i++) 
  1023      outfile << dudt_ALE[
i] << 
" ";
  1030    outfile << std::endl;   
  1047                  const unsigned &nplot) 
  1061  for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
  1068    for(
unsigned i=0;
i<2;
i++) 
  1076    outfile << vorticity[0] << std::endl;;
  1102  for(
unsigned ipt=0;ipt<n_intpt;ipt++)
  1106    for(
unsigned i=0;
i<2;
i++)
  1122    double local_diss=0.0;
  1123    for(
unsigned i=0;
i<3;
i++) 
  1125      for(
unsigned j=0;j<3;j++) 
  1127        local_diss+=2.0*strainrate(
i,j)*strainrate(
i,j);
  1131    diss+=local_diss*w*J;
  1156  for (
unsigned i=0;
i<3;
i++)
  1160    if(
i<2) {traction[
i]=-press*N[
i];}
  1163    else {traction[
i] = 0.0;}
  1165    for (
unsigned j=0;j<2;j++)
  1167      traction[
i]+=2.0*strainrate(
i,j)*N[j];
  1183  double local_diss=0.0;
  1184  for(
unsigned i=0;
i<3;
i++) 
  1186    for(
unsigned j=0;j<3;j++) 
  1188      local_diss+=2.0*strainrate(
i,j)*strainrate(
i,j);
  1205  double interpolated_r = 0.0;
  1206  double interpolated_theta = 0.0;
  1212  unsigned n_node = 
nnode();
  1222  for(
unsigned l=0;l<n_node;l++)
  1230  for(
unsigned i=0;
i<3;
i++)
  1235    for(
unsigned l=0;l<n_node;l++) 
  1238      const double nodal_u = this->
nodal_value(l,u_nodal_index);
  1240      interpolated_u[
i] += nodal_u*psi(l);
  1242      for(
unsigned j=0;j<2;j++)
  1244        dudx(
i,j) += nodal_u*dpsidx(l,j);
  1250  strainrate(0,0) = dudx(0,0);
  1251  strainrate(0,1) = 0.0;
  1252  strainrate(0,2) = 0.0;;
  1253  strainrate(1,1) = 0.0;
  1254  strainrate(1,2) = 0.0;
  1255  strainrate(2,2) = 0.0;
  1260  if(std::fabs(interpolated_r) > 1.0
e-15)
  1263    double inverse_r = 1.0/interpolated_r;
  1266    bool include_cot_terms = 
false;
  1267    double cot_theta = 0.0;
  1269    if((std::fabs(interpolated_theta) > 1.0
e-15) && 
  1270       (std::fabs(pi - interpolated_theta) > 1.0
e-15))
  1272      include_cot_terms = 
true;
  1273      cot_theta = this->
cot(interpolated_theta);
  1276    strainrate(0,1) = 0.5*(dudx(1,0) + 
  1277                           (dudx(0,1) - interpolated_u[1])*inverse_r);
  1278    strainrate(0,2) = 0.5*(dudx(2,0)  - interpolated_u[2]*inverse_r);
  1279    strainrate(1,1) = (dudx(1,1) + interpolated_u[0])*inverse_r;
  1281    if(include_cot_terms)
  1283      strainrate(1,2) = 0.5*(dudx(2,1)- interpolated_u[2]*cot_theta)*inverse_r;
  1285       (interpolated_u[0] + interpolated_u[1]*cot_theta)*inverse_r;
  1290  strainrate(1,0) = strainrate(0,1);
  1291  strainrate(2,0) = strainrate(0,2);
  1292  strainrate(2,1) = strainrate(1,2);
  1306   "Not tested for spherical Navier-Stokes elements",
  1307   OOMPH_CURRENT_FUNCTION,
  1308   OOMPH_EXCEPTION_LOCATION);
  1311    if (vorticity.size()!=1)
  1313      std::ostringstream error_message;
  1315       << 
"Computation of vorticity in 2D requires a 1D vector\n"  1316       << 
"which contains the only non-zero component of the\n"  1317       << 
"vorticity vector. You've passed a vector of size "  1318       << vorticity.size() << std::endl;
  1321                          OOMPH_CURRENT_FUNCTION,
  1322                          OOMPH_EXCEPTION_LOCATION);
  1333  unsigned n_node = 
nnode();
  1337  DShape dpsidx(n_node,DIM);
  1343  for(
unsigned i=0;
i<DIM;
i++)
  1345    for(
unsigned j=0;j<DIM;j++)
  1352    for(
unsigned i=0;
i<DIM;
i++)
  1357      for(
unsigned j=0;j<DIM;j++)
  1360        for(
unsigned l=0;l<n_node;l++) 
  1368  vorticity[0]=dudx(1,0)-dudx(0,1);
  1387  for(
unsigned ipt=0;ipt<n_intpt;ipt++)
  1390    for(
unsigned i=0;
i<2;
i++)
  1402    double veloc_squared=0.0;
  1403    for(
unsigned i=0;
i<3;
i++) 
  1408    kin_en+=0.5*veloc_squared*w*J;
  1422   "Not tested for spherical Navier-Stokes elements",
  1423   OOMPH_CURRENT_FUNCTION,
  1424   OOMPH_EXCEPTION_LOCATION);
  1428  double d_kin_en_dt=0.0;
  1437  const unsigned n_node = this->
nnode();
  1444  unsigned u_index[3];
  1448  for(
unsigned ipt=0;ipt<n_intpt;ipt++)
  1460    for(
unsigned l=0;l<n_node;l++)
  1463      for(
unsigned i=0;
i<3;
i++)
  1477      for(
unsigned l=0;l<n_node;l++) 
  1480        for(
unsigned i=0;
i<2;
i++)
  1486        for(
unsigned i=0;
i<3;
i++)
  1488          for(
unsigned j=0;j<2;j++)
  1490            interpolated_dudx(
i,j) += 
  1497      for(
unsigned i=0;
i<3;
i++)
  1499        for (
unsigned k=0;k<2;k++)
  1501          interpolated_dudt[
i] -= mesh_velocity[k]*interpolated_dudx(
i,k);
  1509    for(
unsigned i=0;
i<3;
i++) 
  1510     { sum += interpolated_u[
i]*interpolated_dudt[
i];}
  1512    d_kin_en_dt += sum*w*J;
  1536  for(
unsigned ipt=0;ipt<n_intpt;ipt++)
  1540    for(
unsigned i=0;
i<2;
i++)
  1580  if (
ndof()==0) 
return;
  1583  const unsigned n_node = 
nnode();
  1592  unsigned u_nodal_index[3];
  1596  Shape psif(n_node), testf(n_node);
  1597  DShape dpsifdx(n_node,2), dtestfdx(n_node,2);
  1600  Shape psip(n_pres), testp(n_pres);
  1618  int local_eqn=0, local_unknown=0;
  1621  for(
unsigned ipt=0;ipt<n_intpt;ipt++)
  1631                                                     dpsifdx,testf,dtestfdx);
  1637    const double W = w*J;
  1641    double interpolated_p=0.0;
  1649    for(
unsigned l=0;l<n_pres;l++) 
  1656    for(
unsigned l=0;l<n_node;l++) 
  1659      double psi_ = psif(l);
  1661      for(
unsigned i=0;
i<2;
i++)
  1667      for(
unsigned i=0;
i<3;
i++)
  1671        interpolated_u[
i] += u_value*psi_;
  1675        for(
unsigned j=0;j<2;j++)
  1677          interpolated_dudx(i,j) += u_value*dpsifdx(l,j);
  1685                      "SphericalNS::fill_in...",
  1686                      OOMPH_EXCEPTION_LOCATION);
  1688      for(
unsigned l=0;l<n_node;l++) 
  1691        for(
unsigned i=0;
i<2;
i++)
  1709    const double r = interpolated_x[0];
  1710    const double r2 = r*r;
  1711    const double sin_theta = sin(interpolated_x[1]);
  1712    const double cos_theta = cos(interpolated_x[1]);
  1713    const double cot_theta = cos_theta/sin_theta;
  1715    const double u_r = interpolated_u[0];
  1716    const double u_theta = interpolated_u[1];
  1717    const double u_phi = interpolated_u[2];
  1720    for(
unsigned l=0;l<n_node;l++)
  1734        double conv = u_r*interpolated_dudx(0,0)*r;
  1737        conv += u_theta*interpolated_dudx(0,1);
  1740        conv -= (u_theta*u_theta + u_phi*u_phi);
  1745         (scaled_re_st*r2*dudt[0] + r*scaled_re*conv)*sin_theta*testf[l];
  1750          sum -= scaled_re_st*
  1751           (mesh_velocity[0]*interpolated_dudx(0,0)*r
  1752            + mesh_velocity[1]*(interpolated_dudx(0,1) - u_theta))
  1753           *r*sin_theta*testf[l];
  1757        sum -= 2.0*scaled_re_inv_ro*sin_theta*u_phi*r2*sin_theta*testf[l];
  1761         (-interpolated_p + 2.0*interpolated_dudx(0,0))*
  1762         r2*sin_theta*dtestfdx(l,0);
  1765        sum += (r*interpolated_dudx(1,0) - 
  1766                u_theta + interpolated_dudx(0,1))*sin_theta*dtestfdx(l,1);
  1769        sum += 2.0*(( -r*interpolated_p + interpolated_dudx(1,1) + 
  1770                       2.0*u_r)*sin_theta + u_theta*cos_theta)*testf(l);
  1774        residuals[local_eqn] -= sum*
W;
  1780          for(
unsigned l2=0;l2<n_node;l2++)
  1789            if(local_unknown >= 0)
  1793               r*(psif(l2)*interpolated_dudx(0,0) + u_r*dpsifdx(l2,0));
  1796              jac_conv += u_theta*dpsifdx(l2,1);
  1802                psif(l2)*r2 + scaled_re*jac_conv*r)*testf(l);
  1807                jac_sum -= scaled_re_st*
  1808                 (mesh_velocity[0]*dpsifdx(l2,0)*r
  1809                  + mesh_velocity[1]*dpsifdx(l2,1))*r*sin_theta*testf(l);
  1815              jac_sum += 2.0*dpsifdx(l2,0)*dtestfdx(l,0)*r2;          
  1819              jac_sum += dpsifdx(l2,1)*dtestfdx(l,1); 
  1824              jac_sum += 4.0*psif[l2]*testf(l);
  1828              jacobian(local_eqn,local_unknown) -= jac_sum*sin_theta*
W;
  1833                mass_matrix(local_eqn,local_unknown) += 
  1834                 scaled_re_st*psif[l2]*testf[l]*r2*sin_theta*
W;
  1844            if(local_unknown >= 0)
  1850               scaled_re*(interpolated_dudx(0,1) - 2.0*u_theta)*
  1851               psif(l2)*r*sin_theta*testf(l); 
  1856                jac_sum += scaled_re_st*
  1857                 mesh_velocity[1]*psif(l2)*r*sin_theta*testf(l);
  1862              jac_sum += (r*dpsifdx(l2,0) - psif(l2))*dtestfdx(l,1)*sin_theta;
  1867               2.0*(dpsifdx(l2,1)*sin_theta + psif(l2)*cos_theta)*testf(l);
  1870              jacobian(local_eqn,local_unknown) -= jac_sum*
W;
  1879            if(local_unknown >= 0)
  1882              jacobian(local_eqn,local_unknown) += 
  1883               2.0*scaled_re*u_phi*psif(l2)*r*sin_theta*testf[l]*
W;
  1886              jacobian(local_eqn,local_unknown) +=
  1887               2.0*scaled_re_inv_ro*sin_theta*psif(l2)*r2*sin_theta*testf[l]*
W;
  1896          for(
unsigned l2=0;l2<n_pres;l2++)
  1900            if(local_unknown >= 0)
  1902              jacobian(local_eqn,local_unknown) += 
  1903               psip(l2)*(r2*dtestfdx(l,0) + 2.0*r*testf(l))*sin_theta*W;
  1922         (u_r*interpolated_dudx(1,0)*r + 
  1923          u_theta*interpolated_dudx(1,1)
  1924          + u_r*u_theta)*sin_theta - u_phi*u_phi*cos_theta;
  1929         (scaled_re_st*dudt[1]*r2*sin_theta + scaled_re*r*conv)*testf(l);
  1934          sum -= scaled_re_st*
  1935           (mesh_velocity[0]*interpolated_dudx(1,0)*r
  1936            + mesh_velocity[1]*(interpolated_dudx(1,1) + u_r))
  1937            *r*sin_theta*testf(l);
  1941        sum -= 2.0*scaled_re_inv_ro*cos_theta*u_phi*r2*sin_theta*testf[l];
  1944        sum += (r*interpolated_dudx(1,0) - u_theta + interpolated_dudx(0,1))
  1945         *r*sin_theta*dtestfdx(l,0);
  1948        sum += (-r*interpolated_p + 2.0*interpolated_dudx(1,1) +
  1949                2.0*u_r)*dtestfdx(l,1)*sin_theta;
  1952        sum -= ((r*interpolated_dudx(1,0) - u_theta + interpolated_dudx(0,1))*
  1954                 -(-r*interpolated_p + 2.0*u_r + 2.0*u_theta*cot_theta)*
  1955                cos_theta)*testf(l);
  1959        residuals[local_eqn] -= sum*
W;
  1965          for(
unsigned l2=0;l2<n_node;l2++)
  1974            if(local_unknown >= 0)
  1979              double jac_sum = scaled_re*(
  1980               r2*interpolated_dudx(1,0) + r*u_theta)*psif(l2)*
  1986                jac_sum -= scaled_re_st*
  1987                 mesh_velocity[1]*psif(l2)*r*sin_theta*testf(l);
  1992              jac_sum += dpsifdx(l2,1)*dtestfdx(l,0)*sin_theta*r;
  1996              jac_sum += 2.0*psif(l2)*dtestfdx(l,1)*sin_theta;
  2000              jac_sum -= (dpsifdx(l2,1)*sin_theta  
  2001                          - 2.0*psif(l2)*cos_theta)*testf(l);
  2004              jacobian(local_eqn,local_unknown) -= jac_sum*
W;
  2014            if(local_unknown >= 0)
  2017              double jac_conv = r*u_r*dpsifdx(l2,0) + u_theta*dpsifdx(l2,1) + 
  2018               (interpolated_dudx(1,1) + u_r)*psif(l2);
  2024                psif(l2)*r2 + scaled_re*r*jac_conv)*testf(l)*sin_theta;
  2030                jac_sum -= scaled_re_st*
  2031                 (mesh_velocity[0]*dpsifdx(l2,0)*r
  2032                  + mesh_velocity[1]*dpsifdx(l2,1))*r*sin_theta*testf(l);
  2037              jac_sum += (r*dpsifdx(l2,0) - psif(l2))*r*dtestfdx(l,0)*sin_theta;
  2041              jac_sum += 2.0*dpsifdx(l2,1)*dtestfdx(l,1)*sin_theta;
  2045              jac_sum -= ((r*dpsifdx(l2,0) - psif(l2))*sin_theta 
  2046                          - 2.0*psif(l2)*cot_theta*cos_theta)*testf(l);
  2049              jacobian(local_eqn,local_unknown) -= jac_sum*
W;
  2054                mass_matrix(local_eqn,local_unknown) += 
  2055                 scaled_re_st*psif[l2]*testf[l]*r2*sin_theta*
W;
  2065            if(local_unknown >= 0)
  2068              jacobian(local_eqn,local_unknown) += 
  2069               scaled_re*2.0*r*psif(l2)*u_phi*cos_theta*testf(l)*
W;
  2072              jacobian(local_eqn,local_unknown) +=
  2073               2.0*scaled_re_inv_ro*cos_theta*psif(l2)*r2*sin_theta*testf[l]*
W;
  2082          for(
unsigned l2=0;l2<n_pres;l2++)
  2086            if(local_unknown >= 0)
  2088              jacobian(local_eqn,local_unknown) += 
  2089               psip(l2)*r*(dtestfdx(l,1)*sin_theta + 
  2090                           cos_theta*testf[l])*W;
  2108        double conv = u_r*interpolated_dudx(2,0)*r*sin_theta;
  2111        conv += u_theta*interpolated_dudx(2,1)*sin_theta;
  2114        conv += u_phi*(u_r*sin_theta + u_theta*cos_theta);
  2117        double sum = (scaled_re_st*r2*dudt[2]*sin_theta
  2118                      + scaled_re*conv*r)*testf(l);
  2123          sum -= scaled_re_st*
  2124           (mesh_velocity[0]*interpolated_dudx(2,0)*r
  2125            + mesh_velocity[1]*interpolated_dudx(2,1))*r*sin_theta*testf(l);
  2129        sum += 2.0*scaled_re_inv_ro*
  2130         (cos_theta*u_theta + sin_theta*u_r)*r2*sin_theta*testf[l];
  2133        sum += (r2*interpolated_dudx(2,0) - r*u_phi)*dtestfdx(l,0)*sin_theta;
  2136        sum += (interpolated_dudx(2,1)*sin_theta - u_phi*cos_theta)*
  2141         ((r*interpolated_dudx(2,0) - u_phi)*sin_theta
  2142          + (interpolated_dudx(2,1) - u_phi*cot_theta)*cos_theta)*testf(l);
  2145        residuals[local_eqn] -= sum*
W;
  2152          for(
unsigned l2=0;l2<n_node;l2++)
  2161            if(local_unknown >= 0)
  2164              jacobian(local_eqn,local_unknown) -= 
  2165               scaled_re*(r*interpolated_dudx(2,0) + u_phi)
  2166               *psif(l2)*testf(l)*r*sin_theta*
W;
  2169              jacobian(local_eqn,local_unknown) -=
  2170               2.0*scaled_re_inv_ro*sin_theta*psif(l2)*r2*sin_theta*testf[l]*
W;
  2178            if(local_unknown >= 0)
  2181              jacobian(local_eqn,local_unknown) -=
  2182               scaled_re*(interpolated_dudx(2,1)*sin_theta
  2183                          + u_phi*cos_theta)*r*psif(l2)*testf(l)*
W;
  2187              jacobian(local_eqn,local_unknown) -=
  2188               2.0*scaled_re_inv_ro*cos_theta*psif(l2)*r2*sin_theta*testf[l]*
W;
  2198            if(local_unknown >= 0)
  2201              double jac_conv = r*u_r*dpsifdx(l2,0)*sin_theta;
  2204              jac_conv += u_theta*dpsifdx(l2,1)*sin_theta;
  2207              jac_conv += (u_r*sin_theta + u_theta*cos_theta)*psif(l2);
  2212                psif(l2)*r2*sin_theta +
  2213                scaled_re*r*jac_conv)*testf(l);
  2219                jac_sum -= scaled_re_st*
  2220                 (mesh_velocity[0]*dpsifdx(l2,0)*r
  2221                  + mesh_velocity[1]*dpsifdx(l2,1))*r*sin_theta*testf(l);
  2226              jac_sum += (r*dpsifdx(l2,0) - psif(l2))*dtestfdx(l,0)*r*sin_theta;
  2230              jac_sum += (dpsifdx(l2,1)*sin_theta - psif(l2)*cos_theta)*
  2235              jac_sum -= ((r*dpsifdx(l2,0) - psif(l2))*sin_theta
  2236                          + (dpsifdx(l2,1) - psif(l2)*cot_theta)*cos_theta)*
  2240              jacobian(local_eqn,local_unknown) -= jac_sum*
W;
  2245                mass_matrix(local_eqn,local_unknown) += 
  2246                 scaled_re_st*psif(l2)*testf[l]*r2*sin_theta*
W;
  2271    for(
unsigned l=0;l<n_pres;l++)
  2278        residuals[local_eqn] += 
  2279         ((2.0*u_r + r*interpolated_dudx(0,0) + interpolated_dudx(1,1))*
  2280          sin_theta + u_theta*cos_theta)*r*testp(l)*
W;
  2286          for(
unsigned l2=0;l2<n_node;l2++)
  2295            if(local_unknown >= 0)
  2297              jacobian(local_eqn,local_unknown) += 
  2298               (2.0*psif(l2) + r*dpsifdx(l2,0))*r*sin_theta*testp(l)*
W;
  2308            if(local_unknown >= 0)
  2310              jacobian(local_eqn,local_unknown) += 
  2311               r*(dpsifdx(l2,1)*sin_theta + psif(l2)*cos_theta)*testp(l)*
W;
  2342  unsigned u_index[3];
  2346  unsigned n_node = this->
nnode();
  2347  for(
unsigned n=0;n<n_node;n++)
  2351    for(
unsigned i=0;
i<3;
i++)
  2353      paired_load_data.insert(std::make_pair(this->
node_pt(n),u_index[
i]));
  2375  for(
unsigned l=0;l<n_internal;l++)
  2379    for (
unsigned j=0;j<nval;j++)
  2395  std::list<std::pair<unsigned long,unsigned> >& dof_lookup_list)
 const  2398  unsigned n_node = this->
nnode();
  2404  std::pair<unsigned,unsigned> dof_lookup;
  2407  unsigned pressure_dof_number = 3;
  2410  for (
unsigned n = 0; n < n_press; n++)
  2418    if (local_eqn_number >= 0)
  2422      dof_lookup.first = this->
eqn_number(local_eqn_number);
  2423      dof_lookup.second = pressure_dof_number;
  2426      dof_lookup_list.push_front(dof_lookup);
  2431  for (
unsigned n = 0; n < n_node; n++)
  2437    for (
unsigned v = 0; v < nv; v++)
  2443      if (local_eqn_number >= 0)
  2447        dof_lookup.first = this->
eqn_number(local_eqn_number);
  2448        dof_lookup.second = v;
  2451        dof_lookup_list.push_front(dof_lookup);
  2468 {4,3,4,3,3,3,4,3,4};
  2486  unsigned u_index[3];
  2490  unsigned n_node = this->
nnode();
  2491  for(
unsigned n=0;n<n_node;n++)
  2495    for(
unsigned i=0;
i<3;
i++)
  2497      paired_load_data.insert(std::make_pair(this->
node_pt(n),u_index[
i]));
  2522  for(
unsigned l=0;l<n_pres;l++)
  2526    paired_pressure_data.insert(
  2527     std::make_pair(this->
node_pt(Pconv[l]),p_index));
  2541  std::list<std::pair<
unsigned long,
  2542  unsigned> >& dof_lookup_list)
 const  2545  unsigned n_node = this->
nnode();
  2551  std::pair<unsigned,unsigned> dof_lookup;
  2554  for (
unsigned n = 0; n < n_node; n++)
  2560    for (
unsigned v = 0; v < nv; v++)
  2568      if (local_eqn_number >= 0)
  2572        dof_lookup.first = this->
eqn_number(local_eqn_number);
  2575        dof_lookup.second = v;
  2578        dof_lookup_list.push_front(dof_lookup);
 virtual std::string tecplot_zone_string(const unsigned &nplot) const
Return string for tecplot zone header (when plotting nplot points in each "coordinate direction") ...
void output(std::ostream &outfile)
Output function: x,y,[z],u,v,[w],p in tecplot format. Default number of plot points. 
static Vector< double > Gamma
Vector to decide whether the stress-divergence form is used or not. 
void get_dof_numbers_for_unknowns(std::list< std::pair< unsigned long, unsigned > > &dof_lookup_list) const
Create a list of pairs for all unknowns in this element, so that the first entry in each pair contain...
double raw_nodal_value(const unsigned &n, const unsigned &i) const
Return the i-th value stored at local node n but do NOT take hanging nodes into account. 
void interpolated_u_spherical_nst(const Vector< double > &s, Vector< double > &veloc) const
Compute vector of FE interpolated velocity u at local coordinate s. 
void output_vorticity(std::ostream &outfile, const unsigned &nplot)
Output function: x,y,[z], [omega_x,omega_y,[and/or omega_z]] in tecplot format. nplot points in each ...
virtual void get_body_force_spherical_nst(const double &time, const unsigned &ipt, const Vector< double > &s, const Vector< double > &x, Vector< double > &result)
Calculate the body force at a given time and local and/or Eulerian position. This function is virtual...
virtual double p_spherical_nst(const unsigned &n_p) const =0
Pressure at local pressure "node" n_p Uses suitably interpolated value for hanging nodes...
double pressure_integral() const
Integral of pressure over element. 
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 const unsigned Pconv[]
Static array of ints to hold conversion from pressure node numbers to actual node numbers...
const double & re() const
Reynolds number. 
virtual void get_s_plot(const unsigned &i, const unsigned &nplot, Vector< double > &s, const bool &shifted_to_interior=false) const
Get cector of local coordinates of plot point i (when plotting nplot points in each "coordinate direc...
virtual double dshape_eulerian_at_knot(const unsigned &ipt, Shape &psi, DShape &dpsidx) const
Return the geometric shape functions and also first derivatives w.r.t. global coordinates at the ipt-...
double nodal_position(const unsigned &n, const unsigned &i) const
Return the i-th coordinate at local node n. If the node is hanging, the appropriate interpolation is ...
const double Pi
50 digits from maple 
void identify_pressure_data(std::set< std::pair< Data *, unsigned > > &paired_pressure_data)
Add to the set paired_pressure_data pairs containing. 
static double Default_Physical_Ratio_Value
Static default value for the physical ratios (all are initialised to one) 
void get_vorticity(const Vector< double > &s, Vector< double > &vorticity) const
Compute the vorticity vector at local coordinate s. 
void(* UnsteadyExactSolutionFctPt)(const double &, const Vector< double > &, Vector< double > &)
Function pointer for function that computes Vector-valued time-dependent function  as ...
const double & density_ratio() const
Density ratio for element: Element's density relative to the viscosity used in the definition of the ...
virtual double J_eulerian_at_knot(const unsigned &ipt) const
Return the Jacobian of the mapping from local to global coordinates at the ipt-th integration point...
unsigned nvalue() const
Return number of values stored in data object (incl pinned ones). 
virtual double dshape_and_dtest_eulerian_at_knot_spherical_nst(const unsigned &ipt, Shape &psi, DShape &dpsidx, Shape &test, DShape &dtestdx) const =0
Compute the shape functions and derivatives w.r.t. global coords at ipt-th integration point Return J...
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. Plot at a given number of plot points and compute L2 error and L2 norm of velocity solution over element. 
virtual void identify_pressure_data(std::set< std::pair< Data *, unsigned > > &paired_pressure_data)=0
Add to the set paired_pressure_data pairs containing. 
virtual double weight(const unsigned &i) const =0
Return weight of i-th integration point. 
double dissipation() const
Return integral of dissipation over element. 
virtual unsigned nplot_points(const unsigned &nplot) const
Return total number of plot points (when plotting nplot points in each "coordinate direction") ...
void get_dof_numbers_for_unknowns(std::list< std::pair< unsigned long, unsigned > > &dof_lookup_list) const
Create a list of pairs for all unknowns in this element, so that the first entry in each pair contain...
bool ALE_is_disabled
Boolean flag to indicate if ALE formulation is disabled when time-derivatives are computed...
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 compute_error_e(std::ostream &outfile, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt, FiniteElement::SteadyExactSolutionFctPt exact_soln_dr_pt, FiniteElement::SteadyExactSolutionFctPt exact_soln_dtheta_pt, double &u_error, double &u_norm, double &p_error, double &p_norm)
unsigned ndof() const
Return the number of equations/dofs in the element. 
virtual unsigned npres_spherical_nst() const =0
Function to return number of pressure degrees of freedom. 
double kin_energy() const
Get integral of kinetic energy over element. 
void(* SteadyExactSolutionFctPt)(const Vector< double > &, Vector< double > &)
Function pointer for function that computes vector-valued steady "exact solution"  as ...
virtual double interpolated_x(const Vector< double > &s, const unsigned &i) const
Return FE interpolated coordinate x[i] at local coordinate s. 
void identify_load_data(std::set< std::pair< Data *, unsigned > > &paired_load_data)
Add to the set paired_load_data pairs containing. 
double interpolated_p_spherical_nst(const Vector< double > &s) const
Return FE interpolated pressure at local coordinate s. 
double dshape_eulerian(const Vector< double > &s, Shape &psi, DShape &dpsidx) const
Compute the geometric shape functions and also first derivatives w.r.t. global coordinates at local c...
double interpolated_dudx_spherical_nst(const Vector< double > &s, const unsigned &i, const unsigned &j) const
Return matrix entry dudx(i,j) of the FE interpolated velocity derivative at local coordinate s...
Integral *const  & integral_pt() const
Return the pointer to the integration scheme (const version) 
virtual void shape_at_knot(const unsigned &ipt, Shape &psi) const
Return the geometric shape function at the ipt-th integration point. 
virtual double knot(const unsigned &i, const unsigned &j) const =0
Return local coordinate s[j] of i-th integration point. 
virtual void fill_in_generic_residual_contribution_spherical_nst(Vector< double > &residuals, DenseMatrix< double > &jacobian, DenseMatrix< double > &mass_matrix, unsigned flag)
Compute the residuals for the Navier–Stokes equations; flag=1(or 0): do (or don't) compute the Jacob...
Data *& internal_data_pt(const unsigned &i)
Return a pointer to i-th internal data object. 
virtual void write_tecplot_zone_footer(std::ostream &outfile, const unsigned &nplot) const
Add tecplot zone "footer" to output stream (when plotting nplot points in each "coordinate direction"...
unsigned long eqn_number(const unsigned &ieqn_local) const
Return the global equation number corresponding to the ieqn_local-th local equation number...
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...
double & time()
Return the current value of the continuous time. 
void output_veloc(std::ostream &outfile, const unsigned &nplot, const unsigned &t)
Output function: x,y,[z],u,v,[w] in tecplot format. nplot points in each coordinate direction at time...
virtual void pshape_spherical_nst(const Vector< double > &s, Shape &psi) const =0
Compute the pressure shape functions at local coordinate s. 
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n. 
double nodal_value(const unsigned &n, const unsigned &i) const
Return the i-th value stored at local node n. Produces suitably interpolated values for hanging nodes...
const double & re_invro() const
Global Reynolds number multiplied by inverse Rossby number. 
void identify_pressure_data(std::set< std::pair< Data *, unsigned > > &paired_pressure_data)
Add to the set paired_pressure_data pairs containing. 
void identify_load_data(std::set< std::pair< Data *, unsigned > > &paired_load_data)
Add to the set paired_load_data pairs containing. 
double cot(const double &th) const
virtual unsigned u_index_spherical_nst(const unsigned &i) const
Return the index at which the i-th unknown velocity component. 
double raw_nodal_position(const unsigned &n, const unsigned &i) const
Return the i-th coordinate at local node n. Do not use the hanging node representation. NOTE: Moved to cc file because of a possible compiler bug in gcc (yes, really!). The move to the cc file avoids inlining which appears to cause problems (only) when compiled with gcc and -O3; offensive "illegal read" is in optimised-out section of code and data that is allegedly illegal is readily readable (by other means) just before this function is called so I can't really see how we could possibly be responsible for this... 
unsigned ninternal_data() const
Return the number of internal data objects. 
static int Pressure_not_stored_at_node
Static "magic" number that indicates that the pressure is not stored at a node. 
double du_dt_spherical_nst(const unsigned &n, const unsigned &i) const
i-th component of du/dt at local node n. Uses suitably interpolated value for hanging nodes...
const double & re_st() const
Product of Reynolds and Strouhal number (=Womersley number) 
static double Default_Physical_Constant_Value
Static default value for the physical constants (all initialised to zero) 
virtual unsigned nweight() const =0
Return the number of integration points of the scheme. 
Time *const  & time_pt() const
Access function for the pointer to time (const version) 
TimeStepper *& time_stepper_pt()
Return the pointer to the timestepper. 
virtual int p_local_eqn(const unsigned &n) const =0
Access function for the local equation number information for the pressure. p_local_eqn[n] = local eq...
double raw_dnodal_position_dt(const unsigned &n, const unsigned &i) const
Return the i-th component of nodal velocity: dx/dt at local node n. Do not use the hanging node repre...
double dnodal_position_dt(const unsigned &n, const unsigned &i) const
Return the i-th component of nodal velocity: dx/dt at local node n. 
const Vector< double > & g() const
Vector of gravitational components. 
void extract_velocity(std::ostream &outfile)
virtual int p_nodal_index_spherical_nst() const
Return the index at which the pressure is stored if it is stored at the nodes. If not stored at the n...
static const unsigned Initial_Nvalue[]
Static array of ints to hold number of variables at node. 
int local_eqn_number(const unsigned long &ieqn_global) const
Return the local equation number corresponding to the ieqn_global-th global equation number...
unsigned nnode() const
Return the number of nodes. 
virtual double weight(const unsigned &i, const unsigned &j) const
Access function for j-th weight for the i-th derivative. 
void compute_shear_stress(std::ostream &outfile)
double d_kin_energy_dt() const
Get integral of time derivative of kinetic energy over element. 
virtual double J_eulerian(const Vector< double > &s) const
Return the Jacobian of mapping from local to global coordinates at local position s...
virtual void shape(const Vector< double > &s, Shape &psi) const =0
Calculate the geometric shape functions at local coordinate s. This function must be overloaded for e...
static Vector< double > Default_Gravity_vector
Static default value for the gravity vector. 
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. Function prints as many components as are returned in solution Vector. 
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...
int nodal_local_eqn(const unsigned &n, const unsigned &i) const
Return the local equation number corresponding to the i-th value at the n-th local node...