31 #ifndef OOMPH_HELMHOLTZ_ELEMENTS_HEADER 32 #define OOMPH_HELMHOLTZ_ELEMENTS_HEADER 37 #include <oomph-lib-config.h> 42 #include "../generic/projection.h" 43 #include "../generic/nodes.h" 44 #include "../generic/Qelements.h" 45 #include "../generic/oomph_utilities.h" 61 template <
unsigned DIM>
70 std::complex<double>& f);
97 {
return std::complex<unsigned>(0,1);}
114 "Please set pointer to k_squared using access fct to pointer!",
115 OOMPH_CURRENT_FUNCTION,
116 OOMPH_EXCEPTION_LOCATION);
135 const unsigned& nplot)
const 142 for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
154 file_out << u.real() << std::endl;
159 file_out << u.imag() << std::endl;
164 std::stringstream error_stream;
166 <<
"Helmholtz elements only store 2 fields so i must be 0 or 1" 170 OOMPH_CURRENT_FUNCTION,
171 OOMPH_EXCEPTION_LOCATION);
189 return "Imaginary part";
194 std::stringstream error_stream;
196 <<
"Helmholtz elements only store 2 fields so i must be 0 or 1" 200 OOMPH_CURRENT_FUNCTION,
201 OOMPH_EXCEPTION_LOCATION);
212 const unsigned n_plot=5;
218 void output(std::ostream &outfile,
const unsigned &n_plot);
225 void output_real(std::ostream &outfile,
const double& phi,
226 const unsigned &n_plot);
231 const unsigned n_plot=5;
237 void output(FILE* file_pt,
const unsigned &n_plot);
241 void output_fct(std::ostream &outfile,
const unsigned &n_plot,
246 virtual void output_fct(std::ostream &outfile,
const unsigned &n_plot,
252 "There is no time-dependent output_fct() for Helmholtz elements ",
253 OOMPH_CURRENT_FUNCTION,
254 OOMPH_EXCEPTION_LOCATION);
266 const unsigned &n_plot,
273 double& error,
double& norm);
279 const double& time,
double& error,
double& norm)
282 "There is no time-dependent compute_error() for Helmholtz elements",
283 OOMPH_CURRENT_FUNCTION,
284 OOMPH_EXCEPTION_LOCATION);
300 std::complex<double>& source)
const 305 source = std::complex<double>(0.0,0.0);
310 (*Source_fct_pt)(x,source);
317 Vector<std::complex <double> >& flux)
const 320 const unsigned n_node =
nnode();
325 DShape dpsidx(n_node,DIM);
331 const std::complex<double> zero(0.0,0.0);
332 for(
unsigned j=0;j<DIM;j++)
338 for(
unsigned l=0;l<n_node;l++)
341 const std::complex<double> u_value(
345 for(
unsigned j=0;j<DIM;j++)
347 flux[j] += u_value*dpsidx(l,j);
380 const unsigned n_node =
nnode();
389 std::complex<double> interpolated_u(0.0,0.0);
396 for(
unsigned l=0;l<n_node;l++)
399 const std::complex<double> u_value(
403 interpolated_u += u_value*psi[l];
405 return interpolated_u;
436 const unsigned& flag);
461 template <
unsigned DIM,
unsigned NNODE_1D>
496 {
return Initial_Nvalue;}
506 void output(std::ostream &outfile,
const unsigned &n_plot)
515 const unsigned &n_plot)
527 void output(FILE* file_pt,
const unsigned &n_plot)
533 void output_fct(std::ostream &outfile,
const unsigned &n_plot,
545 const unsigned &n_plot,
555 void output_fct(std::ostream &outfile,
const unsigned &n_plot,
592 template<
unsigned DIM,
unsigned NNODE_1D>
620 template<
unsigned DIM,
unsigned NNODE_1D>
652 template<
unsigned DIM,
unsigned NNODE_1D>
654 public virtual QElement<DIM-1,NNODE_1D>
673 template<
unsigned NNODE_1D>
697 template<
class HELMHOLTZ_ELEMENT>
718 std::stringstream error_stream;
720 <<
"Helmholtz elements only store 2 fields so fld = " 721 << fld <<
" is illegal \n";
724 OOMPH_CURRENT_FUNCTION,
725 OOMPH_EXCEPTION_LOCATION);
730 unsigned nnod=this->
nnode();
734 for (
unsigned j=0;j<nnod;j++)
737 data_values[j]=std::make_pair(this->
node_pt(j),fld);
757 std::stringstream error_stream;
759 <<
"Helmholtz elements only store two fields so fld = " 760 << fld <<
" is illegal\n";
763 OOMPH_CURRENT_FUNCTION,
764 OOMPH_EXCEPTION_LOCATION);
786 std::stringstream error_stream;
788 <<
"Helmholtz elements only store two fields so fld = " 789 << fld <<
" is illegal.\n";
792 OOMPH_CURRENT_FUNCTION,
793 OOMPH_EXCEPTION_LOCATION);
796 unsigned n_dim=this->
dim();
797 unsigned n_node=this->
nnode();
799 DShape dpsidx(n_node,n_dim), dtestdx(n_node,n_dim);
816 std::stringstream error_stream;
818 <<
"Helmholtz elements only store two fields so fld = " 819 << fld <<
" is illegal\n";
822 OOMPH_CURRENT_FUNCTION,
823 OOMPH_EXCEPTION_LOCATION);
828 unsigned u_nodal_index = 0;
831 u_nodal_index = complex_u_nodal_index.real();
835 u_nodal_index = complex_u_nodal_index.imag();
840 unsigned n_node=this->
nnode();
847 double interpolated_u = 0.0;
850 for(
unsigned l=0;l<n_node;l++)
852 interpolated_u += this->
nodal_value(t,l,u_nodal_index)*psi[l];
854 return interpolated_u;
866 std::stringstream error_stream;
868 <<
"Helmholtz elements only store two fields so fld = " 869 << fld <<
" is illegal\n";
872 OOMPH_CURRENT_FUNCTION,
873 OOMPH_EXCEPTION_LOCATION);
876 return this->
nnode();
887 std::stringstream error_stream;
889 <<
"Helmholtz elements only store two fields so fld = " 890 << fld <<
" is illegal\n";
893 OOMPH_CURRENT_FUNCTION,
894 OOMPH_EXCEPTION_LOCATION);
898 unsigned u_nodal_index = 0;
901 u_nodal_index = complex_u_nodal_index.real();
905 u_nodal_index = complex_u_nodal_index.imag();
915 void output(std::ostream &outfile,
const unsigned &nplot)
928 template<
class ELEMENT>
941 template<
class ELEMENT>
HelmholtzSourceFctPt & source_fct_pt()
Access function: Pointer to source function.
void fill_in_contribution_to_residuals(Vector< double > &residuals)
Add the element's contribution to its residual vector (wrapper)
double k_squared()
Get the square of wavenumber.
unsigned nscalar_paraview() const
Number of scalars/fields output by this element. Reimplements broken virtual function in base class...
void broken_copy(const std::string &class_name)
Issue error message and terminate execution.
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.
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-...
HelmholtzSourceFctPt Source_fct_pt
Pointer to source function:
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...
void output(FILE *file_pt)
C_style output with default number of plot points.
QHelmholtzElement()
Constructor: Call constructors for QElement and Helmholtz equations.
unsigned nhistory_values_for_projection(const unsigned &fld)
Number of history values to be stored for fld-th field. (includes current value!) ...
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_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(* HelmholtzSourceFctPt)(const Vector< double > &x, std::complex< double > &f)
Function pointer to source function fct(x,f(x)) – x is a Vector!
TimeStepper *& position_time_stepper_pt()
Return a pointer to the position timestepper.
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.
Helmholtz upgraded to become projectable.
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.
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...
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 void get_source_helmholtz(const unsigned &ipt, const Vector< double > &x, std::complex< double > &source) const
unsigned self_test()
Self-test: Return 0 for OK.
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 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 output(std::ostream &outfile)
Output function: x,y,u or x,y,z,u.
unsigned nfields_for_projection()
Number of fields to be projected: 2 (real and imag part)
int local_equation(const unsigned &fld, const unsigned &j)
Return local equation number of value j in field fld.
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(* SteadyExactSolutionFctPt)(const Vector< double > &, Vector< double > &)
Function pointer for function that computes vector-valued steady "exact solution" as ...
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_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...
ProjectableHelmholtzElement()
Constructor [this was only required explicitly from gcc 4.5.2 onwards...].
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_coordinate_projection()
Number of positional history values (includes current value!)
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 ...
void compute_error(std::ostream &outfile, FiniteElement::UnsteadyExactSolutionFctPt exact_soln_pt, const double &time, double &error, double &norm)
Dummy, time dependent error checker.
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 ...
HelmholtzSourceFctPt source_fct_pt() const
Access function: Pointer to source function. Const version.
unsigned required_nvalue(const unsigned &n) const
Broken assignment operator.
double *& k_squared_pt()
Get pointer to square of wavenumber.
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 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) ...
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
QHelmholtzElement(const QHelmholtzElement< DIM, NNODE_1D > &dummy)
Broken copy constructor.
double * K_squared_pt
Pointer to square of wavenumber.
void output(std::ostream &outfile)
Output with default number of plot points.
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 ntstorage() const
Return total number of doubles stored per value to record time history of each value (one for steady ...
virtual std::complex< unsigned > u_index_helmholtz() const
Broken assignment operator.
void compute_error(std::ostream &outfile, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt, double &error, double &norm)
Get error against and norm of exact solution.
std::complex< double > interpolated_u_helmholtz(const Vector< double > &s) const
Return FE representation of function value u_helmholtz(s) at local coordinate s.
unsigned dim() const
Return the spatial dimension of the element, i.e. the number of local coordinates required to paramet...
void output_fct(std::ostream &outfile, const unsigned &n_plot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn't been defined.
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...
FaceGeometry()
Constructor: Call the constructor for the appropriate lower-dimensional QElement. ...
unsigned nvalue_of_field(const unsigned &fld)
Return number of values in field fld: One per node.
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 ...
FaceGeometry()
Constructor: Call the constructor for the appropriate lower-dimensional QElement. ...
HelmholtzEquations(const HelmholtzEquations &dummy)
Broken copy constructor.
void output(std::ostream &outfile)
Output with default number of plot points.
unsigned nnode() const
Return the number of nodes.
void output(FILE *file_pt)
C-style output function: x,y,u or x,y,z,u.
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.
HelmholtzEquations()
Constructor (must initialise the Source_fct_pt to null)
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...
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.
static DenseMatrix< double > Dummy_matrix
Empty dense matrix used as a dummy argument to combined residual and jacobian functions in the case w...
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...
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 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...