28 #ifndef OOMPH_PML_HELMHOLTZ_FLUX_ELEMENTS_HEADER
29 #define OOMPH_PML_HELMHOLTZ_FLUX_ELEMENTS_HEADER
34 #include <oomph-lib-config.h>
38 #include "../generic/Qelements.h"
50 template<
class ELEMENT>
64 "Don't call empty constructor for PMLHelmholtzPowerElement",
88 const unsigned&
i)
const
108 std::ofstream outfile;
119 ELEMENT* bulk_elem_pt =
dynamic_cast<ELEMENT*
>(this->
bulk_element_pt());
122 unsigned nnode_bulk = bulk_elem_pt->nnode();
123 const unsigned n_node_local =
nnode();
126 const unsigned bulk_dim = bulk_elem_pt->dim();
127 const unsigned local_dim = this->
dim();
130 Shape psi(n_node_local);
133 Shape psi_bulk(nnode_bulk);
134 DShape dpsi_bulk_dx(nnode_bulk, bulk_dim);
147 if (outfile.is_open())
154 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
157 for (
unsigned i = 0;
i < local_dim;
i++)
179 (void)bulk_elem_pt->dshape_eulerian(s_bulk, psi_bulk, dpsi_bulk_dx);
183 std::complex<double> dphi_dn(0.0, 0.0);
185 bulk_dim, std::complex<double>(0.0, 0.0));
186 std::complex<double> interpolated_phi(0.0, 0.0);
192 for (
unsigned l = 0; l < nnode_bulk; l++)
195 const std::complex<double> phi_value(
196 bulk_elem_pt->nodal_value(l,
197 bulk_elem_pt->u_index_helmholtz().real()),
198 bulk_elem_pt->nodal_value(
199 l, bulk_elem_pt->u_index_helmholtz().imag()));
202 for (
unsigned i = 0;
i < bulk_dim;
i++)
204 interpolated_dphidx[
i] += phi_value * dpsi_bulk_dx(l,
i);
208 for (
unsigned l = 0; l < n_node_local; l++)
211 const std::complex<double> phi_value(
215 interpolated_phi += phi_value * psi(l);
219 for (
unsigned i = 0;
i < bulk_dim;
i++)
221 dphi_dn += interpolated_dphidx[
i] * unit_normal[
i];
225 double integrand = 0.5 * (interpolated_phi.real() * dphi_dn.imag() -
226 interpolated_phi.imag() * dphi_dn.real());
229 if (outfile.is_open())
232 double phi =
atan2(
x[1],
x[0]);
233 outfile <<
x[0] <<
" " <<
x[1] <<
" " << phi <<
" " << integrand
238 power += integrand *
W;
250 std::ofstream outfile;
261 ELEMENT* bulk_elem_pt =
dynamic_cast<ELEMENT*
>(this->
bulk_element_pt());
264 unsigned nnode_bulk = bulk_elem_pt->nnode();
265 const unsigned n_node_local =
nnode();
268 const unsigned bulk_dim = bulk_elem_pt->dim();
269 const unsigned local_dim = this->
dim();
272 Shape psi(n_node_local);
275 Shape psi_bulk(nnode_bulk);
276 DShape dpsi_bulk_dx(nnode_bulk, bulk_dim);
286 std::complex<double>
flux(0.0, 0.0);
289 if (outfile.is_open())
296 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
299 for (
unsigned i = 0;
i < local_dim;
i++)
321 (void)bulk_elem_pt->dshape_eulerian(s_bulk, psi_bulk, dpsi_bulk_dx);
325 std::complex<double> dphi_dn(0.0, 0.0);
327 bulk_dim, std::complex<double>(0.0, 0.0));
333 for (
unsigned l = 0; l < nnode_bulk; l++)
336 const std::complex<double> phi_value(
337 bulk_elem_pt->nodal_value(l,
338 bulk_elem_pt->u_index_helmholtz().real()),
339 bulk_elem_pt->nodal_value(
340 l, bulk_elem_pt->u_index_helmholtz().imag()));
343 for (
unsigned i = 0;
i < bulk_dim;
i++)
345 interpolated_dphidx[
i] += phi_value * dpsi_bulk_dx(l,
i);
351 for (
unsigned i = 0;
i < bulk_dim;
i++)
353 dphi_dn += interpolated_dphidx[
i] * unit_normal[
i];
357 if (outfile.is_open())
360 outfile <<
x[0] <<
" " <<
x[1] <<
" " << dphi_dn.real() <<
" "
361 << dphi_dn.imag() <<
"\n";
393 template<
class ELEMENT>
401 ELEMENT* elem_pt =
dynamic_cast<ELEMENT*
>(bulk_el_pt);
403 if (elem_pt->dim() == 3)
412 throw OomphLibError(
"This flux element will not work correctly if "
413 "nodes are hanging\n",
451 "Bulk element must inherit from PMLHelmholtzEquations.";
453 "Nodes are one dimensional, but cannot cast the bulk element to\n";
454 error_string +=
"PMLHelmholtzEquations<1>\n.";
455 error_string +=
"If you desire this functionality, you must "
456 "implement it yourself\n";
479 "Bulk element must inherit from PMLHelmholtzEquations.";
481 "Nodes are two dimensional, but cannot cast the bulk element to\n";
482 error_string +=
"PMLHelmholtzEquations<2>\n.";
483 error_string +=
"If you desire this functionality, you must "
484 "implement it yourself\n";
507 "Bulk element must inherit from PMLHelmholtzEquations.";
508 error_string +=
"Nodes are three dimensional, but cannot cast the "
510 error_string +=
"PMLHelmholtzEquations<3>\n.";
511 error_string +=
"If you desire this functionality, you must "
512 "implement it yourself\n";
527 std::ostringstream error_stream;
528 error_stream <<
"Dimension of node is " <<
Dim
529 <<
". It should be 1,2, or 3!" << std::endl;
549 template<
class ELEMENT>
558 std::complex<double>&
flux);
569 "Don't call empty constructor for PMLHelmholtzFluxElement",
605 residuals, jacobian, 1);
616 const unsigned&
i)
const
631 void output(std::ostream& outfile,
const unsigned& n_plot)
647 void output(FILE* file_pt,
const unsigned& n_plot)
676 std::list<std::pair<unsigned long, unsigned>>& dof_lookup_list)
const
679 std::pair<unsigned, unsigned> dof_lookup;
682 unsigned n_node = this->
nnode();
685 for (
unsigned n = 0;
n < n_node;
n++)
692 if (local_eqn_number >= 0)
696 dof_lookup.first = this->
eqn_number(local_eqn_number);
697 dof_lookup.second = 0;
700 dof_lookup_list.push_front(dof_lookup);
708 if (local_eqn_number >= 0)
712 dof_lookup.first = this->
eqn_number(local_eqn_number);
713 dof_lookup.second = 1;
716 dof_lookup_list.push_front(dof_lookup);
730 unsigned n_node =
nnode();
736 for (
unsigned i = 0;
i < n_node;
i++)
754 unsigned n_node =
nnode();
760 for (
unsigned i = 0;
i < n_node;
i++)
777 flux = std::complex<double>(0.0, 0.0);
782 (*Flux_fct_pt)(
x,
flux);
798 const unsigned& flag);
820 template<
class ELEMENT>
828 ELEMENT* elem_pt =
dynamic_cast<ELEMENT*
>(bulk_el_pt);
830 if (elem_pt->dim() == 3)
839 throw OomphLibError(
"This flux element will not work correctly if "
840 "nodes are hanging\n",
881 "Bulk element must inherit from PMLHelmholtzEquations.";
883 "Nodes are one dimensional, but cannot cast the bulk element to\n";
884 error_string +=
"PMLHelmholtzEquations<1>\n.";
885 error_string +=
"If you desire this functionality, you must "
886 "implement it yourself\n";
909 "Bulk element must inherit from PMLHelmholtzEquations.";
911 "Nodes are two dimensional, but cannot cast the bulk element to\n";
912 error_string +=
"PMLHelmholtzEquations<2>\n.";
913 error_string +=
"If you desire this functionality, you must "
914 "implement it yourself\n";
937 "Bulk element must inherit from PMLHelmholtzEquations.";
938 error_string +=
"Nodes are three dimensional, but cannot cast the "
940 error_string +=
"PMLHelmholtzEquations<3>\n.";
941 error_string +=
"If you desire this functionality, you must "
942 "implement it yourself\n";
957 std::ostringstream error_stream;
958 error_stream <<
"Dimension of node is " <<
Dim
959 <<
". It should be 1,2, or 3!" << std::endl;
971 template<
class ELEMENT>
976 const unsigned& flag)
979 const unsigned n_node = nnode();
982 Shape psif(n_node), testf(n_node);
985 const unsigned n_intpt = integral_pt()->nweight();
991 int local_eqn_real = 0, local_eqn_imag = 0;
995 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
998 for (
unsigned i = 0;
i < (
Dim - 1);
i++)
1000 s[
i] = integral_pt()->knot(ipt,
i);
1004 double w = integral_pt()->weight(ipt);
1008 double J = shape_and_test(
s, psif, testf);
1017 for (
unsigned l = 0; l < n_node; l++)
1019 for (
unsigned i = 0;
i <
Dim;
i++)
1021 interpolated_x[
i] += nodal_position(l,
i) * psif[l];
1026 std::complex<double>
flux(0.0, 0.0);
1031 for (
unsigned l = 0; l < n_node; l++)
1033 local_eqn_real = nodal_local_eqn(l, U_index_helmholtz.real());
1035 if (local_eqn_real >= 0)
1038 residuals[local_eqn_real] -=
flux.real() * testf[l] *
W;
1044 local_eqn_imag = nodal_local_eqn(l, U_index_helmholtz.imag());
1046 if (local_eqn_imag >= 0)
1049 residuals[local_eqn_imag] -=
flux.imag() * testf[l] *
W;
AnnoyingScalar atan2(const AnnoyingScalar &y, const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:139
AnnoyingScalar imag(const AnnoyingScalar &)
Definition: AnnoyingScalar.h:132
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
JacobiRotation< float > J
Definition: Jacobi_makeJacobi.cpp:3
RowVector3d w
Definition: Matrix_resize_int.cpp:3
Definition: elements.h:4338
int & face_index()
Definition: elements.h:4626
void outer_unit_normal(const Vector< double > &s, Vector< double > &unit_normal) const
Compute outer unit normal at the specified local coordinate.
Definition: elements.cc:6006
double zeta_nodal(const unsigned &n, const unsigned &k, const unsigned &i) const
Definition: elements.h:4497
Vector< double > local_coordinate_in_bulk(const Vector< double > &s) const
Definition: elements.cc:6353
FiniteElement *& bulk_element_pt()
Pointer to higher-dimensional "bulk" element.
Definition: elements.h:4735
double interpolated_x(const Vector< double > &s, const unsigned &i) const
Definition: elements.h:4528
double J_eulerian(const Vector< double > &s) const
Definition: elements.cc:5242
double J_eulerian_at_knot(const unsigned &ipt) const
Definition: elements.cc:5328
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 output(std::ostream &outfile)
Definition: elements.h:3050
virtual void build_face_element(const int &face_index, FaceElement *face_element_pt)
Definition: elements.cc:5132
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
Integral *const & integral_pt() const
Return the pointer to the integration scheme (const version)
Definition: elements.h:1963
virtual void shape_at_knot(const unsigned &ipt, Shape &psi) const
Definition: elements.cc:3220
bool has_hanging_nodes() const
Definition: elements.h:2470
unsigned long eqn_number(const unsigned &ieqn_local) const
Definition: elements.h:704
int local_eqn_number(const unsigned long &ieqn_global) const
Definition: elements.h:726
static DenseMatrix< double > Dummy_matrix
Definition: elements.h:227
virtual double knot(const unsigned &i, const unsigned &j) const =0
Return local coordinate s[j] of i-th integration point.
virtual unsigned nweight() const =0
Return the number of integration points of the scheme.
virtual double weight(const unsigned &i) const =0
Return weight of i-th integration point.
unsigned ndim() const
Return (Eulerian) spatial dimension of the node.
Definition: nodes.h:1054
Definition: oomph_definitions.h:222
Definition: pml_helmholtz_elements.h:62
virtual std::complex< unsigned > u_index_helmholtz() const
Broken assignment operator.
Definition: pml_helmholtz_elements.h:91
Definition: pml_helmholtz_flux_elements.h:552
void fill_in_contribution_to_jacobian(Vector< double > &residuals, DenseMatrix< double > &jacobian)
Definition: pml_helmholtz_flux_elements.h:600
virtual std::complex< unsigned > u_index_helmholtz() const
Definition: pml_helmholtz_flux_elements.h:655
void output(FILE *file_pt, const unsigned &n_plot)
Definition: pml_helmholtz_flux_elements.h:647
std::complex< unsigned > U_index_helmholtz
Definition: pml_helmholtz_flux_elements.h:789
void output(std::ostream &outfile, const unsigned &n_plot)
Definition: pml_helmholtz_flux_elements.h:631
double shape_and_test(const Vector< double > &s, Shape &psi, Shape &test) const
Definition: pml_helmholtz_flux_elements.h:725
void get_dof_numbers_for_unknowns(std::list< std::pair< unsigned long, unsigned >> &dof_lookup_list) const
Definition: pml_helmholtz_flux_elements.h:675
PMLHelmholtzFluxElement(const PMLHelmholtzFluxElement &dummy)=delete
Broken copy constructor.
double zeta_nodal(const unsigned &n, const unsigned &k, const unsigned &i) const
Definition: pml_helmholtz_flux_elements.h:614
unsigned Dim
The spatial dimension of the problem.
Definition: pml_helmholtz_flux_elements.h:805
unsigned ndof_types() const
Definition: pml_helmholtz_flux_elements.h:664
PMLHelmholtzPrescribedFluxFctPt Flux_fct_pt
Function pointer to the (global) prescribed-flux function.
Definition: pml_helmholtz_flux_elements.h:802
PMLHelmholtzPrescribedFluxFctPt & flux_fct_pt()
Broken assignment operator.
Definition: pml_helmholtz_flux_elements.h:582
void get_flux(const Vector< double > &x, std::complex< double > &flux)
Definition: pml_helmholtz_flux_elements.h:772
virtual void fill_in_generic_residual_contribution_helmholtz_flux(Vector< double > &residuals, DenseMatrix< double > &jacobian, const unsigned &flag)
Compute the element's residual vector and the (zero) Jacobian matrix.
Definition: pml_helmholtz_flux_elements.h:973
void output(FILE *file_pt)
Definition: pml_helmholtz_flux_elements.h:639
PMLHelmholtzFluxElement()
Broken empty constructor.
Definition: pml_helmholtz_flux_elements.h:566
double shape_and_test_at_knot(const unsigned &ipt, Shape &psi, Shape &test) const
Definition: pml_helmholtz_flux_elements.h:749
void fill_in_contribution_to_residuals(Vector< double > &residuals)
Add the element's contribution to its residual vector.
Definition: pml_helmholtz_flux_elements.h:589
void(* PMLHelmholtzPrescribedFluxFctPt)(const Vector< double > &x, std::complex< double > &flux)
Definition: pml_helmholtz_flux_elements.h:557
void output(std::ostream &outfile)
Definition: pml_helmholtz_flux_elements.h:624
Definition: pml_helmholtz_flux_elements.h:53
double global_power_contribution(std::ofstream &outfile)
Definition: pml_helmholtz_flux_elements.h:116
std::complex< unsigned > U_index_helmholtz
Definition: pml_helmholtz_flux_elements.h:375
std::complex< double > global_flux_contribution()
Definition: pml_helmholtz_flux_elements.h:247
double zeta_nodal(const unsigned &n, const unsigned &k, const unsigned &i) const
Broken assignment operator.
Definition: pml_helmholtz_flux_elements.h:86
double global_power_contribution()
Definition: pml_helmholtz_flux_elements.h:105
unsigned Dim
The spatial dimension of the problem.
Definition: pml_helmholtz_flux_elements.h:378
PMLHelmholtzPowerElement()
Broken empty constructor.
Definition: pml_helmholtz_flux_elements.h:61
PMLHelmholtzPowerElement(const PMLHelmholtzPowerElement &dummy)=delete
Broken copy constructor.
std::complex< double > global_flux_contribution(std::ofstream &outfile)
Definition: pml_helmholtz_flux_elements.h:258
virtual std::complex< unsigned > u_index_helmholtz() const
Definition: pml_helmholtz_flux_elements.h:96
Definition: refineable_elements.h:97
float real
Definition: datatypes.h:10
RealScalar s
Definition: level1_cplx_impl.h:130
char char char int int * k
Definition: level2_impl.h:374
static const unsigned Dim
Problem dimension.
Definition: two_d_tilted_square.cc:62
void flux(const double &time, const Vector< double > &x, double &flux)
Get flux applied along boundary x=0.
Definition: pretend_melt.cc:59
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
@ W
Definition: quadtree.h:63
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
void get_flux(const Vector< double > &s, Vector< double > &flux) const
Get flux: .
Definition: gen_axisym_advection_diffusion_elements.h:424
list x
Definition: plotDoE.py:28
Definition: indexed_view.cpp:20
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86