31 #ifndef OOMPH_PML_HELMHOLTZ_ELEMENTS_HEADER 32 #define OOMPH_PML_HELMHOLTZ_ELEMENTS_HEADER 37 #include <oomph-lib-config.h> 44 #include "../generic/nodes.h" 45 #include "../generic/Qelements.h" 46 #include "../generic/oomph_utilities.h" 47 #include "../generic/pml_meshes.h" 48 #include "../generic/projection.h" 49 #include "../generic/pml_mapping_functions.h" 63 template <
unsigned DIM>
72 std::complex<double>& f);
103 {
return std::complex<unsigned>(0,1);}
115 "Please set pointer to k_squared using access fct to pointer!",
116 OOMPH_CURRENT_FUNCTION,
117 OOMPH_EXCEPTION_LOCATION);
141 const unsigned& nplot)
const 149 for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
161 file_out << u.real() << std::endl;
166 file_out << u.imag() << std::endl;
172 std::stringstream error_stream;
174 <<
"PML Helmholtz elements only store 2 fields (real and imaginary) " 175 <<
"so i must be 0 or 1 rather " 176 <<
"than " << i << std::endl;
179 OOMPH_CURRENT_FUNCTION,
180 OOMPH_EXCEPTION_LOCATION);
192 const unsigned& nplot,
207 for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
216 (*exact_soln_pt)(x,exact_soln);
224 file_out << exact_soln[0] << std::endl;
229 file_out << exact_soln[1] << std::endl;
235 std::stringstream error_stream;
237 <<
"PML Helmholtz elements only store 2 fields (real and imaginary) " 238 <<
"so i must be 0 or 1 rather " 239 <<
"than " << i << std::endl;
242 OOMPH_CURRENT_FUNCTION,
243 OOMPH_EXCEPTION_LOCATION);
263 return "Imaginary part";
269 std::stringstream error_stream;
271 <<
"PML Helmholtz elements only store 2 fields (real and imaginary) " 272 <<
"so i must be 0 or 1 rather " 273 <<
"than " << i << std::endl;
276 OOMPH_CURRENT_FUNCTION,
277 OOMPH_EXCEPTION_LOCATION);
289 const unsigned n_plot=5;
295 void output(std::ostream &outfile,
const unsigned &n_plot);
303 std::ostream &outfile,
306 const unsigned &nplot);
313 void output_real(std::ostream &outfile,
const double& phi,
314 const unsigned &n_plot);
321 void output_imag(std::ostream &outfile,
const double& phi,
322 const unsigned &n_plot);
327 const unsigned n_plot=5;
333 void output(FILE* file_pt,
const unsigned &n_plot);
337 void output_fct(std::ostream &outfile,
const unsigned &n_plot,
342 virtual void output_fct(std::ostream &outfile,
const unsigned &n_plot,
348 "There is no time-dependent output_fct() for PMLHelmholtz elements.",
349 OOMPH_CURRENT_FUNCTION,
350 OOMPH_EXCEPTION_LOCATION);
362 const unsigned &n_plot,
372 const unsigned &n_plot,
379 double& error,
double& norm);
385 const double& time,
double& error,
double& norm)
388 "There is no time-dependent compute_error() for PMLHelmholtz elements.",
389 OOMPH_CURRENT_FUNCTION,
390 OOMPH_EXCEPTION_LOCATION);
410 std::complex<double>& source)
const 415 source = std::complex<double>(0.0,0.0);
420 (*Source_fct_pt)(x,source);
430 values_to_pin.resize(2);
439 Vector<std::complex <double> >& flux)
const 442 const unsigned n_node =
nnode();
447 DShape dpsidx(n_node,DIM);
453 const std::complex<double> zero(0.0,0.0);
454 for(
unsigned j=0;j<DIM;j++)
460 for(
unsigned l=0;l<n_node;l++)
463 const std::complex<double> u_value(
467 for(
unsigned j=0;j<DIM;j++)
469 flux[j] += u_value*dpsidx(l,j);
476 inline std::complex<double>
480 const unsigned n_node =
nnode();
489 std::complex<double> interpolated_u(0.0,0.0);
496 for(
unsigned l=0;l<n_node;l++)
499 const std::complex<double> u_value(
503 interpolated_u += u_value*psi[l];
505 return interpolated_u;
526 std::list<std::pair<unsigned long,unsigned> >& dof_lookup_list)
const 529 std::pair<unsigned,unsigned> dof_lookup;
532 unsigned n_node = this->
nnode();
535 for (
unsigned n = 0; n < n_node; n++)
542 if (local_eqn_number >= 0)
546 dof_lookup.first = this->
eqn_number(local_eqn_number);
547 dof_lookup.second = 0;
550 dof_lookup_list.push_front(dof_lookup);
558 if (local_eqn_number >= 0)
562 dof_lookup.first = this->
eqn_number(local_eqn_number);
563 dof_lookup.second = 1;
566 dof_lookup_list.push_front(dof_lookup);
614 template <
unsigned DIM,
class PML_ELEMENT>
617 public virtual PML_ELEMENT,
634 fill_in_generic_residual_contribution_helmholtz(
645 fill_in_generic_residual_contribution_helmholtz(residuals,jacobian,1);
661 virtual void fill_in_generic_residual_contribution_helmholtz(
663 const unsigned& flag);
682 template <
unsigned DIM,
unsigned NNODE_1D,
class PML_ELEMENT>
719 {
return Initial_Nvalue;}
729 void output(std::ostream &outfile,
const unsigned &n_plot)
738 const unsigned &n_plot)
747 const unsigned &n_plot)
759 void output(FILE* file_pt,
const unsigned &n_plot)
765 void output_fct(std::ostream &outfile,
const unsigned &n_plot,
779 const unsigned &n_plot,
795 const unsigned &n_plot,
808 void output_fct(std::ostream &outfile,
const unsigned &n_plot,
847 template<
unsigned DIM,
unsigned NNODE_1D,
class PML_ELEMENT>
875 template<
unsigned DIM,
unsigned NNODE_1D,
class PML_ELEMENT>
907 template<
unsigned DIM,
unsigned NNODE_1D,
class PML_ELEMENT>
909 public virtual QElement<DIM-1,NNODE_1D>
929 template<
unsigned NNODE_1D,
class PML_ELEMENT>
951 template<
class HELMHOLTZ_ELEMENT>
972 std::stringstream error_stream;
974 <<
"PMLHelmholtz elements only store 2 fields so fld = " 975 << fld <<
" is illegal \n";
978 OOMPH_CURRENT_FUNCTION,
979 OOMPH_EXCEPTION_LOCATION);
984 unsigned nnod=this->
nnode();
988 for (
unsigned j=0;j<nnod;j++)
991 data_values[j]=std::make_pair(this->
node_pt(j),fld);
1011 std::stringstream error_stream;
1013 <<
"PMLHelmholtz elements only store two fields so fld = " 1014 << fld <<
" is illegal\n";
1017 OOMPH_CURRENT_FUNCTION,
1018 OOMPH_EXCEPTION_LOCATION);
1040 std::stringstream error_stream;
1042 <<
"PMLHelmholtz elements only store two fields so fld = " 1043 << fld <<
" is illegal.\n";
1046 OOMPH_CURRENT_FUNCTION,
1047 OOMPH_EXCEPTION_LOCATION);
1050 unsigned n_dim=this->
dim();
1051 unsigned n_node=this->
nnode();
1053 DShape dpsidx(n_node,n_dim), dtestdx(n_node,n_dim);
1064 const unsigned &fld,
1070 std::stringstream error_stream;
1072 <<
"PMLHelmholtz elements only store two fields so fld = " 1073 << fld <<
" is illegal\n";
1076 OOMPH_CURRENT_FUNCTION,
1077 OOMPH_EXCEPTION_LOCATION);
1082 unsigned u_nodal_index = 0;
1085 u_nodal_index = complex_u_nodal_index.real();
1089 u_nodal_index = complex_u_nodal_index.imag();
1094 unsigned n_node=this->
nnode();
1101 double interpolated_u = 0.0;
1104 for(
unsigned l=0;l<n_node;l++)
1106 interpolated_u += this->
nodal_value(t,l,u_nodal_index)*psi[l];
1108 return interpolated_u;
1120 std::stringstream error_stream;
1122 <<
"PMLHelmholtz elements only store two fields so fld = " 1123 << fld <<
" is illegal\n";
1126 OOMPH_CURRENT_FUNCTION,
1127 OOMPH_EXCEPTION_LOCATION);
1130 return this->
nnode();
1141 std::stringstream error_stream;
1143 <<
"PMLHelmholtz elements only store two fields so fld = " 1144 << fld <<
" is illegal\n";
1147 OOMPH_CURRENT_FUNCTION,
1148 OOMPH_EXCEPTION_LOCATION);
1152 unsigned u_nodal_index = 0;
1155 u_nodal_index = complex_u_nodal_index.real();
1159 u_nodal_index = complex_u_nodal_index.imag();
1166 void output(std::ostream &outfile,
const unsigned &nplot)
1179 template<
class ELEMENT>
1195 template<
unsigned NNODE_1D,
class PML_ELEMENT>
std::complex< double > interpolated_u_pml_helmholtz(const Vector< double > &s) const
Return FE representation of function value u_helmholtz(s) at local coordinate s.
void compute_error(std::ostream &outfile, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt, double &error, double &norm)
Get error against and norm of exact solution.
PMLHelmholtzEquationsBase()
Constructor.
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. x,y,u_exact or x,y,z,u_exact at n_plot^DIM plot ...
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.
void broken_copy(const std::string &class_name)
Issue error message and terminate execution.
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)
EquivalentQElement()
Constructor: Call the constructor for the appropriate QElement.
void output(std::ostream &outfile)
Output with default number of plot points.
QPMLHelmholtzElement()
Constructor: Call constructors for QElement and PMLHelmholtz equations.
virtual void get_s_plot(const unsigned &i, const unsigned &nplot, Vector< double > &s, const bool &shifted_to_interior=false) const
Get cector of local coordinates of plot point i (when plotting nplot points in each "coordinate direc...
virtual double dshape_eulerian_at_knot(const unsigned &ipt, Shape &psi, DShape &dpsidx) const
Return the geometric shape functions and also first derivatives w.r.t. global coordinates at the ipt-...
virtual void output(std::ostream &outfile)
Output the element data — typically the values at the nodes in a format suitable for post-processing...
unsigned required_nvalue(const unsigned &n) const
Broken assignment operator.
std::string scalar_name_paraview(const unsigned &i) const
Name of the i-th scalar field. Default implementation returns V1 for the first one, V2 for the second etc. Can (should!) be overloaded with more meaningful names in specific elements.
unsigned nhistory_values_for_projection(const unsigned &fld)
Number of history values to be stored for fld-th field. (Note: count includes current value!) ...
virtual unsigned nplot_points_paraview(const unsigned &nplot) const
Return the number of actual plot points for paraview plot with parameter nplot. Broken virtual; can b...
PMLHelmholtz upgraded to become projectable.
PMLHelmholtzSourceFctPt Source_fct_pt
Pointer to source function:
void scalar_value_paraview(std::ofstream &file_out, const unsigned &i, const unsigned &nplot) const
Write values of the i-th scalar field at the plot points. Needs to be implemented for each new specif...
void compute_norm(double &norm)
Compute norm of fe solution.
ProjectablePMLHelmholtzElement()
Constructor [this was only required explicitly from gcc 4.5.2 onwards...].
PMLHelmholtzSourceFctPt & source_fct_pt()
Access function: Pointer to source function.
int local_equation(const unsigned &fld, const unsigned &j)
Return local equation number of value j in field fld.
A general Finite Element class.
const double & alpha() const
Alpha, wavenumber complex shift.
void(* UnsteadyExactSolutionFctPt)(const double &, const Vector< double > &, Vector< double > &)
Function pointer for function that computes Vector-valued time-dependent function as ...
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)) a...
void output_imag(std::ostream &outfile, const double &phi, const unsigned &n_plot)
Output function for imaginary part of full time-dependent solution u = Im( (u_r +i u_i) exp(-i omega ...
double dshape_and_dtest_eulerian_at_knot_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.
void output_fct(std::ostream &outfile, const unsigned &n_plot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
TimeStepper *& position_time_stepper_pt()
Return a pointer to the position timestepper.
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.
double wavenumber() const
Get wavenumber (used in PML)
void output(std::ostream &outfile, const unsigned &n_plot)
Output function: x,y,u or x,y,z,u at n_plot^DIM plot points.
void output(FILE *file_pt)
C-style output function: x,y,u or x,y,z,u.
PMLHelmholtzEquations()
Constructor.
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 *& alpha_pt()
Pointer to Alpha, wavenumber complex shift.
unsigned ndof_types() const
The number of "DOF types" that degrees of freedom in this element are sub-divided into: real and imag...
void output_imag(std::ostream &outfile, const double &phi, const unsigned &n_plot)
Output function for imaginary part of full time-dependent solution u = Im( (u_r +i u_i) exp(-i omega ...
double *& k_squared_pt()
Get pointer to k_squared.
virtual double dshape_and_dtest_eulerian_helmholtz(const Vector< double > &s, Shape &psi, DShape &dpsidx, Shape &test, DShape &dtestdx) const =0
Shape/test functions and derivs w.r.t. to global coords at local coord. s; return Jacobian of mapping...
PMLHelmholtzEquationsBase(const PMLHelmholtzEquationsBase &dummy)
Broken copy constructor.
PMLHelmholtzSourceFctPt source_fct_pt() const
Access function: Pointer to source function. Const version.
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 output(std::ostream &outfile)
Output function: x,y,u or x,y,z,u.
virtual void get_source_helmholtz(const unsigned &ipt, const Vector< double > &x, std::complex< double > &source) const
void get_dof_numbers_for_unknowns(std::list< std::pair< unsigned long, unsigned > > &dof_lookup_list) const
Create a list of pairs for all unknowns in this element, so that the first entry in each pair contain...
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(* SteadyExactSolutionFctPt)(const Vector< double > &, Vector< double > &)
Function pointer for function that computes vector-valued steady "exact solution" as ...
virtual double interpolated_x(const Vector< double > &s, const unsigned &i) const
Return FE interpolated coordinate x[i] at local coordinate s.
double * K_squared_pt
Pointer to wave number (must be set!)
double dshape_eulerian(const Vector< double > &s, Shape &psi, DShape &dpsidx) const
Compute the geometric shape functions and also first derivatives w.r.t. global coordinates at local c...
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.
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 with default number of plot points.
unsigned long eqn_number(const unsigned &ieqn_local) const
Return the global equation number corresponding to the ieqn_local-th local equation number...
unsigned nhistory_values_for_coordinate_projection()
Number of positional history values (Note: count includes current value!)
virtual void output_fct(std::ostream &outfile, const unsigned &n_plot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
Output an exact solution over the element.
static const unsigned Initial_Nvalue
Static int that holds the number of variables at nodes: always the same.
unsigned nfields_for_projection()
Number of fields to be projected: 2 (real and imag part)
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...
void output_fct(std::ostream &outfile, const unsigned &n_plot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
Output function for an exact solution: x,y,u_exact or x,y,z,u_exact at n_plot^DIM plot points...
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
void output(std::ostream &outfile)
Output with default number of plot points.
unsigned nvalue_of_field(const unsigned &fld)
Return number of values in field fld: One per node.
double k_squared() const
Get the square of wavenumber.
double nodal_value(const unsigned &n, const unsigned &i) const
Return the i-th value stored at local node n. Produces suitably interpolated values for hanging nodes...
unsigned ntstorage() const
Return the number of doubles required to represent history (one for steady)
unsigned self_test()
Self-test: Return 0 for OK.
unsigned ntstorage() const
Return total number of doubles stored per value to record time history of each value (one for steady ...
void output(FILE *file_pt, const unsigned &n_plot)
C-style output function: x,y,u or x,y,z,u at n_plot^DIM plot points.
double * Alpha_pt
Pointer to wavenumber complex shift.
virtual double dshape_and_dtest_eulerian_at_knot_helmholtz(const unsigned &ipt, Shape &psi, DShape &dpsidx, Shape &test, DShape &dtestdx) const =0
Shape/test functions and derivs w.r.t. to global coords at integration point ipt; return Jacobian of ...
unsigned nscalar_paraview() const
Number of scalars/fields output by this element. Reimplements broken virtual function in base class...
unsigned dim() const
Return the spatial dimension of the element, i.e. the number of local coordinates required to paramet...
void output_imag_fct(std::ostream &outfile, const double &phi, const unsigned &n_plot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
Output function for imaginary part of full time-dependent fct u = Im( (u_r +i u_i) exp(-i omega t)) a...
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn't been defined.
void scalar_value_fct_paraview(std::ofstream &file_out, const unsigned &i, const unsigned &nplot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt) const
Write values of the i-th scalar field at the plot points. Needs to be implemented for each new specif...
virtual std::complex< unsigned > u_index_helmholtz() const
Broken assignment operator.
void values_to_be_pinned_on_outer_pml_boundary(Vector< unsigned > &values_to_pin)
Resolve amibiguity of which function to call between two base classes.
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...
FaceGeometry()
Constructor: Call the constructor for the appropriate lower-dimensional QElement. ...
void output_imag_fct(std::ostream &outfile, const double &phi, const unsigned &n_plot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
Output function for imaginary part of full time-dependent fct u = Im( (u_r +i u_i) exp(-i omega t)) a...
static double Default_Physical_Constant_Value
Static default value for the physical constants (initialised to zero)
void compute_error(std::ostream &outfile, FiniteElement::UnsteadyExactSolutionFctPt exact_soln_pt, const double &time, double &error, double &norm)
Dummy, time dependent error checker.
QPMLHelmholtzElement elements are linear/quadrilateral/ brick-shaped PMLHelmholtz elements with isopa...
void output_total_real(std::ostream &outfile, FiniteElement::SteadyExactSolutionFctPt incoming_wave_fct_pt, const double &phi, const unsigned &nplot)
double dshape_and_dtest_eulerian_helmholtz(const Vector< double > &s, Shape &psi, DShape &dpsidx, Shape &test, DShape &dtestdx) const
Shape, test functions & derivs. w.r.t. to global coords. Return Jacobian.
int local_eqn_number(const unsigned long &ieqn_global) const
Return the local equation number corresponding to the ieqn_global-th global equation number...
unsigned nnode() const
Return the number of nodes.
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...
virtual void shape(const Vector< double > &s, Shape &psi) const =0
Calculate the geometric shape functions at local coordinate s. This function must be overloaded for e...
static DenseMatrix< double > Dummy_matrix
Empty dense matrix used as a dummy argument to combined residual and jacobian functions in the case w...
FaceGeometry()
Constructor: Call the constructor for the appropriate lower-dimensional QElement. ...
void(* PMLHelmholtzSourceFctPt)(const Vector< double > &x, std::complex< double > &f)
Function pointer to source function fct(x,f(x)) – x is a Vector!
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 ...
static BermudezPMLMapping Default_pml_mapping
int nodal_local_eqn(const unsigned &n, const unsigned &i) const
Return the local equation number corresponding to the i-th value at the n-th local node...