42 template<
unsigned DIM,
unsigned NNODE_1D>
54 template <
unsigned DIM>
61 const unsigned n_node = nnode();
64 Shape psi(n_node), test(n_node);
65 DShape dpsidx(n_node,DIM), dtestdx(n_node,DIM);
68 const unsigned n_intpt = integral_pt()->nweight();
71 int local_eqn_real=0, local_unknown_real=0;
72 int local_eqn_imag=0, local_unknown_imag=0;
75 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
78 double w = integral_pt()->weight(ipt);
81 double J = dshape_and_dtest_eulerian_at_knot_helmholtz(ipt,psi,dpsidx,
89 std::complex<double> interpolated_u(0.0,0.0);
96 for(
unsigned l=0;l<n_node;l++)
99 for(
unsigned j=0;j<DIM;j++)
101 interpolated_x[j] += raw_nodal_position(l,j)*psi(l);
105 const std::complex<double>
106 u_value(raw_nodal_value(l,u_index_helmholtz().real()),
107 raw_nodal_value(l,u_index_helmholtz().imag()));
110 interpolated_u += u_value*psi(l);
113 for(
unsigned j=0;j<DIM;j++)
115 interpolated_dudx[j] += u_value*dpsidx(l,j);
121 std::complex<double> source(0.0,0.0);
122 get_source_helmholtz(ipt,interpolated_x,source);
128 for(
unsigned l=0;l<n_node;l++)
135 local_eqn_real = nodal_local_eqn(l,u_index_helmholtz().real());
138 if(local_eqn_real >= 0)
141 residuals[local_eqn_real] +=
142 (source.real()-k_squared()*interpolated_u.real())*test(l)*
W;
145 for(
unsigned k=0;k<DIM;k++)
147 residuals[local_eqn_real] += interpolated_dudx[k].real()*dtestdx(l,k)*
W;
155 for(
unsigned l2=0;l2<n_node;l2++)
157 local_unknown_real = nodal_local_eqn(l2,u_index_helmholtz().real());
159 if(local_unknown_real >= 0)
162 for(
unsigned i=0;
i<DIM;
i++)
164 jacobian(local_eqn_real,local_unknown_real)
165 += dpsidx(l2,
i)*dtestdx(l,
i)*
W;
168 jacobian(local_eqn_real,local_unknown_real)
169 -= k_squared()*psi(l2)*test(l)*
W;
179 local_eqn_imag = nodal_local_eqn(l,u_index_helmholtz().imag());
182 if(local_eqn_imag >= 0)
185 residuals[local_eqn_imag] +=
186 (source.imag()-k_squared()*interpolated_u.imag())*test(l)*
W;
189 for(
unsigned k=0;k<DIM;k++)
191 residuals[local_eqn_imag] += interpolated_dudx[k].imag()*dtestdx(l,k)*
W;
199 for(
unsigned l2=0;l2<n_node;l2++)
201 local_unknown_imag = nodal_local_eqn(l2,u_index_helmholtz().imag());
203 if(local_unknown_imag >= 0)
206 for(
unsigned i=0;
i<DIM;
i++)
208 jacobian(local_eqn_imag,local_unknown_imag)
209 += dpsidx(l2,
i)*dtestdx(l,
i)*
W;
212 jacobian(local_eqn_imag,local_unknown_imag)
213 -= k_squared()*psi(l2)*test(l)*
W;
227 template <
unsigned DIM>
260 template <
unsigned DIM>
262 const unsigned &nplot)
269 outfile << tecplot_zone_string(nplot);
272 unsigned num_plot_points=nplot_points(nplot);
273 for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
277 get_s_plot(iplot,nplot,s);
278 std::complex<double> u(interpolated_u_helmholtz(s));
279 for(
unsigned i=0;
i<DIM;
i++)
281 outfile << interpolated_x(s,
i) <<
" ";
283 outfile << u.real() <<
" " << u.imag() << std::endl;
288 write_tecplot_zone_footer(outfile,nplot);
306 template <
unsigned DIM>
309 const unsigned &nplot)
316 outfile << tecplot_zone_string(nplot);
319 unsigned num_plot_points=nplot_points(nplot);
320 for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
324 get_s_plot(iplot,nplot,s);
325 std::complex<double> u(interpolated_u_helmholtz(s));
326 for(
unsigned i=0;
i<DIM;
i++)
328 outfile << interpolated_x(s,
i) <<
" ";
330 outfile << u.real()*cos(phi)+u.imag()*sin(phi) << std::endl;
335 write_tecplot_zone_footer(outfile,nplot);
347 template <
unsigned DIM>
349 const unsigned &nplot)
355 fprintf(file_pt,
"%s",tecplot_zone_string(nplot).c_str());
358 unsigned num_plot_points=nplot_points(nplot);
359 for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
362 get_s_plot(iplot,nplot,s);
363 std::complex<double> u(interpolated_u_helmholtz(s));
365 for(
unsigned i=0;
i<DIM;
i++)
367 fprintf(file_pt,
"%g ",interpolated_x(s,
i));
370 for(
unsigned i=0;
i<DIM;
i++)
372 fprintf(file_pt,
"%g ",interpolated_x(s,
i));
374 fprintf(file_pt,
"%g ",u.real());
375 fprintf(file_pt,
"%g \n",u.imag());
380 write_tecplot_zone_footer(file_pt,nplot);
393 template <
unsigned DIM>
395 const unsigned &nplot,
405 outfile << tecplot_zone_string(nplot);
411 unsigned num_plot_points=nplot_points(nplot);
412 for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
416 get_s_plot(iplot,nplot,s);
422 (*exact_soln_pt)(x,exact_soln);
425 for(
unsigned i=0;
i<DIM;
i++)
427 outfile << x[
i] <<
" ";
429 outfile << exact_soln[0] <<
" " << exact_soln[1] << std::endl;
433 write_tecplot_zone_footer(outfile,nplot);
449 template <
unsigned DIM>
451 std::ostream &outfile,
453 const unsigned &nplot,
463 outfile << tecplot_zone_string(nplot);
469 unsigned num_plot_points=nplot_points(nplot);
470 for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
474 get_s_plot(iplot,nplot,s);
480 (*exact_soln_pt)(x,exact_soln);
483 for(
unsigned i=0;
i<DIM;
i++)
485 outfile << x[
i] <<
" ";
487 outfile << exact_soln[0]*cos(phi)+ exact_soln[1]*sin(phi) << std::endl;
491 write_tecplot_zone_footer(outfile,nplot);
504 template <
unsigned DIM>
507 double& error,
double& norm)
521 unsigned n_node = nnode();
526 unsigned n_intpt = integral_pt()->nweight();
529 outfile <<
"ZONE" << std::endl;
535 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
539 for(
unsigned i=0;
i<DIM;
i++)
541 s[
i] = integral_pt()->knot(ipt,
i);
545 double w = integral_pt()->weight(ipt);
548 double J=J_eulerian(s);
557 std::complex<double> u_fe=interpolated_u_helmholtz(s);
560 (*exact_soln_pt)(x,exact_soln);
563 for(
unsigned i=0;
i<DIM;
i++)
565 outfile << x[
i] <<
" ";
567 outfile << exact_soln[0] <<
" " << exact_soln[1] <<
" " 568 << exact_soln[0]-u_fe.real() <<
" " << exact_soln[1]-u_fe.imag()
572 norm+=(exact_soln[0]*exact_soln[0]+exact_soln[1]*exact_soln[1])*W;
573 error+=( (exact_soln[0]-u_fe.real())*(exact_soln[0]-u_fe.real())+
574 (exact_soln[1]-u_fe.imag())*(exact_soln[1]-u_fe.imag()) )*
W;
static const unsigned Initial_Nvalue
Static int that holds the number of variables at nodes: always the same.
virtual unsigned self_test()
Self-test: Check inversion of element & do self-test for GeneralisedElement. Return 0 if OK...
void output_real_fct(std::ostream &outfile, const double &phi, const unsigned &n_plot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
Output function for real part of full time-dependent fct u = Re( (u_r +i u_i) exp(-i omega t) at phas...
virtual void fill_in_generic_residual_contribution_helmholtz(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(* SteadyExactSolutionFctPt)(const Vector< double > &, Vector< double > &)
Function pointer for function that computes vector-valued steady "exact solution" as ...
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)
void output_real(std::ostream &outfile, const double &phi, const unsigned &n_plot)
Output function for real part of full time-dependent solution u = Re( (u_r +i u_i) exp(-i omega t) at...
void output(std::ostream &outfile)
Output with default number of plot points.