34 #include "helmholtz.h" 35 #include "time_harmonic_linear_elasticity.h" 50 template <
class ELASTICITY_BULK_ELEMENT,
class HELMHOLTZ_BULK_ELEMENT>
87 Q_pt(&Default_Q_Value)
97 ELASTICITY_BULK_ELEMENT* elem_pt =
98 dynamic_cast<ELASTICITY_BULK_ELEMENT*
>(element_pt);
100 if(elem_pt->dim()==3)
109 "This flux element will not work correctly if nodes are hanging\n",
110 OOMPH_CURRENT_FUNCTION,
111 OOMPH_EXCEPTION_LOCATION);
126 ELASTICITY_BULK_ELEMENT* cast_element_pt =
127 dynamic_cast<ELASTICITY_BULK_ELEMENT*
>(element_pt);
130 for(
unsigned i=0;
i<n_dim;
i++)
133 cast_element_pt->u_index_time_harmonic_linear_elasticity(
i);
162 const double &
q()
const {
return *
Q_pt;}
179 void output(std::ostream &outfile,
const unsigned &n_plot)
188 const double q_value=
q();
196 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
199 for (
unsigned i=0;
i<n_dim-1;
i++)
213 HELMHOLTZ_BULK_ELEMENT* ext_el_pt=
216 std::complex<double> u_helmholtz=
217 ext_el_pt->interpolated_u_helmholtz(s_ext);
220 ext_el_pt->interpolated_u_helmholtz(s_ext);
221 traction[0]=-q_value*interpolated_normal[0]*u_helmholtz;
222 traction[1]=-q_value*interpolated_normal[1]*u_helmholtz;
224 outfile << ext_el_pt->interpolated_x(s_ext,0) <<
" " 225 << ext_el_pt->interpolated_x(s_ext,1) <<
" " 226 << traction[0].real() <<
" " 227 << traction[1].real() <<
" " 228 << traction[0].imag() <<
" " 229 << traction[1].imag() <<
" " 230 << interpolated_normal[0] <<
" " 231 << interpolated_normal[1] <<
" " 232 << u_helmholtz.real() <<
" " 233 << u_helmholtz.imag() <<
" " 237 << sqrt(pow(ext_el_pt->interpolated_x(s_ext,0)-
239 pow(ext_el_pt->interpolated_x(s_ext,1)-
241 << zeta[0] << std::endl;
250 void output(FILE* file_pt,
const unsigned &n_plot)
265 template <
class ELASTICITY_BULK_ELEMENT,
class HELMHOLTZ_BULK_ELEMENT>
273 template <
class ELASTICITY_BULK_ELEMENT,
class HELMHOLTZ_BULK_ELEMENT>
275 ELASTICITY_BULK_ELEMENT, HELMHOLTZ_BULK_ELEMENT>
:: 281 unsigned n_node =
nnode();
286 if(n_position_type != 1)
289 "LinearElasticity is not yet implemented for more than one position type.",
290 OOMPH_CURRENT_FUNCTION,
291 OOMPH_EXCEPTION_LOCATION);
299 std::vector<std::complex<unsigned> > u_nodal_index(n_dim);
300 for(
unsigned i=0;
i<n_dim;
i++)
311 DShape dpsids(n_node,n_dim-1);
314 const double q_value=
q();
323 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
338 for(
unsigned l=0;l<n_node;l++)
341 for(
unsigned i=0;
i<n_dim;
i++)
345 interpolated_x[
i] += x_local*psi(l);
348 for(
unsigned j=0;j<n_dim-1;j++)
350 interpolated_A(j,
i) += x_local*dpsids(l,j);
357 for(
unsigned i=0;
i<n_dim-1;
i++)
359 for(
unsigned j=0;j<n_dim-1;j++)
365 for(
unsigned k=0;k<n_dim;k++)
367 A(
i,j) += interpolated_A(
i,k)*interpolated_A(j,k);
384 Adet = A(0,0)*A(1,1) - A(0,1)*A(1,0);
389 "Wrong dimension in TimeHarmonicLinElastLoadedByPressureElement",
390 "TimeHarmonicLinElastLoadedByPressureElement::fill_in_contribution_to_residuals()",
391 OOMPH_EXCEPTION_LOCATION);
396 double W = w*sqrt(Adet);
399 HELMHOLTZ_BULK_ELEMENT* ext_el_pt=
404 std::complex<double> u_helmholtz=ext_el_pt->interpolated_u_helmholtz(s_ext);
405 traction[0]=-q_value*interpolated_normal[0]*u_helmholtz;
406 traction[1]=-q_value*interpolated_normal[1]*u_helmholtz;
409 for(
unsigned l=0;l<n_node;l++)
412 for(
unsigned i=0;
i<n_dim;
i++)
420 residuals[local_eqn] -= traction[
i].real()*psi(l)*
W;
428 residuals[local_eqn] -= traction[
i].imag()*psi(l)*
W;
455 template <
class HELMHOLTZ_BULK_ELEMENT,
class ELASTICITY_BULK_ELEMENT>
493 fill_in_generic_residual_contribution_helmholtz_flux_from_displacement(
504 fill_in_generic_residual_contribution_helmholtz_flux_from_displacement
505 (residuals,jacobian,1);
520 void output(std::ostream &outfile,
const unsigned &n_plot)
531 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
535 for(
unsigned i=0;
i<(
Dim-1);
i++)
548 ELASTICITY_BULK_ELEMENT* ext_el_pt=
dynamic_cast<ELASTICITY_BULK_ELEMENT*
>(
552 ext_el_pt->interpolated_u_time_harmonic_linear_elasticity(s_ext,displ);
557 std::complex<double> flux=(displ[0]*interpolated_normal[0]+
558 displ[1]*interpolated_normal[1]);
561 outfile << ext_el_pt->interpolated_x(s_ext,0) <<
" " 562 << ext_el_pt->interpolated_x(s_ext,1) <<
" " 563 << flux.real()*interpolated_normal[0] <<
" " 564 << flux.real()*interpolated_normal[1] <<
" " 565 << flux.imag()*interpolated_normal[0] <<
" " 566 << flux.imag()*interpolated_normal[1] <<
" " 567 << interpolated_normal[0] <<
" " 568 << interpolated_normal[1] <<
" " 569 << flux.real() <<
" " 570 << flux.imag() <<
" " 573 << sqrt(pow(ext_el_pt->interpolated_x(s_ext,0)-
575 pow(ext_el_pt->interpolated_x(s_ext,1)-
577 << zeta[0] << std::endl;
587 void output(FILE* file_pt,
const unsigned &n_plot)
601 unsigned n_node =
nnode();
607 for(
unsigned i=0;
i<n_node;
i++) {test[
i] = psi[
i];}
622 unsigned n_node =
nnode();
628 for(
unsigned i=0;
i<n_node;
i++) {test[
i] = psi[
i];}
642 void fill_in_generic_residual_contribution_helmholtz_flux_from_displacement(
644 const unsigned& flag);
666 template <
class HELMHOLTZ_BULK_ELEMENT,
class ELASTICITY_BULK_ELEMENT>
668 <HELMHOLTZ_BULK_ELEMENT, ELASTICITY_BULK_ELEMENT>::
669 HelmholtzFluxFromNormalDisplacementBCElement(
FiniteElement*
const &bulk_el_pt,
682 HELMHOLTZ_BULK_ELEMENT* elem_pt =
683 dynamic_cast<HELMHOLTZ_BULK_ELEMENT*
>(bulk_el_pt);
685 if(elem_pt->dim()==3)
694 "This flux element will not work correctly if nodes are hanging\n",
695 OOMPH_CURRENT_FUNCTION,
696 OOMPH_EXCEPTION_LOCATION);
733 "Bulk element must inherit from HelmholtzEquations.";
735 "Nodes are one dimensional, but cannot cast the bulk element to\n";
736 error_string +=
"HelmholtzEquations<1>\n.";
738 "If you desire this functionality, you must implement it yourself\n";
742 OOMPH_CURRENT_FUNCTION,
743 OOMPH_EXCEPTION_LOCATION);
763 "Bulk element must inherit from HelmholtzEquations.";
765 "Nodes are two dimensional, but cannot cast the bulk element to\n";
766 error_string +=
"HelmholtzEquations<2>\n.";
768 "If you desire this functionality, you must implement it yourself\n";
772 OOMPH_CURRENT_FUNCTION,
773 OOMPH_EXCEPTION_LOCATION);
792 "Bulk element must inherit from HelmholtzEquations.";
794 "Nodes are three dimensional, but cannot cast the bulk element to\n";
795 error_string +=
"HelmholtzEquations<3>\n.";
797 "If you desire this functionality, you must implement it yourself\n";
801 OOMPH_CURRENT_FUNCTION,
802 OOMPH_EXCEPTION_LOCATION);
815 std::ostringstream error_stream;
817 <<
"Dimension of node is " <<
Dim 818 <<
". It should be 1,2, or 3!" << std::endl;
822 OOMPH_CURRENT_FUNCTION,
823 OOMPH_EXCEPTION_LOCATION);
833 template <
class HELMHOLTZ_BULK_ELEMENT,
class ELASTICITY_BULK_ELEMENT>
835 <HELMHOLTZ_BULK_ELEMENT,ELASTICITY_BULK_ELEMENT>
:: 838 const unsigned& flag)
841 const unsigned n_node =
nnode();
844 Shape psif(n_node), testf(n_node);
856 const std::complex<unsigned> u_index_helmholtz =
861 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
881 for(
unsigned l=0;l<n_node;l++)
884 for(
unsigned i=0;
i<
Dim;
i++)
895 ELASTICITY_BULK_ELEMENT* ext_el_pt=
dynamic_cast<ELASTICITY_BULK_ELEMENT*
>(
899 ext_el_pt->interpolated_u_time_harmonic_linear_elasticity(s_ext,displ);
904 std::complex<double> flux=(displ[0]*interpolated_normal[0]+
905 displ[1]*interpolated_normal[1]);
910 for(
unsigned l=0;l<n_node;l++)
917 residuals[local_eqn] -= flux.real()*testf[l]*
W;
929 residuals[local_eqn] -= flux.imag()*testf[l]*
W;
double J_eulerian_at_knot(const unsigned &ipt) const
Return the Jacobian of the mapping from local to global coordinates at the ipt-th integration point O...
bool has_hanging_nodes() const
Return boolean to indicate if any of the element's nodes are geometrically hanging.
void broken_copy(const std::string &class_name)
Issue error message and terminate execution.
void fill_in_contribution_to_jacobian(Vector< double > &residuals, DenseMatrix< double > &jacobian)
Add the element's contribution to its residual vector and its Jacobian matrix.
Vector< std::complex< unsigned > > U_index_time_harmonic_linear_elasticity_helmholtz_traction
Index at which the i-th displacement component is stored.
void fill_in_contribution_to_residuals(Vector< double > &residuals)
Broken assignment operator.
Vector< double > & external_element_local_coord(const unsigned &interaction_index, const unsigned &ipt)
Access function to get source element's local coords for specified interaction index at specified int...
double nodal_position(const unsigned &n, const unsigned &i) const
Return the i-th coordinate at local node n. If the node is hanging, the appropriate interpolation is ...
void fill_in_contribution_to_residuals_helmholtz_traction(Vector< double > &residuals)
Helper function that actually calculates the residuals.
void output(FILE *file_pt)
C_style output function.
void fill_in_contribution_to_residuals(Vector< double > &residuals)
Return the residuals.
int & face_index()
Index of the face (a number that uniquely identifies the face in the element)
void fill_in_jacobian_from_external_interaction_by_fd(Vector< double > &residuals, DenseMatrix< double > &jacobian)
Calculate the contributions to the jacobian from all external interaction degrees of freedom (geometr...
void outer_unit_normal(const Vector< double > &s, Vector< double > &unit_normal) const
Compute outer unit normal at the specified local coordinate.
A general Finite Element class.
TimeHarmonicLinElastLoadedByHelmholtzPressureBCElement(FiniteElement *const &element_pt, const int &face_index)
Constructor, which takes a "bulk" element and the value of the index and its limit.
double interpolated_x(const Vector< double > &s, const unsigned &i) const
Return FE interpolated coordinate x[i] at local coordinate s. Overloaded to get information from bulk...
void set_ninteraction(const unsigned &n_interaction)
Set the number of interactions in the element This function is usually called in the specific element...
virtual double weight(const unsigned &i) const =0
Return weight of i-th integration point.
void output(FILE *file_pt)
C-style output function.
std::complex< unsigned > U_index_helmholtz_from_displacement
The index at which the unknown is stored at the nodes.
unsigned Dim
Dimension of zeta tuples (set by get_dim_helper) – needed because we store the scalar coordinates in...
A class for elements that allow the imposition of an prescribed flux (determined from the normal disp...
double J_eulerian(const Vector< double > &s) const
Return the Jacobian of mapping from local to global coordinates at local position s...
unsigned nnodal_position_type() const
Return the number of coordinate types that the element requires to interpolate the geometry between t...
unsigned ndim() const
Return (Eulerian) spatial dimension of the node.
unsigned nodal_dimension() const
Return the required Eulerian dimension of the nodes in this element.
double shape_and_test_at_knot(const unsigned &ipt, Shape &psi, Shape &test) const
Function to compute the shape and test functions and to return.
double shape_and_test(const Vector< double > &s, Shape &psi, Shape &test) const
Function to compute the shape and test functions and to return the Jacobian of mapping between local ...
Integral *const & integral_pt() const
Return the pointer to the integration scheme (const version)
double * Q_pt
Pointer to the ratio, , of the stress used to non-dimensionalise the fluid stresses to the stress us...
double *& q_pt()
Return a pointer the ratio of stress scales used to non-dimensionalise the fluid and solid equations...
void interpolated_zeta(const Vector< double > &s, Vector< double > &zeta) const
Calculate the interpolated value of zeta, the intrinsic coordinate of the element when viewed as a co...
virtual void shape_at_knot(const unsigned &ipt, Shape &psi) const
Return the geometric shape function at the ipt-th integration point.
virtual double knot(const unsigned &i, const unsigned &j) const =0
Return local coordinate s[j] of i-th integration point.
void output(std::ostream &outfile, const unsigned &n_plot)
Output function: Plot traction etc at Gauss points nplot is ignored.
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
void output(std::ostream &outfile)
Output with default number of plot points.
static double Default_Q_Value
Static default value for the ratio of stress scales used in the fluid and solid equations (default is...
virtual std::complex< unsigned > u_index_helmholtz() const
Broken assignment operator.
virtual void dshape_local_at_knot(const unsigned &ipt, Shape &psi, DShape &dpsids) const
Return the geometric shape function and its derivative w.r.t. the local coordinates at the ipt-th int...
virtual unsigned nweight() const =0
Return the number of integration points of the scheme.
FiniteElement *& external_element_pt(const unsigned &interaction_index, const unsigned &ipt)
Access function to source element for specified interaction index at specified integration point...
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn't been defined.
virtual void build_face_element(const int &face_index, FaceElement *face_element_pt)
Function for building a lower dimensional FaceElement on the specified face of the FiniteElement...
HelmholtzFluxFromNormalDisplacementBCElement(const HelmholtzFluxFromNormalDisplacementBCElement &dummy)
Broken copy constructor.
const double & q() const
Return the ratio of the stress scales used to non-dimensionalise the fluid and elasticity equations...
void output(std::ostream &outfile, const unsigned &n_plot)
Output function: flux etc at Gauss points; n_plot is ignored.
void output(std::ostream &outfile)
Output function.
void fill_in_generic_residual_contribution_helmholtz_flux_from_displacement(Vector< double > &residuals, DenseMatrix< double > &jacobian, const unsigned &flag)
Add the element's contribution to its residual vector. flag=1(or 0): do (or don't) compute the contri...
unsigned nnode() const
Return the number of nodes.
void output(FILE *file_pt, const unsigned &n_plot)
C-style output function.
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...
static DenseMatrix< double > Dummy_matrix
Empty dense matrix used as a dummy argument to combined residual and jacobian functions in the case w...
void fill_in_contribution_to_jacobian(Vector< double > &residuals, DenseMatrix< double > &jacobian)
Fill in contribution from Jacobian.
unsigned Dim
The spatial dimension of the problem.
void output(FILE *file_pt, const unsigned &n_plot)
C-style output function.
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...
void output(std::ostream &outfile)
Output function.