41 namespace Legendre_functions_helper
57 double plgndr1(
const unsigned& n,
const double& x)
65 if (std::fabs(x) > 1.0)
67 std::ostringstream error_stream;
68 error_stream <<
"Bad arguments in routine plgndr1: x=" << x
69 <<
" but should be less than 1 in absolute value.\n";
71 OOMPH_CURRENT_FUNCTION,
72 OOMPH_EXCEPTION_LOCATION);
92 pmm2=(x*(2*i-1)*pmm1-(i-1)*pmm)/i;
106 double plgndr2(
const unsigned& l,
const unsigned& m,
const double& x)
109 double fact,pmm,pmmp1,somx2;
114 if (std::fabs(x) > 1.0)
116 std::ostringstream error_stream;
117 error_stream <<
"Bad arguments in routine plgndr2: x=" << x
118 <<
" but should be less than 1 in absolute value.\n";
120 OOMPH_CURRENT_FUNCTION,
121 OOMPH_EXCEPTION_LOCATION);
135 somx2=sqrt((1.0-x)*(1.0+x));
143 if (l == m)
return pmm;
156 for (ll=m+2;ll<=l;ll++)
158 pll=(x*(2*ll-1)*pmmp1-(ll+m-1)*pmm)/(ll-m);
180 template<
unsigned NNODE_1D>
196 const unsigned& flag)
199 const unsigned n_node = nnode();
202 Shape psi(n_node), test(n_node);
203 DShape dpsidx(n_node,2), dtestdx(n_node,2);
206 const unsigned n_intpt = integral_pt()->nweight();
209 int local_eqn_real=0, local_unknown_real=0;
210 int local_eqn_imag=0, local_unknown_imag=0;
213 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
216 double w = integral_pt()->weight(ipt);
219 double J = dshape_and_dtest_eulerian_at_knot_fourier_decomposed_helmholtz
220 (ipt,psi,dpsidx,test,dtestdx);
227 std::complex<double> interpolated_u(0.0,0.0);
234 for(
unsigned l=0;l<n_node;l++)
237 for(
unsigned j=0;j<2;j++)
239 interpolated_x[j] += raw_nodal_position(l,j)*psi(l);
243 const std::complex<double> u_value(
244 raw_nodal_value(l,u_index_fourier_decomposed_helmholtz().real()),
245 raw_nodal_value(l,u_index_fourier_decomposed_helmholtz().imag()));
248 interpolated_u += u_value*psi(l);
251 for(
unsigned j=0;j<2;j++)
253 interpolated_dudx[j] += u_value*dpsidx(l,j);
259 std::complex<double> source(0.0,0.0);
260 get_source_fourier_decomposed_helmholtz(ipt,interpolated_x,source);
262 double r = interpolated_x[0];
264 double n = (double)fourier_wavenumber();
265 double n_squared = n*n;
271 for(
unsigned l=0;l<n_node;l++)
279 nodal_local_eqn(l,u_index_fourier_decomposed_helmholtz().real());
282 if(local_eqn_real >= 0)
286 residuals[local_eqn_real] +=
287 (source.real()-((-n_squared/rr)+k_squared())*
288 interpolated_u.real())*test(l)*r*
W;
291 for(
unsigned k=0;k<2;k++)
293 residuals[local_eqn_real] +=
294 interpolated_dudx[k].real()*dtestdx(l,k)*r*
W;
302 for(
unsigned l2=0;l2<n_node;l2++)
305 nodal_local_eqn(l2,u_index_fourier_decomposed_helmholtz().real());
308 if(local_unknown_real >= 0)
311 for(
unsigned i=0;
i<2;
i++)
313 jacobian(local_eqn_real,local_unknown_real)
314 += dpsidx(l2,
i)*dtestdx(l,
i)*r*
W;
318 jacobian(local_eqn_real,local_unknown_real)
319 -= ((-n_squared/rr)+k_squared())*psi(l2)*test(l)*r*
W;
330 local_eqn_imag = nodal_local_eqn
331 (l,u_index_fourier_decomposed_helmholtz().imag());
334 if(local_eqn_imag >= 0)
337 residuals[local_eqn_imag] +=
338 (source.imag() - ( (-n_squared/rr) + k_squared() ) *
339 interpolated_u.imag() )*test(l)*r*
W;
342 for(
unsigned k=0;k<2;k++)
344 residuals[local_eqn_imag] += interpolated_dudx[k].imag()*
353 for(
unsigned l2=0;l2<n_node;l2++)
355 local_unknown_imag = nodal_local_eqn
356 (l2,u_index_fourier_decomposed_helmholtz().imag());
359 if(local_unknown_imag >= 0)
362 for(
unsigned i=0;
i<2;
i++)
364 jacobian(local_eqn_imag,local_unknown_imag)
365 += dpsidx(l2,
i)*dtestdx(l,
i)*r*
W;
368 jacobian(local_eqn_imag,local_unknown_imag)
369 -= ((-n_squared/rr)+k_squared())*psi(l2)*test(l)*r*
W;
415 const unsigned &nplot)
422 outfile << tecplot_zone_string(nplot);
425 unsigned num_plot_points=nplot_points(nplot);
426 for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
430 get_s_plot(iplot,nplot,s);
431 std::complex<double> u(interpolated_u_fourier_decomposed_helmholtz(s));
432 for(
unsigned i=0;
i<2;
i++)
434 outfile << interpolated_x(s,
i) <<
" ";
436 outfile << u.real() <<
" " << u.imag() << std::endl;
441 write_tecplot_zone_footer(outfile,nplot);
461 const unsigned &nplot)
468 outfile << tecplot_zone_string(nplot);
471 unsigned num_plot_points=nplot_points(nplot);
472 for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
476 get_s_plot(iplot,nplot,s);
477 std::complex<double> u(interpolated_u_fourier_decomposed_helmholtz(s));
478 for(
unsigned i=0;
i<2;
i++)
480 outfile << interpolated_x(s,
i) <<
" ";
482 outfile << u.real()*cos(phi)+u.imag()*sin(phi) << std::endl;
487 write_tecplot_zone_footer(outfile,nplot);
500 const unsigned &nplot)
506 fprintf(file_pt,
"%s",tecplot_zone_string(nplot).c_str());
509 unsigned num_plot_points=nplot_points(nplot);
510 for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
513 get_s_plot(iplot,nplot,s);
514 std::complex<double> u(interpolated_u_fourier_decomposed_helmholtz(s));
516 for(
unsigned i=0;
i<2;
i++)
518 fprintf(file_pt,
"%g ",interpolated_x(s,
i));
521 for(
unsigned i=0;
i<2;
i++)
523 fprintf(file_pt,
"%g ",interpolated_x(s,
i));
525 fprintf(file_pt,
"%g ",u.real());
526 fprintf(file_pt,
"%g \n",u.imag());
531 write_tecplot_zone_footer(file_pt,nplot);
545 std::ostream &outfile,
546 const unsigned &nplot,
556 outfile << tecplot_zone_string(nplot);
562 unsigned num_plot_points=nplot_points(nplot);
563 for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
566 get_s_plot(iplot,nplot,s);
572 (*exact_soln_pt)(x,exact_soln);
575 for(
unsigned i=0;
i<2;
i++)
577 outfile << x[
i] <<
" ";
579 outfile << exact_soln[0] <<
" " << exact_soln[1] << std::endl;
583 write_tecplot_zone_footer(outfile,nplot);
600 std::ostream &outfile,
602 const unsigned &nplot,
612 outfile << tecplot_zone_string(nplot);
618 unsigned num_plot_points=nplot_points(nplot);
619 for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
622 get_s_plot(iplot,nplot,s);
628 (*exact_soln_pt)(x,exact_soln);
631 for(
unsigned i=0;
i<2;
i++)
633 outfile << x[
i] <<
" ";
635 outfile << exact_soln[0]*cos(phi)+ exact_soln[1]*sin(phi) << std::endl;
639 write_tecplot_zone_footer(outfile,nplot);
653 std::ostream &outfile,
655 double& error,
double& norm)
669 unsigned n_node = nnode();
674 unsigned n_intpt = integral_pt()->nweight();
677 outfile <<
"ZONE" << std::endl;
683 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
687 for(
unsigned i=0;
i<2;
i++)
689 s[
i] = integral_pt()->knot(ipt,
i);
693 double w = integral_pt()->weight(ipt);
696 double J=J_eulerian(s);
705 std::complex<double> u_fe=interpolated_u_fourier_decomposed_helmholtz(s);
708 (*exact_soln_pt)(x,exact_soln);
711 for(
unsigned i=0;
i<2;
i++)
713 outfile << x[
i] <<
" ";
715 outfile << exact_soln[0] <<
" " << exact_soln[1] <<
" " 716 << exact_soln[0]-u_fe.real() <<
" " << exact_soln[1]-u_fe.imag()
720 norm+=(exact_soln[0]*exact_soln[0]+exact_soln[1]*exact_soln[1])*W;
721 error+=( (exact_soln[0]-u_fe.real())*(exact_soln[0]-u_fe.real())+
722 (exact_soln[1]-u_fe.imag())*(exact_soln[1]-u_fe.imag()) )*
W;
745 unsigned n_node = nnode();
750 unsigned n_intpt = integral_pt()->nweight();
753 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
757 for(
unsigned i=0;
i<2;
i++)
759 s[
i] = integral_pt()->knot(ipt,
i);
763 double w = integral_pt()->weight(ipt);
766 double J=J_eulerian(s);
772 std::complex<double> u_fe=interpolated_u_fourier_decomposed_helmholtz(s);
775 norm+=(u_fe.real()*u_fe.real()+u_fe.imag()*u_fe.imag())*W;
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...
double factorial(const unsigned &l)
Factorial.
void output_fct(std::ostream &outfile, const unsigned &n_plot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
void output(std::ostream &outfile)
Output with default number of plot points.
virtual unsigned self_test()
Self-test: Check inversion of element & do self-test for GeneralisedElement. Return 0 if OK...
unsigned self_test()
Self-test: Return 0 for OK.
double plgndr1(const unsigned &n, const double &x)
Legendre polynomials depending on one parameter.
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 compute_norm(double &norm)
Compute norm of fe solution.
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...
double plgndr2(const unsigned &l, const unsigned &m, const double &x)
Legendre polynomials depending on two parameters.
virtual void fill_in_generic_residual_contribution_fourier_decomposed_helmholtz(Vector< double > &residuals, DenseMatrix< double > &jacobian, const unsigned &flag)
Compute element residual Vector only (if flag=and/or element Jacobian matrix.