32 template<
unsigned NREAGENT,
unsigned DIM>
40 template<
unsigned NREAGENT,
unsigned DIM>
54 template<
unsigned NREAGENT,
unsigned DIM>
63 const unsigned n_node = nnode();
66 unsigned c_nodal_index[NREAGENT];
67 for (
unsigned r = 0; r < NREAGENT; r++)
69 c_nodal_index[r] = c_index_adv_diff_react(r);
73 Shape psi(n_node), test(n_node);
74 DShape dpsidx(n_node, DIM), dtestdx(n_node, DIM);
77 unsigned n_intpt = integral_pt()->nweight();
90 int local_eqn = 0, local_unknown = 0;
93 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);
102 double J = dshape_and_dtest_eulerian_at_knot_adv_diff_react(
103 ipt, psi, dpsidx, test, dtestdx);
119 for (
unsigned l = 0; l < n_node; l++)
122 for (
unsigned j = 0; j < DIM; j++)
124 interpolated_x[j] += raw_nodal_position(l, j) * psi(l);
128 for (
unsigned r = 0; r < NREAGENT; r++)
131 const double c_value = raw_nodal_value(l, c_nodal_index[r]);
134 interpolated_c[r] += c_value * psi(l);
135 dcdt[r] += dc_dt_adv_diff_react(l, r) * psi(l);
138 for (
unsigned j = 0; j < DIM; j++)
140 interpolated_dcdx(r, j) += c_value * dpsidx(l, j);
146 if (!ALE_is_disabled)
148 for (
unsigned l = 0; l < n_node; l++)
150 for (
unsigned j = 0; j < DIM; j++)
152 mesh_velocity[j] += raw_dnodal_position_dt(l, j) * psi(l);
160 get_source_adv_diff_react(ipt, interpolated_x, source);
165 get_wind_adv_diff_react(ipt,
s, interpolated_x, wind);
169 get_reaction_adv_diff_react(ipt, interpolated_c,
R);
175 get_reaction_deriv_adv_diff_react(ipt, interpolated_c, dRdC);
183 for (
unsigned l = 0; l < n_node; l++)
186 for (
unsigned r = 0; r < NREAGENT; r++)
189 local_eqn = nodal_local_eqn(l, c_nodal_index[r]);
195 residuals[local_eqn] -=
196 (
T[r] * dcdt[r] + source[r] +
R[r]) * test(l) *
W;
199 for (
unsigned k = 0; k < DIM; k++)
202 double tmp = wind[k];
204 if (!ALE_is_disabled)
206 tmp -=
T[r] * mesh_velocity[k];
209 residuals[local_eqn] -= interpolated_dcdx(r, k) *
210 (tmp * test(l) +
D[r] * dtestdx(l, k)) *
219 for (
unsigned l2 = 0; l2 < n_node; l2++)
222 for (
unsigned r2 = 0; r2 < NREAGENT; r2++)
225 local_unknown = nodal_local_eqn(l2, c_nodal_index[r2]);
228 if (local_unknown >= 0)
234 jacobian(local_eqn, local_unknown) -=
235 T[r] * test(l) * psi(l2) *
236 node_pt(l2)->time_stepper_pt()->weight(1, 0) *
W;
241 mass_matrix(local_eqn, local_unknown) +=
242 T[r] * test(l) * psi(l2) *
W;
246 for (
unsigned i = 0;
i < DIM;
i++)
249 double tmp = wind[
i];
250 if (!ALE_is_disabled) tmp -=
T[r] * mesh_velocity[
i];
252 jacobian(local_eqn, local_unknown) -=
254 (tmp * test(l) +
D[r] * dtestdx(l,
i)) *
W;
260 jacobian(local_eqn, local_unknown) -=
261 dRdC(r, r2) * psi(l2) * test(l) *
W;
276 template<
unsigned NREAGENT,
unsigned DIM>
290 unsigned n_node = this->nnode();
295 unsigned n_intpt = this->integral_pt()->nweight();
298 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
301 for (
unsigned i = 0;
i < DIM;
i++)
303 s[
i] = this->integral_pt()->knot(ipt,
i);
307 double w = this->integral_pt()->weight(ipt);
310 double J = this->J_eulerian(
s);
316 for (
unsigned r = 0; r < NREAGENT; ++r)
319 c = this->interpolated_c_adv_diff_react(
s, r);
330 template<
unsigned NREAGENT,
unsigned DIM>
356 template<
unsigned NREAGENT,
unsigned DIM>
361 const unsigned n_node = nnode();
364 unsigned c_nodal_index[NREAGENT];
365 for (
unsigned r = 0; r < NREAGENT; r++)
367 c_nodal_index[r] = c_index_adv_diff_react(r);
372 DShape dpsidx(n_node, DIM);
375 unsigned n_intpt = integral_pt()->nweight();
378 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
381 double w = integral_pt()->weight(ipt);
384 double J = dshape_eulerian_at_knot(ipt, psi, dpsidx);
395 for (
unsigned l = 0; l < n_node; l++)
398 for (
unsigned r = 0; r < NREAGENT; r++)
401 const double c_value = raw_nodal_value(l, c_nodal_index[r]);
404 interpolated_c[r] += c_value * psi(l);
408 for (
unsigned r = 0; r < NREAGENT; r++)
410 C[r] += interpolated_c[r] *
W;
423 template<
unsigned NREAGENT,
unsigned DIM>
425 std::ostream& outfile,
const unsigned& nplot)
432 outfile << tecplot_zone_string(nplot);
435 unsigned num_plot_points = nplot_points(nplot);
436 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
439 get_s_plot(iplot, nplot,
s);
443 interpolated_x(
s, x);
445 for (
unsigned i = 0;
i < DIM;
i++)
447 outfile << x[
i] <<
" ";
449 for (
unsigned i = 0;
i < NREAGENT;
i++)
451 outfile << interpolated_c_adv_diff_react(
s,
i) <<
" ";
458 get_wind_adv_diff_react(ipt,
s, x, wind);
459 for (
unsigned i = 0;
i < DIM;
i++)
461 outfile << wind[
i] <<
" ";
463 outfile << std::endl;
467 write_tecplot_zone_footer(outfile, nplot);
478 template<
unsigned NREAGENT,
unsigned DIM>
480 FILE* file_pt,
const unsigned& nplot)
486 fprintf(file_pt,
"%s", tecplot_zone_string(nplot).c_str());
489 unsigned num_plot_points = nplot_points(nplot);
490 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
493 get_s_plot(iplot, nplot,
s);
495 for (
unsigned i = 0;
i < DIM;
i++)
497 fprintf(file_pt,
"%g ", interpolated_x(
s,
i));
499 for (
unsigned i = 0;
i < NREAGENT;
i++)
501 fprintf(file_pt,
"%g \n", interpolated_c_adv_diff_react(
s,
i));
506 write_tecplot_zone_footer(file_pt, nplot);
518 template<
unsigned NREAGENT,
unsigned DIM>
520 std::ostream& outfile,
521 const unsigned& nplot,
531 outfile << tecplot_zone_string(nplot);
537 unsigned num_plot_points = nplot_points(nplot);
538 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
541 get_s_plot(iplot, nplot,
s);
544 interpolated_x(
s, x);
547 (*exact_soln_pt)(x, exact_soln);
550 for (
unsigned i = 0;
i < DIM;
i++)
552 outfile << x[
i] <<
" ";
554 outfile << exact_soln[0] << std::endl;
558 write_tecplot_zone_footer(outfile, nplot);
569 template<
unsigned NREAGENT,
unsigned DIM>
571 std::ostream& outfile,
587 unsigned n_node = nnode();
592 unsigned n_intpt = integral_pt()->nweight();
595 outfile <<
"ZONE" << std::endl;
601 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
604 for (
unsigned i = 0;
i < DIM;
i++)
606 s[
i] = integral_pt()->knot(ipt,
i);
610 double w = integral_pt()->weight(ipt);
613 double J = J_eulerian(
s);
619 interpolated_x(
s, x);
622 double u_fe = interpolated_c_adv_diff_react(
s, 0);
625 (*exact_soln_pt)(x, exact_soln);
628 for (
unsigned i = 0;
i < DIM;
i++)
630 outfile << x[
i] <<
" ";
632 outfile << exact_soln[0] <<
" " << exact_soln[0] - u_fe << std::endl;
635 norm += exact_soln[0] * exact_soln[0] *
W;
636 error += (exact_soln[0] - u_fe) * (exact_soln[0] - u_fe) *
W;
A class for all elements that solve the Advection Diffusion Reaction equations using isoparametric el...
void compute_error(std::ostream &outfile, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt, double &error, double &norm)
Get error against and norm of exact solution.
unsigned self_test()
Self-test: Return 0 for OK.
static const unsigned N_reagent
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 output(std::ostream &outfile)
Output with default number of plot points.
void integrate_reagents(Vector< double > &C) const
Return the integrated reagent concentrations.
static Vector< double > Default_dimensionless_number
Static default value for the dimensionless numbers.
void compute_norm(double &norm)
Compute norm of the solution: sum of squares of the L2 norm for each reagent.
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.
A Class for the derivatives of shape functions The class design is essentially the same as Shape,...
void(* SteadyExactSolutionFctPt)(const Vector< double > &, Vector< double > &)
Function pointer for function that computes vector-valued steady "exact solution" as .
virtual unsigned self_test()
Self-test: Check inversion of element & do self-test for GeneralisedElement. Return 0 if OK.
//////////////////////////////////////////////////////////////////////// ////////////////////////////...
A Class for shape functions. In simple cases, the shape functions have only one index that can be tho...
//////////////////////////////////////////////////////////////////// ////////////////////////////////...