40 template<
unsigned DIM>
51 template <
unsigned DIM>
60 const unsigned n_node = nnode();
63 const unsigned u_nodal_index = u_index_cons_adv_diff();
66 Shape psi(n_node), test(n_node);
67 DShape dpsidx(n_node,DIM), dtestdx(n_node,DIM);
70 const unsigned n_intpt = integral_pt()->nweight();
76 const double peclet =
pe();
79 const double peclet_st =
pe_st();
83 int local_eqn=0, local_unknown=0;
86 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
90 for(
unsigned i=0;
i<DIM;
i++) s[
i] = integral_pt()->knot(ipt,
i);
93 double w = integral_pt()->weight(ipt);
97 dshape_and_dtest_eulerian_at_knot_cons_adv_diff(ipt,psi,dpsidx,test,dtestdx);
104 double interpolated_u=0.0;
114 for(
unsigned l=0;l<n_node;l++)
117 double u_value = raw_nodal_value(l,u_nodal_index);
118 interpolated_u += u_value*psi(l);
119 dudt += du_dt_cons_adv_diff(l)*psi(l);
121 for(
unsigned j=0;j<DIM;j++)
123 interpolated_x[j] += raw_nodal_position(l,j)*psi(l);
124 interpolated_dudx[j] += u_value*dpsidx(l,j);
131 for(
unsigned l=0;l<n_node;l++)
133 for(
unsigned j=0;j<DIM;j++)
135 mesh_velocity[j] += raw_dnodal_position_dt(l,j)*psi(l);
144 get_source_cons_adv_diff(ipt,interpolated_x,source);
150 get_wind_cons_adv_diff(ipt,s,interpolated_x,wind);
154 get_conserved_wind_cons_adv_diff(ipt,s,interpolated_x,conserved_wind);
159 get_diff_cons_adv_diff(ipt,s,interpolated_x,D);
165 for(
unsigned l=0;l<n_node;l++)
168 local_eqn = nodal_local_eqn(l,u_nodal_index);
174 residuals[local_eqn] -= (peclet_st*dudt + source)*test(l)*
W;
177 for(
unsigned k=0;k<DIM;k++)
181 double tmp = peclet*wind[k];
184 tmp *= interpolated_dudx[k];
188 double tmp2 = -conserved_wind[k]*interpolated_u;
190 for(
unsigned j=0;j<DIM;j++)
192 tmp2 +=
D(k,j)*interpolated_dudx[j];
195 residuals[local_eqn] -= (tmp*test(l) + tmp2*dtestdx(l,k))*W;
203 for(
unsigned l2=0;l2<n_node;l2++)
206 local_unknown = nodal_local_eqn(l2,u_nodal_index);
209 if(local_unknown >= 0)
212 jacobian(local_eqn,local_unknown)
213 -= peclet_st*test(l)*psi(l2)*
214 node_pt(l2)->time_stepper_pt()->weight(1,0)*
W;
219 mass_matrix(local_eqn,local_unknown)
220 += peclet_st*test(l)*psi(l2)*
W;
224 for(
unsigned k=0;k<DIM;k++)
227 double tmp = -peclet*wind[k];
229 {tmp -= peclet_st*mesh_velocity[k];}
232 double tmp2 = -conserved_wind[k]*psi(l2);
234 for(
unsigned j=0;j<DIM;j++)
236 tmp2 +=
D(k,j)*dpsidx(l2,j);
240 jacobian(local_eqn,local_unknown)
241 -= (tmp*test(l) + tmp2*dtestdx(l,k))*W;
258 template <
unsigned DIM>
291 template <
unsigned DIM>
293 const unsigned &nplot)
300 outfile << tecplot_zone_string(nplot);
302 const unsigned n_node = this->nnode();
304 DShape dpsidx(n_node,DIM);
307 unsigned num_plot_points=nplot_points(nplot);
308 for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
311 get_s_plot(iplot,nplot,s);
317 for(
unsigned i=0;
i<DIM;
i++)
319 outfile << x[
i] <<
" ";
321 outfile << interpolated_u_cons_adv_diff(s) <<
" ";
324 (void)this->dshape_eulerian(s,psi,dpsidx);
326 for(
unsigned n=0;n<n_node;n++)
328 const double u_ = this->nodal_value(n,0);
329 for(
unsigned i=0;
i<DIM;
i++)
331 interpolated_dudx[
i] += u_*dpsidx(n,
i);
335 for(
unsigned i=0;
i<DIM;
i++)
337 outfile << interpolated_dudx[
i] <<
" ";
344 get_wind_cons_adv_diff(ipt,s,x,wind);
345 for(
unsigned i=0;
i<DIM;
i++)
347 outfile << wind[
i] <<
" ";
349 outfile << std::endl;
354 write_tecplot_zone_footer(outfile,nplot);
366 template <
unsigned DIM>
368 const unsigned &nplot)
374 fprintf(file_pt,
"%s",tecplot_zone_string(nplot).c_str());
377 unsigned num_plot_points=nplot_points(nplot);
378 for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
382 get_s_plot(iplot,nplot,s);
384 for(
unsigned i=0;
i<DIM;
i++)
386 fprintf(file_pt,
"%g ",interpolated_x(s,
i));
389 fprintf(file_pt,
"%g \n",interpolated_u_cons_adv_diff(s));
393 write_tecplot_zone_footer(file_pt,nplot);
407 template <
unsigned DIM>
409 const unsigned &nplot,
420 outfile << tecplot_zone_string(nplot);
426 unsigned num_plot_points=nplot_points(nplot);
427 for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
431 get_s_plot(iplot,nplot,s);
437 (*exact_soln_pt)(x,exact_soln);
440 for(
unsigned i=0;
i<DIM;
i++)
442 outfile << x[
i] <<
" ";
444 outfile << exact_soln[0] << std::endl;
448 write_tecplot_zone_footer(outfile,nplot);
462 template <
unsigned DIM>
465 double& error,
double& norm)
479 unsigned n_node = nnode();
484 unsigned n_intpt = integral_pt()->nweight();
487 outfile <<
"ZONE" << std::endl;
493 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
497 for(
unsigned i=0;
i<DIM;
i++)
499 s[
i] = integral_pt()->knot(ipt,
i);
503 double w = integral_pt()->weight(ipt);
506 double J=J_eulerian(s);
515 double u_fe=interpolated_u_cons_adv_diff(s);
518 (*exact_soln_pt)(x,exact_soln);
521 for(
unsigned i=0;
i<DIM;
i++)
523 outfile << x[
i] <<
" ";
525 outfile << exact_soln[0] <<
" " << exact_soln[0]-u_fe << std::endl;
528 norm+=exact_soln[0]*exact_soln[0]*
W;
529 error+=(exact_soln[0]-u_fe)*(exact_soln[0]-u_fe)*
W;
539 template <
unsigned DIM>
550 const unsigned n_node = nnode();
553 const unsigned u_nodal_index = this->u_index_cons_adv_diff();
559 const unsigned n_intpt = integral_pt()->nweight();
562 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
565 const double w = integral_pt()->weight(ipt);
568 this->shape_at_knot(ipt,psi);
571 double interpolated_u = 0.0;
572 for(
unsigned l=0;l<n_node;l++)
573 {interpolated_u += this->nodal_value(l,u_nodal_index)*psi(l);}
576 const double J=J_eulerian_at_knot(ipt);
579 sum += interpolated_u*w*J;
590 template<
unsigned DIM,
unsigned NNODE_1D>
bool ALE_is_disabled
Boolean flag to indicate if ALE formulation is disabled when time-derivatives are computed...
const double & pe() const
Peclet number.
void output_fct(std::ostream &outfile, const unsigned &nplot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
Output exact soln: x,y,u_exact or x,y,z,u_exact at nplot^DIM plot points.
virtual void fill_in_generic_residual_contribution_cons_adv_diff(Vector< double > &residuals, DenseMatrix< double > &jacobian, DenseMatrix< double > &mass_matrix, unsigned flag)
Add the element's contribution to its residual vector only (if flag=and/or element Jacobian matrix...
virtual unsigned self_test()
Self-test: Check inversion of element & do self-test for GeneralisedElement. Return 0 if OK...
double integrate_u()
Integrate the concentration over the element.
A class for all elements that solve the Advection Diffusion equations in conservative form using isop...
void(* SteadyExactSolutionFctPt)(const Vector< double > &, Vector< double > &)
Function pointer for function that computes vector-valued steady "exact solution" as ...
const double & pe_st() const
Peclet number multiplied by Strouhal number.
static double Default_peclet_number
Static default value for the Peclet number.
unsigned self_test()
Self-test: Return 0 for OK.
QGeneralisedAdvectionDiffusionElement elements are linear/quadrilateral/brick-shaped Advection Diffus...
void output(std::ostream &outfile)
Output with default number of plot points.
void compute_error(std::ostream &outfile, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt, double &error, double &norm)
Get error against and norm of exact solution.