36 template<
unsigned DIM>
38 std::ostream& outfile,
54 const unsigned n_node = nnode();
60 const unsigned n_intpt = integral_pt()->nweight();
63 outfile <<
"ZONE" << std::endl;
69 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
72 for (
unsigned i = 0;
i < DIM;
i++)
74 s[
i] = integral_pt()->knot(ipt,
i);
78 double w = integral_pt()->weight(ipt);
81 double J = J_eulerian(
s);
93 get_Z2_flux(
s, fe_flux);
96 (*exact_flux_pt)(x, exact_flux);
99 for (
unsigned i = 0;
i < DIM;
i++)
101 outfile << x[
i] <<
" ";
105 for (
unsigned i = 0;
i < DIM;
i++)
107 outfile << exact_flux[
i] <<
" ";
111 for (
unsigned i = 0;
i < DIM;
i++)
113 outfile << exact_flux[
i] - fe_flux[
i] <<
" ";
115 outfile << std::endl;
120 for (
unsigned i = 0;
i < DIM;
i++)
122 sum += (fe_flux[
i] - exact_flux[
i]) * (fe_flux[
i] - exact_flux[
i]);
123 sum2 += exact_flux[
i] * exact_flux[
i];
138 template<
unsigned DIM>
142 const unsigned& flag)
145 unsigned n_node = nnode();
148 Shape psi(n_node), test(n_node);
149 DShape dpsidx(n_node, DIM), dtestdx(n_node, DIM);
152 unsigned n_intpt = integral_pt()->nweight();
155 unsigned u_nodal_index = this->u_index_poisson();
158 int local_eqn = 0, local_unknown = 0;
161 HangInfo *hang_info_pt = 0, *hang_info2_pt = 0;
164 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
167 double w = integral_pt()->weight(ipt);
170 double J = this->dshape_and_dtest_eulerian_at_knot_poisson(
171 ipt, psi, dpsidx, test, dtestdx);
184 for (
unsigned l = 0; l < n_node; l++)
188 double u_value = this->nodal_value(l, u_nodal_index);
191 for (
unsigned j = 0; j < DIM; j++)
193 interpolated_x[j] += nodal_position(l, j) * psi(l);
194 interpolated_dudx[j] += u_value * dpsidx(l, j);
200 this->get_source_poisson(ipt, interpolated_x, source);
206 for (
unsigned l = 0; l < n_node; l++)
210 unsigned n_master = 1;
211 double hang_weight = 1.0;
214 bool is_node_hanging = this->node_pt(l)->is_hanging();
219 hang_info_pt = this->node_pt(l)->hanging_pt();
220 n_master = hang_info_pt->
nmaster();
229 for (
unsigned m = 0; m < n_master; m++)
246 local_eqn = this->nodal_local_eqn(l, u_nodal_index);
256 residuals[local_eqn] += source * test(l) *
W * hang_weight;
259 for (
unsigned k = 0; k < DIM; k++)
261 residuals[local_eqn] +=
262 interpolated_dudx[k] * dtestdx(l, k) *
W * hang_weight;
270 unsigned n_master2 = 1;
271 double hang_weight2 = 1.0;
274 for (
unsigned l2 = 0; l2 < n_node; l2++)
277 bool is_node2_hanging = this->node_pt(l2)->is_hanging();
280 if (is_node2_hanging)
282 hang_info2_pt = this->node_pt(l2)->hanging_pt();
283 n_master2 = hang_info2_pt->nmaster();
292 for (
unsigned m2 = 0; m2 < n_master2; m2++)
296 if (is_node2_hanging)
299 local_unknown = this->local_hang_eqn(
300 hang_info2_pt->master_node_pt(m2), u_nodal_index);
303 hang_weight2 = hang_info2_pt->master_weight(m2);
309 local_unknown = this->nodal_local_eqn(l2, u_nodal_index);
316 if (local_unknown >= 0)
319 for (
unsigned i = 0;
i < DIM;
i++)
321 jacobian(local_eqn, local_unknown) +=
322 dpsidx(l2,
i) * dtestdx(l,
i) *
W * hang_weight *
344 template<
unsigned DIM>
349 const unsigned n_node = nnode();
352 Shape psi(n_node), test(n_node);
353 DShape dpsidx(n_node, DIM), dtestdx(n_node, DIM);
356 const unsigned n_shape_controlling_node = nshape_controlling_nodes();
360 DIM, n_shape_controlling_node, n_node, DIM);
362 DIM, n_shape_controlling_node, n_node, DIM);
375 const unsigned u_nodal_index = this->u_index_poisson();
378 const unsigned n_intpt = integral_pt()->nweight();
387 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
390 double w = integral_pt()->weight(ipt);
395 const double J = this->dshape_and_dtest_eulerian_at_knot_poisson(
396 ipt, psi, dpsidx, d_dpsidx_dX, test, dtestdx, d_dtestdx_dX, dJ_dX);
406 for (
unsigned l = 0; l < n_node; l++)
409 double u_value = nodal_value(l, u_nodal_index);
412 for (
unsigned i = 0;
i < DIM;
i++)
414 interpolated_x[
i] += nodal_position(l,
i) * psi(l);
415 interpolated_dudx[
i] += u_value * dpsidx(l,
i);
422 for (
unsigned q = 0; q < n_shape_controlling_node; q++)
425 for (
unsigned p = 0; p < DIM; p++)
427 for (
unsigned i = 0;
i < DIM;
i++)
430 for (
unsigned j = 0; j < n_node; j++)
432 aux += nodal_value(j, u_nodal_index) * d_dpsidx_dX(p, q, j,
i);
434 d_dudx_dX(p, q,
i) = aux;
440 this->get_source_poisson(ipt, interpolated_x, source);
443 this->get_source_gradient_poisson(ipt, interpolated_x, d_source_dx);
452 for (
unsigned l = 0; l < n_node; l++)
456 unsigned n_master = 1;
457 double hang_weight = 1.0;
460 bool is_node_hanging = this->node_pt(l)->is_hanging();
465 hang_info_pt = this->node_pt(l)->hanging_pt();
466 n_master = hang_info_pt->
nmaster();
475 for (
unsigned m = 0; m < n_master; m++)
492 local_eqn = this->nodal_local_eqn(l, u_nodal_index);
501 for (
unsigned p = 0; p < DIM; p++)
504 for (
unsigned q = 0; q < n_shape_controlling_node; q++)
506 double sum = source * test(l) * dJ_dX(p, q) +
507 d_source_dx[p] * test(l) * psi(q) * J;
509 for (
unsigned i = 0;
i < DIM;
i++)
511 sum += interpolated_dudx[
i] * (dtestdx(l,
i) * dJ_dX(p, q) +
512 d_dtestdx_dX(p, q, l,
i) * J) +
513 d_dudx_dX(p, q,
i) * dtestdx(l,
i) * J;
517 dresidual_dnodal_coordinates(local_eqn, p, q) +=
518 sum * w * hang_weight;
528 template<
unsigned DIM>
530 std::ostream& outfile,
546 unsigned n_intpt = this->integral_pt()->nweight();
556 nplot = unsigned(pow(n_intpt, 1.0 /
double(DIM)));
560 outfile << this->tecplot_zone_string(nplot);
566 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
569 for (
unsigned i = 0;
i < DIM;
i++)
571 s[
i] = this->integral_pt()->knot(ipt,
i);
575 double w = this->integral_pt()->weight(ipt);
578 double J = this->J_eulerian(
s);
584 this->interpolated_x(
s, x);
591 (*exact_grad_pt)(x, exact_grad);
594 for (
unsigned i = 0;
i < DIM;
i++)
596 outfile << x[
i] <<
" ";
598 for (
unsigned i = 0;
i < DIM;
i++)
600 outfile << exact_grad[
i] <<
" " << exact_grad[
i] - dudx_fe[
i]
605 for (
unsigned i = 0;
i < DIM;
i++)
607 norm += exact_grad[
i] * exact_grad[
i] *
W;
609 (exact_grad[
i] - dudx_fe[
i]) * (exact_grad[
i] - dudx_fe[
i]) *
W;
614 template<
unsigned DIM>
617 if (this->tree_pt()->father_pt() != 0)
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 .
Class that contains data for hanging nodes.
double const & master_weight(const unsigned &i) const
Return weight for dofs on i-th master node.
Node *const & master_node_pt(const unsigned &i) const
Return a pointer to the i-th master node.
unsigned nmaster() const
Return the number of master nodes.
A class that is used to template the p-refineable Q elements by dimension. It's really nothing more t...
p-refineable version of 2D QPoissonElement elements
void further_build()
Further build: Copy source function pointer from father element.
void compute_energy_error(std::ostream &outfile, FiniteElement::SteadyExactSolutionFctPt exact_grad_pt, double &error, double &norm)
Get error against and norm of exact solution.
void get_flux(const Vector< double > &s, Vector< double > &flux) const
Get flux: flux[i] = du/dx_i.
////////////////////////////////////////////////////////////////// //////////////////////////////////...
////////////////////////////////////////////////////////////////// //////////////////////////////////...
virtual void get_dresidual_dnodal_coordinates(RankThreeTensor< double > &dresidual_dnodal_coordinates)
Compute derivatives of elemental residual vector with respect to nodal coordinates....
void fill_in_generic_residual_contribution_poisson(Vector< double > &residuals, DenseMatrix< double > &jacobian, const unsigned &flag)
Add element's contribution to elemental residual vector and/or Jacobian matrix flag=1: compute both f...
void compute_exact_Z2_error(std::ostream &outfile, FiniteElement::SteadyExactSolutionFctPt exact_flux_pt, double &error, double &norm)
Get error against and norm of exact flux.
void further_build()
Further build: Copy source function pointer from father element.
Refineable version of 2D QPoissonElement elements.
A Class for shape functions. In simple cases, the shape functions have only one index that can be tho...
//////////////////////////////////////////////////////////////////// ////////////////////////////////...