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 "LinearElasticity is not yet implemented for more than one position type",
76 OOMPH_CURRENT_FUNCTION,
77 OOMPH_EXCEPTION_LOCATION);
83 unsigned n_node = nnode();
86 unsigned u_nodal_index[DIM];
87 for(
unsigned i=0;
i<DIM;
i++) {u_nodal_index[
i] = u_index_linear_elasticity(
i);}
94 (void) dshape_eulerian(s,psi,dpsidx);
100 for(
unsigned l=0;l<n_node;l++)
103 for(
unsigned i=0;
i<DIM;
i++)
106 const double u_value = this->nodal_value(l,u_nodal_index[
i]);
109 for(
unsigned j=0;j<DIM;j++)
111 interpolated_dudx(i,j) += u_value*dpsidx(l,j);
117 for(
unsigned i=0;
i<DIM;
i++)
122 for(
int j=(DIM-1);j>=
static_cast<int>(
i);j--)
125 if(static_cast<int>(
i)!=j)
128 0.5*(interpolated_dudx(
i,j) + interpolated_dudx(j,
i));
133 strain(
i,
i) = interpolated_dudx(
i,
i);
137 for(
int j=(
i-1);j>=0;j--)
139 strain(
i,j) = strain(j,
i);
152 template<
unsigned DIM>
158 if ((stress.
ncol()!=DIM)||(stress.
nrow()!=DIM))
160 std::ostringstream error_message;
161 error_message <<
"Stress matrix is " << stress.
ncol() <<
" x " 162 << stress.
nrow() <<
", but dimension of the equations is " 165 OOMPH_CURRENT_FUNCTION,
166 OOMPH_EXCEPTION_LOCATION);
172 this->get_strain(s,strain);
177 for(
unsigned i=0;
i<DIM;
i++)
179 for(
unsigned j=0;j<DIM;j++)
182 for (
unsigned k=0;k<DIM;k++)
184 for (
unsigned l=0;l<DIM;l++)
186 stress(
i,j)+=this->
E(
i,j,k,l)*strain(k,l);
198 template <
unsigned DIM>
204 unsigned n_node = this->nnode();
208 unsigned n_position_type = this->nnodal_position_type();
210 if(n_position_type != 1)
213 "LinearElasticity is not yet implemented for more than one position type",
214 OOMPH_CURRENT_FUNCTION,
215 OOMPH_EXCEPTION_LOCATION);
219 if(this->Elasticity_tensor_pt==0)
222 "No elasticity tensor set.",
223 OOMPH_CURRENT_FUNCTION,
224 OOMPH_EXCEPTION_LOCATION);
229 unsigned u_nodal_index[DIM];
230 for(
unsigned i=0;
i<DIM;
i++)
231 {u_nodal_index[
i] = this->u_index_linear_elasticity(
i);}
234 double Lambda_sq = this->lambda_sq();
238 DShape dpsidx(n_node,DIM);
241 unsigned n_intpt = this->integral_pt()->nweight();
247 int local_eqn=0, local_unknown=0;
250 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
253 for(
unsigned i=0;
i<DIM;++
i) {s[
i] = this->integral_pt()->knot(ipt,
i);}
256 double w = this->integral_pt()->weight(ipt);
259 double J = this->dshape_eulerian_at_knot(ipt,psi,dpsidx);
272 for(
unsigned l=0;l<n_node;l++)
275 for(
unsigned i=0;
i<DIM;
i++)
278 interpolated_x[
i] += this->raw_nodal_position(l,
i)*psi(l);
283 accel[
i] += this->d2u_dt2_linear_elasticity(l,
i)*psi(l);
287 const double u_value = this->raw_nodal_value(l,u_nodal_index[
i]);
290 for(
unsigned j=0;j<DIM;j++)
292 interpolated_dudx(i,j) += u_value*dpsidx(l,j);
299 this->body_force(interpolated_x,b);
307 for(
unsigned l=0;l<n_node;l++)
310 for(
unsigned a=0;a<DIM;a++)
313 local_eqn = this->nodal_local_eqn(l,u_nodal_index[a]);
318 residuals[local_eqn] +=
319 (Lambda_sq*accel[a]-b[a])*psi(l)*
W;
322 for(
unsigned b=0;b<DIM;b++)
324 for(
unsigned c=0;c<DIM;c++)
326 for(
unsigned d=0;d<DIM;d++)
329 residuals[local_eqn] +=
330 this->
E(a,b,c,d)*interpolated_dudx(c,d)*dpsidx(l,b)*
W;
339 for(
unsigned l2=0;l2<n_node;l2++)
342 for(
unsigned c=0;c<DIM;c++)
344 local_unknown = this->nodal_local_eqn(l2,u_nodal_index[c]);
346 if(local_unknown >= 0)
351 jacobian(local_eqn,local_unknown) +=
353 this->node_pt(l2)->time_stepper_pt()->weight(2,0)*
357 for(
unsigned b=0;b<DIM;b++)
359 for(
unsigned d=0;d<DIM;d++)
362 jacobian(local_eqn,local_unknown) +=
363 this->
E(a,b,c,d)*dpsidx(l2,d)*dpsidx(l,b)*
W;
386 template <
unsigned DIM>
388 const unsigned &nplot,
398 outfile << this->tecplot_zone_string(nplot);
404 unsigned num_plot_points=this->nplot_points(nplot);
405 for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
409 this->get_s_plot(iplot,nplot,s);
412 this->interpolated_x(s,x);
415 (*exact_soln_pt)(x,exact_soln);
418 for(
unsigned i=0;
i<DIM;
i++)
420 outfile << x[
i] <<
" ";
422 for(
unsigned i=0;
i<DIM;
i++)
424 outfile << exact_soln[
i] <<
" ";
426 outfile << std::endl;
430 this->write_tecplot_zone_footer(outfile,nplot);
439 template <
unsigned DIM>
441 const unsigned &nplot,
452 outfile << this->tecplot_zone_string(nplot);
458 unsigned num_plot_points=this->nplot_points(nplot);
459 for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
463 this->get_s_plot(iplot,nplot,s);
466 this->interpolated_x(s,x);
469 (*exact_soln_pt)(time,x,exact_soln);
472 for(
unsigned i=0;
i<DIM;
i++)
474 outfile << x[
i] <<
" ";
476 for(
unsigned i=0;
i<DIM;
i++)
478 outfile << exact_soln[
i] <<
" ";
480 outfile << std::endl;
484 this->write_tecplot_zone_footer(outfile,nplot);
493 template <
unsigned DIM>
495 const unsigned &nplot)
503 outfile << this->tecplot_zone_string(nplot);
506 unsigned num_plot_points=this->nplot_points(nplot);
507 for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
511 this->get_s_plot(iplot,nplot,s);
514 this->interpolated_x(s,x);
515 this->interpolated_u_linear_elasticity(s,u);
518 for(
unsigned i=0;
i<DIM;
i++)
519 {outfile << x[
i] <<
" ";}
522 for(
unsigned i=0;
i<DIM;
i++)
523 {outfile << u[
i] <<
" ";}
525 outfile << std::endl;
529 this->write_tecplot_zone_footer(outfile,nplot);
538 template <
unsigned DIM>
540 const unsigned &nplot)
546 fprintf(file_pt,
"%s",this->tecplot_zone_string(nplot).c_str());
549 unsigned num_plot_points=this->nplot_points(nplot);
550 for (
unsigned iplot=0;iplot<num_plot_points;iplot++)
553 this->get_s_plot(iplot,nplot,s);
556 for(
unsigned i=0;
i<DIM;
i++)
558 fprintf(file_pt,
"%g ",this->interpolated_x(s,
i));
562 for(
unsigned i=0;
i<DIM;
i++)
564 fprintf(file_pt,
"%g ",this->interpolated_u_linear_elasticity(s,
i));
567 fprintf(file_pt,
"\n");
570 this->write_tecplot_zone_footer(file_pt,nplot);
581 template<
unsigned DIM>
583 std::ostream &outfile,
585 double& error,
double& norm)
598 unsigned n_intpt = this->integral_pt()->nweight();
600 outfile <<
"ZONE" << std::endl;
606 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
610 for(
unsigned i=0;
i<DIM;
i++)
612 s[
i] = this->integral_pt()->knot(ipt,
i);
616 double w = this->integral_pt()->weight(ipt);
619 double J=this->J_eulerian(s);
625 this->interpolated_x(s,x);
628 (*exact_soln_pt)(x,exact_soln);
631 for(
unsigned i=0;
i<DIM;
i++)
633 norm+=exact_soln[
i]*exact_soln[
i]*
W;
634 error+=(exact_soln[
i]-this->interpolated_u_linear_elasticity(s,
i))*
635 (exact_soln[
i]-this->interpolated_u_linear_elasticity(s,
i))*W;
639 for(
unsigned i=0;
i<DIM;
i++)
641 outfile << x[
i] <<
" ";
645 for(
unsigned i=0;
i<DIM;
i++)
647 outfile << exact_soln[
i]-this->interpolated_u_linear_elasticity(s,
i)
650 outfile << std::endl;
660 template<
unsigned DIM>
662 std::ostream &outfile,
664 const double& time,
double& error,
double& norm)
677 unsigned n_intpt = this->integral_pt()->nweight();
679 outfile <<
"ZONE" << std::endl;
685 for(
unsigned ipt=0;ipt<n_intpt;ipt++)
689 for(
unsigned i=0;
i<DIM;
i++)
691 s[
i] = this->integral_pt()->knot(ipt,
i);
695 double w = this->integral_pt()->weight(ipt);
698 double J=this->J_eulerian(s);
704 this->interpolated_x(s,x);
707 (*exact_soln_pt)(time,x,exact_soln);
710 for(
unsigned i=0;
i<DIM;
i++)
712 norm+=exact_soln[
i]*exact_soln[
i]*
W;
713 error+=(exact_soln[
i]-this->interpolated_u_linear_elasticity(s,
i))*
714 (exact_soln[
i]-this->interpolated_u_linear_elasticity(s,
i))*W;
718 for(
unsigned i=0;
i<DIM;
i++)
720 outfile << x[
i] <<
" ";
724 for(
unsigned i=0;
i<DIM;
i++)
726 outfile << exact_soln[
i]-this->interpolated_u_linear_elasticity(s,
i)
729 outfile << std::endl;
unsigned long nrow() const
Return the number of rows of the matrix.
unsigned long ncol() const
Return the number of columns of the matrix.
virtual void fill_in_generic_contribution_to_residuals_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...
void get_stress(const Vector< double > &s, DenseMatrix< double > &sigma) const
Return the Cauchy stress tensor, as calculated from the elasticity tensor at specified local coordina...
void(* UnsteadyExactSolutionFctPt)(const double &, const Vector< double > &, Vector< double > &)
Function pointer for function that computes Vector-valued time-dependent function as ...
void compute_error(std::ostream &outfile, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt, double &error, double &norm)
Validate against exact solution. Solution is provided via function pointer. Plot at a given number of...
void(* SteadyExactSolutionFctPt)(const Vector< double > &, Vector< double > &)
Function pointer for function that computes vector-valued steady "exact solution" as ...
void output_fct(std::ostream &outfile, const unsigned &nplot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
Output exact solution x,y,[z],u,v,[w].
void get_strain(const Vector< double > &s, DenseMatrix< double > &strain) const
Return the strain tensor.
void output(std::ostream &outfile)
Output: x,y,[z],u,v,[w].
static double Default_lambda_sq_value
Static default value for timescale ratio (1.0 – for natural scaling)