44 template<
class ELASTICITY_BULK_ELEMENT,
class HELMHOLTZ_BULK_ELEMENT>
87 ELASTICITY_BULK_ELEMENT* elem_pt =
88 dynamic_cast<ELASTICITY_BULK_ELEMENT*
>(element_pt);
90 if (elem_pt->dim() == 3)
99 throw OomphLibError(
"This flux element will not work correctly "
100 "if nodes are hanging\n",
117 ELASTICITY_BULK_ELEMENT* cast_element_pt =
118 dynamic_cast<ELASTICITY_BULK_ELEMENT*
>(element_pt);
121 for (
unsigned i = 0;
i < n_dim;
i++)
124 cast_element_pt->u_index_time_harmonic_linear_elasticity(
i);
152 const double&
q()
const
175 void output(std::ostream& outfile,
const unsigned& n_plot)
184 const double q_value =
q();
192 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
195 for (
unsigned i = 0;
i < n_dim - 1;
i++)
209 HELMHOLTZ_BULK_ELEMENT* ext_el_pt =
212 std::complex<double> u_helmholtz =
213 ext_el_pt->interpolated_u_helmholtz(s_ext);
216 ext_el_pt->interpolated_u_helmholtz(s_ext);
217 traction[0] = -q_value * interpolated_normal[0] * u_helmholtz;
218 traction[1] = -q_value * interpolated_normal[1] * u_helmholtz;
220 outfile << ext_el_pt->interpolated_x(s_ext, 0) <<
" "
221 << ext_el_pt->interpolated_x(s_ext, 1) <<
" "
222 << traction[0].real() <<
" " << traction[1].real() <<
" "
223 << traction[0].imag() <<
" " << traction[1].imag() <<
" "
224 << interpolated_normal[0] <<
" " << interpolated_normal[1]
225 <<
" " << u_helmholtz.real() <<
" " << u_helmholtz.imag() <<
" "
229 <<
sqrt(
pow(ext_el_pt->interpolated_x(s_ext, 0) -
232 pow(ext_el_pt->interpolated_x(s_ext, 1) -
235 <<
" " <<
zeta[0] << std::endl;
246 void output(FILE* file_pt,
const unsigned& n_plot)
261 template<
class ELASTICITY_BULK_ELEMENT,
class HELMHOLTZ_BULK_ELEMENT>
262 double TimeHarmonicLinElastLoadedByHelmholtzPressureBCElement<
263 ELASTICITY_BULK_ELEMENT,
264 HELMHOLTZ_BULK_ELEMENT>::Default_Q_Value = 1.0;
270 template<
class ELASTICITY_BULK_ELEMENT,
class HELMHOLTZ_BULK_ELEMENT>
271 void TimeHarmonicLinElastLoadedByHelmholtzPressureBCElement<
272 ELASTICITY_BULK_ELEMENT,
273 HELMHOLTZ_BULK_ELEMENT>::
274 fill_in_contribution_to_residuals_helmholtz_traction(
278 unsigned n_node = nnode();
282 unsigned n_position_type = this->nnodal_position_type();
283 if (n_position_type != 1)
285 throw OomphLibError(
"LinearElasticity is not yet implemented for more "
286 "than one position type.",
293 const unsigned n_dim = this->nodal_dimension();
296 std::vector<std::complex<unsigned>> u_nodal_index(n_dim);
297 for (
unsigned i = 0;
i < n_dim;
i++)
300 this->U_index_time_harmonic_linear_elasticity_helmholtz_traction[
i];
308 DShape dpsids(n_node, n_dim - 1);
311 const double q_value =
q();
317 unsigned n_intpt = integral_pt()->nweight();
320 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
323 double w = integral_pt()->weight(ipt);
326 dshape_local_at_knot(ipt, psi, dpsids);
335 for (
unsigned l = 0; l < n_node; l++)
338 for (
unsigned i = 0;
i < n_dim;
i++)
341 const double x_local = nodal_position(l,
i);
342 interpolated_x[
i] += x_local * psi(l);
345 for (
unsigned j = 0;
j < n_dim - 1;
j++)
347 interpolated_A(
j,
i) += x_local * dpsids(l,
j);
354 for (
unsigned i = 0;
i < n_dim - 1;
i++)
356 for (
unsigned j = 0;
j < n_dim - 1;
j++)
362 for (
unsigned k = 0;
k < n_dim;
k++)
364 A(
i,
j) += interpolated_A(
i,
k) * interpolated_A(
j,
k);
371 outer_unit_normal(ipt, interpolated_normal);
381 Adet =
A(0, 0) *
A(1, 1) -
A(0, 1) *
A(1, 0);
385 "Wrong dimension in TimeHarmonicLinElastLoadedByPressureElement",
386 "TimeHarmonicLinElastLoadedByPressureElement::fill_in_contribution_"
393 double W =
w *
sqrt(Adet);
396 HELMHOLTZ_BULK_ELEMENT* ext_el_pt =
397 dynamic_cast<HELMHOLTZ_BULK_ELEMENT*
>(external_element_pt(0, ipt));
401 std::complex<double> u_helmholtz =
402 ext_el_pt->interpolated_u_helmholtz(s_ext);
403 traction[0] = -q_value * interpolated_normal[0] * u_helmholtz;
404 traction[1] = -q_value * interpolated_normal[1] * u_helmholtz;
407 for (
unsigned l = 0; l < n_node; l++)
410 for (
unsigned i = 0;
i < n_dim;
i++)
412 local_eqn = this->nodal_local_eqn(l, u_nodal_index[
i].
real());
417 residuals[local_eqn] -= traction[
i].real() * psi(l) *
W;
420 local_eqn = this->nodal_local_eqn(l, u_nodal_index[
i].
imag());
425 residuals[local_eqn] -= traction[
i].imag() * psi(l) *
W;
448 template<
class HELMHOLTZ_BULK_ELEMENT,
class ELASTICITY_BULK_ELEMENT>
491 residuals, jacobian, 1);
506 void output(std::ostream& outfile,
const unsigned& n_plot)
517 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
520 for (
unsigned i = 0;
i < (
Dim - 1);
i++)
533 ELASTICITY_BULK_ELEMENT* ext_el_pt =
537 ext_el_pt->interpolated_u_time_harmonic_linear_elasticity(s_ext, displ);
542 std::complex<double>
flux = (displ[0] * interpolated_normal[0] +
543 displ[1] * interpolated_normal[1]);
546 outfile << ext_el_pt->interpolated_x(s_ext, 0) <<
" "
547 << ext_el_pt->interpolated_x(s_ext, 1) <<
" "
548 <<
flux.real() * interpolated_normal[0] <<
" "
549 <<
flux.real() * interpolated_normal[1] <<
" "
550 <<
flux.imag() * interpolated_normal[0] <<
" "
551 <<
flux.imag() * interpolated_normal[1] <<
" "
552 << interpolated_normal[0] <<
" " << interpolated_normal[1]
553 <<
" " <<
flux.real() <<
" " <<
flux.imag() <<
" "
556 <<
sqrt(
pow(ext_el_pt->interpolated_x(s_ext, 0) -
559 pow(ext_el_pt->interpolated_x(s_ext, 1) -
562 <<
" " <<
zeta[0] << std::endl;
574 void output(FILE* file_pt,
const unsigned& n_plot)
589 unsigned n_node =
nnode();
595 for (
unsigned i = 0;
i < n_node;
i++)
613 unsigned n_node =
nnode();
619 for (
unsigned i = 0;
i < n_node;
i++)
636 const unsigned& flag);
655 template<
class HELMHOLTZ_BULK_ELEMENT,
class ELASTICITY_BULK_ELEMENT>
657 ELASTICITY_BULK_ELEMENT>::
658 HelmholtzFluxFromNormalDisplacementBCElement(
670 HELMHOLTZ_BULK_ELEMENT* elem_pt =
671 dynamic_cast<HELMHOLTZ_BULK_ELEMENT*
>(bulk_el_pt);
673 if (elem_pt->dim() == 3)
682 throw OomphLibError(
"This flux element will not work correctly if "
683 "nodes are hanging\n",
722 "Bulk element must inherit from HelmholtzEquations.";
724 "Nodes are one dimensional, but cannot cast the bulk element to\n";
725 error_string +=
"HelmholtzEquations<1>\n.";
726 error_string +=
"If you desire this functionality, you must "
727 "implement it yourself\n";
750 "Bulk element must inherit from HelmholtzEquations.";
752 "Nodes are two dimensional, but cannot cast the bulk element to\n";
753 error_string +=
"HelmholtzEquations<2>\n.";
754 error_string +=
"If you desire this functionality, you must "
755 "implement it yourself\n";
777 "Bulk element must inherit from HelmholtzEquations.";
778 error_string +=
"Nodes are three dimensional, but cannot cast the "
780 error_string +=
"HelmholtzEquations<3>\n.";
781 error_string +=
"If you desire this functionality, you must "
782 "implement it yourself\n";
797 std::ostringstream error_stream;
798 error_stream <<
"Dimension of node is " <<
Dim
799 <<
". It should be 1,2, or 3!" << std::endl;
812 template<
class HELMHOLTZ_BULK_ELEMENT,
class ELASTICITY_BULK_ELEMENT>
814 ELASTICITY_BULK_ELEMENT>::
815 fill_in_generic_residual_contribution_helmholtz_flux_from_displacement(
818 const unsigned& flag)
821 const unsigned n_node = nnode();
824 Shape psif(n_node), testf(n_node);
827 const unsigned n_intpt = integral_pt()->nweight();
836 const std::complex<unsigned> u_index_helmholtz =
837 U_index_helmholtz_from_displacement;
841 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
844 for (
unsigned i = 0;
i < (
Dim - 1);
i++)
846 s[
i] = integral_pt()->knot(ipt,
i);
850 double w = integral_pt()->weight(ipt);
854 double J = shape_and_test(
s, psif, testf);
863 for (
unsigned l = 0; l < n_node; l++)
866 for (
unsigned i = 0;
i <
Dim;
i++)
868 interpolated_x[
i] += nodal_position(l,
i) * psif[l];
874 outer_unit_normal(ipt, interpolated_normal);
877 ELASTICITY_BULK_ELEMENT* ext_el_pt =
878 dynamic_cast<ELASTICITY_BULK_ELEMENT*
>(external_element_pt(0, ipt));
881 ext_el_pt->interpolated_u_time_harmonic_linear_elasticity(s_ext, displ);
886 std::complex<double>
flux =
887 (displ[0] * interpolated_normal[0] + displ[1] * interpolated_normal[1]);
892 for (
unsigned l = 0; l < n_node; l++)
894 local_eqn = nodal_local_eqn(l, u_index_helmholtz.real());
899 residuals[local_eqn] -=
flux.real() * testf[l] *
W;
906 local_eqn = nodal_local_eqn(l, u_index_helmholtz.imag());
911 residuals[local_eqn] -=
flux.imag() * testf[l] *
W;
AnnoyingScalar imag(const AnnoyingScalar &)
Definition: AnnoyingScalar.h:132
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
int i
Definition: BiCGSTAB_step_by_step.cpp:9
JacobiRotation< float > J
Definition: Jacobi_makeJacobi.cpp:3
RowVector3d w
Definition: Matrix_resize_int.cpp:3
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:47
Definition: element_with_external_element.h:56
Vector< double > & external_element_local_coord(const unsigned &interaction_index, const unsigned &ipt)
Definition: element_with_external_element.h:136
void set_ninteraction(const unsigned &n_interaction)
Definition: element_with_external_element.h:178
FiniteElement *& external_element_pt(const unsigned &interaction_index, const unsigned &ipt)
Definition: element_with_external_element.h:107
void fill_in_jacobian_from_external_interaction_by_fd(Vector< double > &residuals, DenseMatrix< double > &jacobian)
Definition: element_with_external_element.h:345
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 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
void interpolated_zeta(const Vector< double > &s, Vector< double > &zeta) const
Definition: elements.cc:4675
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
Definition: elements.h:2175
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
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
unsigned nodal_dimension() const
Return the required Eulerian dimension of the nodes in this element.
Definition: elements.h:2484
virtual void shape_at_knot(const unsigned &ipt, Shape &psi) const
Definition: elements.cc:3220
bool has_hanging_nodes() const
Definition: elements.h:2470
static DenseMatrix< double > Dummy_matrix
Definition: elements.h:227
Definition: helmholtz_elements.h:56
virtual std::complex< unsigned > u_index_helmholtz() const
Broken assignment operator.
Definition: helmholtz_elements.h:80
Definition: helmholtz_time_harmonic_linear_elasticity_interaction.h:453
void output(FILE *file_pt, const unsigned &n_plot)
C-style output function.
Definition: helmholtz_time_harmonic_linear_elasticity_interaction.h:574
void fill_in_contribution_to_jacobian(Vector< double > &residuals, DenseMatrix< double > &jacobian)
Definition: helmholtz_time_harmonic_linear_elasticity_interaction.h:486
void fill_in_generic_residual_contribution_helmholtz_flux_from_displacement(Vector< double > &residuals, DenseMatrix< double > &jacobian, const unsigned &flag)
Definition: helmholtz_time_harmonic_linear_elasticity_interaction.h:815
unsigned Dim
The spatial dimension of the problem.
Definition: helmholtz_time_harmonic_linear_elasticity_interaction.h:639
void output(std::ostream &outfile)
Output function.
Definition: helmholtz_time_harmonic_linear_elasticity_interaction.h:498
std::complex< unsigned > U_index_helmholtz_from_displacement
The index at which the unknown is stored at the nodes.
Definition: helmholtz_time_harmonic_linear_elasticity_interaction.h:642
double shape_and_test(const Vector< double > &s, Shape &psi, Shape &test) const
Definition: helmholtz_time_harmonic_linear_elasticity_interaction.h:584
void fill_in_contribution_to_residuals(Vector< double > &residuals)
Broken assignment operator.
Definition: helmholtz_time_harmonic_linear_elasticity_interaction.h:475
double shape_and_test_at_knot(const unsigned &ipt, Shape &psi, Shape &test) const
Definition: helmholtz_time_harmonic_linear_elasticity_interaction.h:608
HelmholtzFluxFromNormalDisplacementBCElement(FiniteElement *const &bulk_el_pt, const int &face_index)
Definition: helmholtz_time_harmonic_linear_elasticity_interaction.h:658
HelmholtzFluxFromNormalDisplacementBCElement(const HelmholtzFluxFromNormalDisplacementBCElement &dummy)=delete
Broken copy constructor.
void output(FILE *file_pt)
C-style output function.
Definition: helmholtz_time_harmonic_linear_elasticity_interaction.h:568
void output(std::ostream &outfile, const unsigned &n_plot)
Output function: flux etc at Gauss points; n_plot is ignored.
Definition: helmholtz_time_harmonic_linear_elasticity_interaction.h:506
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.
unsigned ndim() const
Return (Eulerian) spatial dimension of the node.
Definition: nodes.h:1054
Definition: oomph_definitions.h:222
Definition: refineable_elements.h:97
Definition: helmholtz_time_harmonic_linear_elasticity_interaction.h:49
void fill_in_contribution_to_residuals(Vector< double > &residuals)
Return the residuals.
Definition: helmholtz_time_harmonic_linear_elasticity_interaction.h:130
void fill_in_contribution_to_jacobian(Vector< double > &residuals, DenseMatrix< double > &jacobian)
Fill in contribution from Jacobian.
Definition: helmholtz_time_harmonic_linear_elasticity_interaction.h:137
void output(std::ostream &outfile)
Output function.
Definition: helmholtz_time_harmonic_linear_elasticity_interaction.h:166
void output(std::ostream &outfile, const unsigned &n_plot)
Definition: helmholtz_time_harmonic_linear_elasticity_interaction.h:175
void fill_in_contribution_to_residuals_helmholtz_traction(Vector< double > &residuals)
Helper function that actually calculates the residuals.
Definition: helmholtz_time_harmonic_linear_elasticity_interaction.h:274
Vector< std::complex< unsigned > > U_index_time_harmonic_linear_elasticity_helmholtz_traction
Index at which the i-th displacement component is stored.
Definition: helmholtz_time_harmonic_linear_elasticity_interaction.h:62
void output(FILE *file_pt)
C_style output function.
Definition: helmholtz_time_harmonic_linear_elasticity_interaction.h:240
static double Default_Q_Value
Definition: helmholtz_time_harmonic_linear_elasticity_interaction.h:58
double *& q_pt()
Definition: helmholtz_time_harmonic_linear_elasticity_interaction.h:159
void output(FILE *file_pt, const unsigned &n_plot)
C-style output function.
Definition: helmholtz_time_harmonic_linear_elasticity_interaction.h:246
double * Q_pt
Definition: helmholtz_time_harmonic_linear_elasticity_interaction.h:54
TimeHarmonicLinElastLoadedByHelmholtzPressureBCElement(FiniteElement *const &element_pt, const int &face_index)
Definition: helmholtz_time_harmonic_linear_elasticity_interaction.h:74
const double & q() const
Definition: helmholtz_time_harmonic_linear_elasticity_interaction.h:152
Definition: oomph-lib/src/generic/Vector.h:58
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
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 pow(const bfloat16 &a, const bfloat16 &b)
Definition: BFloat16.h:625
EIGEN_DEVICE_FUNC const Scalar & q
Definition: SpecialFunctionsImpl.h:2019
EIGEN_STRONG_INLINE const Eigen::CwiseBinaryOp< Eigen::internal::scalar_zeta_op< typename DerivedX::Scalar >, const DerivedX, const DerivedQ > zeta(const Eigen::ArrayBase< DerivedX > &x, const Eigen::ArrayBase< DerivedQ > &q)
Definition: SpecialFunctionsArrayAPI.h:152
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
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
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2