35 template<
unsigned DIM>
46 template<
unsigned DIM>
55 unsigned n_node = nnode();
58 unsigned u_nodal_index = u_index_adv_diff();
61 Shape psi(n_node), test(n_node);
62 DShape dpsidx(n_node, DIM), dtestdx(n_node, DIM);
65 unsigned n_intpt = integral_pt()->nweight();
74 double peclet_st = pe_st();
78 int local_eqn = 0, local_unknown = 0;
81 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
84 for (
unsigned i = 0;
i < DIM;
i++)
s[
i] = integral_pt()->knot(ipt,
i);
87 double w = integral_pt()->weight(ipt);
90 double J = dshape_and_dtest_eulerian_at_knot_adv_diff(
91 ipt, psi, dpsidx, test, dtestdx);
98 double interpolated_u = 0.0;
108 for (
unsigned l = 0; l < n_node; l++)
111 double u_value = raw_nodal_value(l, u_nodal_index);
112 interpolated_u += u_value * psi(l);
113 dudt += du_dt_adv_diff(l) * psi(l);
115 for (
unsigned j = 0; j < DIM; j++)
117 interpolated_x[j] += raw_nodal_position(l, j) * psi(l);
118 interpolated_dudx[j] += u_value * dpsidx(l, j);
123 if (!ALE_is_disabled)
125 for (
unsigned l = 0; l < n_node; l++)
127 for (
unsigned j = 0; j < DIM; j++)
129 mesh_velocity[j] += raw_dnodal_position_dt(l, j) * psi(l);
138 get_source_adv_diff(ipt, interpolated_x, source);
144 get_wind_adv_diff(ipt,
s, interpolated_x, wind);
150 for (
unsigned l = 0; l < n_node; l++)
153 local_eqn = nodal_local_eqn(l, u_nodal_index);
159 residuals[local_eqn] -= (peclet_st * dudt + source) * test(l) *
W;
162 for (
unsigned k = 0; k < DIM; k++)
165 double tmp = peclet * wind[k];
167 if (!ALE_is_disabled)
169 tmp -= peclet_st * mesh_velocity[k];
172 residuals[local_eqn] -=
173 interpolated_dudx[k] * (tmp * test(l) + dtestdx(l, k)) *
W;
181 for (
unsigned l2 = 0; l2 < n_node; l2++)
184 local_unknown = nodal_local_eqn(l2, u_nodal_index);
187 if (local_unknown >= 0)
190 jacobian(local_eqn, local_unknown) -=
191 peclet_st * test(l) * psi(l2) *
192 node_pt(l2)->time_stepper_pt()->weight(1, 0) *
W;
197 mass_matrix(local_eqn, local_unknown) +=
198 peclet_st * test(l) * psi(l2) *
W;
202 for (
unsigned i = 0;
i < DIM;
i++)
205 double tmp = peclet * wind[
i];
206 if (!ALE_is_disabled) tmp -= peclet_st * mesh_velocity[
i];
208 jacobian(local_eqn, local_unknown) -=
209 dpsidx(l2,
i) * (tmp * test(l) + dtestdx(l,
i)) *
W;
225 template<
unsigned DIM>
255 template<
unsigned DIM>
257 const unsigned& nplot)
264 outfile << tecplot_zone_string(nplot);
267 unsigned num_plot_points = nplot_points(nplot);
268 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
271 get_s_plot(iplot, nplot,
s);
275 interpolated_x(
s, x);
277 for (
unsigned i = 0;
i < DIM;
i++)
279 outfile << x[
i] <<
" ";
281 outfile << interpolated_u_adv_diff(
s) <<
" ";
287 get_wind_adv_diff(ipt,
s, x, wind);
288 for (
unsigned i = 0;
i < DIM;
i++)
290 outfile << wind[
i] <<
" ";
292 outfile << std::endl;
296 write_tecplot_zone_footer(outfile, nplot);
307 template<
unsigned DIM>
309 const unsigned& nplot)
315 fprintf(file_pt,
"%s", tecplot_zone_string(nplot).c_str());
318 unsigned num_plot_points = nplot_points(nplot);
319 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
322 get_s_plot(iplot, nplot,
s);
324 for (
unsigned i = 0;
i < DIM;
i++)
326 fprintf(file_pt,
"%g ", interpolated_x(
s,
i));
328 fprintf(file_pt,
"%g \n", interpolated_u_adv_diff(
s));
332 write_tecplot_zone_footer(file_pt, nplot);
344 template<
unsigned DIM>
346 std::ostream& outfile,
347 const unsigned& nplot,
357 outfile << tecplot_zone_string(nplot);
363 unsigned num_plot_points = nplot_points(nplot);
364 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
367 get_s_plot(iplot, nplot,
s);
370 interpolated_x(
s, x);
373 (*exact_soln_pt)(x, exact_soln);
376 for (
unsigned i = 0;
i < DIM;
i++)
378 outfile << x[
i] <<
" ";
380 outfile << exact_soln[0] << std::endl;
384 write_tecplot_zone_footer(outfile, nplot);
395 template<
unsigned DIM>
397 std::ostream& outfile,
413 unsigned n_node = nnode();
418 unsigned n_intpt = integral_pt()->nweight();
421 outfile <<
"ZONE" << std::endl;
427 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
430 for (
unsigned i = 0;
i < DIM;
i++)
432 s[
i] = integral_pt()->knot(ipt,
i);
436 double w = integral_pt()->weight(ipt);
439 double J = J_eulerian(
s);
445 interpolated_x(
s, x);
448 double u_fe = interpolated_u_adv_diff(
s);
451 (*exact_soln_pt)(x, exact_soln);
454 for (
unsigned i = 0;
i < DIM;
i++)
456 outfile << x[
i] <<
" ";
458 outfile << exact_soln[0] <<
" " << exact_soln[0] - u_fe << std::endl;
461 norm += exact_soln[0] * exact_soln[0] *
W;
462 error += (exact_soln[0] - u_fe) * (exact_soln[0] - u_fe) *
W;
470 template<
unsigned DIM,
unsigned NNODE_1D>
A class for all elements that solve the Advection Diffusion equations using isoparametric elements.
void output(std::ostream &outfile)
Output with default number of plot points.
virtual void fill_in_generic_residual_contribution_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.
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.
unsigned self_test()
Self-test: Return 0 for OK.
void compute_error(std::ostream &outfile, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt, double &error, double &norm)
Get error against and norm of exact solution.
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...
//////////////////////////////////////////////////////////////////// ////////////////////////////////...