27 #ifndef OOMPH_PML_FOURIER_DECOMPOSED_HELMHOLTZ_ELEMENTS_HEADER
28 #define OOMPH_PML_FOURIER_DECOMPOSED_HELMHOLTZ_ELEMENTS_HEADER
33 #include <oomph-lib-config.h>
41 #include "../generic/projection.h"
42 #include "../generic/nodes.h"
43 #include "../generic/Qelements.h"
44 #include "../generic/oomph_utilities.h"
45 #include "../generic/pml_meshes.h"
46 #include "../generic/projection.h"
47 #include "../generic/oomph_definitions.h"
55 namespace Legendre_functions_helper
58 extern double factorial(
const unsigned& l);
61 extern double plgndr1(
const unsigned&
n,
const double&
x);
64 extern double plgndr2(
const unsigned& l,
88 virtual std::complex<double>
gamma(
const double& nu_i,
89 const double& pml_width_i,
90 const double& k_squared) = 0;
97 const double& pml_width_i,
98 const double& pml_inner_boundary,
99 const double& k_squared) = 0;
117 std::complex<double>
gamma(
const double& nu_i,
118 const double& pml_width_i,
119 const double& k_squared)
124 std::complex<double>(1.0 /
sqrt(k_squared), 0) *
125 std::complex<double>(0.0, 1.0 / (
std::fabs(pml_width_i - nu_i)));
132 const double& pml_width_i,
133 const double& pml_inner_boundary,
134 const double& k_squared)
137 double log_arg = 1.0 -
std::fabs(nu_i / pml_width_i);
138 return std::complex<double>(pml_inner_boundary + nu_i,
139 -
log(log_arg) /
sqrt(k_squared));
200 return std::complex<unsigned>(0, 1);
218 "Please set pointer to k_squared using access fct to pointer!",
262 const unsigned n_plot = 5;
268 void output(std::ostream& outfile,
const unsigned& n_plot);
277 const unsigned& n_plot);
282 const unsigned n_plot = 5;
288 void output(FILE* file_pt,
const unsigned& n_plot);
293 const unsigned& n_plot,
299 std::ostream& outfile,
300 const unsigned& n_plot,
304 throw OomphLibError(
"There is no time-dependent output_fct() for "
305 "PMLFourierDecomposedHelmholtz elements ",
318 const unsigned& n_plot,
336 throw OomphLibError(
"There is no time-dependent compute_error() for "
337 "PMLFourierDecomposedHelmholtz elements",
367 std::complex<double>&
source)
const
372 source = std::complex<double>(0.0, 0.0);
387 values_to_pin.resize(2);
388 for (
unsigned j = 0;
j < 2;
j++)
390 values_to_pin[
j] =
j;
400 const unsigned n_node =
nnode();
410 const std::complex<double>
zero(0.0, 0.0);
411 for (
unsigned j = 0;
j < 2;
j++)
417 for (
unsigned l = 0; l < n_node; l++)
420 const std::complex<double> u_value(
427 for (
unsigned j = 0;
j < 2;
j++)
429 flux[
j] += u_value * dpsidx(l,
j);
452 residuals, jacobian, 1);
462 const unsigned n_node =
nnode();
471 std::complex<double> interpolated_u(0.0, 0.0);
474 const unsigned u_nodal_index_real =
476 const unsigned u_nodal_index_imag =
480 for (
unsigned l = 0; l < n_node; l++)
483 const std::complex<double> u_value(
487 interpolated_u += u_value * psi[l];
489 return interpolated_u;
505 Vector<std::complex<double>>& pml_laplace_factor,
506 std::complex<double>& pml_k_squared_factor)
510 for (
unsigned k = 0;
k < 2;
k++)
518 for (
unsigned k = 0;
k < 2;
k++)
532 for (
unsigned k = 0;
k < 2;
k++)
538 nu[
k], pml_width[
k], k_squared_local);
550 pml_laplace_factor[0] = pml_gamma[1] / pml_gamma[0];
551 pml_laplace_factor[1] = pml_gamma[0] / pml_gamma[1];
552 pml_k_squared_factor = pml_gamma[0] * pml_gamma[1];
558 for (
unsigned k = 0;
k < 2;
k++)
560 pml_laplace_factor[
k] = std::complex<double>(1.0, 0.0);
563 pml_k_squared_factor = std::complex<double>(1.0, 0.0);
572 std::complex<double>& complex_r)
599 complex_r = std::complex<double>(
r, 0.0);
630 DShape& dtestdx)
const = 0;
640 DShape& dtestdx)
const = 0;
647 const unsigned& flag);
681 template<
unsigned NNODE_1D>
683 :
public virtual QElement<2, NNODE_1D>,
723 void output(std::ostream& outfile,
const unsigned& n_plot)
735 const unsigned& n_plot)
748 void output(FILE* file_pt,
const unsigned& n_plot)
756 const unsigned& n_plot,
760 outfile, n_plot, exact_soln_pt);
770 const unsigned& n_plot,
774 outfile, phi, n_plot, exact_soln_pt);
782 const unsigned& n_plot,
787 outfile, n_plot, time, exact_soln_pt);
821 template<
unsigned NNODE_1D>
831 const double J = this->dshape_eulerian(
s, psi, dpsidx);
848 template<
unsigned NNODE_1D>
858 const double J = this->dshape_eulerian_at_knot(ipt, psi, dpsidx);
880 template<
unsigned NNODE_1D>
882 :
public virtual QElement<1, NNODE_1D>
899 template<
class FOURIER_DECOMPOSED_HELMHOLTZ_ELEMENT>
916 std::stringstream error_stream;
917 error_stream <<
"Fourier decomposed Helmholtz elements only store 2 "
919 << fld <<
" is illegal \n";
926 unsigned nnod = this->
nnode();
930 for (
unsigned j = 0;
j < nnod;
j++)
933 data_values[
j] = std::make_pair(this->
node_pt(
j), fld);
953 std::stringstream error_stream;
954 error_stream <<
"Helmholtz elements only store two fields so fld = "
955 << fld <<
" is illegal\n";
979 std::stringstream error_stream;
980 error_stream <<
"Helmholtz elements only store two fields so fld = "
981 << fld <<
" is illegal.\n";
986 unsigned n_dim = this->
dim();
987 unsigned n_node = this->
nnode();
989 DShape dpsidx(n_node, n_dim), dtestdx(n_node, n_dim);
991 this->dshape_and_dtest_eulerian_pml_fourier_decomposed_helmholtz(
992 s, psi, dpsidx,
test, dtestdx);
1000 const unsigned& fld,
1006 std::stringstream error_stream;
1007 error_stream <<
"Helmholtz elements only store two fields so fld = "
1008 << fld <<
" is illegal\n";
1014 std::complex<unsigned> complex_u_nodal_index =
1015 this->u_index_pml_fourier_decomposed_helmholtz();
1016 unsigned u_nodal_index = 0;
1019 u_nodal_index = complex_u_nodal_index.real();
1023 u_nodal_index = complex_u_nodal_index.imag();
1028 unsigned n_node = this->
nnode();
1032 this->
shape(s, psi);
1035 double interpolated_u = 0.0;
1038 for (
unsigned l = 0; l < n_node; l++)
1040 interpolated_u += this->
nodal_value(t, l, u_nodal_index) * psi[l];
1042 return interpolated_u;
1052 std::stringstream error_stream;
1053 error_stream <<
"Helmholtz elements only store two fields so fld = "
1054 << fld <<
" is illegal\n";
1059 return this->
nnode();
1069 std::stringstream error_stream;
1070 error_stream <<
"Helmholtz elements only store two fields so fld = "
1071 << fld <<
" is illegal\n";
1076 std::complex<unsigned> complex_u_nodal_index =
1077 this->u_index_pml_fourier_decomposed_helmholtz();
1078 unsigned u_nodal_index = 0;
1081 u_nodal_index = complex_u_nodal_index.real();
1085 u_nodal_index = complex_u_nodal_index.imag();
1093 void output(std::ostream& outfile,
const unsigned& nplot)
1104 template<
class ELEMENT>
1117 template<
class ELEMENT>
1135 template<
unsigned NNODE_1D>
AnnoyingScalar imag(const AnnoyingScalar &)
Definition: AnnoyingScalar.h:132
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
JacobiRotation< float > J
Definition: Jacobi_makeJacobi.cpp:3
unsigned ntstorage() const
Definition: nodes.cc:879
FaceGeometry()
Definition: pml_fourier_decomposed_helmholtz_elements.h:1123
FaceGeometry()
Definition: pml_fourier_decomposed_helmholtz_elements.h:1109
FaceGeometry()
Definition: pml_fourier_decomposed_helmholtz_elements.h:887
Definition: elements.h:4998
Definition: elements.h:1313
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
Definition: elements.h:2175
double nodal_value(const unsigned &n, const unsigned &i) const
Definition: elements.h:2593
virtual void shape(const Vector< double > &s, Shape &psi) const =0
int nodal_local_eqn(const unsigned &n, const unsigned &i) const
Definition: elements.h:1432
unsigned dim() const
Definition: elements.h:2611
unsigned nnode() const
Return the number of nodes.
Definition: elements.h:2210
void(* SteadyExactSolutionFctPt)(const Vector< double > &, Vector< double > &)
Definition: elements.h:1759
void(* UnsteadyExactSolutionFctPt)(const double &, const Vector< double > &, Vector< double > &)
Definition: elements.h:1765
double dshape_eulerian(const Vector< double > &s, Shape &psi, DShape &dpsidx) const
Definition: elements.cc:3298
static DenseMatrix< double > Dummy_matrix
Definition: elements.h:227
TimeStepper *& position_time_stepper_pt()
Return a pointer to the position timestepper.
Definition: nodes.h:1022
Definition: oomph_definitions.h:222
Base class for elements with pml capabilities.
Definition: pml_meshes.h:60
bool Pml_is_enabled
Boolean indicating if element is used in pml mode.
Definition: pml_meshes.h:119
std::vector< bool > Pml_direction_active
Definition: pml_meshes.h:124
Vector< double > Pml_outer_boundary
Definition: pml_meshes.h:134
Vector< double > Pml_inner_boundary
Definition: pml_meshes.h:129
Definition: pml_fourier_decomposed_helmholtz_elements.h:162
std::complex< double > interpolated_u_pml_fourier_decomposed_helmholtz(const Vector< double > &s) const
Definition: pml_fourier_decomposed_helmholtz_elements.h:458
int pml_fourier_wavenumber()
Get the Fourier wavenumber.
Definition: pml_fourier_decomposed_helmholtz_elements.h:246
virtual void fill_in_generic_residual_contribution_pml_fourier_decomposed_helmholtz(Vector< double > &residuals, DenseMatrix< double > &jacobian, const unsigned &flag)
Definition: pml_fourier_decomposed_helmholtz_elements.cc:192
PMLMappingAndTransformedCoordinate *const & pml_mapping_and_transformed_coordinate_pt() const
Return a pointer to the PML Mapping object (const version)
Definition: pml_fourier_decomposed_helmholtz_elements.h:611
void compute_error(std::ostream &outfile, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt, double &error, double &norm)
Get error against and norm of exact solution.
Definition: pml_fourier_decomposed_helmholtz_elements.cc:715
double * K_squared_pt
Pointer to k^2 (wavenumber squared)
Definition: pml_fourier_decomposed_helmholtz_elements.h:653
void output_real(std::ostream &outfile, const double &phi, const unsigned &n_plot)
Definition: pml_fourier_decomposed_helmholtz_elements.cc:529
double *& alpha_pt()
Get pointer to complex shift.
Definition: pml_fourier_decomposed_helmholtz_elements.h:227
void(* PMLFourierDecomposedHelmholtzSourceFctPt)(const Vector< double > &x, std::complex< double > &f)
Definition: pml_fourier_decomposed_helmholtz_elements.h:166
void output(std::ostream &outfile)
Output with default number of plot points.
Definition: pml_fourier_decomposed_helmholtz_elements.h:260
virtual double dshape_and_dtest_eulerian_pml_fourier_decomposed_helmholtz(const Vector< double > &s, Shape &psi, DShape &dpsidx, Shape &test, DShape &dtestdx) const =0
void compute_complex_r(const unsigned &ipt, const Vector< double > &x, std::complex< double > &complex_r)
Definition: pml_fourier_decomposed_helmholtz_elements.h:570
static double Default_Physical_Constant_Value
Static default value for the physical constants (initialised to zero)
Definition: pml_fourier_decomposed_helmholtz_elements.h:664
void compute_error(std::ostream &outfile, FiniteElement::UnsteadyExactSolutionFctPt exact_soln_pt, const double &time, double &error, double &norm)
Dummy, time dependent error checker.
Definition: pml_fourier_decomposed_helmholtz_elements.h:330
double * Alpha_pt
Pointer to wavenumber complex shift.
Definition: pml_fourier_decomposed_helmholtz_elements.h:661
unsigned self_test()
Self-test: Return 0 for OK.
Definition: pml_fourier_decomposed_helmholtz_elements.cc:460
void fill_in_contribution_to_jacobian(Vector< double > &residuals, DenseMatrix< double > &jacobian)
Definition: pml_fourier_decomposed_helmholtz_elements.h:447
virtual void output_fct(std::ostream &outfile, const unsigned &n_plot, const double &time, FiniteElement::UnsteadyExactSolutionFctPt exact_soln_pt)
Definition: pml_fourier_decomposed_helmholtz_elements.h:298
PMLFourierDecomposedHelmholtzEquations(const PMLFourierDecomposedHelmholtzEquations &dummy)=delete
Broken copy constructor.
double k_squared()
Get k squared.
Definition: pml_fourier_decomposed_helmholtz_elements.h:212
virtual void get_source_pml_fourier_decomposed_helmholtz(const unsigned &ipt, const Vector< double > &x, std::complex< double > &source) const
Definition: pml_fourier_decomposed_helmholtz_elements.h:364
int * N_pml_fourier_pt
Pointer to Fourier wave number.
Definition: pml_fourier_decomposed_helmholtz_elements.h:667
PMLFourierDecomposedHelmholtzSourceFctPt Source_fct_pt
Pointer to source function:
Definition: pml_fourier_decomposed_helmholtz_elements.h:650
PMLFourierDecomposedHelmholtzSourceFctPt & source_fct_pt()
Access function: Pointer to source function.
Definition: pml_fourier_decomposed_helmholtz_elements.h:347
PMLFourierDecomposedHelmholtzSourceFctPt source_fct_pt() const
Access function: Pointer to source function. Const version.
Definition: pml_fourier_decomposed_helmholtz_elements.h:354
int *& pml_fourier_wavenumber_pt()
Get pointer to Fourier wavenumber.
Definition: pml_fourier_decomposed_helmholtz_elements.h:240
void compute_norm(double &norm)
Compute norm of fe solution.
Definition: pml_fourier_decomposed_helmholtz_elements.cc:795
void output_fct(std::ostream &outfile, const unsigned &n_plot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
Definition: pml_fourier_decomposed_helmholtz_elements.cc:609
void fill_in_contribution_to_residuals(Vector< double > &residuals)
Add the element's contribution to its residual vector (wrapper)
Definition: pml_fourier_decomposed_helmholtz_elements.h:436
void values_to_be_pinned_on_outer_pml_boundary(Vector< unsigned > &values_to_pin)
Definition: pml_fourier_decomposed_helmholtz_elements.h:384
void compute_pml_coefficients(const unsigned &ipt, const Vector< double > &x, Vector< std::complex< double >> &pml_laplace_factor, std::complex< double > &pml_k_squared_factor)
Definition: pml_fourier_decomposed_helmholtz_elements.h:502
void output(FILE *file_pt)
C_style output with default number of plot points.
Definition: pml_fourier_decomposed_helmholtz_elements.h:280
double *& k_squared_pt()
Get pointer to frequency.
Definition: pml_fourier_decomposed_helmholtz_elements.h:205
void output_real_fct(std::ostream &outfile, const double &phi, const unsigned &n_plot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
Definition: pml_fourier_decomposed_helmholtz_elements.cc:663
double alpha()
Get complex shift.
Definition: pml_fourier_decomposed_helmholtz_elements.h:234
virtual double dshape_and_dtest_eulerian_at_knot_pml_fourier_decomposed_helmholtz(const unsigned &ipt, Shape &psi, DShape &dpsidx, Shape &test, DShape &dtestdx) const =0
PMLMappingAndTransformedCoordinate *& pml_mapping_and_transformed_coordinate_pt()
Return a pointer to the PML Mapping object.
Definition: pml_fourier_decomposed_helmholtz_elements.h:605
static BermudezPMLMappingAndTransformedCoordinate Default_pml_mapping_and_transformed_coordinate
Definition: pml_fourier_decomposed_helmholtz_elements.h:620
PMLFourierDecomposedHelmholtzEquations()
Constructor.
Definition: pml_fourier_decomposed_helmholtz_elements.h:170
PMLMappingAndTransformedCoordinate * Pml_mapping_and_transformed_coordinate_pt
Definition: pml_fourier_decomposed_helmholtz_elements.h:658
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.
Definition: pml_fourier_decomposed_helmholtz_elements.h:396
virtual std::complex< unsigned > u_index_pml_fourier_decomposed_helmholtz() const
Broken assignment operator.
Definition: pml_fourier_decomposed_helmholtz_elements.h:197
PMLLayerElement()
Definition: pml_fourier_decomposed_helmholtz_elements.h:1142
Definition: pml_meshes.h:48
Definition: projection.h:183
Fourier decomposed Helmholtz upgraded to become projectable.
Definition: pml_fourier_decomposed_helmholtz_elements.h:902
unsigned nhistory_values_for_projection(const unsigned &fld)
Definition: pml_fourier_decomposed_helmholtz_elements.h:948
int local_equation(const unsigned &fld, const unsigned &j)
Return local equation number of value j in field fld.
Definition: pml_fourier_decomposed_helmholtz_elements.h:1064
double get_field(const unsigned &t, const unsigned &fld, const Vector< double > &s)
Definition: pml_fourier_decomposed_helmholtz_elements.h:999
ProjectablePMLFourierDecomposedHelmholtzElement()
Definition: pml_fourier_decomposed_helmholtz_elements.h:906
unsigned nfields_for_projection()
Number of fields to be projected: 2 (real and imag part)
Definition: pml_fourier_decomposed_helmholtz_elements.h:941
unsigned nhistory_values_for_coordinate_projection()
Definition: pml_fourier_decomposed_helmholtz_elements.h:965
double jacobian_and_shape_of_field(const unsigned &fld, const Vector< double > &s, Shape &psi)
Definition: pml_fourier_decomposed_helmholtz_elements.h:972
Vector< std::pair< Data *, unsigned > > data_values_of_field(const unsigned &fld)
Definition: pml_fourier_decomposed_helmholtz_elements.h:911
void output(std::ostream &outfile, const unsigned &nplot)
Definition: pml_fourier_decomposed_helmholtz_elements.h:1093
unsigned nvalue_of_field(const unsigned &fld)
Return number of values in field fld: One per node.
Definition: pml_fourier_decomposed_helmholtz_elements.h:1047
Definition: Qelements.h:459
Definition: pml_fourier_decomposed_helmholtz_elements.h:685
double dshape_and_dtest_eulerian_pml_fourier_decomposed_helmholtz(const Vector< double > &s, Shape &psi, DShape &dpsidx, Shape &test, DShape &dtestdx) const
Definition: pml_fourier_decomposed_helmholtz_elements.h:823
void output(std::ostream &outfile, const unsigned &n_plot)
Definition: pml_fourier_decomposed_helmholtz_elements.h:723
void output_fct(std::ostream &outfile, const unsigned &n_plot, const double &time, FiniteElement::UnsteadyExactSolutionFctPt exact_soln_pt)
Definition: pml_fourier_decomposed_helmholtz_elements.h:781
static const unsigned Initial_Nvalue
Definition: pml_fourier_decomposed_helmholtz_elements.h:689
void output_fct(std::ostream &outfile, const unsigned &n_plot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
Definition: pml_fourier_decomposed_helmholtz_elements.h:755
void output_real_fct(std::ostream &outfile, const double &phi, const unsigned &n_plot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
Definition: pml_fourier_decomposed_helmholtz_elements.h:768
QPMLFourierDecomposedHelmholtzElement(const QPMLFourierDecomposedHelmholtzElement< NNODE_1D > &dummy)=delete
Broken copy constructor.
void output(FILE *file_pt)
C-style output function: r,z,u.
Definition: pml_fourier_decomposed_helmholtz_elements.h:741
unsigned required_nvalue(const unsigned &n) const
Broken assignment operator.
Definition: pml_fourier_decomposed_helmholtz_elements.h:710
double dshape_and_dtest_eulerian_at_knot_pml_fourier_decomposed_helmholtz(const unsigned &ipt, Shape &psi, DShape &dpsidx, Shape &test, DShape &dtestdx) const
Definition: pml_fourier_decomposed_helmholtz_elements.h:850
void output(FILE *file_pt, const unsigned &n_plot)
Definition: pml_fourier_decomposed_helmholtz_elements.h:748
QPMLFourierDecomposedHelmholtzElement()
Definition: pml_fourier_decomposed_helmholtz_elements.h:694
void output_real(std::ostream &outfile, const double &phi, const unsigned &n_plot)
Definition: pml_fourier_decomposed_helmholtz_elements.h:733
void output(std::ostream &outfile)
Output function: r,z,u.
Definition: pml_fourier_decomposed_helmholtz_elements.h:716
unsigned ntstorage() const
Definition: timesteppers.h:601
static int f(const TensorMap< Tensor< int, 3 > > &tensor)
Definition: cxx11_tensor_map.cpp:237
float real
Definition: datatypes.h:10
RealScalar s
Definition: level1_cplx_impl.h:130
int * m
Definition: level2_cplx_impl.h:294
char char char int int * k
Definition: level2_impl.h:374
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 log(const bfloat16 &a)
Definition: BFloat16.h:618
squared absolute sa ArrayBase::abs2 DOXCOMMA MatrixBase::cwiseAbs2 sa Eigen::abs2 DOXCOMMA Eigen::pow DOXCOMMA ArrayBase::square nearest sa Eigen::floor DOXCOMMA Eigen::ceil DOXCOMMA ArrayBase::round nearest integer not less than the given sa Eigen::floor DOXCOMMA ArrayBase::ceil not a number test
Definition: GlobalFunctions.h:109
void flux(const double &time, const Vector< double > &x, double &flux)
Get flux applied along boundary x=0.
Definition: pretend_melt.cc:59
void source(const Vector< double > &x, Vector< double > &f)
Source function.
Definition: unstructured_two_d_circle.cc:46
Real fabs(const Real &a)
Definition: boostmultiprec.cpp:117
int error
Definition: calibrate.py:297
double factorial(const unsigned &l)
Factorial.
Definition: fourier_decomposed_helmholtz_elements.cc:40
double plgndr1(const unsigned &n, const double &x)
Legendre polynomials depending on one parameter.
Definition: fourier_decomposed_helmholtz_elements.cc:50
double plgndr2(const unsigned &l, const unsigned &m, const double &x)
Legendre polynomials depending on two parameters.
Definition: fourier_decomposed_helmholtz_elements.cc:97
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
list x
Definition: plotDoE.py:28
t
Definition: plotPSD.py:36
Definition: indexed_view.cpp:20
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86
void output(std::ostream &outfile, const unsigned &nplot)
Overload output function.
Definition: overloaded_element_body.h:490
EIGEN_DONT_INLINE Scalar zero()
Definition: svd_common.h:232
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2