27 #ifndef OOMPH_HELMHOLTZ_ELEMENTS_HEADER
28 #define OOMPH_HELMHOLTZ_ELEMENTS_HEADER
33 #include <oomph-lib-config.h>
38 #include "../generic/projection.h"
39 #include "../generic/nodes.h"
40 #include "../generic/Qelements.h"
41 #include "../generic/oomph_utilities.h"
54 template<
unsigned DIM>
61 std::complex<double>& f);
82 return std::complex<unsigned>(0, 1);
100 "Please set pointer to k_squared using access fct to pointer!",
101 OOMPH_CURRENT_FUNCTION,
102 OOMPH_EXCEPTION_LOCATION);
120 const unsigned& nplot)
const
127 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
139 file_out << u.real() << std::endl;
144 file_out << u.imag() << std::endl;
149 std::stringstream error_stream;
151 <<
"Helmholtz elements only store 2 fields so i must be 0 or 1"
154 OOMPH_CURRENT_FUNCTION,
155 OOMPH_EXCEPTION_LOCATION);
173 return "Imaginary part";
178 std::stringstream error_stream;
180 <<
"Helmholtz elements only store 2 fields so i must be 0 or 1"
183 OOMPH_CURRENT_FUNCTION,
184 OOMPH_EXCEPTION_LOCATION);
195 const unsigned n_plot = 5;
201 void output(std::ostream& outfile,
const unsigned& n_plot);
210 const unsigned& n_plot);
215 const unsigned n_plot = 5;
221 void output(FILE* file_pt,
const unsigned& n_plot);
226 const unsigned& n_plot,
232 std::ostream& outfile,
233 const unsigned& n_plot,
238 "There is no time-dependent output_fct() for Helmholtz elements ",
239 OOMPH_CURRENT_FUNCTION,
240 OOMPH_EXCEPTION_LOCATION);
251 const unsigned& n_plot,
270 "There is no time-dependent compute_error() for Helmholtz elements",
271 OOMPH_CURRENT_FUNCTION,
272 OOMPH_EXCEPTION_LOCATION);
294 std::complex<double>& source)
const
299 source = std::complex<double>(0.0, 0.0);
304 (*Source_fct_pt)(x, source);
311 Vector<std::complex<double>>& flux)
const
314 const unsigned n_node =
nnode();
319 DShape dpsidx(n_node, DIM);
325 const std::complex<double> zero(0.0, 0.0);
326 for (
unsigned j = 0; j < DIM; j++)
332 for (
unsigned l = 0; l < n_node; l++)
335 const std::complex<double> u_value(
339 for (
unsigned j = 0; j < DIM; j++)
341 flux[j] += u_value * dpsidx(l, j);
373 const unsigned n_node =
nnode();
382 std::complex<double> interpolated_u(0.0, 0.0);
389 for (
unsigned l = 0; l < n_node; l++)
392 const std::complex<double> u_value(
396 interpolated_u += u_value * psi[l];
398 return interpolated_u;
414 DShape& dtestdx)
const = 0;
424 DShape& dtestdx)
const = 0;
431 const unsigned& flag);
450 template<
unsigned DIM,
unsigned NNODE_1D>
490 void output(std::ostream& outfile,
const unsigned& n_plot)
502 const unsigned& n_plot)
518 void output(FILE* file_pt,
const unsigned& n_plot)
527 const unsigned& n_plot,
541 const unsigned& n_plot,
545 outfile, phi, n_plot, exact_soln_pt);
553 const unsigned& n_plot,
591 template<
unsigned DIM,
unsigned NNODE_1D>
600 const double J = this->dshape_eulerian(
s, psi, dpsidx);
617 template<
unsigned DIM,
unsigned NNODE_1D>
626 const double J = this->dshape_eulerian_at_knot(ipt, psi, dpsidx);
647 template<
unsigned DIM,
unsigned NNODE_1D>
649 :
public virtual QElement<DIM - 1, NNODE_1D>
665 template<
unsigned NNODE_1D>
684 template<
class HELMHOLTZ_ELEMENT>
701 std::stringstream error_stream;
702 error_stream <<
"Helmholtz elements only store 2 fields so fld = "
703 << fld <<
" is illegal \n";
705 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
710 unsigned nnod = this->
nnode();
714 for (
unsigned j = 0; j < nnod; j++)
717 data_values[j] = std::make_pair(this->
node_pt(j), fld);
737 std::stringstream error_stream;
738 error_stream <<
"Helmholtz elements only store two fields so fld = "
739 << fld <<
" is illegal\n";
741 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
763 std::stringstream error_stream;
764 error_stream <<
"Helmholtz elements only store two fields so fld = "
765 << fld <<
" is illegal.\n";
767 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
770 unsigned n_dim = this->
dim();
771 unsigned n_node = this->
nnode();
773 DShape dpsidx(n_node, n_dim), dtestdx(n_node, n_dim);
774 double J = this->dshape_and_dtest_eulerian_helmholtz(
775 s, psi, dpsidx, test, dtestdx);
789 std::stringstream error_stream;
790 error_stream <<
"Helmholtz elements only store two fields so fld = "
791 << fld <<
" is illegal\n";
793 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
797 std::complex<unsigned> complex_u_nodal_index = this->u_index_helmholtz();
798 unsigned u_nodal_index = 0;
801 u_nodal_index = complex_u_nodal_index.real();
805 u_nodal_index = complex_u_nodal_index.imag();
810 unsigned n_node = this->
nnode();
817 double interpolated_u = 0.0;
820 for (
unsigned l = 0; l < n_node; l++)
822 interpolated_u += this->
nodal_value(t, l, u_nodal_index) * psi[l];
824 return interpolated_u;
834 std::stringstream error_stream;
835 error_stream <<
"Helmholtz elements only store two fields so fld = "
836 << fld <<
" is illegal\n";
838 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
841 return this->
nnode();
851 std::stringstream error_stream;
852 error_stream <<
"Helmholtz elements only store two fields so fld = "
853 << fld <<
" is illegal\n";
855 error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
858 std::complex<unsigned> complex_u_nodal_index = this->u_index_helmholtz();
859 unsigned u_nodal_index = 0;
862 u_nodal_index = complex_u_nodal_index.real();
866 u_nodal_index = complex_u_nodal_index.imag();
874 void output(std::ostream& outfile,
const unsigned& nplot)
885 template<
class ELEMENT>
898 template<
class ELEMENT>
A Class for the derivatives of shape functions The class design is essentially the same as Shape,...
unsigned ntstorage() const
Return total number of doubles stored per value to record time history of each value (one for steady ...
FaceGeometry()
Constructor: Call the constructor for the appropriate lower-dimensional QElement.
FaceGeometry()
Constructor: Call the constructor for the appropriate lower-dimensional QElement.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
A general Finite Element class.
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...
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
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...
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...
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.
unsigned dim() const
Return the spatial dimension of the element, i.e. the number of local coordinates required to paramet...
unsigned nnode() const
Return the number of nodes.
void(* SteadyExactSolutionFctPt)(const Vector< double > &, Vector< double > &)
Function pointer for function that computes vector-valued steady "exact solution" as .
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...
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(* UnsteadyExactSolutionFctPt)(const double &, const Vector< double > &, Vector< double > &)
Function pointer for function that computes Vector-valued time-dependent function as .
static DenseMatrix< double > Dummy_matrix
Empty dense matrix used as a dummy argument to combined residual and jacobian functions in the case w...
A class for all isoparametric elements that solve the Helmholtz equations.
HelmholtzSourceFctPt & source_fct_pt()
Access function: Pointer to source function.
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...
std::string scalar_name_paraview(const unsigned &i) const
Name of the i-th scalar field. Default implementation returns V1 for the first one,...
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.
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.
virtual std::complex< unsigned > u_index_helmholtz() const
Broken assignment operator.
unsigned nscalar_paraview() const
Number of scalars/fields output by this element. Reimplements broken virtual function in base class.
HelmholtzEquations(const HelmholtzEquations &dummy)=delete
Broken copy constructor.
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 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 ...
HelmholtzEquations()
Constructor (must initialise the Source_fct_pt to null)
double * K_squared_pt
Pointer to square of wavenumber.
void output(FILE *file_pt)
C_style output with default number of plot points.
void(* HelmholtzSourceFctPt)(const Vector< double > &x, std::complex< double > &f)
Function pointer to source function fct(x,f(x)) – x is a Vector!
virtual void get_source_helmholtz(const unsigned &ipt, const Vector< double > &x, std::complex< double > &source) const
Get source term at (Eulerian) position x. This function is virtual to allow overloading in multi-phys...
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 fill_in_contribution_to_residuals(Vector< double > &residuals)
Add the element's contribution to its residual vector (wrapper)
HelmholtzSourceFctPt Source_fct_pt
Pointer to source function:
std::complex< double > interpolated_u_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.
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...
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 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_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()
Get the square of wavenumber.
void output(std::ostream &outfile)
Output with default number of plot points.
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)
double *& k_squared_pt()
Get pointer to square of wavenumber.
HelmholtzSourceFctPt source_fct_pt() const
Access function: Pointer to source function. Const version.
TimeStepper *& position_time_stepper_pt()
Return a pointer to the position timestepper.
An OomphLibError object which should be thrown when an run-time error is encountered....
/////////////////////////////////////////////////////////////////////// /////////////////////////////...
Wrapper class for projectable elements. Adds "projectability" to the underlying ELEMENT.
///////////////////////////////////////////////////////////////////// ///////////////////////////////...
ProjectableHelmholtzElement()
Constructor [this was only required explicitly from gcc 4.5.2 onwards...].
unsigned nhistory_values_for_coordinate_projection()
Number of positional history values (includes current value!)
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 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...
unsigned nfields_for_projection()
Number of fields to be projected: 2 (real and imag part)
unsigned nhistory_values_for_projection(const unsigned &fld)
Number of history values to be stored for fld-th field. (includes current value!)
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.
unsigned nvalue_of_field(const unsigned &fld)
Return number of values in field fld: One per node.
int local_equation(const unsigned &fld, const unsigned &j)
Return local equation number of value j in field fld.
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, const unsigned &n_plot)
C-style output function: 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...
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...
QHelmholtzElement(const QHelmholtzElement< DIM, NNODE_1D > &dummy)=delete
Broken copy constructor.
QHelmholtzElement()
Constructor: Call constructors for QElement and Helmholtz equations.
unsigned required_nvalue(const unsigned &n) const
Broken assignment operator.
void output(std::ostream &outfile)
Output function: x,y,u or x,y,z,u.
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.
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 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....
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.
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.
A Class for shape functions. In simple cases, the shape functions have only one index that can be tho...
unsigned ntstorage() const
Return the number of doubles required to represent history (one for steady)
void output()
Doc the command line arguments.
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn't been defined.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...