35 template<
unsigned DIM>
47 template<
unsigned DIM>
56 const unsigned n_node = nnode();
59 const unsigned u_nodal_index = u_index_cons_adv_diff();
62 Shape psi(n_node), test(n_node);
63 DShape dpsidx(n_node, DIM), dtestdx(n_node, DIM);
66 const unsigned n_intpt = integral_pt()->nweight();
72 const double peclet = pe();
75 const double peclet_st = pe_st();
79 int local_eqn = 0, local_unknown = 0;
82 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
85 for (
unsigned i = 0;
i < DIM;
i++)
s[
i] = integral_pt()->knot(ipt,
i);
88 double w = integral_pt()->weight(ipt);
91 double J = dshape_and_dtest_eulerian_at_knot_cons_adv_diff(
92 ipt, psi, dpsidx, test, dtestdx);
99 double interpolated_u = 0.0;
109 for (
unsigned l = 0; l < n_node; l++)
112 double u_value = raw_nodal_value(l, u_nodal_index);
113 interpolated_u += u_value * psi(l);
114 dudt += du_dt_cons_adv_diff(l) * psi(l);
116 for (
unsigned j = 0; j < DIM; j++)
118 interpolated_x[j] += raw_nodal_position(l, j) * psi(l);
119 interpolated_dudx[j] += u_value * dpsidx(l, j);
124 if (!ALE_is_disabled)
126 for (
unsigned l = 0; l < n_node; l++)
128 for (
unsigned j = 0; j < DIM; j++)
130 mesh_velocity[j] += raw_dnodal_position_dt(l, j) * psi(l);
139 get_source_cons_adv_diff(ipt, interpolated_x, source);
145 get_wind_cons_adv_diff(ipt,
s, interpolated_x, wind);
149 get_conserved_wind_cons_adv_diff(ipt,
s, interpolated_x, conserved_wind);
154 get_diff_cons_adv_diff(ipt,
s, interpolated_x,
D);
160 for (
unsigned l = 0; l < n_node; l++)
163 local_eqn = nodal_local_eqn(l, u_nodal_index);
169 residuals[local_eqn] -= (peclet_st * dudt + source) * test(l) *
W;
172 for (
unsigned k = 0; k < DIM; k++)
176 double tmp = peclet * wind[k];
178 if (!ALE_is_disabled)
180 tmp -= peclet_st * mesh_velocity[k];
182 tmp *= interpolated_dudx[k];
186 double tmp2 = -conserved_wind[k] * interpolated_u;
188 for (
unsigned j = 0; j < DIM; j++)
190 tmp2 +=
D(k, j) * interpolated_dudx[j];
193 residuals[local_eqn] -= (tmp * test(l) + tmp2 * dtestdx(l, k)) *
W;
201 for (
unsigned l2 = 0; l2 < n_node; l2++)
204 local_unknown = nodal_local_eqn(l2, u_nodal_index);
207 if (local_unknown >= 0)
210 jacobian(local_eqn, local_unknown) -=
211 peclet_st * test(l) * psi(l2) *
212 node_pt(l2)->time_stepper_pt()->weight(1, 0) *
W;
217 mass_matrix(local_eqn, local_unknown) +=
218 peclet_st * test(l) * psi(l2) *
W;
222 for (
unsigned k = 0; k < DIM; k++)
225 double tmp = -peclet * wind[k];
226 if (!ALE_is_disabled)
228 tmp -= peclet_st * mesh_velocity[k];
230 tmp *= dpsidx(l2, 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;
257 template<
unsigned DIM>
287 template<
unsigned DIM>
289 std::ostream& outfile,
const unsigned& nplot)
296 outfile << tecplot_zone_string(nplot);
298 const unsigned n_node = this->nnode();
300 DShape dpsidx(n_node, DIM);
303 unsigned num_plot_points = nplot_points(nplot);
304 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
307 get_s_plot(iplot, nplot,
s);
311 interpolated_x(
s, x);
313 for (
unsigned i = 0;
i < DIM;
i++)
315 outfile << x[
i] <<
" ";
317 outfile << interpolated_u_cons_adv_diff(
s) <<
" ";
320 (void)this->dshape_eulerian(
s, psi, dpsidx);
322 for (
unsigned n = 0; n < n_node; n++)
324 const double u_ = this->nodal_value(n, 0);
325 for (
unsigned i = 0;
i < DIM;
i++)
327 interpolated_dudx[
i] += u_ * dpsidx(n,
i);
331 for (
unsigned i = 0;
i < DIM;
i++)
333 outfile << interpolated_dudx[
i] <<
" ";
340 get_wind_cons_adv_diff(ipt,
s, x, wind);
341 for (
unsigned i = 0;
i < DIM;
i++)
343 outfile << wind[
i] <<
" ";
345 outfile << std::endl;
349 write_tecplot_zone_footer(outfile, nplot);
360 template<
unsigned DIM>
362 FILE* file_pt,
const unsigned& nplot)
368 fprintf(file_pt,
"%s", tecplot_zone_string(nplot).c_str());
371 unsigned num_plot_points = nplot_points(nplot);
372 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
375 get_s_plot(iplot, nplot,
s);
377 for (
unsigned i = 0;
i < DIM;
i++)
379 fprintf(file_pt,
"%g ", interpolated_x(
s,
i));
381 fprintf(file_pt,
"%g \n", interpolated_u_cons_adv_diff(
s));
385 write_tecplot_zone_footer(file_pt, nplot);
397 template<
unsigned DIM>
399 std::ostream& outfile,
400 const unsigned& nplot,
410 outfile << tecplot_zone_string(nplot);
416 unsigned num_plot_points = nplot_points(nplot);
417 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
420 get_s_plot(iplot, nplot,
s);
423 interpolated_x(
s, x);
426 (*exact_soln_pt)(x, exact_soln);
429 for (
unsigned i = 0;
i < DIM;
i++)
431 outfile << x[
i] <<
" ";
433 outfile << exact_soln[0] << std::endl;
437 write_tecplot_zone_footer(outfile, nplot);
448 template<
unsigned DIM>
450 std::ostream& outfile,
466 unsigned n_node = nnode();
471 unsigned n_intpt = integral_pt()->nweight();
474 outfile <<
"ZONE" << std::endl;
480 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
483 for (
unsigned i = 0;
i < DIM;
i++)
485 s[
i] = integral_pt()->knot(ipt,
i);
489 double w = integral_pt()->weight(ipt);
492 double J = J_eulerian(
s);
498 interpolated_x(
s, x);
501 double u_fe = interpolated_u_cons_adv_diff(
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] <<
" " << exact_soln[0] - u_fe << std::endl;
514 norm += exact_soln[0] * exact_soln[0] *
W;
515 error += (exact_soln[0] - u_fe) * (exact_soln[0] - u_fe) *
W;
523 template<
unsigned DIM>
533 const unsigned n_node = nnode();
536 const unsigned u_nodal_index = this->u_index_cons_adv_diff();
542 const unsigned n_intpt = integral_pt()->nweight();
545 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
548 const double w = integral_pt()->weight(ipt);
551 this->shape_at_knot(ipt, psi);
554 double interpolated_u = 0.0;
555 for (
unsigned l = 0; l < n_node; l++)
557 interpolated_u += this->nodal_value(l, u_nodal_index) * psi(l);
561 const double J = J_eulerian_at_knot(ipt);
564 sum += interpolated_u * w * J;
575 template<
unsigned DIM,
unsigned NNODE_1D>
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 all elements that solve the Advection Diffusion equations in conservative form using isop...
void compute_error(std::ostream &outfile, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt, double &error, double &norm)
Get error against and norm of exact solution.
static double Default_peclet_number
Static default value for the Peclet number.
void output(std::ostream &outfile)
Output with default number of plot points.
unsigned self_test()
Self-test: Return 0 for OK.
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.
double integrate_u()
Integrate the concentration over the element.
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.
//////////////////////////////////////////////////////////////////////// ////////////////////////////...
A Class for shape functions. In simple cases, the shape functions have only one index that can be tho...
//////////////////////////////////////////////////////////////////// ////////////////////////////////...