33 #include "../generic/shape.h" 34 #include "../generic/timesteppers.h" 43 template<
unsigned DIM>
48 const unsigned n_flux = nflux();
55 for(
unsigned p=0;p<n_flux;p++)
58 const double old_var = u_local[p];
60 u_local[p] += fd_step;
67 u_local[p] -= fd_step;
69 flux(u_local,F_minus);
72 for(
unsigned r=0;r<n_flux;r++)
74 for(
unsigned j=0;j<DIM;j++)
76 df_du(r,j,p) = (F_plus(r,j) - F_minus(r,j))/(2.0*fd_step);
91 template<
unsigned DIM>
98 const unsigned n_flux = this->nflux();
100 const unsigned n_node = this->nnode();
102 Shape psi(n_node), test(n_node);
103 DShape dpsidx(n_node,DIM), dtestdx(n_node,DIM);
106 unsigned u_nodal_index[n_flux];
107 for(
unsigned i=0;
i<n_flux;
i++)
108 {u_nodal_index[
i] = this->u_index_flux_transport(
i);}
111 unsigned n_intpt = this->integral_pt()->nweight();
114 int local_eqn=0, local_unknown = 0;
117 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
121 this->dshape_and_dtest_eulerian_at_knot_flux_transport(ipt,psi,dpsidx,
125 double W = this->integral_pt()->weight(ipt)*J;
132 for(
unsigned l=0;l<n_node;l++)
135 const double psi_ = psi(l);
136 for(
unsigned i=0;
i<n_flux;
i++)
139 interpolated_u[
i] += this->nodal_value(l,u_nodal_index[
i])*psi_;
140 interpolated_dudt[
i] += this->du_dt_flux_transport(l,i)*psi_;
146 this->flux(interpolated_u,F);
149 if((flag) && (flag!=3))
150 {this->dflux_du(interpolated_u,dF_du);}
153 for(
unsigned l=0;l<n_node;l++)
156 for(
unsigned i=0;
i<n_flux;
i++)
159 local_eqn = this->nodal_local_eqn(l,
i);
165 residuals[local_eqn] -= interpolated_dudt[
i]*test(l)*
W;
169 double flux_dot = 0.0;
170 for(
unsigned k=0;k<DIM;k++)
171 {flux_dot +=
F(
i,k)*dtestdx(l,k);}
174 residuals[local_eqn] += flux_dot*
W;
183 for(
unsigned l2=0;l2<n_node;l2++)
186 for(
unsigned i2=0;i2<n_flux;i2++)
189 local_unknown = this->nodal_local_eqn(l2,i2);
191 if(local_unknown >= 0)
196 jacobian(local_eqn,local_unknown) -=
197 node_pt(l2)->time_stepper_pt()->weight(1,0)*
204 mass_matrix(local_eqn,local_unknown) +=
210 double dflux_dot = 0.0;
211 for(
unsigned k=0;k<DIM;k++)
213 dflux_dot += dF_du(
i,k,i2)*dtestdx(l,k);
215 jacobian(local_eqn,local_unknown) +=
225 for(
unsigned l2=0;l2<n_node;l2++)
227 local_unknown = this->nodal_local_eqn(l2,
i);
228 if(local_unknown >= 0)
230 mass_matrix(local_eqn,local_unknown) += psi(l2)*test(l)*
W;
244 template<
unsigned DIM>
249 const unsigned n_node = this->nnode();
258 for(
unsigned n=0;n<n_node;n++)
260 const double psi_ = psi[n];
261 u += this->nodal_value(n,u_index_flux_transport(i))*psi_;
270 template<
unsigned DIM>
275 TimeStepper* time_stepper_pt = this->node_pt(n)->time_stepper_pt();
284 const unsigned u_nodal_index = this->u_index_flux_transport(i);
287 const unsigned n_time = time_stepper_pt->
ntstorage();
289 for(
unsigned t=0;
t<n_time;
t++)
291 dudt+=time_stepper_pt->
weight(1,
t)*nodal_value(
t,n,u_nodal_index);
302 template<
unsigned DIM>
304 double* &average_value)
307 const unsigned n_flux = this->nflux();
309 if(average_value==0) {average_value =
new double[n_flux+1];}
312 for(
unsigned i=0;
i<n_flux+1;
i++) {average_value[
i] = 0.0;}
315 const unsigned n_node = this->nnode();
318 DShape dpsidx(n_node,DIM);
321 unsigned u_nodal_index[n_flux];
322 for(
unsigned i=0;
i<n_flux;
i++)
323 {u_nodal_index[
i] = this->u_index_flux_transport(
i);}
326 unsigned n_intpt = this->integral_pt()->nweight();
329 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
332 double J = this->dshape_eulerian_at_knot(ipt,psi,dpsidx);
335 double W = this->integral_pt()->weight(ipt)*J;
341 for(
unsigned l=0;l<n_node;l++)
344 const double psi_ = psi(l);
345 for(
unsigned i=0;
i<n_flux;
i++)
348 interpolated_u[
i] += this->nodal_value(l,u_nodal_index[
i])*psi_;
352 average_value[n_flux] +=
W;
354 for(
unsigned i=0;
i<n_flux;
i++)
356 average_value[
i] += interpolated_u[
i]*
W;
361 for(
unsigned i=0;
i<n_flux;
i++)
363 average_value[
i] /= average_value[n_flux];
373 template<
unsigned DIM>
375 output(std::ostream &outfile,
const unsigned &nplot)
378 const unsigned n_flux = this->nflux();
384 outfile << tecplot_zone_string(nplot);
387 unsigned num_plot_points=nplot_points(nplot);
388 for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
392 get_s_plot(iplot,nplot,s);
395 for(
unsigned i=0;
i<DIM;
i++)
397 outfile << interpolated_x(s,
i) <<
" ";
401 for(
unsigned i=0;
i<n_flux;
i++)
403 outfile << interpolated_u_flux_transport(s,
i) <<
" ";
406 outfile << std::endl;
408 outfile << std::endl;
411 write_tecplot_zone_footer(outfile,nplot);
void output(std::ostream &outfile)
Output the element data — typically the values at the nodes in a format suitable for post-processing...
void shape(const double &s, double *Psi)
Definition for 1D Lagrange shape functions. The value of all the shape functions at the local coordin...
double interpolated_u_flux_transport(const Vector< double > &s, const unsigned &i)
Return the i-th unknown at the local coordinate s.
unsigned ntstorage() const
Return the number of doubles required to represent history (one for steady)
virtual void fill_in_generic_residual_contribution_flux_transport(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...
void calculate_element_averages(double *&average_values)
Compute the average values of the fluxes.
bool is_steady() const
Flag to indicate if a timestepper has been made steady (possibly temporarily to switch off time-depen...
virtual void dflux_du(const Vector< double > &u, RankThreeTensor< double > &df_du)
Return the flux derivatives as a funciton of the unknowns Default finite-different implementation...
Base class for time-stepping schemes. Timestepper provides an approximation of the temporal derivativ...
virtual double weight(const unsigned &i, const unsigned &j) const
Access function for j-th weight for the i-th derivative.
static double Default_fd_jacobian_step
Double used for the default finite difference step in elemental jacobian calculations.
double du_dt_flux_transport(const unsigned &n, const unsigned &i) const
i-th component of du/dt at local node n. Uses suitably interpolated value for hanging nodes...