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 n_intpt = integral_pt()->nweight();
65 int local_eqn_real = 0, local_unknown_real = 0;
66 int local_eqn_imag = 0, local_unknown_imag = 0;
69 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
72 double w = integral_pt()->weight(ipt);
75 double J = dshape_and_dtest_eulerian_at_knot_helmholtz(
76 ipt, psi, dpsidx, test, dtestdx);
83 std::complex<double> interpolated_u(0.0, 0.0);
90 for (
unsigned l = 0; l < n_node; l++)
93 for (
unsigned j = 0; j < DIM; j++)
95 interpolated_x[j] += raw_nodal_position(l, j) * psi(l);
99 const std::complex<double> u_value(
100 raw_nodal_value(l, u_index_helmholtz().real()),
101 raw_nodal_value(l, u_index_helmholtz().imag()));
104 interpolated_u += u_value * psi(l);
107 for (
unsigned j = 0; j < DIM; j++)
109 interpolated_dudx[j] += u_value * dpsidx(l, j);
115 std::complex<double> source(0.0, 0.0);
116 get_source_helmholtz(ipt, interpolated_x, source);
122 for (
unsigned l = 0; l < n_node; l++)
128 local_eqn_real = nodal_local_eqn(l, u_index_helmholtz().real());
131 if (local_eqn_real >= 0)
134 residuals[local_eqn_real] +=
135 (source.real() - k_squared() * interpolated_u.real()) * test(l) *
W;
138 for (
unsigned k = 0; k < DIM; k++)
140 residuals[local_eqn_real] +=
141 interpolated_dudx[k].real() * dtestdx(l, k) *
W;
149 for (
unsigned l2 = 0; l2 < n_node; l2++)
152 nodal_local_eqn(l2, u_index_helmholtz().real());
154 if (local_unknown_real >= 0)
157 for (
unsigned i = 0;
i < DIM;
i++)
159 jacobian(local_eqn_real, local_unknown_real) +=
160 dpsidx(l2,
i) * dtestdx(l,
i) *
W;
163 jacobian(local_eqn_real, local_unknown_real) -=
164 k_squared() * psi(l2) * test(l) *
W;
174 local_eqn_imag = nodal_local_eqn(l, u_index_helmholtz().imag());
177 if (local_eqn_imag >= 0)
180 residuals[local_eqn_imag] +=
181 (source.imag() - k_squared() * interpolated_u.imag()) * test(l) *
W;
184 for (
unsigned k = 0; k < DIM; k++)
186 residuals[local_eqn_imag] +=
187 interpolated_dudx[k].imag() * dtestdx(l, k) *
W;
195 for (
unsigned l2 = 0; l2 < n_node; l2++)
198 nodal_local_eqn(l2, u_index_helmholtz().imag());
200 if (local_unknown_imag >= 0)
203 for (
unsigned i = 0;
i < DIM;
i++)
205 jacobian(local_eqn_imag, local_unknown_imag) +=
206 dpsidx(l2,
i) * dtestdx(l,
i) *
W;
209 jacobian(local_eqn_imag, local_unknown_imag) -=
210 k_squared() * psi(l2) * test(l) *
W;
223 template<
unsigned DIM>
253 template<
unsigned DIM>
255 const unsigned& nplot)
261 outfile << tecplot_zone_string(nplot);
264 unsigned num_plot_points = nplot_points(nplot);
265 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
268 get_s_plot(iplot, nplot,
s);
269 std::complex<double> u(interpolated_u_helmholtz(
s));
270 for (
unsigned i = 0;
i < DIM;
i++)
272 outfile << interpolated_x(
s,
i) <<
" ";
274 outfile << u.real() <<
" " << u.imag() << std::endl;
278 write_tecplot_zone_footer(outfile, nplot);
293 template<
unsigned DIM>
296 const unsigned& nplot)
302 outfile << tecplot_zone_string(nplot);
305 unsigned num_plot_points = nplot_points(nplot);
306 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
309 get_s_plot(iplot, nplot,
s);
310 std::complex<double> u(interpolated_u_helmholtz(
s));
311 for (
unsigned i = 0;
i < DIM;
i++)
313 outfile << interpolated_x(
s,
i) <<
" ";
315 outfile << u.real() * cos(phi) + u.imag() * sin(phi) << std::endl;
319 write_tecplot_zone_footer(outfile, nplot);
330 template<
unsigned DIM>
337 fprintf(file_pt,
"%s", tecplot_zone_string(nplot).c_str());
340 unsigned num_plot_points = nplot_points(nplot);
341 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
344 get_s_plot(iplot, nplot,
s);
345 std::complex<double> u(interpolated_u_helmholtz(
s));
347 for (
unsigned i = 0;
i < DIM;
i++)
349 fprintf(file_pt,
"%g ", interpolated_x(
s,
i));
352 for (
unsigned i = 0;
i < DIM;
i++)
354 fprintf(file_pt,
"%g ", interpolated_x(
s,
i));
356 fprintf(file_pt,
"%g ", u.real());
357 fprintf(file_pt,
"%g \n", u.imag());
361 write_tecplot_zone_footer(file_pt, nplot);
373 template<
unsigned DIM>
375 std::ostream& outfile,
376 const unsigned& nplot,
386 outfile << tecplot_zone_string(nplot);
392 unsigned num_plot_points = nplot_points(nplot);
393 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
396 get_s_plot(iplot, nplot,
s);
399 interpolated_x(
s, x);
402 (*exact_soln_pt)(x, exact_soln);
405 for (
unsigned i = 0;
i < DIM;
i++)
407 outfile << x[
i] <<
" ";
409 outfile << exact_soln[0] <<
" " << exact_soln[1] << std::endl;
413 write_tecplot_zone_footer(outfile, nplot);
428 template<
unsigned DIM>
430 std::ostream& outfile,
432 const unsigned& nplot,
442 outfile << tecplot_zone_string(nplot);
448 unsigned num_plot_points = nplot_points(nplot);
449 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
452 get_s_plot(iplot, nplot,
s);
455 interpolated_x(
s, x);
458 (*exact_soln_pt)(x, exact_soln);
461 for (
unsigned i = 0;
i < DIM;
i++)
463 outfile << x[
i] <<
" ";
465 outfile << exact_soln[0] * cos(phi) + exact_soln[1] * sin(phi)
470 write_tecplot_zone_footer(outfile, nplot);
481 template<
unsigned DIM>
483 std::ostream& outfile,
499 unsigned n_node = nnode();
504 unsigned n_intpt = integral_pt()->nweight();
507 outfile <<
"ZONE" << std::endl;
513 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
516 for (
unsigned i = 0;
i < DIM;
i++)
518 s[
i] = integral_pt()->knot(ipt,
i);
522 double w = integral_pt()->weight(ipt);
525 double J = J_eulerian(
s);
531 interpolated_x(
s, x);
534 std::complex<double> u_fe = interpolated_u_helmholtz(
s);
537 (*exact_soln_pt)(x, exact_soln);
540 for (
unsigned i = 0;
i < DIM;
i++)
542 outfile << x[
i] <<
" ";
544 outfile << exact_soln[0] <<
" " << exact_soln[1] <<
" "
545 << exact_soln[0] - u_fe.real() <<
" "
546 << exact_soln[1] - u_fe.imag() << std::endl;
550 (exact_soln[0] * exact_soln[0] + exact_soln[1] * exact_soln[1]) *
W;
551 error += ((exact_soln[0] - u_fe.real()) * (exact_soln[0] - u_fe.real()) +
552 (exact_soln[1] - u_fe.imag()) * (exact_soln[1] - u_fe.imag())) *
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.
A class for all isoparametric elements that solve the Helmholtz equations.
void output_fct(std::ostream &outfile, const unsigned &n_plot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
Output exact soln: x,y,u_re_exact,u_im_exact or x,y,z,u_re_exact,u_im_exact at n_plot^DIM plot points...
unsigned self_test()
Self-test: Return 0 for OK.
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.
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 compute_error(std::ostream &outfile, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt, double &error, double &norm)
Get error against and norm of exact 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...
void output(std::ostream &outfile)
Output with default number of 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...
//////////////////////////////////////////////////////////////////// ////////////////////////////////...