31 #ifndef OOMPH_PML_FOURIER_DECOMPOSED_HELMHOLTZ_ELEMENTS_HEADER 32 #define OOMPH_PML_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" 49 #include "../generic/pml_meshes.h" 50 #include "../generic/projection.h" 51 #include "../generic/oomph_definitions.h" 61 namespace Legendre_functions_helper
65 extern double factorial(
const unsigned& l);
68 extern double plgndr1(
const unsigned& n,
const double& x);
71 extern double plgndr2(
const unsigned& l,
const unsigned& m,
const double& x);
102 typedef void (*PMLFourierDecomposedHelmholtzSourceFctPt)(
104 std::complex<double>& f);
108 K_squared_pt(0), N_pml_fourier_pt(0)
136 virtual inline std::complex<unsigned>
139 {
return std::complex<unsigned>(0,1);}
156 "Please set pointer to k_squared using access fct to pointer!",
157 OOMPH_CURRENT_FUNCTION,
158 OOMPH_EXCEPTION_LOCATION);
161 return *K_squared_pt;
180 return N_pml_fourier_pt;
186 if (N_pml_fourier_pt==0)
192 return *N_pml_fourier_pt;
200 const unsigned n_plot=5;
206 void output(std::ostream &outfile,
const unsigned &n_plot);
213 void output_real(std::ostream &outfile,
const double& phi,
214 const unsigned &n_plot);
219 const unsigned n_plot=5;
225 void output(FILE* file_pt,
const unsigned &n_plot);
229 void output_fct(std::ostream &outfile,
const unsigned &n_plot,
234 virtual void output_fct(std::ostream &outfile,
const unsigned &n_plot,
240 "There is no time-dependent output_fct() for PMLFourierDecomposedHelmholtz elements ",
241 OOMPH_CURRENT_FUNCTION,
242 OOMPH_EXCEPTION_LOCATION);
251 void output_real_fct(std::ostream &outfile,
253 const unsigned &n_plot,
260 double& error,
double& norm);
266 const double& time,
double& error,
double& norm)
269 "There is no time-dependent compute_error() for PMLFourierDecomposedHelmholtz elements",
270 OOMPH_CURRENT_FUNCTION,
271 OOMPH_EXCEPTION_LOCATION);
275 void compute_norm(
double& norm);
295 std::complex<double>& source)
const 300 source = std::complex<double>(0.0,0.0);
305 (*Source_fct_pt)(x,source);
315 values_to_pin.resize(2);
316 for (
unsigned j=0;j<2;j++)
325 Vector<std::complex <double> >& flux)
const 328 const unsigned n_node = nnode();
335 dshape_eulerian(s,psi,dpsidx);
338 const std::complex<double> zero(0.0,0.0);
339 for(
unsigned j=0;j<2;j++)
345 for(
unsigned l=0;l<n_node;l++)
348 const std::complex<double> u_value(
350 (l,u_index_pml_fourier_decomposed_helmholtz().real()),
352 (l,u_index_pml_fourier_decomposed_helmholtz().imag()));
355 for(
unsigned j=0;j<2;j++)
357 flux[j] += u_value*dpsidx(l,j);
364 inline std::complex<double>
369 const unsigned n_node = nnode();
378 std::complex<double> interpolated_u(0.0,0.0);
381 const unsigned u_nodal_index_real =
382 u_index_pml_fourier_decomposed_helmholtz().real();
383 const unsigned u_nodal_index_imag =
384 u_index_pml_fourier_decomposed_helmholtz().imag();
387 for(
unsigned l=0;l<n_node;l++)
390 const std::complex<double> u_value(
391 this->nodal_value(l,u_nodal_index_real),
392 this->nodal_value(l,u_nodal_index_imag));
394 interpolated_u += u_value*psi[l];
396 return interpolated_u;
410 dshape_and_dtest_eulerian_pml_fourier_decomposed_helmholtz(
420 dshape_and_dtest_eulerian_at_knot_pml_fourier_decomposed_helmholtz(
447 template <
class PML_ELEMENT>
450 public virtual PML_ELEMENT,
459 this->Pml_mapping_pt =
464 double wavenumber()
const {
return std::sqrt(this->k_squared()); }
479 fill_in_generic_residual_contribution_pml_fourier_decomposed_helmholtz(
489 fill_in_generic_residual_contribution_pml_fourier_decomposed_helmholtz(
490 residuals,jacobian,1);
498 fill_in_generic_residual_contribution_pml_fourier_decomposed_helmholtz(
500 const unsigned& flag);
519 template <
unsigned NNODE_1D,
class PML_ELEMENT>
521 public virtual QElement<2,NNODE_1D>,
559 {
return Initial_Nvalue;}
567 void output(std::ostream &outfile,
const unsigned &n_plot)
576 const unsigned &n_plot)
578 (outfile,phi,n_plot);}
586 void output(FILE* file_pt,
const unsigned &n_plot)
591 void output_fct(std::ostream &outfile,
const unsigned &n_plot,
605 const unsigned &n_plot,
616 void output_fct(std::ostream &outfile,
const unsigned &n_plot,
621 (outfile,n_plot,time,exact_soln_pt);
629 dshape_and_dtest_eulerian_pml_fourier_decomposed_helmholtz(
637 dshape_and_dtest_eulerian_at_knot_pml_fourier_decomposed_helmholtz(
658 template<
unsigned NNODE_1D,
class PML_ELEMENT>
668 const double J = this->dshape_eulerian(s,psi,dpsidx);
687 template<
unsigned NNODE_1D,
class PML_ELEMENT>
697 const double J = this->dshape_eulerian_at_knot(ipt,psi,dpsidx);
720 template<
unsigned NNODE_1D,
class PML_ELEMENT>
742 template<
class FOURIER_DECOMPOSED_HELMHOLTZ_ELEMENT>
763 std::stringstream error_stream;
765 <<
"Fourier decomposed Helmholtz elements only store 2 fields so fld = " 766 << fld <<
" is illegal \n";
769 OOMPH_CURRENT_FUNCTION,
770 OOMPH_EXCEPTION_LOCATION);
775 unsigned nnod=this->nnode();
779 for (
unsigned j=0;j<nnod;j++)
782 data_values[j]=std::make_pair(this->node_pt(j),fld);
802 std::stringstream error_stream;
804 <<
"Helmholtz elements only store two fields so fld = " 805 << fld <<
" is illegal\n";
808 OOMPH_CURRENT_FUNCTION,
809 OOMPH_EXCEPTION_LOCATION);
812 return this->node_pt(0)->ntstorage();
819 return this->node_pt(0)->position_time_stepper_pt()->ntstorage();
831 std::stringstream error_stream;
833 <<
"Helmholtz elements only store two fields so fld = " 834 << fld <<
" is illegal.\n";
837 OOMPH_CURRENT_FUNCTION,
838 OOMPH_EXCEPTION_LOCATION);
841 unsigned n_dim=this->dim();
842 unsigned n_node=this->nnode();
844 DShape dpsidx(n_node,n_dim), dtestdx(n_node,n_dim);
846 dshape_and_dtest_eulerian_pml_fourier_decomposed_helmholtz(
863 std::stringstream error_stream;
865 <<
"Helmholtz elements only store two fields so fld = " 866 << fld <<
" is illegal\n";
869 OOMPH_CURRENT_FUNCTION,
870 OOMPH_EXCEPTION_LOCATION);
874 std::complex<unsigned> complex_u_nodal_index =
875 this->u_index_pml_fourier_decomposed_helmholtz();
876 unsigned u_nodal_index = 0;
879 u_nodal_index = complex_u_nodal_index.real();
883 u_nodal_index = complex_u_nodal_index.imag();
888 unsigned n_node=this->nnode();
895 double interpolated_u = 0.0;
898 for(
unsigned l=0;l<n_node;l++)
900 interpolated_u += this->nodal_value(t,l,u_nodal_index)*psi[l];
902 return interpolated_u;
914 std::stringstream error_stream;
916 <<
"Helmholtz elements only store two fields so fld = " 917 << fld <<
" is illegal\n";
920 OOMPH_CURRENT_FUNCTION,
921 OOMPH_EXCEPTION_LOCATION);
924 return this->nnode();
935 std::stringstream error_stream;
937 <<
"Helmholtz elements only store two fields so fld = " 938 << fld <<
" is illegal\n";
941 OOMPH_CURRENT_FUNCTION,
942 OOMPH_EXCEPTION_LOCATION);
945 std::complex<unsigned> complex_u_nodal_index =
946 this->u_index_pml_fourier_decomposed_helmholtz();
947 unsigned u_nodal_index = 0;
950 u_nodal_index = complex_u_nodal_index.real();
954 u_nodal_index = complex_u_nodal_index.imag();
956 return this->nodal_local_eqn(j,u_nodal_index);
964 void output(std::ostream &outfile,
const unsigned &nplot)
977 template<
class ELEMENT>
991 template<
class ELEMENT>
1010 template<
unsigned NNODE_1D,
class PML_ELEMENT>
double dshape_and_dtest_eulerian_pml_fourier_decomposed_helmholtz(const Vector< double > &s, Shape &psi, DShape &dpsidx, Shape &test, DShape &dtestdx) const
QPMLFourierDecomposedHelmholtzElement()
Constructor: Call constructors for QElement and PMLFourierDecomposedHelmholtz equations.
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 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:
double *& k_squared_pt()
Get pointer to frequency.
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...
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...
unsigned nvalue_of_field(const unsigned &fld)
Return number of values in field fld: One per node.
void compute_error(std::ostream &outfile, FiniteElement::UnsteadyExactSolutionFctPt exact_soln_pt, const double &time, double &error, double &norm)
Dummy, time dependent error checker.
virtual void output(std::ostream &outfile)
Output the element data — typically the values at the nodes in a format suitable for post-processing...
double wavenumber() const
Wavenumber used in PML.
int pml_fourier_wavenumber()
Get the Fourier wavenumber.
Fourier decomposed Helmholtz upgraded to become projectable.
virtual std::complex< unsigned > u_index_pml_fourier_decomposed_helmholtz() const
Broken assignment operator.
PMLFourierDecomposedHelmholtzEquationsBase(const PMLFourierDecomposedHelmholtzEquationsBase &dummy)
Broken copy constructor.
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.
EquivalentQElement()
Constructor: Call the constructor for the appropriate QElement.
double dshape_and_dtest_eulerian_at_knot_pml_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.
PMLFourierDecomposedHelmholtzSourceFctPt & source_fct_pt()
Access function: Pointer to source function.
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 ...
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 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)
double * K_squared_pt
Pointer to k^2 (wavenumber squared)
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.
double plgndr1(const unsigned &n, const double &x)
Legendre polynomials depending on one parameter.
QPMLFourierDecomposedHelmholtzElement(const QPMLFourierDecomposedHelmholtzElement< NNODE_1D, PML_ELEMENT > &dummy)
Broken copy constructor.
static const unsigned Initial_Nvalue
Static int that holds the number of variables at nodes: always the same.
unsigned required_nvalue(const unsigned &n) const
Broken assignment operator.
void output(std::ostream &outfile, const unsigned &n_plot)
Output function: r,z,u at n_plot^2 plot points.
double * Alpha_pt
Pointer to wavenumber complex shift.
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(* SteadyExactSolutionFctPt)(const Vector< double > &, Vector< double > &)
Function pointer for function that computes vector-valued steady "exact solution" as ...
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.
unsigned self_test()
Self-test: Return 0 for OK.
static double Default_Physical_Constant_Value
Static default value for the physical constants (initialised to zero)
void output(FILE *file_pt, const unsigned &n_plot)
C-style output function: r,z,u at n_plot^2 plot points.
int * N_pml_fourier_pt
Pointer to Fourier wave number.
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...
void fill_in_contribution_to_residuals(Vector< double > &residuals)
Add the element's contribution to its residual vector (wrapper)
void output(FILE *file_pt)
C-style output function: r,z,u.
static BermudezPMLMapping Default_pml_mapping
PMLFourierDecomposedHelmholtzEquationsBase()
Constructor.
virtual void output_fct(std::ostream &outfile, const unsigned &n_plot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
Output an exact solution over the element.
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) ...
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 Default_Physical_Constant_Value
Default value for physical constants.
int *& pml_fourier_wavenumber_pt()
Get pointer to Fourier wavenumber.
FaceGeometry()
Constructor: Call the constructor for the appropriate lower-dimensional QElement. ...
void compute_error(std::ostream &outfile, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt, double &error, double &norm)
Get error against and norm of exact solution.
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 with default number of plot points.
unsigned nfields_for_projection()
Number of fields to be projected: 2 (real and imag part)
unsigned nhistory_values_for_coordinate_projection()
Number of positional history values (Note: count includes current value!)
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...
int local_equation(const unsigned &fld, const unsigned &j)
Return local equation number of value j in field fld.
double alpha()
Get complex shift.
double k_squared() const
Get k squared.
PMLFourierDecomposedHelmholtzSourceFctPt source_fct_pt() const
Access function: Pointer to source function. Const version.
void output(std::ostream &outfile)
Output function: r,z,u.
PMLFourierDecomposedHelmholtzEquations()
Constructor.
virtual void get_source_pml_fourier_decomposed_helmholtz(const unsigned &ipt, const Vector< double > &x, std::complex< double > &source) const
PMLFourierDecomposedHelmholtzSourceFctPt Source_fct_pt
Pointer to source function:
void output(std::ostream &outfile)
Output with default number of plot points.
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 values_to_be_pinned_on_outer_pml_boundary(Vector< unsigned > &values_to_pin)
double *& alpha_pt()
Get pointer to complex shift.
std::complex< double > interpolated_u_pml_fourier_decomposed_helmholtz(const Vector< double > &s) const
Return FE representation of function value u(s) at local coordinate s.
ProjectablePMLFourierDecomposedHelmholtzElement()
Constructor [this was only required explicitly from gcc 4.5.2 onwards...].
void values_to_be_pinned_on_outer_pml_boundary(Vector< unsigned > &values_to_pin)
Pure virtual function in which we specify the values to be pinned (and set to zero) on the outer edge...
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.
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.