42 template <
unsigned DIM>
44 std::ostream &outfile,
46 double& error,
double& norm)
59 const unsigned n_node = nnode();
65 const unsigned n_intpt = integral_pt()->nweight();
68 outfile <<
"ZONE" << std::endl;
74 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
78 for(
unsigned i=0;
i<DIM;
i++)
80 s[
i] = integral_pt()->knot(ipt,
i);
84 double w = integral_pt()->weight(ipt);
87 double J = J_eulerian(s);
99 get_Z2_flux(s,fe_flux);
102 (*exact_flux_pt)(x,exact_flux);
105 for(
unsigned i=0;
i<DIM;
i++)
107 outfile << x[
i] <<
" ";
111 for(
unsigned i=0;
i<DIM;
i++)
113 outfile << exact_flux[
i] <<
" ";
117 for(
unsigned i=0;
i<DIM;
i++)
119 outfile << exact_flux[
i]-fe_flux[
i] <<
" ";
121 outfile << std::endl;
126 for(
unsigned i=0;
i<DIM;
i++)
128 sum += (fe_flux[
i]-exact_flux[
i])*(fe_flux[
i]-exact_flux[
i]);
129 sum2 += exact_flux[
i]*exact_flux[
i];
145 template<
unsigned DIM>
149 const unsigned& flag)
153 unsigned n_node = nnode();
156 Shape psi(n_node), test(n_node);
157 DShape dpsidx(n_node,DIM), dtestdx(n_node,DIM);
160 unsigned n_intpt = integral_pt()->nweight();
163 unsigned u_nodal_index = this->u_index_poisson();
166 int local_eqn=0, local_unknown=0;
169 HangInfo *hang_info_pt=0, *hang_info2_pt=0;
172 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
175 double w = integral_pt()->weight(ipt);
179 this->dshape_and_dtest_eulerian_at_knot_poisson(ipt,psi,dpsidx,test,dtestdx);
192 for(
unsigned l=0;l<n_node;l++)
196 double u_value = this->nodal_value(l,u_nodal_index);
199 for(
unsigned j=0;j<DIM;j++)
201 interpolated_x[j] += nodal_position(l,j)*psi(l);
202 interpolated_dudx[j] += u_value*dpsidx(l,j);
208 this->get_source_poisson(ipt,interpolated_x,source);
214 for(
unsigned l=0;l<n_node;l++)
218 unsigned n_master=1;
double hang_weight=1.0;
221 bool is_node_hanging = this->node_pt(l)->is_hanging();
226 hang_info_pt = this->node_pt(l)->hanging_pt();
227 n_master = hang_info_pt->
nmaster();
236 for(
unsigned m=0;m<n_master;m++)
253 local_eqn = this->nodal_local_eqn(l,u_nodal_index);
263 residuals[local_eqn] += source*test(l)*W*hang_weight;
266 for(
unsigned k=0;k<DIM;k++)
268 residuals[local_eqn] +=
269 interpolated_dudx[k]*dtestdx(l,k)*W*hang_weight;
277 unsigned n_master2=1;
double hang_weight2=1.0;
280 for(
unsigned l2=0;l2<n_node;l2++)
283 bool is_node2_hanging = this->node_pt(l2)->is_hanging();
288 hang_info2_pt = this->node_pt(l2)->hanging_pt();
289 n_master2 = hang_info2_pt->nmaster();
298 for(
unsigned m2=0;m2<n_master2;m2++)
306 this->local_hang_eqn(hang_info2_pt->master_node_pt(m2),
310 hang_weight2 = hang_info2_pt->master_weight(m2);
316 local_unknown = this->nodal_local_eqn(l2,u_nodal_index);
323 if(local_unknown >= 0)
326 for(
unsigned i=0;
i<DIM;
i++)
328 jacobian(local_eqn,local_unknown) +=
329 dpsidx(l2,
i)*dtestdx(l,
i)*W*hang_weight*hang_weight2;
352 template <
unsigned DIM>
355 dresidual_dnodal_coordinates)
358 const unsigned n_node = nnode();
361 Shape psi(n_node), test(n_node);
362 DShape dpsidx(n_node,DIM), dtestdx(n_node,DIM);
365 const unsigned n_shape_controlling_node = nshape_controlling_nodes();
382 const unsigned u_nodal_index = this->u_index_poisson();
385 const unsigned n_intpt = integral_pt()->nweight();
394 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
397 double w = integral_pt()->weight(ipt);
402 const double J = this->dshape_and_dtest_eulerian_at_knot_poisson(
403 ipt,psi,dpsidx,d_dpsidx_dX,test,dtestdx,d_dtestdx_dX,dJ_dX);
413 for(
unsigned l=0;l<n_node;l++)
416 double u_value = nodal_value(l,u_nodal_index);
419 for(
unsigned i=0;
i<DIM;
i++)
421 interpolated_x[
i] += nodal_position(l,
i)*psi(l);
422 interpolated_dudx[
i] += u_value*dpsidx(l,
i);
429 for(
unsigned q=0;q<n_shape_controlling_node;q++)
432 for(
unsigned p=0;p<DIM;p++)
434 for(
unsigned i=0;
i<DIM;
i++)
437 for(
unsigned j=0;j<n_node;j++)
439 aux += nodal_value(j,u_nodal_index)*d_dpsidx_dX(p,q,j,
i);
441 d_dudx_dX(p,q,
i) = aux;
447 this->get_source_poisson(ipt,interpolated_x,source);
450 this->get_source_gradient_poisson(ipt,interpolated_x,d_source_dx);
458 for(
unsigned l=0;l<n_node;l++)
463 double hang_weight=1.0;
466 bool is_node_hanging = this->node_pt(l)->is_hanging();
471 hang_info_pt = this->node_pt(l)->hanging_pt();
472 n_master = hang_info_pt->
nmaster();
481 for(
unsigned m=0;m<n_master;m++)
498 local_eqn = this->nodal_local_eqn(l,u_nodal_index);
507 for(
unsigned p=0;p<DIM;p++)
510 for(
unsigned q=0;q<n_shape_controlling_node;q++)
512 double sum = source*test(l)*dJ_dX(p,q)
513 + d_source_dx[p]*test(l)*psi(q)*J;
515 for(
unsigned i=0;
i<DIM;
i++)
517 sum += interpolated_dudx[
i]*(dtestdx(l,
i)*dJ_dX(p,q)+
518 d_dtestdx_dX(p,q,l,
i)*J)
519 + d_dudx_dX(p,q,
i)*dtestdx(l,
i)*J;
523 dresidual_dnodal_coordinates(local_eqn,p,q) += sum*w*hang_weight;
533 template<
unsigned DIM>
536 double& error,
double& norm)
549 unsigned n_intpt = this->integral_pt()->nweight();
559 nplot=unsigned(pow(n_intpt,1.0/
double(DIM)));
563 outfile << this->tecplot_zone_string(nplot);
569 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
573 for(
unsigned i=0;
i<DIM;
i++)
575 s[
i] = this->integral_pt()->knot(ipt,
i);
579 double w = this->integral_pt()->weight(ipt);
582 double J=this->J_eulerian(s);
588 this->interpolated_x(s,x);
595 (*exact_grad_pt)(x,exact_grad);
598 for(
unsigned i=0;
i<DIM;
i++)
600 outfile << x[
i] <<
" ";
602 for(
unsigned i=0;
i<DIM;
i++)
604 outfile << exact_grad[
i] <<
" " << exact_grad[
i]-dudx_fe[
i] << std::endl;
608 for(
unsigned i=0;
i<DIM;
i++)
610 norm+=exact_grad[
i]*exact_grad[
i]*
W;
611 error+=(exact_grad[
i]-dudx_fe[
i])*(exact_grad[
i]-dudx_fe[
i])*
W;
617 template<
unsigned DIM>
620 if(this->tree_pt()->father_pt()!=0)
virtual void get_dresidual_dnodal_coordinates(RankThreeTensor< double > &dresidual_dnodal_coordinates)
Compute derivatives of elemental residual vector with respect to nodal coordinates. Overwrites default implementation in FiniteElement base class. dresidual_dnodal_coordinates(l,i,j) = d res(l) / dX_{ij}.
double const & master_weight(const unsigned &i) const
Return weight for dofs on i-th master node.
p-refineable version of 2D QPoissonElement elements
unsigned nmaster() const
Return the number of master nodes.
void further_build()
Further build: Copy source function pointer from father element.
void(* SteadyExactSolutionFctPt)(const Vector< double > &, Vector< double > &)
Function pointer for function that computes vector-valued steady "exact solution" as ...
void compute_energy_error(std::ostream &outfile, FiniteElement::SteadyExactSolutionFctPt exact_grad_pt, double &error, double &norm)
Get error against and norm of exact solution.
Node *const & master_node_pt(const unsigned &i) const
Return a pointer to the i-th master node.
Class that contains data for hanging nodes.
void get_flux(const Vector< double > &s, Vector< double > &flux) const
Get flux: flux[i] = du/dx_i.
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.