35 template<
unsigned DIM>
46 template<
unsigned DIM>
51 if ((strain.
ncol() != DIM) || (strain.
nrow() != DIM))
53 std::ostringstream error_message;
54 error_message <<
"Strain matrix is " << strain.
ncol() <<
" x "
55 << strain.
nrow() <<
", but dimension of the equations is "
58 error_message.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
62 unsigned n_position_type = this->nnodal_position_type();
64 if (n_position_type != 1)
66 throw OomphLibError(
"LinearElasticity is not yet implemented for more "
67 "than one position type",
68 OOMPH_CURRENT_FUNCTION,
69 OOMPH_EXCEPTION_LOCATION);
75 unsigned n_node = nnode();
78 unsigned u_nodal_index[DIM];
79 for (
unsigned i = 0;
i < DIM;
i++)
81 u_nodal_index[
i] = u_index_linear_elasticity(
i);
86 DShape dpsidx(n_node, DIM);
89 (void)dshape_eulerian(
s, psi, dpsidx);
95 for (
unsigned l = 0; l < n_node; l++)
98 for (
unsigned i = 0;
i < DIM;
i++)
101 const double u_value = this->nodal_value(l, u_nodal_index[
i]);
104 for (
unsigned j = 0; j < DIM; j++)
106 interpolated_dudx(
i, j) += u_value * dpsidx(l, j);
112 for (
unsigned i = 0;
i < DIM;
i++)
117 for (
int j = (DIM - 1); j >=
static_cast<int>(
i); j--)
120 if (
static_cast<int>(
i) != j)
123 0.5 * (interpolated_dudx(
i, j) + interpolated_dudx(j,
i));
128 strain(
i,
i) = interpolated_dudx(
i,
i);
132 for (
int j = (
i - 1); j >= 0; j--)
134 strain(
i, j) = strain(j,
i);
144 template<
unsigned DIM>
149 if ((stress.
ncol() != DIM) || (stress.
nrow() != DIM))
151 std::ostringstream error_message;
152 error_message <<
"Stress matrix is " << stress.
ncol() <<
" x "
153 << stress.
nrow() <<
", but dimension of the equations is "
156 error_message.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
162 this->get_strain(
s, strain);
167 for (
unsigned i = 0;
i < DIM;
i++)
169 for (
unsigned j = 0; j < DIM; j++)
172 for (
unsigned k = 0; k < DIM; k++)
174 for (
unsigned l = 0; l < DIM; l++)
176 stress(
i, j) += this->
E(
i, j, k, l) * strain(k, l);
188 template<
unsigned DIM>
194 unsigned n_node = this->nnode();
198 unsigned n_position_type = this->nnodal_position_type();
200 if (n_position_type != 1)
202 throw OomphLibError(
"LinearElasticity is not yet implemented for more "
203 "than one position type",
204 OOMPH_CURRENT_FUNCTION,
205 OOMPH_EXCEPTION_LOCATION);
209 if (this->Elasticity_tensor_pt == 0)
212 OOMPH_CURRENT_FUNCTION,
213 OOMPH_EXCEPTION_LOCATION);
218 unsigned u_nodal_index[DIM];
219 for (
unsigned i = 0;
i < DIM;
i++)
221 u_nodal_index[
i] = this->u_index_linear_elasticity(
i);
225 double Lambda_sq = this->lambda_sq();
229 DShape dpsidx(n_node, DIM);
232 unsigned n_intpt = this->integral_pt()->nweight();
238 int local_eqn = 0, local_unknown = 0;
241 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
244 for (
unsigned i = 0;
i < DIM; ++
i)
246 s[
i] = this->integral_pt()->knot(ipt,
i);
250 double w = this->integral_pt()->weight(ipt);
253 double J = this->dshape_eulerian_at_knot(ipt, psi, dpsidx);
266 for (
unsigned l = 0; l < n_node; l++)
269 for (
unsigned i = 0;
i < DIM;
i++)
272 interpolated_x[
i] += this->raw_nodal_position(l,
i) * psi(l);
277 accel[
i] += this->d2u_dt2_linear_elasticity(l,
i) * psi(l);
281 const double u_value = this->raw_nodal_value(l, u_nodal_index[
i]);
284 for (
unsigned j = 0; j < DIM; j++)
286 interpolated_dudx(
i, j) += u_value * dpsidx(l, j);
293 this->body_force(interpolated_x, b);
301 for (
unsigned l = 0; l < n_node; l++)
304 for (
unsigned a = 0; a < DIM; a++)
307 local_eqn = this->nodal_local_eqn(l, u_nodal_index[a]);
312 residuals[local_eqn] += (Lambda_sq * accel[a] - b[a]) * psi(l) *
W;
315 for (
unsigned b = 0; b < DIM; b++)
317 for (
unsigned c = 0; c < DIM; c++)
319 for (
unsigned d = 0; d < DIM; d++)
322 residuals[local_eqn] += this->
E(a, b, c, d) *
323 interpolated_dudx(c, d) *
333 for (
unsigned l2 = 0; l2 < n_node; l2++)
336 for (
unsigned c = 0; c < DIM; c++)
338 local_unknown = this->nodal_local_eqn(l2, u_nodal_index[c]);
340 if (local_unknown >= 0)
345 jacobian(local_eqn, local_unknown) +=
347 this->node_pt(l2)->time_stepper_pt()->weight(2, 0) *
348 psi(l) * psi(l2) *
W;
351 for (
unsigned b = 0; b < DIM; b++)
353 for (
unsigned d = 0; d < DIM; d++)
356 jacobian(local_eqn, local_unknown) +=
357 this->
E(a, b, c, d) * dpsidx(l2, d) * dpsidx(l, b) *
376 template<
unsigned DIM>
378 std::ostream& outfile,
379 const unsigned& nplot,
389 outfile << this->tecplot_zone_string(nplot);
395 unsigned num_plot_points = this->nplot_points(nplot);
396 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
399 this->get_s_plot(iplot, nplot,
s);
402 this->interpolated_x(
s, x);
405 (*exact_soln_pt)(x, exact_soln);
408 for (
unsigned i = 0;
i < DIM;
i++)
410 outfile << x[
i] <<
" ";
412 for (
unsigned i = 0;
i < DIM;
i++)
414 outfile << exact_soln[
i] <<
" ";
416 outfile << std::endl;
420 this->write_tecplot_zone_footer(outfile, nplot);
427 template<
unsigned DIM>
429 std::ostream& outfile,
430 const unsigned& nplot,
441 outfile << this->tecplot_zone_string(nplot);
447 unsigned num_plot_points = this->nplot_points(nplot);
448 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
451 this->get_s_plot(iplot, nplot,
s);
454 this->interpolated_x(
s, x);
457 (*exact_soln_pt)(time, x, exact_soln);
460 for (
unsigned i = 0;
i < DIM;
i++)
462 outfile << x[
i] <<
" ";
464 for (
unsigned i = 0;
i < DIM;
i++)
466 outfile << exact_soln[
i] <<
" ";
468 outfile << std::endl;
472 this->write_tecplot_zone_footer(outfile, nplot);
479 template<
unsigned DIM>
481 const unsigned& nplot)
489 outfile << this->tecplot_zone_string(nplot);
492 unsigned num_plot_points = this->nplot_points(nplot);
493 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
496 this->get_s_plot(iplot, nplot,
s);
499 this->interpolated_x(
s, x);
500 this->interpolated_u_linear_elasticity(
s, u);
503 for (
unsigned i = 0;
i < DIM;
i++)
505 outfile << x[
i] <<
" ";
509 for (
unsigned i = 0;
i < DIM;
i++)
511 outfile << u[
i] <<
" ";
514 outfile << std::endl;
518 this->write_tecplot_zone_footer(outfile, nplot);
525 template<
unsigned DIM>
527 const unsigned& nplot)
533 fprintf(file_pt,
"%s", this->tecplot_zone_string(nplot).c_str());
536 unsigned num_plot_points = this->nplot_points(nplot);
537 for (
unsigned iplot = 0; iplot < num_plot_points; iplot++)
540 this->get_s_plot(iplot, nplot,
s);
543 for (
unsigned i = 0;
i < DIM;
i++)
545 fprintf(file_pt,
"%g ", this->interpolated_x(
s,
i));
549 for (
unsigned i = 0;
i < DIM;
i++)
551 fprintf(file_pt,
"%g ", this->interpolated_u_linear_elasticity(
s,
i));
554 fprintf(file_pt,
"\n");
557 this->write_tecplot_zone_footer(file_pt, nplot);
567 template<
unsigned DIM>
569 std::ostream& outfile,
584 unsigned n_intpt = this->integral_pt()->nweight();
586 outfile <<
"ZONE" << std::endl;
592 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
595 for (
unsigned i = 0;
i < DIM;
i++)
597 s[
i] = this->integral_pt()->knot(ipt,
i);
601 double w = this->integral_pt()->weight(ipt);
604 double J = this->J_eulerian(
s);
610 this->interpolated_x(
s, x);
613 (*exact_soln_pt)(x, exact_soln);
616 for (
unsigned i = 0;
i < DIM;
i++)
618 norm += exact_soln[
i] * exact_soln[
i] *
W;
620 (exact_soln[
i] - this->interpolated_u_linear_elasticity(
s,
i)) *
621 (exact_soln[
i] - this->interpolated_u_linear_elasticity(
s,
i)) *
W;
625 for (
unsigned i = 0;
i < DIM;
i++)
627 outfile << x[
i] <<
" ";
631 for (
unsigned i = 0;
i < DIM;
i++)
633 outfile << exact_soln[
i] - this->interpolated_u_linear_elasticity(
s,
i)
636 outfile << std::endl;
646 template<
unsigned DIM>
648 std::ostream& outfile,
664 unsigned n_intpt = this->integral_pt()->nweight();
666 outfile <<
"ZONE" << std::endl;
672 for (
unsigned ipt = 0; ipt < n_intpt; ipt++)
675 for (
unsigned i = 0;
i < DIM;
i++)
677 s[
i] = this->integral_pt()->knot(ipt,
i);
681 double w = this->integral_pt()->weight(ipt);
684 double J = this->J_eulerian(
s);
690 this->interpolated_x(
s, x);
693 (*exact_soln_pt)(time, x, exact_soln);
696 for (
unsigned i = 0;
i < DIM;
i++)
698 norm += exact_soln[
i] * exact_soln[
i] *
W;
700 (exact_soln[
i] - this->interpolated_u_linear_elasticity(
s,
i)) *
701 (exact_soln[
i] - this->interpolated_u_linear_elasticity(
s,
i)) *
W;
705 for (
unsigned i = 0;
i < DIM;
i++)
707 outfile << x[
i] <<
" ";
711 for (
unsigned i = 0;
i < DIM;
i++)
713 outfile << exact_soln[
i] - this->interpolated_u_linear_elasticity(
s,
i)
716 outfile << std::endl;
A Class for the derivatives of shape functions The class design is essentially the same as Shape,...
unsigned long nrow() const
Return the number of rows of the matrix.
unsigned long ncol() const
Return the number of columns of the matrix.
void(* SteadyExactSolutionFctPt)(const Vector< double > &, Vector< double > &)
Function pointer for function that computes vector-valued steady "exact solution" as .
void(* UnsteadyExactSolutionFctPt)(const double &, const Vector< double > &, Vector< double > &)
Function pointer for function that computes Vector-valued time-dependent function as .
A base class for elements that solve the equations of linear elasticity in Cartesian coordinates....
static double Default_lambda_sq_value
Static default value for timescale ratio (1.0 – for natural scaling)
void get_strain(const Vector< double > &s, DenseMatrix< double > &strain) const
Return the strain tensor.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
void output_fct(std::ostream &outfile, const unsigned &nplot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
Output exact solution x,y,[z],u,v,[w].
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 output(std::ostream &outfile)
Output: x,y,[z],u,v,[w].
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...
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.
An OomphLibError object which should be thrown when an run-time error is encountered....
///////////////////////////////////////////////////////////////////// ///////////////////////////////...
A Class for shape functions. In simple cases, the shape functions have only one index that can be tho...
//////////////////////////////////////////////////////////////////// ////////////////////////////////...