31 #ifndef OOMPH_FOURIER_DECOMPOSED_HELMHOLTZ_ELEMENTS_HEADER 32 #define OOMPH_FOURIER_DECOMPOSED_HELMHOLTZ_ELEMENTS_HEADER 37 #include <oomph-lib-config.h> 45 #include "../generic/projection.h" 46 #include "../generic/nodes.h" 47 #include "../generic/Qelements.h" 48 #include "../generic/oomph_utilities.h" 56 namespace Legendre_functions_helper
60 extern double factorial(
const unsigned& l);
63 extern double plgndr1(
const unsigned& n,
const double& x);
66 extern double plgndr2(
const unsigned& l,
const unsigned& m,
const double& x);
98 typedef void (*FourierDecomposedHelmholtzSourceFctPt)(
100 std::complex<double>& f);
105 K_squared_pt(0), N_fourier_pt(0)
131 {
return std::complex<unsigned>(0,1);}
149 return *K_squared_pt;
168 return *N_fourier_pt;
175 const unsigned n_plot=5;
181 void output(std::ostream &outfile,
const unsigned &n_plot);
188 void output_real(std::ostream &outfile,
const double& phi,
189 const unsigned &n_plot);
194 const unsigned n_plot=5;
200 void output(FILE* file_pt,
const unsigned &n_plot);
204 void output_fct(std::ostream &outfile,
const unsigned &n_plot,
209 virtual void output_fct(std::ostream &outfile,
const unsigned &n_plot,
215 "There is no time-dependent output_fct() for FourierDecomposedHelmholtz elements ",
216 OOMPH_CURRENT_FUNCTION,
217 OOMPH_EXCEPTION_LOCATION);
226 void output_real_fct(std::ostream &outfile,
228 const unsigned &n_plot,
235 double& error,
double& norm);
241 const double& time,
double& error,
double& norm)
244 "There is no time-dependent compute_error() for FourierDecomposedHelmholtz elements",
245 OOMPH_CURRENT_FUNCTION,
246 OOMPH_EXCEPTION_LOCATION);
250 void compute_norm(
double& norm);
266 std::complex<double>& source)
const 271 source = std::complex<double>(0.0,0.0);
276 (*Source_fct_pt)(x,source);
283 Vector<std::complex <double> >& flux)
const 286 const unsigned n_node = nnode();
293 dshape_eulerian(s,psi,dpsidx);
296 const std::complex<double> zero(0.0,0.0);
297 for(
unsigned j=0;j<2;j++)
303 for(
unsigned l=0;l<n_node;l++)
306 const std::complex<double> u_value(
307 this->nodal_value(l,u_index_fourier_decomposed_helmholtz().real()),
308 this->nodal_value(l,u_index_fourier_decomposed_helmholtz().imag()));
311 for(
unsigned j=0;j<2;j++)
313 flux[j] += u_value*dpsidx(l,j);
324 fill_in_generic_residual_contribution_fourier_decomposed_helmholtz(
336 fill_in_generic_residual_contribution_fourier_decomposed_helmholtz(
337 residuals,jacobian,1);
349 const unsigned n_node = nnode();
358 std::complex<double> interpolated_u(0.0,0.0);
361 const unsigned u_nodal_index_real =
362 u_index_fourier_decomposed_helmholtz().real();
363 const unsigned u_nodal_index_imag =
364 u_index_fourier_decomposed_helmholtz().imag();
367 for(
unsigned l=0;l<n_node;l++)
370 const std::complex<double> u_value(
371 this->nodal_value(l,u_nodal_index_real),
372 this->nodal_value(l,u_nodal_index_imag));
374 interpolated_u += u_value*psi[l];
376 return interpolated_u;
388 virtual double dshape_and_dtest_eulerian_fourier_decomposed_helmholtz(
397 virtual double dshape_and_dtest_eulerian_at_knot_fourier_decomposed_helmholtz(
407 fill_in_generic_residual_contribution_fourier_decomposed_helmholtz(
409 const unsigned& flag);
436 template <
unsigned NNODE_1D>
438 public virtual QElement<2,NNODE_1D>,
474 {
return Initial_Nvalue;}
482 void output(std::ostream &outfile,
const unsigned &n_plot)
491 const unsigned &n_plot)
500 void output(FILE* file_pt,
const unsigned &n_plot)
505 void output_fct(std::ostream &outfile,
const unsigned &n_plot,
519 const unsigned &n_plot,
523 n_plot,exact_soln_pt);
530 void output_fct(std::ostream &outfile,
const unsigned &n_plot,
542 inline double dshape_and_dtest_eulerian_fourier_decomposed_helmholtz(
550 dshape_and_dtest_eulerian_at_knot_fourier_decomposed_helmholtz(
571 template<
unsigned NNODE_1D>
581 const double J = this->dshape_eulerian(s,psi,dpsidx);
600 template<
unsigned NNODE_1D>
610 const double J = this->dshape_eulerian_at_knot(ipt,psi,dpsidx);
632 template<
unsigned NNODE_1D>
654 template<
class FOURIER_DECOMPOSED_HELMHOLTZ_ELEMENT>
675 std::stringstream error_stream;
677 <<
"Fourier decomposed Helmholtz elements only store 2 fields so fld = " 678 << fld <<
" is illegal \n";
681 OOMPH_CURRENT_FUNCTION,
682 OOMPH_EXCEPTION_LOCATION);
687 unsigned nnod=this->nnode();
691 for (
unsigned j=0;j<nnod;j++)
694 data_values[j]=std::make_pair(this->node_pt(j),fld);
714 std::stringstream error_stream;
716 <<
"Helmholtz elements only store two fields so fld = " 717 << fld <<
" is illegal\n";
720 OOMPH_CURRENT_FUNCTION,
721 OOMPH_EXCEPTION_LOCATION);
724 return this->node_pt(0)->ntstorage();
731 return this->node_pt(0)->position_time_stepper_pt()->ntstorage();
743 std::stringstream error_stream;
745 <<
"Helmholtz elements only store two fields so fld = " 746 << fld <<
" is illegal.\n";
749 OOMPH_CURRENT_FUNCTION,
750 OOMPH_EXCEPTION_LOCATION);
753 unsigned n_dim=this->dim();
754 unsigned n_node=this->nnode();
756 DShape dpsidx(n_node,n_dim), dtestdx(n_node,n_dim);
757 double J=this->dshape_and_dtest_eulerian_fourier_decomposed_helmholtz(
774 std::stringstream error_stream;
776 <<
"Helmholtz elements only store two fields so fld = " 777 << fld <<
" is illegal\n";
780 OOMPH_CURRENT_FUNCTION,
781 OOMPH_EXCEPTION_LOCATION);
785 std::complex<unsigned> complex_u_nodal_index =
786 this->u_index_fourier_decomposed_helmholtz();
787 unsigned u_nodal_index = 0;
790 u_nodal_index = complex_u_nodal_index.real();
794 u_nodal_index = complex_u_nodal_index.imag();
799 unsigned n_node=this->nnode();
806 double interpolated_u = 0.0;
809 for(
unsigned l=0;l<n_node;l++)
811 interpolated_u += this->nodal_value(t,l,u_nodal_index)*psi[l];
813 return interpolated_u;
825 std::stringstream error_stream;
827 <<
"Helmholtz elements only store two fields so fld = " 828 << fld <<
" is illegal\n";
831 OOMPH_CURRENT_FUNCTION,
832 OOMPH_EXCEPTION_LOCATION);
835 return this->nnode();
846 std::stringstream error_stream;
848 <<
"Helmholtz elements only store two fields so fld = " 849 << fld <<
" is illegal\n";
852 OOMPH_CURRENT_FUNCTION,
853 OOMPH_EXCEPTION_LOCATION);
856 std::complex<unsigned> complex_u_nodal_index =
857 this->u_index_fourier_decomposed_helmholtz();
858 unsigned u_nodal_index = 0;
861 u_nodal_index = complex_u_nodal_index.real();
865 u_nodal_index = complex_u_nodal_index.imag();
867 return this->nodal_local_eqn(j,u_nodal_index);
875 void output(std::ostream &outfile,
const unsigned &nplot)
888 template<
class ELEMENT>
901 template<
class ELEMENT>
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 broken_copy(const std::string &class_name)
Issue error message and terminate execution.
double factorial(const unsigned &l)
Factorial.
GeneralisedAxisymAdvectionDiffusionSourceFctPt Source_fct_pt
Pointer to source function:
void output_fct(std::ostream &outfile, const unsigned &n_plot, const double &time, FiniteElement::UnsteadyExactSolutionFctPt exact_soln_pt)
Output function for a time-dependent exact solution. r,z,u_exact at n_plot^2 plot points (Calls the s...
Fourier decomposed Helmholtz upgraded to become projectable.
int fourier_wavenumber()
Get the Fourier wavenumber.
int *& fourier_wavenumber_pt()
Get pointer to Fourier wavenumber.
void output(std::ostream &outfile)
Output function: r,z,u.
double * K_squared_pt
Pointer to square of wavenumber.
QFourierDecomposedHelmholtzElement(const QFourierDecomposedHelmholtzElement< NNODE_1D > &dummy)
Broken copy constructor.
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.
void output_fct(std::ostream &outfile, const unsigned &nplot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
Output exact soln: r,z,u_exact at nplot^2 plot points.
A general Finite Element class.
void(* UnsteadyExactSolutionFctPt)(const double &, const Vector< double > &, Vector< double > &)
Function pointer for function that computes Vector-valued time-dependent function as ...
unsigned nvalue_of_field(const unsigned &fld)
Return number of values in field fld: One per node.
virtual void output_fct(std::ostream &outfile, const unsigned &n_plot, const double &time, FiniteElement::UnsteadyExactSolutionFctPt exact_soln_pt)
Output exact soln: (dummy time-dependent version to keep intel compiler happy)
unsigned required_nvalue(const unsigned &n) const
Broken assignment operator.
double k_squared()
Get the square of wavenumber.
unsigned nhistory_values_for_coordinate_projection()
Number of positional history values (Note: count includes current value!)
void output(std::ostream &outfile, const unsigned &n_plot)
Output function: r,z,u at n_plot^2 plot points.
double plgndr1(const unsigned &n, const double &x)
Legendre polynomials depending on one parameter.
Vector< std::pair< Data *, unsigned > > data_values_of_field(const unsigned &fld)
Specify the values associated with field fld. The information is returned in a vector of pairs which ...
void output(FILE *file_pt)
C-style output function: r,z,u.
void get_flux(const Vector< double > &s, Vector< std::complex< double > > &flux) const
Get flux: flux[i] = du/dx_i for real and imag part.
FourierDecomposedHelmholtzEquations(const FourierDecomposedHelmholtzEquations &dummy)
Broken copy constructor.
unsigned nhistory_values_for_projection(const unsigned &fld)
Number of history values to be stored for fld-th field. (Note: count includes current value!) ...
void(* SteadyExactSolutionFctPt)(const Vector< double > &, Vector< double > &)
Function pointer for function that computes vector-valued steady "exact solution" as ...
ProjectableFourierDecomposedHelmholtzElement()
Constructor [this was only required explicitly from gcc 4.5.2 onwards...].
void fill_in_contribution_to_jacobian(Vector< double > &residuals, DenseMatrix< double > &jacobian)
Add the element's contribution to its residual vector and element Jacobian matrix (wrapper) ...
QFourierDecomposedHelmholtzElement()
Constructor: Call constructors for QElement and FourierDecomposedHelmholtz equations.
unsigned self_test()
Self-test: Return 0 for OK.
virtual void get_source_fourier_decomposed_helmholtz(const unsigned &ipt, const Vector< double > &x, std::complex< double > &source) const
void fill_in_contribution_to_residuals(Vector< double > &residuals)
Add the element's contribution to its residual vector (wrapper)
FourierDecomposedHelmholtzSourceFctPt Source_fct_pt
Pointer to source function:
double *& k_squared_pt()
Get pointer to square of wavenumber.
FourierDecomposedHelmholtzEquations()
Constructor.
void shape(const double &s, double *Psi)
Definition for 1D Lagrange shape functions. The value of all the shape functions at the local coordin...
void output(std::ostream &outfile)
Output with default number of plot points.
double get_field(const unsigned &t, const unsigned &fld, const Vector< double > &s)
Return interpolated field fld at local coordinate s, at time level t (t=0: present; t>0: history valu...
FourierDecomposedHelmholtzSourceFctPt & source_fct_pt()
Access function: Pointer to source function.
int * N_fourier_pt
Pointer to Fourier wave number.
void output(FILE *file_pt, const unsigned &n_plot)
C-style output function: r,z,u at n_plot^2 plot points.
double jacobian_and_shape_of_field(const unsigned &fld, const Vector< double > &s, Shape &psi)
Return Jacobian of mapping and shape functions of field fld at local coordinate s.
int local_equation(const unsigned &fld, const unsigned &j)
Return local equation number of value j in field fld.
void compute_error(std::ostream &outfile, FiniteElement::UnsteadyExactSolutionFctPt exact_soln_pt, const double &time, double &error, double &norm)
Dummy, time dependent error checker.
void compute_error(std::ostream &outfile, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt, double &error, double &norm)
Get error against and norm of exact solution.
FaceGeometry()
Constructor: Call the constructor for the appropriate lower-dimensional QElement. ...
void output(std::ostream &outfile, const unsigned &nplot)
Output FE representation of soln: x,y,u or x,y,z,u at n_plot^DIM plot points.
static const unsigned Initial_Nvalue
Static int that holds the number of variables at nodes: always the same.
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...
unsigned nfields_for_projection()
Number of fields to be projected: 2 (real and imag part)
FourierDecomposedHelmholtzSourceFctPt source_fct_pt() const
Access function: Pointer to source function. Const version.
void output_fct(std::ostream &outfile, const unsigned &n_plot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
Output function for an exact solution: r,z,u_exact at n_plot^2 plot points.
virtual std::complex< unsigned > u_index_fourier_decomposed_helmholtz() const
Broken assignment operator.
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_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...
std::complex< double > interpolated_u_fourier_decomposed_helmholtz(const Vector< double > &s) const
Return FE representation of function value u(s) at local coordinate s.
double dshape_and_dtest_eulerian_at_knot_fourier_decomposed_helmholtz(const unsigned &ipt, Shape &psi, DShape &dpsidx, Shape &test, DShape &dtestdx) const
Shape, test functions & derivs. w.r.t. to global coords. at integration point ipt. Return Jacobian.
double dshape_and_dtest_eulerian_fourier_decomposed_helmholtz(const Vector< double > &s, Shape &psi, DShape &dpsidx, Shape &test, DShape &dtestdx) const
void output(FILE *file_pt)
C_style output with default number of plot points.
static DenseMatrix< double > Dummy_matrix
Empty dense matrix used as a dummy argument to combined residual and jacobian functions in the case w...
double plgndr2(const unsigned &l, const unsigned &m, const double &x)
Legendre polynomials depending on two parameters.