40 template<
unsigned NREAGENT,
unsigned DIM>
54 template <
unsigned NREAGENT,
unsigned DIM>
64 const unsigned n_node = nnode();
67 unsigned c_nodal_index[NREAGENT];
68 for(
unsigned r=0;r<NREAGENT;r++)
69 {c_nodal_index[r]= c_index_adv_diff_react(r);}
72 Shape psi(n_node), test(n_node);
73 DShape dpsidx(n_node,DIM), dtestdx(n_node,DIM);
76 unsigned n_intpt = integral_pt()->nweight();
89 int local_eqn=0, local_unknown=0;
92 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
96 for(
unsigned i=0;
i<DIM;
i++) s[
i] = integral_pt()->knot(ipt,
i);
99 double w = integral_pt()->weight(ipt);
103 dshape_and_dtest_eulerian_at_knot_adv_diff_react(
104 ipt,psi,dpsidx,test,dtestdx);
120 for(
unsigned l=0;l<n_node;l++)
123 for(
unsigned j=0;j<DIM;j++)
125 interpolated_x[j] += raw_nodal_position(l,j)*psi(l);
129 for(
unsigned r=0;r<NREAGENT;r++)
132 const double c_value = raw_nodal_value(l,c_nodal_index[r]);
135 interpolated_c[r] += c_value*psi(l);
136 dcdt[r] += dc_dt_adv_diff_react(l,r)*psi(l);
139 for(
unsigned j=0;j<DIM;j++)
141 interpolated_dcdx(r,j) += c_value*dpsidx(l,j);
149 for(
unsigned l=0;l<n_node;l++)
151 for(
unsigned j=0;j<DIM;j++)
153 mesh_velocity[j] += raw_dnodal_position_dt(l,j)*psi(l);
161 get_source_adv_diff_react(ipt,interpolated_x,source);
166 get_wind_adv_diff_react(ipt,s,interpolated_x,wind);
170 get_reaction_adv_diff_react(ipt,interpolated_c,R);
176 get_reaction_deriv_adv_diff_react(ipt,interpolated_c,dRdC);
184 for(
unsigned l=0;l<n_node;l++)
187 for(
unsigned r=0;r<NREAGENT;r++)
190 local_eqn = nodal_local_eqn(l,c_nodal_index[r]);
196 residuals[local_eqn] -=
197 (T[r]*dcdt[r] + source[r] + R[r])*test(l)*
W;
200 for(
unsigned k=0;k<DIM;k++)
203 double tmp = wind[k];
207 residuals[local_eqn] -=
208 interpolated_dcdx(r,k)*(tmp*test(l) + D[r]*dtestdx(l,k))*W;
216 for(
unsigned l2=0;l2<n_node;l2++)
219 for(
unsigned r2=0;r2<NREAGENT;r2++)
222 local_unknown = nodal_local_eqn(l2,c_nodal_index[r2]);
225 if(local_unknown >= 0)
231 jacobian(local_eqn,local_unknown)
232 -= T[r]*test(l)*psi(l2)*
233 node_pt(l2)->time_stepper_pt()->weight(1,0)*
W;
238 mass_matrix(local_eqn,local_unknown)
239 += T[r]*test(l)*psi(l2)*
W;
243 for(
unsigned i=0;
i<DIM;
i++)
246 double tmp = wind[
i];
249 jacobian(local_eqn,local_unknown)
250 -= dpsidx(l2,
i)*(tmp*test(l)+D[r]*dtestdx(l,
i))*W;
256 jacobian(local_eqn,local_unknown) -=
257 dRdC(r,r2)*psi(l2)*test(l)*
W;
274 template <
unsigned NREAGENT,
unsigned DIM>
302 template <
unsigned NREAGENT,
unsigned DIM>
307 const unsigned n_node = nnode();
310 unsigned c_nodal_index[NREAGENT];
311 for(
unsigned r=0;r<NREAGENT;r++)
312 {c_nodal_index[r]= c_index_adv_diff_react(r);}
316 DShape dpsidx(n_node,DIM);
319 unsigned n_intpt = integral_pt()->nweight();
322 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
325 double w = integral_pt()->weight(ipt);
328 double J = dshape_eulerian_at_knot(ipt,psi,dpsidx);
339 for(
unsigned l=0;l<n_node;l++)
342 for(
unsigned r=0;r<NREAGENT;r++)
345 const double c_value = raw_nodal_value(l,c_nodal_index[r]);
348 interpolated_c[r] += c_value*psi(l);
352 for(
unsigned r=0;r<NREAGENT;r++)
354 C[r] += interpolated_c[r]*
W;
372 template <
unsigned NREAGENT,
unsigned DIM>
374 output(std::ostream &outfile,
const unsigned &nplot)
381 outfile << tecplot_zone_string(nplot);
384 unsigned num_plot_points=nplot_points(nplot);
385 for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
388 get_s_plot(iplot,nplot,s);
394 for(
unsigned i=0;
i<DIM;
i++)
396 outfile << x[
i] <<
" ";
398 for(
unsigned i=0;
i<NREAGENT;
i++)
400 outfile << interpolated_c_adv_diff_react(s,
i) <<
" ";
407 get_wind_adv_diff_react(ipt,s,x,wind);
408 for(
unsigned i=0;
i<DIM;
i++)
410 outfile << wind[
i] <<
" ";
412 outfile << std::endl;
417 write_tecplot_zone_footer(outfile,nplot);
429 template <
unsigned NREAGENT,
unsigned DIM>
431 output(FILE* file_pt,
const unsigned &nplot)
437 fprintf(file_pt,
"%s",tecplot_zone_string(nplot).c_str());
440 unsigned num_plot_points=nplot_points(nplot);
441 for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
445 get_s_plot(iplot,nplot,s);
447 for(
unsigned i=0;
i<DIM;
i++)
449 fprintf(file_pt,
"%g ",interpolated_x(s,
i));
452 for(
unsigned i=0;
i<NREAGENT;
i++)
454 fprintf(file_pt,
"%g \n",interpolated_c_adv_diff_react(s,
i));
459 write_tecplot_zone_footer(file_pt,nplot);
473 template <
unsigned NREAGENT,
unsigned DIM>
476 const unsigned &nplot,
487 outfile << tecplot_zone_string(nplot);
493 unsigned num_plot_points=nplot_points(nplot);
494 for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
498 get_s_plot(iplot,nplot,s);
504 (*exact_soln_pt)(x,exact_soln);
507 for(
unsigned i=0;
i<DIM;
i++)
509 outfile << x[
i] <<
" ";
511 outfile << exact_soln[0] << std::endl;
515 write_tecplot_zone_footer(outfile,nplot);
529 template <
unsigned NREAGENT,
unsigned DIM>
533 double& error,
double& norm)
547 unsigned n_node = nnode();
552 unsigned n_intpt = integral_pt()->nweight();
555 outfile <<
"ZONE" << std::endl;
561 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
565 for(
unsigned i=0;
i<DIM;
i++)
567 s[
i] = integral_pt()->knot(ipt,
i);
571 double w = integral_pt()->weight(ipt);
574 double J=J_eulerian(s);
583 double u_fe=interpolated_c_adv_diff_react(s,0);
586 (*exact_soln_pt)(x,exact_soln);
589 for(
unsigned i=0;
i<DIM;
i++)
591 outfile << x[
i] <<
" ";
593 outfile << exact_soln[0] <<
" " << exact_soln[0]-u_fe << std::endl;
596 norm+=exact_soln[0]*exact_soln[0]*
W;
597 error+=(exact_soln[0]-u_fe)*(exact_soln[0]-u_fe)*
W;
bool ALE_is_disabled
Boolean flag to indicate if ALE formulation is disabled when time-derivatives are computed...
virtual void fill_in_generic_residual_contribution_adv_diff_react(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...
void integrate_reagents(Vector< double > &C) const
Return the integrated reagent concentrations.
QAdvectionDiffusionReactionElement elements are linear/quadrilateral/brick-shaped Advection Diffusion...
virtual unsigned self_test()
Self-test: Check inversion of element & do self-test for GeneralisedElement. Return 0 if OK...
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.
void(* SteadyExactSolutionFctPt)(const Vector< double > &, Vector< double > &)
Function pointer for function that computes vector-valued steady "exact solution" as ...
unsigned self_test()
Self-test: Return 0 for OK.
A class for all elements that solve the Advection Diffusion Reaction equations using isoparametric el...
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.
static Vector< double > Default_dimensionless_number
Static default value for the dimensionless numbers.