36 template<
unsigned DIM,
unsigned NNODE_1D>
48 template<
unsigned DIM>
55 const unsigned n_node = nnode();
58 Shape psi(n_node), test(n_node);
59 DShape dpsidx(n_node, DIM), dtestdx(n_node, DIM);
62 const unsigned u_nodal_index = u_index_poisson();
65 const unsigned n_intpt = integral_pt()->nweight();
68 int local_eqn = 0, local_unknown = 0;
71 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
74 double w = integral_pt()->weight(ipt);
77 double J = dshape_and_dtest_eulerian_at_knot_poisson(
78 ipt, psi, dpsidx, test, dtestdx);
85 double interpolated_u = 0.0;
92 for (
unsigned l = 0; l < n_node; l++)
95 double u_value = raw_nodal_value(l, u_nodal_index);
96 interpolated_u += u_value * psi(l);
98 for (
unsigned j = 0; j < DIM; j++)
100 interpolated_x[j] += raw_nodal_position(l, j) * psi(l);
101 interpolated_dudx[j] += u_value * dpsidx(l, j);
109 get_source_poisson(ipt, interpolated_x, source);
115 for (
unsigned l = 0; l < n_node; l++)
118 local_eqn = nodal_local_eqn(l, u_nodal_index);
123 residuals[local_eqn] += source * test(l) *
W;
126 for (
unsigned k = 0; k < DIM; k++)
128 residuals[local_eqn] += interpolated_dudx[k] * dtestdx(l, k) *
W;
136 for (
unsigned l2 = 0; l2 < n_node; l2++)
138 local_unknown = nodal_local_eqn(l2, u_nodal_index);
140 if (local_unknown >= 0)
143 for (
unsigned i = 0;
i < DIM;
i++)
145 jacobian(local_eqn, local_unknown) +=
146 dpsidx(l2,
i) * dtestdx(l,
i) *
W;
164 template<
unsigned DIM>
169 const unsigned n_node = nnode();
172 Shape psi(n_node), test(n_node);
173 DShape dpsidx(n_node, DIM), dtestdx(n_node, DIM);
190 const unsigned u_nodal_index = u_index_poisson();
193 const unsigned n_intpt = integral_pt()->nweight();
199 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
202 double w = integral_pt()->weight(ipt);
207 const double J = dshape_and_dtest_eulerian_at_knot_poisson(
208 ipt, psi, dpsidx, d_dpsidx_dX, test, dtestdx, d_dtestdx_dX, dJ_dX);
218 for (
unsigned l = 0; l < n_node; l++)
221 double u_value = raw_nodal_value(l, u_nodal_index);
224 for (
unsigned i = 0;
i < DIM;
i++)
226 interpolated_x[
i] += raw_nodal_position(l,
i) * psi(l);
227 interpolated_dudx[
i] += u_value * dpsidx(l,
i);
232 for (
unsigned q = 0; q < n_node; q++)
235 for (
unsigned p = 0; p < DIM; p++)
237 for (
unsigned i = 0;
i < DIM;
i++)
240 for (
unsigned j = 0; j < n_node; j++)
243 raw_nodal_value(j, u_nodal_index) * d_dpsidx_dX(p, q, j,
i);
245 d_dudx_dX(p, q,
i) = aux;
251 get_source_poisson(ipt, interpolated_x, source);
254 get_source_gradient_poisson(ipt, interpolated_x, d_source_dx);
260 for (
unsigned l = 0; l < n_node; l++)
263 local_eqn = nodal_local_eqn(l, u_nodal_index);
269 for (
unsigned p = 0; p < DIM; p++)
272 for (
unsigned q = 0; q < n_node; q++)
274 double sum = source * test(l) * dJ_dX(p, q) +
275 d_source_dx[p] * test(l) * psi(q) * J;
277 for (
unsigned i = 0;
i < DIM;
i++)
279 sum += interpolated_dudx[
i] * (dtestdx(l,
i) * dJ_dX(p, q) +
280 d_dtestdx_dX(p, q, l,
i) * J) +
281 d_dudx_dX(p, q,
i) * dtestdx(l,
i) * J;
285 dresidual_dnodal_coordinates(local_eqn, p, q) += sum * w;
297 template<
unsigned DIM>
327 template<
unsigned DIM>
329 const unsigned& nplot)
335 outfile << tecplot_zone_string(nplot);
338 unsigned num_plot_points = nplot_points(nplot);
339 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
342 get_s_plot(iplot, nplot,
s);
344 for (
unsigned i = 0;
i < DIM;
i++)
346 outfile << interpolated_x(
s,
i) <<
" ";
348 outfile << interpolated_u_poisson(
s) << std::endl;
352 write_tecplot_zone_footer(outfile, nplot);
363 template<
unsigned DIM>
370 fprintf(file_pt,
"%s", tecplot_zone_string(nplot).c_str());
373 unsigned num_plot_points = nplot_points(nplot);
374 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
377 get_s_plot(iplot, nplot,
s);
379 for (
unsigned i = 0;
i < DIM;
i++)
381 fprintf(file_pt,
"%g ", interpolated_x(
s,
i));
383 fprintf(file_pt,
"%g \n", interpolated_u_poisson(
s));
387 write_tecplot_zone_footer(file_pt, nplot);
399 template<
unsigned DIM>
401 std::ostream& outfile,
402 const unsigned& nplot,
412 outfile << tecplot_zone_string(nplot);
418 unsigned num_plot_points = nplot_points(nplot);
419 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
422 get_s_plot(iplot, nplot,
s);
425 interpolated_x(
s, x);
428 (*exact_soln_pt)(x, exact_soln);
431 for (
unsigned i = 0;
i < DIM;
i++)
433 outfile << x[
i] <<
" ";
435 outfile << exact_soln[0] << std::endl;
439 write_tecplot_zone_footer(outfile, nplot);
446 template<
unsigned DIM>
459 unsigned n_node = this->nnode();
464 unsigned n_intpt = this->integral_pt()->nweight();
467 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
470 for (
unsigned i = 0;
i < DIM;
i++)
472 s[
i] = this->integral_pt()->knot(ipt,
i);
476 double w = this->integral_pt()->weight(ipt);
479 double J = this->J_eulerian(
s);
485 u = this->interpolated_u_poisson(
s);
499 template<
unsigned DIM>
501 std::ostream& outfile,
517 unsigned n_node = nnode();
522 unsigned n_intpt = integral_pt()->nweight();
525 outfile <<
"ZONE" << std::endl;
531 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
534 for (
unsigned i = 0;
i < DIM;
i++)
536 s[
i] = integral_pt()->knot(ipt,
i);
540 double w = integral_pt()->weight(ipt);
543 double J = J_eulerian(
s);
549 interpolated_x(
s, x);
552 double u_fe = interpolated_u_poisson(
s);
555 (*exact_soln_pt)(x, exact_soln);
558 for (
unsigned i = 0;
i < DIM;
i++)
560 outfile << x[
i] <<
" ";
562 outfile << exact_soln[0] <<
" " << exact_soln[0] - u_fe << std::endl;
565 norm += exact_soln[0] * exact_soln[0] *
W;
566 error += (exact_soln[0] - u_fe) * (exact_soln[0] - u_fe) *
W;
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.
virtual void fill_in_generic_residual_contribution_poisson(Vector< double > &residuals, DenseMatrix< double > &jacobian, const unsigned &flag)
Compute element residual Vector only (if flag=and/or element Jacobian matrix.
unsigned self_test()
Self-test: Return 0 for OK.
void output(std::ostream &outfile)
Output with default number of plot points.
void compute_norm(double &norm)
Compute norm of solution: square of the L2 norm.
virtual void get_dresidual_dnodal_coordinates(RankThreeTensor< double > &dresidual_dnodal_coordinates)
Compute derivatives of elemental residual vector with respect to nodal coordinates....
void compute_error(std::ostream &outfile, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt, double &error, double &norm)
Get error against and norm of exact solution.
void output_fct(std::ostream &outfile, const unsigned &n_plot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
Output exact soln: x,y,u_exact or x,y,z,u_exact at n_plot^DIM plot points.
//////////////////////////////////////////////////////////////////////// ////////////////////////////...
static const unsigned Initial_Nvalue
Static int that holds the number of variables at nodes: always the same.
////////////////////////////////////////////////////////////////// //////////////////////////////////...
////////////////////////////////////////////////////////////////// //////////////////////////////////...
A Class for shape functions. In simple cases, the shape functions have only one index that can be tho...
//////////////////////////////////////////////////////////////////// ////////////////////////////////...