50 const unsigned n_node =
nnode();
59 unsigned u_nodal_index[3];
68 bool pressure_dof_is_hanging[n_pres];
73 for(
unsigned l=0;l<n_pres;++l)
75 pressure_dof_is_hanging[l] =
82 for(
unsigned l=0;l<n_pres;++l)
83 {pressure_dof_is_hanging[l] =
false;}
88 Shape psif(n_node), testf(n_node);
89 DShape dpsifdx(n_node,2), dtestfdx(n_node,2);
92 Shape psip(n_pres), testp(n_pres);
103 const double scaled_re =
re()*dens_ratio;
104 const double scaled_re_st =
re_st()*dens_ratio;
105 const double scaled_re_inv_ro =
re_invro()*dens_ratio;
111 int local_eqn=0, local_unknown=0;
114 HangInfo *hang_info_pt=0, *hang_info2_pt=0;
117 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
128 dpsifdx,testf,dtestfdx);
138 double interpolated_p=0.0;
146 for(
unsigned l=0;l<n_pres;l++)
152 for(
unsigned l=0;l<n_node;l++)
155 double psi_ = psif(l);
157 for(
unsigned i=0;
i<2;
i++)
163 for(
unsigned i=0;
i<3;
i++)
165 const double u_value = this->
nodal_value(l,u_nodal_index[
i]);
166 interpolated_u[
i] += u_value*psi_;
170 for(
unsigned j=0;j<2;j++)
172 interpolated_dudx(i,j) += u_value*dpsifdx(l,j);
181 "ALE is not properly implemented for Refineable Spherical NS yet",
182 OOMPH_CURRENT_FUNCTION,
183 OOMPH_EXCEPTION_LOCATION);
186 for(
unsigned i=0;
i<2;
i++)
201 const double r = interpolated_x[0];
202 const double r2 = r*r;
204 const double sin_theta = sin(interpolated_x[1]);
205 const double cos_theta = cos(interpolated_x[1]);
206 const double cot_theta = cos_theta/sin_theta;
208 const double u_r = interpolated_u[0];
209 const double u_theta = interpolated_u[1];
210 const double u_phi = interpolated_u[2];
220 unsigned n_master=1;
double hang_weight=1.0;
224 for(
unsigned l=0;l<n_node;l++)
235 n_master = hang_info_pt->
nmaster();
244 for(
unsigned m=0;m<n_master;m++)
247 for(
unsigned i=0;
i<2+1;
i++)
280 double conv = r*u_r*interpolated_dudx(0,0);
283 conv += u_theta*interpolated_dudx(0,1);
286 conv -= (u_theta*u_theta + u_phi*u_phi);
289 sum += (scaled_re_st*dudt[0]*r2 + scaled_re*r*conv)*
293 sum -= r2*sin_theta*body_force[0]*testf(l);
296 sum -= 2.0*scaled_re_inv_ro*sin_theta*u_phi*r2*sin_theta*testf(l);
299 sum += (-interpolated_p + 2*interpolated_dudx(0,0))*
300 r2*sin_theta*dtestfdx(l,0);
303 sum += (r*interpolated_dudx(1,0) - u_theta +
304 interpolated_dudx(0,1))*sin_theta*dtestfdx(l,1);
307 sum += 2.0*( (-r*interpolated_p +
308 + interpolated_dudx(1,1) +
310 u_theta*cos_theta)*testf(l);
319 (u_r*interpolated_dudx(1,0)*r
320 + u_theta*interpolated_dudx(1,1)
321 + u_r*u_theta)*sin_theta - u_phi*u_phi*cos_theta;
324 sum += (scaled_re_st*r2*sin_theta*dudt[1] +
325 scaled_re*r*conv)*testf(l);
328 sum -= r2*sin_theta*body_force[1]*testf(l);
331 sum -= 2.0*scaled_re_inv_ro*cos_theta*u_phi*r2*sin_theta*testf(l);
335 (r*interpolated_dudx(1,0) - u_theta + interpolated_dudx(0,1))*
336 r*sin_theta*dtestfdx(l,0);
340 (-r*interpolated_p + 2.0*interpolated_dudx(1,1) +
341 2*u_r)*sin_theta*dtestfdx(l,1);
345 ((r*interpolated_dudx(1,0) - u_theta + interpolated_dudx(0,1))*
347 - (-r*interpolated_p + 2.0*u_r + 2.0*u_theta*cot_theta)*
358 double conv = u_r*interpolated_dudx(2,0)*r*sin_theta;
361 conv += u_theta*interpolated_dudx(2,1)*sin_theta;
364 conv += u_phi*(u_r*sin_theta + u_theta*cos_theta);
367 sum += (scaled_re_st*r2*dudt[2]*sin_theta
368 + scaled_re*conv*r)*testf(l);
370 sum -= r2*sin_theta*body_force[2]*testf(l);
373 sum += 2.0*scaled_re_inv_ro*
374 (cos_theta*u_theta + sin_theta*u_r)*r2*sin_theta*testf(l);
379 (r2*interpolated_dudx(2,0) - r*u_phi)*dtestfdx(l,0)*sin_theta;
382 sum += (interpolated_dudx(2,1)*sin_theta
383 - u_phi*cos_theta)*dtestfdx(l,1);
386 sum -= ((r*interpolated_dudx(2,0) - u_phi)*sin_theta
387 + (interpolated_dudx(2,1) - u_phi*cot_theta)*cos_theta)*
396 residuals[local_eqn] -= sum*W*hang_weight;
402 unsigned n_master2=1;
double hang_weight2=1.0;
404 for(
unsigned l2=0;l2<n_node;l2++)
414 n_master2 = hang_info2_pt->
nmaster();
423 for(
unsigned m2=0;m2<n_master2;m2++)
426 for(
unsigned i2=0;i2<2+1;i2++)
436 hang_weight2 = hang_info2_pt->master_weight(m2);
446 if(local_unknown >= 0)
461 mass_matrix(local_eqn,local_unknown) +=
462 scaled_re_st*psif(l2)*testf(l)*r2*sin_theta*W
463 *hang_weight*hang_weight2;
469 r*(psif(l2)*interpolated_dudx(0,0) +
473 jac_conv += u_theta*dpsifdx(l2,1);
481 psif(l2)*r2 + scaled_re*jac_conv*r)*testf(l);
486 jac_sum += 2.0*dpsifdx(l2,0)*dtestfdx(l,0)*r2;
490 jac_sum += dpsifdx(l2,1)*dtestfdx(l,1);
496 jac_sum += 4.0*psif[l2]*testf(l);
501 jacobian(local_eqn,local_unknown) -=
502 jac_sum*sin_theta*W*hang_weight*hang_weight2;
514 scaled_re*(interpolated_dudx(0,1) - 2.0*u_theta)*
515 psif(l2)*r*sin_theta*testf(l);
521 (r*dpsifdx(l2,0) - psif(l2))*dtestfdx(l,1)*sin_theta;
527 2.0*(dpsifdx(l2,1)*sin_theta +
528 psif(l2)*cos_theta)*testf(l);
531 jacobian(local_eqn,local_unknown) -=
532 jac_sum*W*hang_weight*hang_weight2;
542 jacobian(local_eqn,local_unknown) +=
543 2.0*scaled_re*u_phi*psif[l2]*r*sin_theta*testf[l]*
544 W*hang_weight*hang_weight2;
547 jacobian(local_eqn,local_unknown) +=
548 2.0*scaled_re_inv_ro*sin_theta*psif(l2)*r2*
549 sin_theta*testf[l]*W*hang_weight*hang_weight2;
564 double jac_sum = scaled_re*(
565 r2*interpolated_dudx(1,0) + r*u_theta)*psif(l2)*
570 jac_sum += dpsifdx(l2,1)*dtestfdx(l,0)*sin_theta*r;
575 jac_sum += 2.0*psif(l2)*dtestfdx(l,1)*sin_theta;
580 jac_sum -= (dpsifdx(l2,1)*sin_theta
581 - 2.0*psif(l2)*cos_theta)*testf(l);
584 jacobian(local_eqn,local_unknown) -=
585 jac_sum*W*hang_weight*hang_weight2;
596 mass_matrix(local_eqn,local_unknown) +=
597 scaled_re_st*psif[l2]*testf[l]*W*r2*sin_theta
598 *hang_weight*hang_weight2;
605 r*u_r*dpsifdx(l2,0) + u_theta*dpsifdx(l2,1) +
606 (interpolated_dudx(1,1) + u_r)*psif(l2);
614 scaled_re*r*jac_conv)*testf(l)*sin_theta;
620 (r*dpsifdx(l2,0) - psif(l2))*r*
621 dtestfdx(l,0)*sin_theta;
626 jac_sum += 2.0*dpsifdx(l2,1)*dtestfdx(l,1)*sin_theta;
632 ((r*dpsifdx(l2,0) - psif(l2))*sin_theta
633 - 2.0*psif(l2)*cot_theta*cos_theta)*testf(l);
636 jacobian(local_eqn,local_unknown) -=
637 jac_sum*W*hang_weight*hang_weight2;
646 jacobian(local_eqn,local_unknown) +=
647 scaled_re*2.0*r*psif(l2)*u_phi*cos_theta*testf(l)*
648 W*hang_weight*hang_weight2;
651 jacobian(local_eqn,local_unknown) +=
652 2.0*scaled_re_inv_ro*cos_theta*psif(l2)*r2
653 *sin_theta*testf[l]*W*hang_weight*hang_weight2;
668 jacobian(local_eqn,local_unknown) -=
669 scaled_re*(r*interpolated_dudx(2,0) + u_phi)
670 *psif(l2)*testf(l)*r*sin_theta*W*
671 hang_weight*hang_weight2;
674 jacobian(local_eqn,local_unknown) -=
675 2.0*scaled_re_inv_ro*sin_theta*psif(l2)*r2
676 *sin_theta*testf[l]*W*hang_weight*hang_weight2;
686 jacobian(local_eqn,local_unknown) -=
687 scaled_re*(interpolated_dudx(2,1)*sin_theta
688 + u_phi*cos_theta)*r*psif(l2)*testf(l)*
689 W*hang_weight*hang_weight2;
692 jacobian(local_eqn,local_unknown) -=
693 2.0*scaled_re_inv_ro*cos_theta*psif(l2)*r2*sin_theta
694 *testf[l]*W*hang_weight*hang_weight2;
706 mass_matrix(local_eqn,local_unknown) +=
707 scaled_re_st*psif[l2]*testf[l]*W*r2*sin_theta
708 *hang_weight*hang_weight2;
713 double jac_conv = r*u_r*dpsifdx(l2,0)*sin_theta;
716 jac_conv += u_theta*dpsifdx(l2,1)*sin_theta;
720 (u_r*sin_theta + u_theta*cos_theta)*psif(l2);
726 psif(l2)*r2*sin_theta +
727 scaled_re*r*jac_conv)*testf(l);
734 - psif(l2))*dtestfdx(l,0)*r*sin_theta;
740 (dpsifdx(l2,1)*sin_theta - psif(l2)*cos_theta)*
746 jac_sum -= ((r*dpsifdx(l2,0) - psif(l2))*sin_theta
747 + (dpsifdx(l2,1) - psif(l2)*cot_theta)*
751 jacobian(local_eqn,local_unknown) -=
752 jac_sum*W*hang_weight*hang_weight2;
766 for(
unsigned l2=0;l2<n_pres;l2++)
769 if(pressure_dof_is_hanging[l2])
776 n_master2 = hang_info2_pt->
nmaster();
785 for(
unsigned m2=0;m2<n_master2;m2++)
789 if(pressure_dof_is_hanging[l2])
796 hang_weight2 = hang_info2_pt->master_weight(m2);
805 if(local_unknown >= 0)
812 jacobian(local_eqn,local_unknown) +=
813 psip(l2)*(r2*dtestfdx(l,0) + 2.0*r*testf[l])*
814 W*sin_theta*hang_weight*hang_weight2;
821 jacobian(local_eqn,local_unknown) +=
822 psip(l2)*r*(dtestfdx(l,1)*sin_theta + cos_theta*testf(l))*
823 W*hang_weight*hang_weight2;
845 for(
unsigned l=0;l<n_pres;l++)
848 if(pressure_dof_is_hanging[l])
853 n_master = hang_info_pt->
nmaster();
862 for(
unsigned m=0;m<n_master;m++)
866 if(pressure_dof_is_hanging[l])
881 residuals[local_eqn] +=
882 ((2.0*u_r + r*interpolated_dudx(0,0) + interpolated_dudx(1,1))*
883 sin_theta + u_theta*cos_theta)*r*testp(l)*W*hang_weight;
889 unsigned n_master2=1;
double hang_weight2=1.0;
891 for(
unsigned l2=0;l2<n_node;l2++)
901 n_master2 = hang_info2_pt->
nmaster();
910 for(
unsigned m2=0;m2<n_master2;m2++)
913 for(
unsigned i2=0;i2<2+1;i2++)
923 hang_weight2 = hang_info2_pt->master_weight(m2);
932 if(local_unknown >= 0)
938 jacobian(local_eqn,local_unknown) +=
939 (2.0*psif(l2) + r*dpsifdx(l2,0))*r*sin_theta*testp(l)*
940 W*hang_weight*hang_weight2;
947 jacobian(local_eqn,local_unknown) +=
948 r*(dpsifdx(l2,1)*sin_theta +
949 psif(l2)*cos_theta)*testp(l)*W*
950 hang_weight*hang_weight2;
int local_hang_eqn(Node *const &node_pt, const unsigned &i)
Access function that returns the local equation number for the hanging node variables (values stored ...
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...
virtual Node * pressure_node_pt(const unsigned &n_p)
Pointer to n_p-th pressure node (Default: NULL, indicating that pressure is not based on nodal interp...
void fill_in_generic_residual_contribution_spherical_nst(Vector< double > &residuals, DenseMatrix< double > &jacobian, DenseMatrix< double > &mass_matrix, unsigned flag)
Add element's contribution to the elemental residual vector and/or Jacobian matrix flag=1: compute bo...
const double & re() const
Reynolds number.
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 ...
HangInfo *const & hanging_pt() const
Return pointer to hanging node data (this refers to the geometric hanging node status) (const version...
double const & master_weight(const unsigned &i) const
Return weight for dofs on i-th master node.
unsigned nmaster() const
Return the number of master nodes.
bool is_hanging() const
Test whether the node is geometrically hanging.
const double & density_ratio() const
Density ratio for element: Element's density relative to the viscosity used in the definition of the ...
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...
virtual double weight(const unsigned &i) const =0
Return weight of i-th integration point.
bool ALE_is_disabled
Boolean flag to indicate if ALE formulation is disabled when time-derivatives are computed...
virtual unsigned npres_spherical_nst() const =0
Function to return number of pressure degrees of freedom.
virtual double interpolated_x(const Vector< double > &s, const unsigned &i) const
Return FE interpolated coordinate x[i] at local coordinate s.
Integral *const & integral_pt() const
Return the pointer to the integration scheme (const version)
virtual double knot(const unsigned &i, const unsigned &j) const =0
Return local coordinate s[j] of i-th integration point.
double & time()
Return the current value of the continuous time.
Node *const & master_node_pt(const unsigned &i) const
Return a pointer to the i-th master node.
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...
Class that contains data for hanging nodes.
const double & re_invro() const
Global Reynolds number multiplied by inverse Rossby number.
virtual unsigned u_index_spherical_nst(const unsigned &i) const
Return the index at which the i-th unknown velocity component.
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)
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 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.
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...
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.
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...