41 template <
unsigned DIM>
52 template<
unsigned DIM>
58 if ((strain.ncol()!=DIM)||(strain.nrow()!=DIM))
60 std::ostringstream error_message;
61 error_message <<
"Strain matrix is " << strain.ncol() <<
" x " 62 << strain.nrow() <<
", but dimension of the equations is " 65 OOMPH_CURRENT_FUNCTION,
66 OOMPH_EXCEPTION_LOCATION);
70 unsigned n_position_type = this->nnodal_position_type();
72 if(n_position_type != 1)
75 "TimeHarmonicLinearElasticity is not yet implemented for more than one position type",
76 OOMPH_CURRENT_FUNCTION,
77 OOMPH_EXCEPTION_LOCATION);
83 unsigned n_node = nnode();
86 std::complex<unsigned> u_nodal_index[DIM];
87 for(
unsigned i=0;
i<DIM;
i++)
89 u_nodal_index[
i] = u_index_time_harmonic_linear_elasticity(
i);
97 (void) dshape_eulerian(s,psi,dpsidx);
101 interpolated_dudx(DIM,DIM,std::complex<double>(0.0,0.0));
104 for(
unsigned l=0;l<n_node;l++)
107 for(
unsigned i=0;
i<DIM;
i++)
110 const std::complex<double> u_value=
111 std::complex<double>(this->nodal_value(l,u_nodal_index[
i].real()),
112 this->nodal_value(l,u_nodal_index[
i].imag()));
115 for(
unsigned j=0;j<DIM;j++)
117 interpolated_dudx(
i,j) += u_value*dpsidx(l,j);
123 for(
unsigned i=0;
i<DIM;
i++)
128 for(
int j=(DIM-1);j>=
static_cast<int>(
i);j--)
131 if(static_cast<int>(
i)!=j)
134 0.5*(interpolated_dudx(
i,j) + interpolated_dudx(j,
i));
139 strain(
i,
i) = interpolated_dudx(
i,
i);
143 for(
int j=(
i-1);j>=0;j--)
145 strain(
i,j) = strain(j,
i);
158 template<
unsigned DIM>
164 if ((stress.ncol()!=DIM)||(stress.nrow()!=DIM))
166 std::ostringstream error_message;
167 error_message <<
"Stress matrix is " << stress.ncol() <<
" x " 168 << stress.nrow() <<
", but dimension of the equations is " 171 OOMPH_CURRENT_FUNCTION,
172 OOMPH_EXCEPTION_LOCATION);
178 this->get_strain(s,strain);
183 for(
unsigned i=0;
i<DIM;
i++)
185 for(
unsigned j=0;j<DIM;j++)
188 for (
unsigned k=0;k<DIM;k++)
190 for (
unsigned l=0;l<DIM;l++)
192 stress(
i,j)+=this->
E(
i,j,k,l)*strain(k,l);
204 template <
unsigned DIM>
210 unsigned n_node = this->nnode();
214 unsigned n_position_type = this->nnodal_position_type();
216 if(n_position_type != 1)
219 "TimeHarmonicLinearElasticity is not yet implemented for more than one position type",
220 OOMPH_CURRENT_FUNCTION,
221 OOMPH_EXCEPTION_LOCATION);
225 if(this->Elasticity_tensor_pt==0)
228 "No elasticity tensor set.",
229 OOMPH_CURRENT_FUNCTION,
230 OOMPH_EXCEPTION_LOCATION);
235 std::complex<unsigned> u_nodal_index[DIM];
236 for(
unsigned i=0;
i<DIM;
i++)
238 u_nodal_index[
i] = this->u_index_time_harmonic_linear_elasticity(
i);
243 const double omega_sq_local = this->omega_sq();
247 DShape dpsidx(n_node,DIM);
250 unsigned n_intpt = this->integral_pt()->nweight();
256 int local_eqn=0, local_unknown=0;
259 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
262 for(
unsigned i=0;
i<DIM;++
i)
264 s[
i] = this->integral_pt()->knot(ipt,
i);
268 double w = this->integral_pt()->weight(ipt);
271 double J = this->dshape_eulerian_at_knot(ipt,psi,dpsidx);
278 interpolated_u(DIM,std::complex<double>(0.0,0.0));
283 interpolated_dudx(DIM,DIM,std::complex<double>(0.0,0.0));
286 for(
unsigned l=0;l<n_node;l++)
289 for(
unsigned i=0;
i<DIM;
i++)
292 interpolated_x[
i] += this->raw_nodal_position(l,
i)*psi(l);
296 const std::complex<double> u_value
297 = std::complex<double>(
298 this->raw_nodal_value(l,u_nodal_index[
i].real()),
299 this->raw_nodal_value(l,u_nodal_index[
i].imag()));
301 interpolated_u[
i]+=u_value*psi(l);
304 for(
unsigned j=0;j<DIM;j++)
306 interpolated_dudx(
i,j) += u_value*dpsidx(l,j);
313 this->body_force(interpolated_x,b);
321 for(
unsigned l=0;l<n_node;l++)
324 for(
unsigned a=0;a<DIM;a++)
327 local_eqn = this->nodal_local_eqn(l,u_nodal_index[a].real());
333 residuals[local_eqn] +=
334 (-omega_sq_local*interpolated_u[a].real()-b[a].real())*psi(l)*
W;
337 for(
unsigned b=0;b<DIM;b++)
339 for(
unsigned c=0;c<DIM;c++)
341 for(
unsigned d=0;d<DIM;d++)
344 residuals[local_eqn] +=
345 this->
E(a,b,c,d)*interpolated_dudx(c,d).real()*dpsidx(l,b)*
W;
354 for(
unsigned l2=0;l2<n_node;l2++)
357 for(
unsigned c=0;c<DIM;c++)
359 local_unknown=this->nodal_local_eqn(l2,u_nodal_index[c].real());
361 if(local_unknown >= 0)
366 jacobian(local_eqn,local_unknown) -=
367 omega_sq_local*psi(l)*psi(l2)*
W;
371 for(
unsigned b=0;b<DIM;b++)
373 for(
unsigned d=0;d<DIM;d++)
376 jacobian(local_eqn,local_unknown) +=
377 this->
E(a,b,c,d)*dpsidx(l2,d)*dpsidx(l,b)*
W;
390 local_eqn = this->nodal_local_eqn(l,u_nodal_index[a].imag());
396 residuals[local_eqn] +=
397 (-omega_sq_local*interpolated_u[a].imag()-b[a].imag())*psi(l)*
W;
400 for(
unsigned b=0;b<DIM;b++)
402 for(
unsigned c=0;c<DIM;c++)
404 for(
unsigned d=0;d<DIM;d++)
407 residuals[local_eqn] +=
408 this->
E(a,b,c,d)*interpolated_dudx(c,d).imag()*dpsidx(l,b)*
W;
417 for(
unsigned l2=0;l2<n_node;l2++)
420 for(
unsigned c=0;c<DIM;c++)
422 local_unknown=this->nodal_local_eqn(l2,u_nodal_index[c].imag());
424 if(local_unknown >= 0)
429 jacobian(local_eqn,local_unknown) -=
430 omega_sq_local*psi(l)*psi(l2)*
W;
434 for(
unsigned b=0;b<DIM;b++)
436 for(
unsigned d=0;d<DIM;d++)
439 jacobian(local_eqn,local_unknown) +=
440 this->
E(a,b,c,d)*dpsidx(l2,d)*dpsidx(l,b)*
W;
459 template <
unsigned DIM>
461 std::ostream &outfile,
462 const unsigned &nplot,
472 outfile << this->tecplot_zone_string(nplot);
478 unsigned num_plot_points=this->nplot_points(nplot);
479 for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
483 this->get_s_plot(iplot,nplot,s);
486 this->interpolated_x(s,x);
489 (*exact_soln_pt)(x,exact_soln);
492 for(
unsigned i=0;
i<DIM;
i++)
494 outfile << x[
i] <<
" ";
496 for(
unsigned i=0;
i<2*DIM;
i++)
498 outfile << exact_soln[
i] <<
" ";
500 outfile << std::endl;
504 this->write_tecplot_zone_footer(outfile,nplot);
513 template <
unsigned DIM>
515 const unsigned &nplot)
523 outfile << this->tecplot_zone_string(nplot);
526 unsigned num_plot_points=this->nplot_points(nplot);
527 for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
531 this->get_s_plot(iplot,nplot,s);
534 this->interpolated_x(s,x);
535 this->interpolated_u_time_harmonic_linear_elasticity(s,u);
538 for(
unsigned i=0;
i<DIM;
i++)
539 {outfile << x[
i] <<
" ";}
542 for(
unsigned i=0;
i<DIM;
i++)
543 {outfile << u[
i].real() <<
" ";}
546 for(
unsigned i=0;
i<DIM;
i++)
547 {outfile << u[
i].imag() <<
" ";}
549 outfile << std::endl;
553 this->write_tecplot_zone_footer(outfile,nplot);
562 template <
unsigned DIM>
564 const unsigned &nplot)
570 fprintf(file_pt,
"%s",this->tecplot_zone_string(nplot).c_str());
573 unsigned num_plot_points=this->nplot_points(nplot);
574 for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
577 this->get_s_plot(iplot,nplot,s);
580 for(
unsigned i=0;
i<DIM;
i++)
582 fprintf(file_pt,
"%g ",this->interpolated_x(s,
i));
586 for(
unsigned i=0;
i<DIM;
i++)
588 fprintf(file_pt,
"%g ",
589 this->interpolated_u_time_harmonic_linear_elasticity(s,
i).real());
591 for(
unsigned i=0;
i<DIM;
i++)
593 fprintf(file_pt,
"%g ",
594 this->interpolated_u_time_harmonic_linear_elasticity(s,
i).imag());
597 fprintf(file_pt,
"\n");
600 this->write_tecplot_zone_footer(file_pt,nplot);
608 template <
unsigned DIM>
625 unsigned n_node = this->nnode();
630 unsigned n_intpt = this->integral_pt()->nweight();
633 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
637 for(
unsigned i=0;
i<DIM;
i++)
639 s[
i] = this->integral_pt()->knot(ipt,
i);
643 double w = this->integral_pt()->weight(ipt);
646 double J=this->J_eulerian(s);
652 this->interpolated_u_time_harmonic_linear_elasticity(s,disp);
655 for (
unsigned ii=0;ii<DIM;ii++)
657 norm+=(disp[ii].real()*disp[ii].real()+disp[ii].imag()*disp[ii].imag())*W;
static double Default_omega_sq_value
Static default value for square of frequency.
void output(std::ostream &outfile)
Output: x,y,[z],u_r,v_r,[w_r],u_i,v_i,[w_i].
void compute_norm(double &norm)
Compute norm of solution: square of the L2 norm.
void get_stress(const Vector< double > &s, DenseMatrix< std::complex< double > > &sigma) const
Return the Cauchy stress tensor, as calculated from the elasticity tensor at specified local coordina...
void(* SteadyExactSolutionFctPt)(const Vector< double > &, Vector< double > &)
Function pointer for function that computes vector-valued steady "exact solution" as ...
void get_strain(const Vector< double > &s, DenseMatrix< std::complex< double > > &strain) const
Return the strain tensor.
Class for dense matrices, storing all the values of the matrix as a pointer to a pointer with assorte...
void output_fct(std::ostream &outfile, const unsigned &nplot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
Output exact solution x,y,[z],u_r,v_r,[w_r],u_i,v_i,[w_i].
virtual void fill_in_generic_contribution_to_residuals_time_harmonic_linear_elasticity(Vector< double > &residuals, DenseMatrix< double > &jacobian, unsigned flag)
Private helper function to compute residuals and (if requested via flag) also the Jacobian matrix...