164 * <a name=
"Includefiles"></a>
165 * <h3>Include files</h3>
166 * The
set of include files is not much of a surprise any more at
this time:
169 * #include <deal.II/base/conditional_ostream.h>
170 * #include <deal.II/base/parameter_handler.h>
171 * #include <deal.II/base/utilities.h>
172 * #include <deal.II/base/index_set.h>
173 * #include <deal.II/base/quadrature_lib.h>
174 * #include <deal.II/base/
function.h>
175 * #include <deal.II/base/logstream.h>
176 * #include <deal.II/base/timer.h>
177 * #include <deal.II/base/table_handler.h>
179 * #include <deal.II/lac/vector.h>
180 * #include <deal.II/lac/full_matrix.h>
181 * #include <deal.II/lac/sparsity_tools.h>
182 * #include <deal.II/lac/sparse_matrix.h>
183 * #include <deal.II/lac/dynamic_sparsity_pattern.h>
184 * #include <deal.II/lac/block_sparsity_pattern.h>
185 * #include <deal.II/lac/solver_bicgstab.h>
186 * #include <deal.II/lac/precondition.h>
187 * #include <deal.II/lac/affine_constraints.h>
188 * #include <deal.II/lac/trilinos_sparse_matrix.h>
189 * #include <deal.II/lac/trilinos_block_sparse_matrix.h>
190 * #include <deal.II/lac/trilinos_vector.h>
191 * #include <deal.II/lac/trilinos_precondition.h>
192 * #include <deal.II/lac/trilinos_solver.h>
193 * #include <deal.II/lac/sparse_direct.h>
195 * #include <deal.II/grid/tria.h>
196 * #include <deal.II/grid/grid_generator.h>
197 * #include <deal.II/grid/grid_refinement.h>
198 * #include <deal.II/grid/grid_tools.h>
199 * #include <deal.II/grid/tria_accessor.h>
200 * #include <deal.II/grid/tria_iterator.h>
201 * #include <deal.II/grid/tria_boundary_lib.h>
202 * #include <deal.II/grid/grid_out.h>
203 * #include <deal.II/grid/manifold_lib.h>
205 * #include <deal.II/distributed/tria.h>
206 * #include <deal.II/distributed/grid_refinement.h>
207 * #include <deal.II/distributed/solution_transfer.h>
209 * #include <deal.II/dofs/dof_handler.h>
210 * #include <deal.II/dofs/dof_accessor.h>
211 * #include <deal.II/dofs/dof_renumbering.h>
212 * #include <deal.II/dofs/dof_tools.h>
214 * #include <deal.II/fe/fe_q.h>
215 * #include <deal.II/fe/fe_system.h>
216 * #include <deal.II/fe/fe_values.h>
217 * #include <deal.II/fe/fe_dgq.h>
218 * #include <deal.II/fe/fe_tools.h>
220 * #include <deal.II/numerics/vector_tools.h>
221 * #include <deal.II/numerics/matrix_tools.h>
222 * #include <deal.II/numerics/data_out.h>
223 * #include <deal.II/numerics/error_estimator.h>
224 * #include <deal.II/numerics/fe_field_function.h>
225 * #include <deal.II/numerics/solution_transfer.h>
229 * And here the only two
new things among the header files: an include file in
230 * which
symmetric tensors of rank 2 and 4 are implemented, as introduced in
234 * #include <deal.II/base/symmetric_tensor.h>
238 * And a header that implements filters
for iterators looping over all
239 * cells. We will use
this when selecting only those cells
for output that are
240 * owned by the present process in a %
parallel program:
243 * #include <deal.II/grid/filtered_iterator.h>
246 * #include <iostream>
250 * This
final include file provides the <code>mkdir</code>
function
251 * that we will use to create a directory
for output files,
if necessary:
254 * #include <sys/stat.h>
256 *
namespace ElastoPlastic
262 *
const unsigned int n_slices,
263 *
const double height,
268 *
Assert (input.n_levels() == 1,
269 *
ExcMessage (
"The input triangulations must be coarse meshes."));
272 *
Assert(result.n_cells()==0,
ExcMessage(
"resultin Triangulation need to be empty upon calling extrude_triangulation."));
273 *
Assert(height>0,
ExcMessage(
"The height in extrude_triangulation needs to be positive."));
274 *
Assert(n_slices>=2,
ExcMessage(
"The number of slices in extrude_triangulation needs to be at least 2."));
276 * std::vector<Point<3> > points(n_slices*input.n_used_vertices());
277 * std::vector<CellData<3> > cells;
278 * cells.reserve((n_slices-1)*input.n_active_cells());
280 *
for (
unsigned int slice=0; slice<n_slices; ++slice)
282 *
for (
unsigned int i=0; i<input.n_vertices(); ++i)
285 *
if (input.get_used_vertices()[i])
287 *
const Point<2> &v = input.get_vertices()[i];
288 * points[i+slice*input.n_vertices()](0) = v(0);
289 * points[i+slice*input.n_vertices()](1) = v(1);
290 * points[i+slice*input.n_vertices()](2) = height * slice / (n_slices-1);
296 * cell = input.begin_active(); cell != input.end(); ++cell)
298 *
for (
unsigned int slice=0; slice<n_slices-1; ++slice)
301 *
for (
unsigned int v=0; v<GeometryInfo<2>::vertices_per_cell; ++v)
304 * = cell->vertex_index(v)+slice*input.n_used_vertices();
306 * = cell->vertex_index(v)+(slice+1)*input.n_used_vertices();
310 * cells.push_back(this_cell);
316 * s.
boundary_quads.reserve(input.n_active_lines()*(n_slices-1) + input.n_active_cells()*2);
318 * cell = input.begin_active(); cell != input.end(); ++cell)
321 *
for (
unsigned int f=0; f<4; ++f)
322 *
if (cell->at_boundary(f))
326 *
for (
unsigned int slice=0; slice<n_slices-1; ++slice)
328 * quad.
vertices[0] = cell->face(f)->vertex_index(0)+slice*input.n_used_vertices();
329 * quad.
vertices[1] = cell->face(f)->vertex_index(1)+slice*input.n_used_vertices();
330 * quad.
vertices[2] = cell->face(f)->vertex_index(0)+(slice+1)*input.n_used_vertices();
331 * quad.
vertices[3] = cell->face(f)->vertex_index(1)+(slice+1)*input.n_used_vertices();
338 * cell = input.begin_active(); cell != input.end(); ++cell)
342 * quad.
vertices[0] = cell->vertex_index(0);
343 * quad.
vertices[1] = cell->vertex_index(1);
344 * quad.
vertices[2] = cell->vertex_index(2);
345 * quad.
vertices[3] = cell->vertex_index(3);
349 *
for (
int i=0; i<4; ++i)
350 * quad.
vertices[i] += (n_slices-1)*input.n_used_vertices();
354 * result.create_triangulation (points,
359 *
namespace Evaluation
371 * von_Mises_stress =
std::sqrt( stress[0][0]*stress[0][0]
372 * + stress[1][1]*stress[1][1]
373 * - stress[0][0]*stress[1][1]
374 * + 3*stress[0][1]*stress[0][1]);
375 * }
else if (dim == 3)
377 * von_Mises_stress =
std::sqrt( stress[0][0]*stress[0][0]
378 * + stress[1][1]*stress[1][1]
379 * + stress[2][2]*stress[2][2]
380 * - stress[0][0]*stress[1][1]
381 * - stress[1][1]*stress[2][2]
382 * - stress[0][0]*stress[2][2]
383 * + 3*( stress[0][1]*stress[0][1]
384 * +stress[1][2]*stress[1][2]
385 * +stress[0][2]*stress[0][2]) );
390 * -----------------------------------------------
391 *
"Perforated_strip_tension"
393 *
const double von_Mises_stress =
std::sqrt( stress[0][0]*stress[0][0]
394 * + stress[1][1]*stress[1][1]
395 * - stress[0][0]*stress[1][1]
396 * + 3*stress[0][1]*stress[0][1]);
397 * -----------------------------------------------
399 * plane strain / 3
d case
405 * -----------------------------------------------
417 *
return von_Mises_stress;
422 *
class PointValuesEvaluation
425 * PointValuesEvaluation (
const Point<dim> &evaluation_point);
433 * <<
"The evaluation point " << arg1
434 * <<
" was not found among the vertices of the present grid.");
441 * PointValuesEvaluation<dim>::
442 * PointValuesEvaluation (
const Point<dim> &evaluation_point)
444 * evaluation_point (evaluation_point)
451 * PointValuesEvaluation<dim>::
456 *
const unsigned int dofs_per_vertex = dof_handler.get_fe().dofs_per_vertex;
457 *
AssertThrow (point_values.size() == dofs_per_vertex,
459 * point_values = 1e20;
463 * endc = dof_handler.end();
464 *
bool evaluation_point_found =
false;
465 *
for (; (cell!=endc) && !evaluation_point_found; ++cell)
467 *
if (cell->is_locally_owned() && !evaluation_point_found)
468 *
for (
unsigned int vertex=0;
469 * vertex<GeometryInfo<dim>::vertices_per_cell;
472 *
if (cell->vertex(vertex).distance (evaluation_point)
474 * cell->diameter() * 1
e-8)
476 *
for (
unsigned int id=0;
id!=dofs_per_vertex; ++id)
478 * point_values[id] = solution(cell->vertex_dof_index(vertex,
id));
481 * evaluation_point_found =
true;
488 * ExcEvaluationPointNotFound(evaluation_point));
497 * <a name=
"ThecodePointHistorycodeclass"></a>
498 * <h3>The <code>PointHistory</code>
class</h3>
502 * As was mentioned in the introduction, we have to store the old stress in
503 * quadrature
point so that we can compute the residual forces at
this point
504 * during the next time step. This alone would not warrant a structure with
505 * only
one member, but in more complicated applications, we would have to
506 * store more information in quadrature points as well, such as the history
507 * variables of plasticity, etc. In essence, we have to store everything
508 * that affects the present state of the material here, which in plasticity
509 * is determined by the deformation history variables.
513 * We will not give
this class any meaningful functionality beyond being
514 * able to store data, i.e. there are no constructors, destructors, or other
515 * member
functions. In such cases of `dumb
' classes, we usually opt to
516 * declare them as <code>struct</code> rather than <code>class</code>, to
517 * indicate that they are closer to C-style structures than C++-style
522 * struct PointHistory
524 * SymmetricTensor<2,dim> old_stress;
525 * SymmetricTensor<2,dim> old_strain;
533 * <a name="ThecodeConstitutiveLawcodeclasstemplate"></a>
534 * <h3>The <code>ConstitutiveLaw</code> class template</h3>
538 * This class provides an interface for a constitutive law, i.e., for the
539 * relationship between strain @f$\varepsilon(\mathbf u)@f$ and stress
540 * @f$\sigma@f$. In this example we are using an elastoplastic material behavior
541 * with linear, isotropic hardening. Such materials are characterized by
542 * Young's modulus @f$E@f$, Poisson
's ratio @f$\nu@f$, the initial yield stress
543 * @f$\sigma_0@f$ and the isotropic hardening parameter @f$\gamma@f$. For @f$\gamma =
544 * 0@f$ we obtain perfect elastoplastic behavior.
548 * As explained in the paper that describes this program, the first Newton
549 * steps are solved with a completely elastic material model to avoid having
550 * to deal with both nonlinearities (plasticity and contact) at once. To this
551 * end, this class has a function <code>set_sigma_0()</code> that we use later
552 * on to simply set @f$\sigma_0@f$ to a very large value -- essentially
553 * guaranteeing that the actual stress will not exceed it, and thereby
554 * producing an elastic material. When we are ready to use a plastic model, we
555 * set @f$\sigma_0@f$ back to its proper value, using the same function. As a
556 * result of this approach, we need to leave <code>sigma_0</code> as the only
557 * non-const member variable of this class.
561 * class ConstitutiveLaw
564 * ConstitutiveLaw (const double E,
566 * const double sigma_0,
567 * const double gamma);
570 * set_sigma_0 (double sigma_zero);
573 * get_stress_strain_tensor (const SymmetricTensor<2, dim> &strain_tensor,
574 * SymmetricTensor<4, dim> &stress_strain_tensor) const;
577 * get_grad_stress_strain_tensor (const SymmetricTensor<2, dim> &strain_tensor,
578 * const std::vector<Tensor<2, dim> > &point_hessian,
579 * Tensor<5, dim> &stress_strain_tensor_grad) const;
582 * get_linearized_stress_strain_tensors (const SymmetricTensor<2, dim> &strain_tensor,
583 * SymmetricTensor<4, dim> &stress_strain_tensor_linearized,
584 * SymmetricTensor<4, dim> &stress_strain_tensor) const;
587 * const double kappa;
590 * const double gamma;
592 * const SymmetricTensor<4, dim> stress_strain_tensor_kappa;
593 * const SymmetricTensor<4, dim> stress_strain_tensor_mu;
598 * The constructor of the ConstitutiveLaw class sets the required material
599 * parameter for our deformable body. Material parameters for elastic
600 * isotropic media can be defined in a variety of ways, such as the pair @f$E,
601 * \nu@f$ (elastic modulus and Poisson's number),
using the Lame parameters
602 * @f$\lambda,
mu@f$ or several other commonly used conventions. Here, the
603 * constructor takes a description of material parameters in the form of
604 * @f$E,\nu@f$, but since
this turns out to these are not the coefficients that
605 * appear in the equations of the plastic projector, we immediately convert
606 * them into the more suitable
set @f$\kappa,\
mu@f$ of bulk and shear moduli. In
607 * addition, the constructor takes @f$\sigma_0@f$ (the yield stress absent any
608 * plastic strain) and @f$
\gamma@f$ (the hardening parameter) as arguments. In
609 *
this constructor, we also compute the two principal components of the
610 * stress-strain relation and its linearization.
614 * ConstitutiveLaw<dim>::ConstitutiveLaw (
double E,
621 * --------------------
623 * kappa (((
E*(1+2*nu)) / (std::pow((1+nu),2))) / (3 * (1 - 2 * (nu / (1+nu))))),
624 *
mu (((
E*(1+2*nu)) / (std::pow((1+nu),2))) / (2 * (1 + (nu / (1+nu))))),
625 * --------------------
626 * 3
d and plane strain
629 * kappa (
E / (3 * (1 - 2 * nu))),
630 *
mu (
E / (2 * (1 + nu))),
633 * --------------------
638 * stress_strain_tensor_kappa (kappa
640 * unit_symmetric_tensor<dim>())),
641 * stress_strain_tensor_mu (2 *
mu
642 * * (identity_tensor<dim>()
644 * unit_symmetric_tensor<dim>()) / 3.0))
650 * ConstitutiveLaw<dim>::set_sigma_0 (
double sigma_zero)
652 * sigma_0 = sigma_zero;
659 * <a name=
"ConstitutiveLawget_stress_strain_tensor"></a>
660 * <h4>ConstitutiveLaw::get_stress_strain_tensor</h4>
664 * This is the principal component of the constitutive law. It projects the
665 * deviatoric part of the stresses in a quadrature
point back to the yield
666 * stress (i.e., the original yield stress @f$\sigma_0@f$ plus the term that
667 * describes linear isotropic hardening). We need
this function to calculate
668 * the nonlinear residual in PlasticityContactProblem::residual_nl_system. The
669 * computations follow the formulas laid out in the introduction.
673 * The
function returns whether the quadrature
point is plastic to allow
for
674 * some statistics
downstream on how many of the quadrature points are
675 * plastic and how many are elastic.
680 * ConstitutiveLaw<dim>::
685 * stress_tensor = (stress_strain_tensor_kappa + stress_strain_tensor_mu)
691 *
const double deviator_stress_tensor_norm = deviator_stress_tensor.norm();
694 *
const double von_Mises_stress = Evaluation::get_von_Mises_stress(stress_tensor);
696 * stress_strain_tensor = stress_strain_tensor_mu;
697 *
if (von_Mises_stress > sigma_0)
699 *
const double beta = sigma_0 / von_Mises_stress;
700 * stress_strain_tensor *= (
gamma + (1 -
gamma) * beta);
703 * stress_strain_tensor += stress_strain_tensor_kappa;
705 *
return (von_Mises_stress > sigma_0);
711 * ConstitutiveLaw<dim>::
717 * stress_tensor = (stress_strain_tensor_kappa + stress_strain_tensor_mu)
720 *
const double von_Mises_stress = Evaluation::get_von_Mises_stress(stress_tensor);
722 *
if (von_Mises_stress > sigma_0)
725 *
const double deviator_strain_tensor_norm = deviator_strain_tensor.
norm();
726 *
const double multiplier = -(1-
gamma)*sigma_0/(2*
mu*std::pow(deviator_strain_tensor_norm,3));
729 * multiplier_vector = 0;
731 *
for (
unsigned int i=0; i!=dim; ++i)
732 *
for (
unsigned int m=0; m!=dim; ++m)
733 *
for (
unsigned int n=0; n!=dim; ++n)
735 * multiplier_vector(i) += deviator_strain_tensor[m][n] *
736 * ( 0.5*( point_hessian[m][n][i] + point_hessian[n][m][i] )
737 * + ( m==n && dim==2 ? -1/dim*(point_hessian[0][0][i]
738 * + point_hessian[1][1][i]) : 0 )
739 * + ( m==n && dim==3 ? -1/dim*(point_hessian[0][0][i]
740 * + point_hessian[1][1][i]
741 * + point_hessian[2][2][i]) : 0 ) );
746 * -----------------------------------------------
747 *
"Perforated_strip_tension"
750 * -----------------------------------------------
752 * plane strain / 3
d case
755 *
const double VM_factor =
std::sqrt(1.5);
758 * -----------------------------------------------
764 *
for (
unsigned int i=0; i!=dim; ++i)
765 *
for (
unsigned int j=0; j!=dim; ++j)
766 *
for (
unsigned int k=0; k!=dim; ++k)
767 *
for (
unsigned int l=0;
l!=dim; ++
l)
768 *
for (
unsigned int m=0; m!=dim; ++m)
770 * stress_strain_tensor_grad[i][j][k][
l][m] = 1/VM_factor
772 * * stress_strain_tensor_mu[i][j][k][
l]
773 * * multiplier_vector(m);
779 * stress_strain_tensor_grad = 0;
782 *
return (von_Mises_stress > sigma_0);
789 * <a name=
"ConstitutiveLawget_linearized_stress_strain_tensors"></a>
790 * <h4>ConstitutiveLaw::get_linearized_stress_strain_tensors</h4>
794 * This
function returns the linearized stress strain tensor, linearized
795 * around the solution @f$u^{i-1}@f$ of the previous Newton step @f$i-1@f$. The
796 * parameter <code>strain_tensor</code> (commonly denoted
797 * @f$\varepsilon(u^{i-1})@f$) must be passed as an argument, and serves as the
798 * linearization
point. The
function returns the derivative of the nonlinear
799 * constitutive law in the variable stress_strain_tensor, as well as the
800 * stress-strain tensor of the linearized problem in
801 * stress_strain_tensor_linearized. See
802 * PlasticityContactProblem::assemble_nl_system where
this function is used.
807 * ConstitutiveLaw<dim>::
813 * stress_tensor = (stress_strain_tensor_kappa + stress_strain_tensor_mu)
816 * stress_strain_tensor = stress_strain_tensor_mu;
817 * stress_strain_tensor_linearized = stress_strain_tensor_mu;
820 *
const double deviator_stress_tensor_norm = deviator_stress_tensor.
norm();
821 *
const double von_Mises_stress = Evaluation::get_von_Mises_stress(stress_tensor);
823 *
if (von_Mises_stress > sigma_0)
825 *
const double beta = sigma_0 / von_Mises_stress;
826 * stress_strain_tensor *= (
gamma + (1 -
gamma) * beta);
827 * stress_strain_tensor_linearized *= (
gamma + (1 -
gamma) * beta);
828 * deviator_stress_tensor /= deviator_stress_tensor_norm;
829 * stress_strain_tensor_linearized -= (1 -
gamma) * beta * 2 *
mu
831 * deviator_stress_tensor);
834 * stress_strain_tensor += stress_strain_tensor_kappa;
835 * stress_strain_tensor_linearized += stress_strain_tensor_kappa;
840 * Finally, below we will need a
function that computes the rotation
matrix
841 * induced by a displacement at a given
point. In fact, of course, the
842 * displacement at a single
point only has a direction and a magnitude, it
843 * is the change in direction and magnitude that induces rotations. In
844 * effect, the rotation
matrix can be computed from the gradients of a
845 * displacement, or, more specifically, from the curl.
849 * The formulas by which the rotation matrices are determined are a little
850 * awkward, especially in 3
d. For 2
d, there is a simpler way, so we
851 * implement
this function twice, once
for 2
d and once
for 3
d, so that we
852 * can compile and use the program in both space dimensions
if so desired --
853 * after all, deal.II is all about dimension independent programming and
854 * reuse of algorithm thoroughly tested with cheap computations in 2
d,
for
855 * the more expensive computations in 3
d. Here is
one case, where we have to
856 * implement different algorithms
for 2
d and 3
d, but then can write the rest
857 * of the program in a way that is independent of the space dimension.
861 * So, without further ado to the 2
d implementation:
865 * get_rotation_matrix (
const std::vector<
Tensor<1,2> > &grad_u)
869 * First, compute the curl of the velocity field from the gradients. Note
870 * that we are in 2
d, so the rotation is a scalar:
873 *
const double curl = (grad_u[1][0] - grad_u[0][1]);
877 * From
this, compute the
angle of rotation:
884 * And from
this, build the antisymmetric rotation
matrix:
896 * The 3
d case is a little more contrived:
900 * get_rotation_matrix (
const std::vector<
Tensor<1,3> > &grad_u)
904 * Again
first compute the curl of the velocity field. This time, it is a
908 *
const Point<3> curl (grad_u[2][1] - grad_u[1][2],
909 * grad_u[0][2] - grad_u[2][0],
910 * grad_u[1][0] - grad_u[0][1]);
914 * From
this vector,
using its magnitude, compute the tangent of the
angle
915 * of rotation, and from it the actual
angle:
918 *
const double tan_angle =
std::sqrt(curl*curl);
923 * Now, here
's one problem: if the angle of rotation is too small, that
924 * means that there is no rotation going on (for example a translational
925 * motion). In that case, the rotation matrix is the identity matrix.
929 * The reason why we stress that is that in this case we have that
930 * <code>tan_angle==0</code>. Further down, we need to divide by that
931 * number in the computation of the axis of rotation, and we would get
932 * into trouble when dividing doing so. Therefore, let's shortcut
this and
939 *
static const double rotation[3][3]
940 * = {{ 1, 0, 0}, { 0, 1, 0 }, { 0, 0, 1 } };
947 * Otherwise compute the real rotation
matrix. The algorithm
for this is
948 * not exactly obvious, but can be found in a number of books,
949 * particularly on computer games where rotation is a very frequent
950 * operation. Online, you can find a description at
952 * the signs as here) at
956 *
const double c = std::cos(
angle);
958 *
const double t = 1-c;
960 *
const Point<3> axis = curl/tan_angle;
961 *
const double rotation[3][3]
963 * t *axis[0] *axis[0]+c,
964 * t *axis[0] *axis[1]+s *axis[2],
965 * t *axis[0] *axis[2]-s *axis[1]
968 * t *axis[0] *axis[1]-s *axis[2],
969 * t *axis[1] *axis[1]+c,
970 * t *axis[1] *axis[2]+s *axis[0]
973 * t *axis[0] *axis[2]+s *axis[1],
974 * t *axis[1] *axis[1]-s *axis[0],
975 * t *axis[2] *axis[2]+c
984 * <h3>Equation data: Body forces, boundary forces,
985 * incremental boundary values</h3>
989 * The following should be relatively standard. We need classes
for
990 * the boundary forcing term (which we here choose to be
zero)
991 * and incremental boundary values.
994 *
namespace EquationData
1240 * ----------------------------- TimoshenkoBeam ---------------------------------------
1443 * ------------------------- Thick_tube_internal_pressure ----------------------------------
1612 * ------------------------- Perforated_strip_tension ----------------------------------
1782 * ------------------------- Cantiliver_beam_3d ----------------------------------
1785 *
template <
int dim>
1786 *
class IncrementalBoundaryForce :
public Function<dim>
1789 * IncrementalBoundaryForce (
const double present_time,
1790 *
const double end_time);
1798 * vector_value_list (
const std::vector<
Point<dim> > &points,
1802 *
const double present_time,
1808 *
template <
int dim>
1809 * IncrementalBoundaryForce<dim>::
1810 * IncrementalBoundaryForce (
const double present_time,
1811 *
const double end_time)
1814 * present_time (present_time),
1815 * end_time (end_time),
1820 *
template <
int dim>
1822 * IncrementalBoundaryForce<dim>::vector_value (
const Point<dim> &p,
1829 *
const double eps = 1.e-7 * height;
1833 * pressure should be imposed on the top surface, y = height
1840 * values(1) = -pressure;
1844 * compute the fraction of imposed force
1847 *
const double frac = present_time/end_time;
1852 *
template <
int dim>
1854 * IncrementalBoundaryForce<dim>::
1855 * vector_value_list (
const std::vector<
Point<dim> > &points,
1858 *
const unsigned int n_points = points.size();
1860 *
Assert (value_list.size() == n_points,
1863 *
for (
unsigned int p=0; p<n_points; ++p)
1864 * IncrementalBoundaryForce<dim>::vector_value (points[p], value_list[p]);
1868 *
template <
int dim>
1876 *
template <
int dim>
1877 *
class IncrementalBoundaryValues :
public Function<dim>
1880 * IncrementalBoundaryValues (
const double present_time,
1881 *
const double end_time);
1890 * vector_value_list (
const std::vector<
Point<dim> > &points,
1894 *
const double present_time,
1899 *
template <
int dim>
1900 * IncrementalBoundaryValues<dim>::
1901 * IncrementalBoundaryValues (
const double present_time,
1902 *
const double end_time)
1905 * present_time (present_time),
1906 * end_time (end_time)
1910 *
template <
int dim>
1912 * IncrementalBoundaryValues<dim>::
1924 *
template <
int dim>
1926 * IncrementalBoundaryValues<dim>::
1927 * vector_value_list (
const std::vector<
Point<dim> > &points,
1930 *
const unsigned int n_points = points.size();
1932 *
Assert (value_list.size() == n_points,
1935 *
for (
unsigned int p=0; p<n_points; ++p)
1936 * IncrementalBoundaryValues<dim>::vector_value (points[p], value_list[p]);
1941 * -------------------------------------------------------------------------------
1947 *
namespace DualFunctional
1950 *
template <
int dim>
1958 *
const ConstitutiveLaw<dim> &constitutive_law,
1964 *
template <
int dim>
1965 *
class PointValuesEvaluation :
public DualFunctionalBase<dim>
1968 * PointValuesEvaluation (
const Point<dim> &evaluation_point);
1974 *
const ConstitutiveLaw<dim> &constitutive_law,
1980 * <<
"The evaluation point " << arg1
1981 * <<
" was not found among the vertices of the present grid.");
1988 *
template <
int dim>
1989 * PointValuesEvaluation<dim>::
1990 * PointValuesEvaluation (
const Point<dim> &evaluation_point)
1992 * evaluation_point (evaluation_point)
1996 *
template <
int dim>
1998 * PointValuesEvaluation<dim>::
2001 *
const ConstitutiveLaw<dim> &,
2005 * rhs_dual.reinit (dof_handler_dual.n_dofs());
2006 *
const unsigned int dofs_per_vertex = dof_handler_dual.get_fe().dofs_per_vertex;
2010 * endc_dual = dof_handler_dual.end();
2011 *
for (; cell_dual!=endc_dual; ++cell_dual)
2012 *
for (
unsigned int vertex=0;
2013 * vertex<GeometryInfo<dim>::vertices_per_cell;
2015 *
if (cell_dual->vertex(vertex).distance(evaluation_point)
2016 * < cell_dual->diameter()*1
e-8)
2018 *
for (
unsigned int id=0;
id!=dofs_per_vertex; ++id)
2020 * rhs_dual(cell_dual->vertex_dof_index(vertex,
id)) = 1;
2025 *
AssertThrow (
false, ExcEvaluationPointNotFound(evaluation_point));
2029 *
template <
int dim>
2030 *
class PointXDerivativesEvaluation :
public DualFunctionalBase<dim>
2033 * PointXDerivativesEvaluation (
const Point<dim> &evaluation_point);
2039 *
const ConstitutiveLaw<dim> &constitutive_law,
2045 * <<
"The evaluation point " << arg1
2046 * <<
" was not found among the vertices of the present grid.");
2053 *
template <
int dim>
2054 * PointXDerivativesEvaluation<dim>::
2055 * PointXDerivativesEvaluation (
const Point<dim> &evaluation_point)
2057 * evaluation_point (evaluation_point)
2061 *
template <
int dim>
2063 * PointXDerivativesEvaluation<dim>::
2066 *
const ConstitutiveLaw<dim> &,
2070 * rhs_dual.reinit (dof_handler_dual.n_dofs());
2073 *
FEValues<dim> fe_values (dof_handler_dual.get_fe(), quadrature,
2077 *
const unsigned int n_q_points = fe_values.n_quadrature_points;
2079 *
const unsigned int dofs_per_cell = dof_handler_dual.get_fe().dofs_per_cell;
2082 * std::vector<types::global_dof_index> local_dof_indices (dofs_per_cell);
2084 *
double total_volume = 0;
2088 * endc = dof_handler_dual.end();
2089 *
for (; cell!=endc; ++cell)
2090 *
if (cell->center().distance(evaluation_point) <=
2093 * fe_values.reinit (cell);
2096 *
for (
unsigned int q=0; q<n_q_points; ++q)
2098 *
for (
unsigned int i=0; i<dofs_per_cell; ++i)
2100 * cell_rhs(i) += fe_values.shape_grad(i,q)[0] *
2101 * fe_values.JxW (q);
2104 * total_volume += fe_values.JxW (q);
2107 * cell->get_dof_indices (local_dof_indices);
2108 *
for (
unsigned int i=0; i<dofs_per_cell; ++i)
2110 * rhs_dual(local_dof_indices[i]) += cell_rhs(i);
2115 * ExcEvaluationPointNotFound(evaluation_point));
2117 * rhs_dual *= 1./total_volume;
2122 *
template <
int dim>
2123 *
class MeanDisplacementFace :
public DualFunctionalBase<dim>
2126 * MeanDisplacementFace (
const unsigned int face_id,
2127 *
const std::vector<bool> comp_mask);
2133 *
const ConstitutiveLaw<dim> &constitutive_law,
2138 *
const unsigned int face_id;
2139 *
const std::vector<bool> comp_mask;
2143 *
template <
int dim>
2144 * MeanDisplacementFace<dim>::
2145 * MeanDisplacementFace (
const unsigned int face_id,
2146 *
const std::vector<bool> comp_mask )
2148 * face_id (face_id),
2149 * comp_mask (comp_mask)
2156 *
template <
int dim>
2158 * MeanDisplacementFace<dim>::
2161 *
const ConstitutiveLaw<dim> &,
2167 * rhs_dual.reinit (dof_handler_dual.n_dofs());
2169 *
const QGauss<dim-1> face_quadrature(dof_handler_dual.get_fe().tensor_degree()+1);
2173 *
const unsigned int dofs_per_vertex = dof_handler_dual.get_fe().dofs_per_vertex;
2174 *
const unsigned int dofs_per_cell = dof_handler_dual.get_fe().dofs_per_cell;
2175 *
const unsigned int n_face_q_points = face_quadrature.size();
2180 * std::vector<unsigned int> comp_vector(dofs_per_vertex);
2181 *
for (
unsigned int i=0; i!=dofs_per_vertex; ++i)
2185 * comp_vector[i] = 1;
2191 * std::vector<types::global_dof_index> local_dof_indices (dofs_per_cell);
2195 * bound_size : size of the boundary, in 2
d is the length
2196 * and in the 3
d case, area
2199 *
double bound_size = 0.;
2203 * endc = dof_handler_dual.end();
2204 *
bool evaluation_face_found =
false;
2205 *
for (; cell!=endc; ++cell)
2208 *
for (
unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
2210 *
if (cell->face(face)->at_boundary()
2212 * cell->face(face)->boundary_id() == face_id)
2214 *
if (!evaluation_face_found)
2216 * evaluation_face_found =
true;
2218 * fe_face_values.reinit (cell, face);
2220 *
for (
unsigned int q_point=0; q_point<n_face_q_points; ++q_point)
2222 * bound_size += fe_face_values.JxW(q_point);
2224 *
for (
unsigned int i=0; i<dofs_per_cell; ++i)
2226 *
const unsigned int
2227 * component_i = dof_handler_dual.get_fe().system_to_component_index(i).first;
2229 * cell_rhs(i) += (fe_face_values.shape_value(i,q_point) *
2230 * comp_vector[component_i] *
2231 * fe_face_values.JxW(q_point));
2239 * cell->get_dof_indices (local_dof_indices);
2240 *
for (
unsigned int i=0; i<dofs_per_cell; ++i)
2242 * rhs_dual(local_dof_indices[i]) += cell_rhs(i);
2249 * rhs_dual /= bound_size;
2254 *
template <
int dim>
2255 *
class MeanStressFace :
public DualFunctionalBase<dim>
2258 * MeanStressFace (
const unsigned int face_id,
2259 *
const std::vector<std::vector<unsigned int> > &comp_stress);
2265 *
const ConstitutiveLaw<dim> &constitutive_law,
2270 *
const unsigned int face_id;
2271 *
const std::vector<std::vector<unsigned int> > comp_stress;
2275 *
template <
int dim>
2276 * MeanStressFace<dim>::
2277 * MeanStressFace (
const unsigned int face_id,
2278 *
const std::vector<std::vector<unsigned int> > &comp_stress )
2280 * face_id (face_id),
2281 * comp_stress (comp_stress)
2288 *
template <
int dim>
2290 * MeanStressFace<dim>::
2293 *
const ConstitutiveLaw<dim> &constitutive_law,
2299 * rhs_dual.reinit (dof_handler_dual.n_dofs());
2301 *
const QGauss<dim-1> face_quadrature(dof_handler_dual.get_fe().tensor_degree()+1);
2305 *
FEFaceValues<dim> fe_face_values_dual (dof_handler_dual.get_fe(), face_quadrature,
2308 *
const unsigned int dofs_per_cell_dual = dof_handler_dual.get_fe().dofs_per_cell;
2309 *
const unsigned int n_face_q_points = face_quadrature.size();
2311 * std::vector<SymmetricTensor<2, dim> > strain_tensor(n_face_q_points);
2316 * std::vector<types::global_dof_index> local_dof_indices (dofs_per_cell_dual);
2320 * bound_size : size of the boundary, in 2
d is the length
2321 * and in the 3
d case, area
2324 *
double bound_size = 0.;
2326 *
bool evaluation_face_found =
false;
2330 * endc_dual = dof_handler_dual.end(),
2335 *
for (; cell_dual!=endc_dual; ++cell_dual, ++cell)
2338 *
for (
unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
2340 *
if (cell_dual->face(face)->at_boundary()
2342 * cell_dual->face(face)->boundary_id() == face_id)
2344 *
if (!evaluation_face_found)
2346 * evaluation_face_found =
true;
2349 * fe_face_values.reinit (cell, face);
2350 * fe_face_values_dual.reinit (cell_dual, face);
2352 * fe_face_values[displacement].get_function_symmetric_gradients(solution,
2355 *
for (
unsigned int q_point=0; q_point<n_face_q_points; ++q_point)
2357 * bound_size += fe_face_values_dual.JxW(q_point);
2359 * constitutive_law.get_stress_strain_tensor(strain_tensor[q_point],
2360 * stress_strain_tensor);
2362 *
for (
unsigned int i=0; i<dofs_per_cell_dual; ++i)
2365 * stress_phi_i = stress_strain_tensor
2366 * * fe_face_values_dual[displacement].symmetric_gradient(i, q_point);
2368 *
for (
unsigned int k=0; k!=dim; ++k)
2370 *
for (
unsigned int l=0;
l!=dim; ++
l)
2372 *
if ( comp_stress[k][
l] == 1 )
2374 * cell_rhs(i) += stress_phi_i[k][
l]
2376 * fe_face_values_dual.JxW(q_point);
2389 * cell_dual->get_dof_indices (local_dof_indices);
2390 *
for (
unsigned int i=0; i<dofs_per_cell_dual; ++i)
2392 * rhs_dual(local_dof_indices[i]) += cell_rhs(i);
2399 * rhs_dual /= bound_size;
2404 *
template <
int dim>
2405 *
class MeanStressDomain :
public DualFunctionalBase<dim>
2408 * MeanStressDomain (
const std::string &base_mesh,
2409 *
const std::vector<std::vector<unsigned int> > &comp_stress);
2415 *
const ConstitutiveLaw<dim> &constitutive_law,
2420 *
const std::string base_mesh;
2421 *
const std::vector<std::vector<unsigned int> > comp_stress;
2425 *
template <
int dim>
2426 * MeanStressDomain<dim>::
2427 * MeanStressDomain (
const std::string &base_mesh,
2428 *
const std::vector<std::vector<unsigned int> > &comp_stress )
2430 * base_mesh (base_mesh),
2431 * comp_stress (comp_stress)
2438 *
template <
int dim>
2440 * MeanStressDomain<dim>::
2443 *
const ConstitutiveLaw<dim> &constitutive_law,
2452 * Mean stress at the specified domain is of interest.
2453 * The interest domains are located on the bottom and top of the flanges
2454 * close to the clamped face, z = 0
2455 * top domain: height/2 - thickness_flange <= y <= height/2
2456 * 0 <= z <= 2 * thickness_flange
2457 * bottom domain: -height/2 <= y <= -height/2 + thickness_flange
2458 * 0 <= z <= 2 * thickness_flange
2464 *
const double height = 200
e-3,
2465 * thickness_flange = 10
e-3;
2467 * rhs_dual.reinit (dof_handler_dual.n_dofs());
2469 *
const QGauss<dim> quadrature_formula(dof_handler_dual.get_fe().tensor_degree()+1);
2471 *
FEValues<dim> fe_values (dof_handler.get_fe(), quadrature_formula,
2473 *
FEValues<dim> fe_values_dual (dof_handler_dual.get_fe(), quadrature_formula,
2476 *
const unsigned int dofs_per_cell_dual = dof_handler_dual.get_fe().dofs_per_cell;
2477 *
const unsigned int n_q_points = quadrature_formula.size();
2479 * std::vector<SymmetricTensor<2, dim> > strain_tensor(n_q_points);
2484 * std::vector<types::global_dof_index> local_dof_indices (dofs_per_cell_dual);
2488 * domain_size : size of the interested domain, in 2
d is the area
2492 *
double domain_size = 0.;
2494 *
bool evaluation_domain_found =
false;
2498 * endc_dual = dof_handler_dual.end(),
2503 *
for (; cell_dual!=endc_dual; ++cell_dual, ++cell)
2505 *
const double y = cell->center()[1],
2506 * z = cell->center()[2];
2509 * top domain: height/2 - thickness_flange <= y <= height/2
2510 * 0 <= z <= 2 * thickness_flange
2511 * bottom domain: -height/2 <= y <= -height/2 + thickness_flange
2512 * 0 <= z <= 2 * thickness_flange
2515 *
if ( ((z > 0) && (z < 2*thickness_flange)) &&
2516 * ( ((y > height/2 - thickness_flange) && (y < height/2)) ||
2517 * ((y > -height/2) && (y < -height/2 + thickness_flange)) ) )
2521 *
if (!evaluation_domain_found)
2523 * evaluation_domain_found =
true;
2526 * fe_values.reinit(cell);
2527 * fe_values_dual.reinit(cell_dual);
2529 * fe_values[displacement].get_function_symmetric_gradients(solution,
2532 *
for (
unsigned int q_point=0; q_point<n_q_points; ++q_point)
2534 * domain_size += fe_values_dual.JxW(q_point);
2536 * constitutive_law.get_stress_strain_tensor(strain_tensor[q_point],
2537 * stress_strain_tensor);
2539 *
for (
unsigned int i=0; i<dofs_per_cell_dual; ++i)
2542 * stress_phi_i = stress_strain_tensor
2543 * * fe_values_dual[displacement].symmetric_gradient(i, q_point);
2545 *
for (
unsigned int k=0; k!=dim; ++k)
2547 *
for (
unsigned int l=0;
l!=dim; ++
l)
2549 *
if ( comp_stress[k][
l] == 1 )
2551 * cell_rhs(i) += stress_phi_i[k][
l]
2553 * fe_values_dual.JxW(q_point);
2565 * cell_dual->get_dof_indices (local_dof_indices);
2566 *
for (
unsigned int i=0; i<dofs_per_cell_dual; ++i)
2568 * rhs_dual(local_dof_indices[i]) += cell_rhs(i);
2575 * rhs_dual /= domain_size;
2580 *
template <
int dim>
2581 *
class MeanStrainEnergyFace :
public DualFunctionalBase<dim>
2584 * MeanStrainEnergyFace (
const unsigned int face_id,
2588 *
void assemble_rhs_nonlinear (
const DoFHandler<dim> &primal_dof_handler,
2594 *
const unsigned int face_id;
2600 *
template <
int dim>
2601 * MeanStrainEnergyFace<dim>::
2602 * MeanStrainEnergyFace (
const unsigned int face_id,
2606 * face_id (face_id),
2607 * lambda_function (&lambda_function),
2608 * mu_function (&mu_function)
2612 *
template <
int dim>
2614 * MeanStrainEnergyFace<dim>::
2622 * Assemble right hand side of the dual problem when the quantity of interest is
2623 * a nonlinear functinoal. In
this case, the QoI should be linearized which depends
2624 * on the solution of the primal problem.
2625 * The extracter of the linearized QoI functional is the gradient of the the original
2626 * QoI functional with the primal solution values.
2634 * rhs.reinit (dof_handler.n_dofs());
2636 *
const QGauss<dim-1> face_quadrature(dof_handler.get_fe().tensor_degree()+1);
2637 *
FEFaceValues<dim> primal_fe_face_values (primal_dof_handler.get_fe(), face_quadrature,
2645 *
const unsigned int dofs_per_vertex = primal_dof_handler.get_fe().dofs_per_vertex;
2646 *
const unsigned int n_face_q_points = face_quadrature.size();
2647 *
const unsigned int dofs_per_cell = dof_handler.get_fe().dofs_per_cell;
2652 * std::vector< std::vector< Tensor<1,dim> > > primal_solution_gradients;
2653 * primal_solution_gradients.resize(n_face_q_points);
2655 * std::vector<std::vector<Tensor<2,dim> > > primal_solution_hessians;
2656 * primal_solution_hessians.resize (n_face_q_points);
2658 *
for (
unsigned int i=0; i!=n_face_q_points; ++i)
2660 * primal_solution_gradients[i].resize (dofs_per_vertex);
2661 * primal_solution_hessians[i].resize (dofs_per_vertex);
2664 * std::vector<double> lambda_values (n_face_q_points);
2665 * std::vector<double> mu_values (n_face_q_points);
2669 * std::vector<types::global_dof_index> local_dof_indices (dofs_per_cell);
2673 * bound_size : size of the boundary, in 2
d is the length
2674 * and in the 3
d case, area
2677 *
double bound_size = 0.;
2679 *
bool evaluation_face_found =
false;
2683 * primal_endc = primal_dof_handler.end();
2687 * endc = dof_handler.end();
2689 *
for (; cell!=endc; ++cell, ++primal_cell)
2692 *
for (
unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
2694 *
if (cell->face(face)->at_boundary()
2696 * cell->face(face)->boundary_id() == face_id)
2698 *
if (!evaluation_face_found)
2700 * evaluation_face_found =
true;
2702 * primal_fe_face_values.reinit (primal_cell, face);
2704 * primal_fe_face_values.get_function_gradients (primal_solution,
2705 * primal_solution_gradients);
2707 * primal_fe_face_values.get_function_hessians (primal_solution,
2708 * primal_solution_hessians);
2710 * lambda_function->value_list (primal_fe_face_values.get_quadrature_points(), lambda_values);
2711 * mu_function->value_list (primal_fe_face_values.get_quadrature_points(), mu_values);
2713 * fe_face_values.reinit (cell, face);
2715 *
for (
unsigned int q_point=0; q_point<n_face_q_points; ++q_point)
2717 * bound_size += primal_fe_face_values.JxW(q_point);
2719 *
for (
unsigned int m=0; m<dofs_per_cell; ++m)
2721 *
const unsigned int
2722 * component_m = dof_handler.get_fe().system_to_component_index(m).first;
2724 *
for (
unsigned int i=0; i!=dofs_per_vertex; ++i)
2726 *
for (
unsigned int j=0; j!=dofs_per_vertex; ++j)
2728 * cell_rhs(m) += fe_face_values.shape_value(m,q_point) *
2730 * lambda_values[q_point] *
2732 * primal_solution_hessians[q_point][i][i][component_m] * primal_solution_gradients[q_point][j][j]
2734 * primal_solution_gradients[q_point][i][i] * primal_solution_hessians[q_point][j][j][component_m]
2737 * mu_values[q_point] *
2739 * 2*primal_solution_hessians[q_point][j][i][component_m] * primal_solution_gradients[q_point][j][i]
2741 * primal_solution_hessians[q_point][i][j][component_m] * primal_solution_gradients[q_point][j][i]
2743 * primal_solution_gradients[q_point][i][j] * primal_solution_hessians[q_point][j][i][component_m]
2746 * primal_fe_face_values.JxW(q_point);
2759 * cell->get_dof_indices (local_dof_indices);
2760 *
for (
unsigned int i=0; i<dofs_per_cell; ++i)
2762 * rhs(local_dof_indices[i]) += cell_rhs(i);
2769 * rhs *= 1./(2*bound_size);
2782 *
template <
int dim>
2789 *
const ConstitutiveLaw<dim> &constitutive_law,
2790 *
const DualFunctional::DualFunctionalBase<dim> &dual_functional,
2791 *
const unsigned int ×tep_no,
2792 *
const std::string &output_dir,
2793 *
const std::string &base_mesh,
2794 *
const double &present_time,
2795 *
const double &end_time);
2797 *
void compute_error_DWR (Vector<float> &estimated_error_per_cell);
2802 *
void setup_system ();
2803 *
void compute_dirichlet_constraints ();
2804 *
void assemble_matrix ();
2805 *
void assemble_rhs ();
2807 *
void output_results ();
2813 *
const unsigned int fe_degree;
2816 *
const unsigned int fe_degree_dual;
2821 *
const QGauss<dim - 1> face_quadrature_formula;
2831 *
const ConstitutiveLaw<dim> constitutive_law;
2836 *
unsigned int timestep_no;
2837 * std::string output_dir;
2838 *
const std::string base_mesh;
2839 *
double present_time;
2849 *
const ConstitutiveLaw<dim> &constitutive_law,
2850 *
const DualFunctional::DualFunctionalBase<dim> &dual_functional,
2851 *
const unsigned int ×tep_no,
2852 *
const std::string &output_dir,
2853 *
const std::string &base_mesh,
2854 *
const double &present_time,
2855 *
const double &end_time)
2859 * solution(solution),
2860 * fe_degree(fe.tensor_degree()),
2861 * fe_degree_dual(fe_degree + 1),
2862 * fe_dual(
FE_Q<dim>(fe_degree_dual), dim),
2864 * quadrature_formula (fe_degree_dual + 1),
2865 * face_quadrature_formula (fe_degree_dual + 1),
2866 * constitutive_law (constitutive_law),
2868 * dual_functional (&dual_functional),
2869 * timestep_no (timestep_no),
2870 * output_dir (output_dir),
2871 * base_mesh (base_mesh),
2872 * present_time (present_time),
2873 * end_time (end_time)
2878 * DualSolver<dim>::~DualSolver()
2880 * dof_handler_dual.clear ();
2885 *
void DualSolver<dim>::setup_system()
2887 * dof_handler.distribute_dofs(fe);
2889 * dof_handler_dual.distribute_dofs (fe_dual);
2890 * std::cout <<
" Number of degrees of freedom in dual problem: "
2891 * << dof_handler_dual.n_dofs()
2894 * constraints_hanging_nodes_dual.clear ();
2896 * constraints_hanging_nodes_dual);
2897 * constraints_hanging_nodes_dual.close ();
2899 * compute_dirichlet_constraints();
2901 * sparsity_pattern_dual.reinit (dof_handler_dual.n_dofs(),
2902 * dof_handler_dual.n_dofs(),
2903 * dof_handler_dual.max_couplings_between_dofs());
2908 * constraints_hanging_nodes_dual.condense (sparsity_pattern_dual);
2911 * constraints_dirichlet_and_hanging_nodes_dual.condense (sparsity_pattern_dual);
2913 * sparsity_pattern_dual.compress();
2915 * system_matrix_dual.reinit (sparsity_pattern_dual);
2917 * solution_dual.reinit (dof_handler_dual.n_dofs());
2918 * system_rhs_dual.reinit (dof_handler_dual.n_dofs());
2923 *
void DualSolver<dim>::compute_dirichlet_constraints()
2925 * constraints_dirichlet_and_hanging_nodes_dual.clear ();
2926 * constraints_dirichlet_and_hanging_nodes_dual.merge(constraints_hanging_nodes_dual);
2928 * std::vector<bool> component_mask(dim);
2930 *
if (base_mesh ==
"Timoshenko beam")
2934 * EquationData::IncrementalBoundaryValues<dim>(present_time, end_time),
2935 * constraints_dirichlet_and_hanging_nodes_dual,
2938 *
else if (base_mesh ==
"Thick_tube_internal_pressure")
2942 * the boundary x = 0
2945 * component_mask[0] =
true;
2946 * component_mask[1] =
false;
2949 * EquationData::IncrementalBoundaryValues<dim>(present_time, end_time),
2950 * constraints_dirichlet_and_hanging_nodes_dual,
2954 * the boundary y = 0
2957 * component_mask[0] =
false;
2958 * component_mask[1] =
true;
2961 * EquationData::IncrementalBoundaryValues<dim>(present_time, end_time),
2962 * constraints_dirichlet_and_hanging_nodes_dual,
2965 *
else if (base_mesh ==
"Perforated_strip_tension")
2969 * the boundary x = 0
2972 * component_mask[0] =
true;
2973 * component_mask[1] =
false;
2974 * component_mask[2] =
false;
2977 * EquationData::IncrementalBoundaryValues<dim>(present_time, end_time),
2978 * constraints_dirichlet_and_hanging_nodes_dual,
2982 * the boundary y = 0
2985 * component_mask[0] =
false;
2986 * component_mask[1] =
true;
2987 * component_mask[2] =
false;
2990 * EquationData::IncrementalBoundaryValues<dim>(present_time, end_time),
2991 * constraints_dirichlet_and_hanging_nodes_dual,
2995 * the boundary y = imposed incremental displacement
2998 * component_mask[0] =
false;
2999 * component_mask[1] =
true;
3000 * component_mask[2] =
false;
3003 * EquationData::IncrementalBoundaryValues<dim>(present_time, end_time),
3004 * constraints_dirichlet_and_hanging_nodes_dual,
3007 *
else if (base_mesh ==
"Cantiliver_beam_3d")
3011 * the boundary x = y = z = 0
3014 * component_mask[0] =
true;
3015 * component_mask[1] =
true;
3016 * component_mask[2] =
true;
3019 * EquationData::IncrementalBoundaryValues<dim>(present_time, end_time),
3020 * constraints_dirichlet_and_hanging_nodes_dual,
3028 * constraints_dirichlet_and_hanging_nodes_dual.close();
3033 *
void DualSolver<dim>::assemble_matrix()
3040 *
const unsigned int dofs_per_cell_dual = fe_dual.dofs_per_cell;
3041 *
const unsigned int n_q_points = quadrature_formula.size();
3045 * std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell_dual);
3049 * endc_dual = dof_handler_dual.end(),
3054 *
for (; cell_dual != endc_dual; ++cell_dual, ++cell)
3055 *
if (cell_dual->is_locally_owned())
3057 * fe_values.reinit(cell);
3059 * fe_values_dual.reinit(cell_dual);
3062 * std::vector<SymmetricTensor<2, dim> > strain_tensor(n_q_points);
3063 * fe_values[displacement].get_function_symmetric_gradients(solution,
3066 *
for (
unsigned int q_point = 0; q_point < n_q_points; ++q_point)
3070 * constitutive_law.get_linearized_stress_strain_tensors(strain_tensor[q_point],
3071 * stress_strain_tensor_linearized,
3072 * stress_strain_tensor);
3074 *
for (
unsigned int i = 0; i < dofs_per_cell_dual; ++i)
3077 * stress_phi_i = stress_strain_tensor_linearized
3078 * * fe_values_dual[displacement].symmetric_gradient(i, q_point);
3080 *
for (
unsigned int j = 0; j < dofs_per_cell_dual; ++j)
3082 * * fe_values_dual[displacement].symmetric_gradient(j, q_point)
3083 * * fe_values_dual.JxW(q_point));
3089 * cell_dual->get_dof_indices(local_dof_indices);
3090 * constraints_dirichlet_and_hanging_nodes_dual.distribute_local_to_global(
cell_matrix,
3091 * local_dof_indices,
3092 * system_matrix_dual);
3100 *
void DualSolver<dim>::assemble_rhs()
3102 * dual_functional->assemble_rhs (dof_handler, solution, constitutive_law,
3103 * dof_handler_dual, system_rhs_dual);
3104 * constraints_dirichlet_and_hanging_nodes_dual.condense (system_rhs_dual);
3109 *
void DualSolver<dim>::solve()
3113 * +++ direct solver +++++++++
3121 * After the decomposition, we can use A_direct like a
matrix representing
3122 * the inverse of our system
matrix, so to compute the solution we just
3123 * have to multiply with the right hand side vector:
3126 * A_direct.vmult(solution_dual, system_rhs_dual);
3130 * ++++ iterative solver ++ CG ++++ doesn
't work
3131 * SolverControl solver_control (5000, 1e-12);
3132 * SolverCG<> cg (solver_control);
3136 * PreconditionSSOR<> preconditioner;
3137 * preconditioner.initialize(system_matrix_dual, 1.2);
3141 * cg.solve (system_matrix_dual, solution_dual, system_rhs_dual,
3146 * ++++ iterative solver ++ BiCGStab ++++++ doesn't work
3153 * preconditioner.
initialize(system_matrix_dual, 1.0);
3157 * bicgstab.solve (system_matrix_dual, solution_dual, system_rhs_dual,
3162 * +++++++++++++++++++++++++++++++++++++++++++++++++
3168 * constraints_dirichlet_and_hanging_nodes_dual.distribute (solution_dual);
3172 *
void DualSolver<dim>::output_results()
3174 * std::string filename = (output_dir +
"dual-solution-" +
3176 * std::ofstream output (filename.c_str());
3179 * std::vector<std::string> solution_names;
3183 * solution_names.push_back (
"displacement");
3186 * solution_names.push_back (
"x_displacement");
3187 * solution_names.push_back (
"y_displacement");
3190 * solution_names.push_back (
"x_displacement");
3191 * solution_names.push_back (
"y_displacement");
3192 * solution_names.push_back (
"z_displacement");
3203 *
void DualSolver<dim>::compute_error_DWR (Vector<float> &estimated_error_per_cell)
3210 * solve the dual problem
3214 * assemble_matrix ();
3217 * output_results ();
3221 * compuate the dual weights
3228 * constraints_dirichlet_and_hanging_nodes_dual,
3233 * constraints_hanging_nodes);
3234 * constraints_hanging_nodes.
close();
3237 * constraints_dirichlet_and_hanging_nodes_dual,
3240 * constraints_hanging_nodes,
3245 * estimate the error
3255 *
const unsigned int n_q_points = quadrature_formula.size();
3256 * std::vector<SymmetricTensor<2, dim> > strain_tensor(n_q_points);
3260 * std::vector<std::vector<Tensor<2,dim> > > cell_hessians (n_q_points);
3261 *
for (
unsigned int i=0; i!=n_q_points; ++i)
3263 * cell_hessians[i].resize (dim);
3265 * std::vector<Vector<double> > dual_weights_cell_values (n_q_points,
Vector<double>(dim));
3267 *
const EquationData::BodyForce<dim> body_force;
3268 * std::vector<Vector<double> > body_force_values (n_q_points,
Vector<double>(dim));
3278 * fe_face_values_neighbor (fe_dual, face_quadrature_formula,
3286 *
const unsigned int n_face_q_points = face_quadrature_formula.size();
3287 * std::vector<Vector<double> > jump_residual (n_face_q_points,
Vector<double>(dim));
3288 * std::vector<Vector<double> > dual_weights_face_values (n_face_q_points,
Vector<double>(dim));
3290 * std::vector<std::vector<Tensor<1,dim> > > cell_grads(n_face_q_points);
3291 *
for (
unsigned int i=0; i!=n_face_q_points; ++i)
3293 * cell_grads[i].resize (dim);
3295 * std::vector<std::vector<Tensor<1,dim> > > neighbor_grads(n_face_q_points);
3296 *
for (
unsigned int i=0; i!=n_face_q_points; ++i)
3298 * neighbor_grads[i].resize (dim);
3306 *
typename std::map<typename DoFHandler<dim>::face_iterator,
Vector<double> >
3310 * endc = dof_handler_dual.end();
3311 *
for (; cell!=endc; ++cell)
3312 *
if (cell->is_locally_owned())
3314 *
for (
unsigned int face_no=0;
3315 * face_no<GeometryInfo<dim>::faces_per_cell;
3318 * face_integrals[cell->face(face_no)].reinit (dim);
3319 * face_integrals[cell->face(face_no)] = -1e20;
3323 * std::vector<Vector<float> > error_indicators_vector;
3324 * error_indicators_vector.resize(
triangulation->n_active_cells(),
3325 * Vector<float>(dim) );
3329 * ----------------- estimate_some -------------------------
3333 *
unsigned int present_cell = 0;
3334 *
for (; cell!=endc; ++cell, ++present_cell)
3335 *
if (cell->is_locally_owned())
3339 * --------------- integrate_over_cell -------------------
3342 * fe_values.reinit(cell);
3343 * body_force.vector_value_list(fe_values.get_quadrature_points(),
3344 * body_force_values);
3345 * fe_values[displacement].get_function_symmetric_gradients(primal_solution,
3347 * fe_values.get_function_hessians(primal_solution, cell_hessians);
3349 * fe_values.get_function_values(dual_weights,
3350 * dual_weights_cell_values);
3352 *
for (
unsigned int q_point = 0; q_point < n_q_points; ++q_point)
3354 * constitutive_law.get_linearized_stress_strain_tensors(strain_tensor[q_point],
3355 * stress_strain_tensor_linearized,
3356 * stress_strain_tensor);
3357 * constitutive_law.get_grad_stress_strain_tensor(strain_tensor[q_point],
3358 * cell_hessians[q_point],
3359 * stress_strain_tensor_grad);
3361 *
for (
unsigned int i=0; i!=dim; ++i)
3363 * error_indicators_vector[present_cell](i) +=
3364 * body_force_values[q_point](i)*
3365 * dual_weights_cell_values[q_point](i)*
3366 * fe_values.JxW(q_point);
3367 *
for (
unsigned int j=0; j!=dim; ++j)
3369 *
for (
unsigned int k=0; k!=dim; ++k)
3371 *
for (
unsigned int l=0;
l!=dim; ++
l)
3373 * error_indicators_vector[present_cell](i) +=
3374 * ( stress_strain_tensor[i][j][k][
l]*
3375 * 0.5*(cell_hessians[q_point][k][
l][j]
3377 * cell_hessians[q_point][
l][k][j])
3378 * + stress_strain_tensor_grad[i][j][k][
l][j] * strain_tensor[q_point][k][
l]
3380 * dual_weights_cell_values[q_point](i) *
3381 * fe_values.JxW(q_point);
3391 * -------------------------------------------------------
3392 * compute face_integrals
3395 *
for (
unsigned int face_no=0;
3396 * face_no<GeometryInfo<dim>::faces_per_cell;
3399 *
if (cell->face(face_no)->at_boundary())
3401 *
for (
unsigned int id=0;
id!=dim; ++id)
3403 * face_integrals[cell->face(face_no)](id) = 0;
3408 *
if ((cell->neighbor(face_no)->has_children() ==
false) &&
3409 * (cell->neighbor(face_no)->level() == cell->level()) &&
3410 * (cell->neighbor(face_no)->index() < cell->index()))
3413 *
if (cell->at_boundary(face_no) ==
false)
3414 *
if (cell->neighbor(face_no)->level() < cell->level())
3418 *
if (cell->face(face_no)->has_children() ==
false)
3422 * ------------- integrate_over_regular_face -----------
3425 * fe_face_values_cell.reinit(cell, face_no);
3426 * fe_face_values_cell.get_function_gradients (primal_solution,
3431 *
const unsigned int
3432 * neighbor_neighbor = cell->neighbor_of_neighbor (face_no);
3434 * neighbor = cell->neighbor(face_no);
3436 * fe_face_values_neighbor.reinit(neighbor, neighbor_neighbor);
3437 * fe_face_values_neighbor.get_function_gradients (primal_solution,
3440 *
for (
unsigned int q_point=0; q_point<n_face_q_points; ++q_point)
3442 * q_cell_strain_tensor = 0.;
3443 * q_neighbor_strain_tensor = 0.;
3444 *
for (
unsigned int i=0; i!=dim; ++i)
3446 *
for (
unsigned int j=0; j!=dim; ++j)
3448 * q_cell_strain_tensor[i][j] = 0.5*(cell_grads[q_point][i][j] +
3449 * cell_grads[q_point][j][i] );
3450 * q_neighbor_strain_tensor[i][j] = 0.5*(neighbor_grads[q_point][i][j] +
3451 * neighbor_grads[q_point][j][i] );
3455 * constitutive_law.get_stress_strain_tensor (q_cell_strain_tensor,
3456 * cell_stress_strain_tensor);
3457 * constitutive_law.get_stress_strain_tensor (q_neighbor_strain_tensor,
3458 * neighbor_stress_strain_tensor);
3460 * jump_residual[q_point] = 0.;
3461 *
for (
unsigned int i=0; i!=dim; ++i)
3463 *
for (
unsigned int j=0; j!=dim; ++j)
3465 *
for (
unsigned int k=0; k!=dim; ++k)
3467 *
for (
unsigned int l=0;
l!=dim; ++
l)
3469 * jump_residual[q_point](i) += (cell_stress_strain_tensor[i][j][k][
l]*
3470 * q_cell_strain_tensor[k][
l]
3472 * neighbor_stress_strain_tensor[i][j][k][
l]*
3473 * q_neighbor_strain_tensor[k][
l] )*
3474 * fe_face_values_cell.normal_vector(q_point)[j];
3482 * fe_face_values_cell.get_function_values (dual_weights,
3483 * dual_weights_face_values);
3486 * face_integral_vector = 0;
3487 *
for (
unsigned int q_point=0; q_point<n_face_q_points; ++q_point)
3489 *
for (
unsigned int i=0; i!=dim; ++i)
3491 * face_integral_vector(i) += jump_residual[q_point](i) *
3492 * dual_weights_face_values[q_point](i) *
3493 * fe_face_values_cell.JxW(q_point);
3497 *
Assert (face_integrals.find (cell->face(face_no)) != face_integrals.end(),
3500 *
for (
unsigned int i=0; i!=dim; ++i)
3502 *
Assert (face_integrals[cell->face(face_no)](i) == -1e20,
3504 * face_integrals[cell->face(face_no)](i) = face_integral_vector(i);
3510 * -----------------------------------------------------
3518 * ------------- integrate_over_irregular_face ---------
3522 * face = cell->face(face_no);
3524 * neighbor = cell->neighbor(face_no);
3527 *
Assert (neighbor->has_children(),
3530 *
const unsigned int
3531 * neighbor_neighbor = cell->neighbor_of_neighbor (face_no);
3533 *
for (
unsigned int subface_no=0;
3534 * subface_no<face->n_children(); ++subface_no)
3537 * neighbor_child = cell->neighbor_child_on_subface (face_no, subface_no);
3538 *
Assert (neighbor_child->face(neighbor_neighbor) ==
3539 * cell->face(face_no)->child(subface_no),
3542 * fe_subface_values_cell.reinit (cell, face_no, subface_no);
3543 * fe_subface_values_cell.get_function_gradients (primal_solution,
3545 * fe_face_values_neighbor.reinit (neighbor_child,
3546 * neighbor_neighbor);
3547 * fe_face_values_neighbor.get_function_gradients (primal_solution,
3550 *
for (
unsigned int q_point=0; q_point<n_face_q_points; ++q_point)
3552 * q_cell_strain_tensor = 0.;
3553 * q_neighbor_strain_tensor = 0.;
3554 *
for (
unsigned int i=0; i!=dim; ++i)
3556 *
for (
unsigned int j=0; j!=dim; ++j)
3558 * q_cell_strain_tensor[i][j] = 0.5*(cell_grads[q_point][i][j] +
3559 * cell_grads[q_point][j][i] );
3560 * q_neighbor_strain_tensor[i][j] = 0.5*(neighbor_grads[q_point][i][j] +
3561 * neighbor_grads[q_point][j][i] );
3565 * constitutive_law.get_stress_strain_tensor (q_cell_strain_tensor,
3566 * cell_stress_strain_tensor);
3567 * constitutive_law.get_stress_strain_tensor (q_neighbor_strain_tensor,
3568 * neighbor_stress_strain_tensor);
3570 * jump_residual[q_point] = 0.;
3571 *
for (
unsigned int i=0; i!=dim; ++i)
3573 *
for (
unsigned int j=0; j!=dim; ++j)
3575 *
for (
unsigned int k=0; k!=dim; ++k)
3577 *
for (
unsigned int l=0;
l!=dim; ++
l)
3579 * jump_residual[q_point](i) += (-cell_stress_strain_tensor[i][j][k][
l]*
3580 * q_cell_strain_tensor[k][
l]
3582 * neighbor_stress_strain_tensor[i][j][k][
l]*
3583 * q_neighbor_strain_tensor[k][
l] )*
3584 * fe_face_values_neighbor.normal_vector(q_point)[j];
3592 * fe_face_values_neighbor.get_function_values (dual_weights,
3593 * dual_weights_face_values);
3596 * face_integral_vector = 0;
3597 *
for (
unsigned int q_point=0; q_point<n_face_q_points; ++q_point)
3599 *
for (
unsigned int i=0; i!=dim; ++i)
3601 * face_integral_vector(i) += jump_residual[q_point](i) *
3602 * dual_weights_face_values[q_point](i) *
3603 * fe_face_values_neighbor.JxW(q_point);
3607 *
for (
unsigned int i=0; i!=dim; ++i)
3609 * face_integrals[neighbor_child->face(neighbor_neighbor)](i) = face_integral_vector(i);
3616 *
for (
unsigned int subface_no=0;
3617 * subface_no<face->n_children(); ++subface_no)
3619 *
Assert (face_integrals.find(face->child(subface_no)) !=
3620 * face_integrals.end(),
3622 *
for (
unsigned int i=0; i!=dim; ++i)
3624 *
Assert (face_integrals[face->child(subface_no)](i) != -1e20,
3626 *
sum(i) += face_integrals[face->child(subface_no)](i);
3629 *
for (
unsigned int i=0; i!=dim; ++i)
3631 * face_integrals[face](i) =
sum(i);
3637 * -----------------------------------------------------
3647 * ----------------------------------------------------------
3654 * cell = dof_handler_dual.begin_active();
3655 *
for (; cell!=endc; ++cell, ++present_cell)
3656 *
if (cell->is_locally_owned())
3658 *
for (
unsigned int face_no=0; face_no<GeometryInfo<dim>::faces_per_cell;
3661 *
Assert(face_integrals.find(cell->face(face_no)) !=
3662 * face_integrals.end(),
3665 *
for (
unsigned int id=0;
id!=dim; ++id)
3667 * error_indicators_vector[present_cell](id)
3668 * -= 0.5*face_integrals[cell->face(face_no)](id);
3673 * estimated_error_per_cell(present_cell) = error_indicators_vector[present_cell].l2_norm();
3683 * <a name=
"ThecodePlasticityContactProblemcodeclasstemplate"></a>
3684 * <h3>The <code>PlasticityContactProblem</code>
class template</h3>
3688 * This is the main
class of this program and supplies all
functions
3689 * and variables needed to describe
3690 * the nonlinear contact problem. It is
3691 * close to @ref step_41
"step-41" but with some additional
3692 * features like handling hanging nodes,
3693 * a Newton method,
using Trilinos and p4est
3694 *
for parallel distributed computing.
3695 * To deal with hanging nodes makes
3696 * life a bit more complicated since
3698 * We create a Newton method
for the
3699 * active
set method
for the contact
3700 * situation and to handle the nonlinear
3701 *
operator for the constitutive law.
3705 * The
general layout of
this class is very much like for most other tutorial programs.
3706 * To make our life a bit easier,
this class reads a
set of input parameters from an input file. These
3707 * parameters,
using the
ParameterHandler class, are declared in the <code>declare_parameters</code>
3708 *
function (which is
static so that it can be called before we even create an
object of the current
3709 * type), and a
ParameterHandler object that has been used to read an input file will then be passed
3710 * to the constructor of
this class.
3714 * The remaining member
functions are by and large as we have seen in several of the other tutorial
3715 * programs, though with additions
for the current nonlinear system. We will comment on their purpose
3716 * as we get to them further below.
3719 * template <int dim>
3720 *
class ElastoPlasticProblem
3730 *
void make_grid ();
3731 *
void setup_system ();
3732 *
void compute_dirichlet_constraints ();
3736 *
void solve_newton_system ();
3737 *
void solve_newton ();
3738 *
void compute_error ();
3740 *
void refine_grid ();
3742 *
void output_results (
const std::string &filename_base);
3746 * Next are three
functions that handle the history variables stored in each
3748 *
set up a pristine state
for the history variables. It only works on
3749 * those quadrature points on cells that belong to the present processor:
3752 *
void setup_quadrature_point_history ();
3756 * The
second one updates the history variables at the
end of each
3760 *
void update_quadrature_point_history ();
3764 * As far as member variables are concerned, we start with ones that we use to
3765 * indicate the MPI universe
this program runs on, and then two
numbers
3766 * telling us how many participating processors there are, and where in
3767 *
this world we are., a stream we use to let
3768 * exactly
one processor produce output to the console (see @ref step_17
"step-17") and
3769 * a variable that is used to time the various sections of the program:
3780 * The next group describes the mesh and the finite element space.
3781 * In particular,
for this parallel program, the finite element
3782 * space has associated with it variables that indicate which degrees
3783 * of freedom live on the current processor (the index sets, see
3784 * also @ref step_40
"step-40" and the @ref distributed documentation module) as
3785 * well as a variety of constraints: those imposed by hanging nodes,
3786 * by Dirichlet boundary conditions, and by the active
set of
3788 * here, the
first only contains hanging node constraints, the
3789 *
second also those associated with Dirichlet boundary conditions,
3790 * and the third these plus the contact constraints.
3794 * The variable <code>active_set</code> consists of those degrees
3795 * of freedom constrained by the contact, and we use
3796 * <code>fraction_of_plastic_q_points_per_cell</code> to keep
3797 * track of the fraction of quadrature points on each cell where
3798 * the stress equals the yield stress. The latter is only used to
3799 * create graphical output showing the plastic zone, but not
for
3800 * any further computation; the variable is a member variable of
3801 *
this class since the information is computed as a by-product
3802 * of computing the residual, but is used only much later. (Note
3803 * that the vector is a vector of length
equal to the number of
3804 * active cells on the <i>local mesh</i>; it is never used to
3805 * exchange information between processors and can therefore be
3806 * a regular deal.II vector.)
3809 *
const unsigned int n_initial_global_refinements;
3812 *
const unsigned int fe_degree;
3822 * Vector<float> fraction_of_plastic_q_points_per_cell;
3826 * One difference of
this program is that we declare the quadrature
3827 * formula in the
class declaration. The reason is that in all the other
3828 * programs, it didn
't do much harm if we had used different quadrature
3829 * formulas when computing the matrix and the right hand side, for
3830 * example. However, in the present case it does: we store information in
3831 * the quadrature points, so we have to make sure all parts of the program
3832 * agree on where they are and how many there are on each cell. Thus, let
3833 * us first declare the quadrature formula that will be used throughout...
3836 * const QGauss<dim> quadrature_formula;
3837 * const QGauss<dim - 1> face_quadrature_formula;
3841 * ... and then also have a vector of history objects, one per quadrature
3842 * point on those cells for which we are responsible (i.e. we don't store
3843 * history data
for quadrature points on cells that are owned by other
3847 * std::vector<PointHistory<dim> > quadrature_point_history;
3851 * The way
this object is accessed is through a <code>user pointer</code>
3852 * that each cell, face, or edge holds: it is a <code>
void*</code> pointer
3853 * that can be used by application programs to associate arbitrary data to
3854 * cells, faces, or edges. What the program actually does with
this data
3855 * is within its own responsibility, the library just allocates some space
3856 *
for these pointers, and application programs can
set and read the
3857 * pointers
for each of these objects.
3864 * The next block of variables corresponds to the solution
3865 * and the linear systems we need to form. In particular,
this
3866 * includes the Newton
matrix and right hand side; the vector
3867 * that corresponds to the residual (i.e., the Newton right hand
3868 * side) but from which we have not eliminated the various
3869 * constraints and that is used to determine which degrees of
3870 * freedom need to be constrained in the next iteration; and
3871 * a vector that corresponds to the
diagonal of the @f$B@f$
matrix
3872 * briefly mentioned in the introduction and discussed in the
3873 * accompanying paper.
3885 * The next block of variables is then related to the time dependent
3886 * nature of the problem: they denote the length of the time interval
3887 * which we want to simulate, the present time and number of time step,
3888 * and length of present timestep:
3891 *
double present_time;
3892 *
double present_timestep;
3894 *
unsigned int timestep_no;
3898 * The next block contains the variables that describe the material
3902 *
const double e_modulus, nu, sigma_0,
gamma;
3903 * ConstitutiveLaw<dim> constitutive_law;
3907 * And then there is an assortment of other variables that are used
3908 * to identify the mesh we are asked to build as selected by the
3909 * parameter file, the obstacle that is being pushed into the
3910 * deformable body, the mesh refinement strategy, whether to transfer
3911 * the solution from
one mesh to the next, and how many mesh
3912 * refinement cycles to perform. As possible, we mark these kinds
3913 * of variables as <code>
const</code> to help the reader identify
3914 * which ones may or may not be modified later on (the output directory
3915 * being an exception -- it is never modified outside the constructor
3916 * but it is awkward to initialize in the member-initializer-list
3917 * following the colon in the constructor since there we have only
3918 *
one shot at setting it; the same is
true for the mesh refinement
3922 *
const std::string base_mesh;
3924 *
struct RefinementStrategy
3929 * refine_percentage,
3935 *
struct ErrorEstimationStrategy
3941 * weighted_residual_error,
3942 * weighted_kelly_error
3947 * Vector<float> estimated_error_per_cell;
3949 *
const bool transfer_solution;
3950 * std::string output_dir;
3955 *
unsigned int current_refinement_cycle;
3957 *
const double max_relative_error;
3958 *
float relative_error;
3960 *
const bool show_stresses;
3967 * <a name=
"ImplementationofthecodePlasticityContactProblemcodeclass"></a>
3968 * <h3>Implementation of the <code>PlasticityContactProblem</code>
class</h3>
3973 * <a name=
"PlasticityContactProblemdeclare_parameters"></a>
3974 * <h4>PlasticityContactProblem::declare_parameters</h4>
3978 * Let us start with the declaration of
run-time parameters that can be
3979 * selected in the input file. These values will be read back in the
3980 * constructor of
this class to initialize the member variables of this
3984 *
template <
int dim>
3990 *
"Polynomial degree of the FE_Q finite element space, typically 1 or 2.");
3993 *
"Number of initial global mesh refinement steps before "
3994 *
"the first computation.");
3997 *
"Mesh refinement strategy:\n"
3998 *
" global: one global refinement\n"
3999 *
" percentage: a fixed percentage of cells gets refined using the selected error estimator.");
4000 * prm.
declare_entry(
"error estimation strategy",
"kelly_error",
4002 *
"Error estimation strategy:\n"
4003 *
" kelly_error: Kelly error estimator\n"
4004 *
" residual_error: residual-based error estimator\n"
4005 *
" weighted_residual_error: dual weighted residual (Goal-oriented) error estimator.\n");
4008 *
"maximum relative error which plays the role of a criteria for refinement.");
4011 *
"Number of adaptive mesh refinement cycles to run.");
4014 *
"Directory for output files (graphical output and benchmark "
4015 *
"statistics). If empty, use the current directory.");
4018 *
"Whether the solution should be used as a starting guess "
4019 *
"for the next finer mesh. If false, then the iteration starts at "
4020 *
"zero on every mesh.");
4021 * prm.
declare_entry(
"base mesh",
"Thick_tube_internal_pressure",
4023 *
"Perforated_strip_tension|Cantiliver_beam_3d"),
4024 *
"Select the shape of the domain: 'box' or 'half sphere'");
4027 *
"Elasticity modulus of the material in MPa (N/mm2)");
4030 *
"Poisson's ratio of the material");
4033 *
"Yield stress of the material in MPa (N/mm2)");
4036 *
"Isotropic hardening parameter of the material");
4039 *
"Whether illustrates the stresses and von Mises stresses or not.");
4048 * <a name=
"ThecodePlasticityContactProblemcodeconstructor"></a>
4049 * <h4>The <code>PlasticityContactProblem</code> constructor</h4>
4053 * Given the declarations of member variables as well as the
4054 * declarations of
run-time parameters that are read from the input
4055 * file, there is nothing surprising in
this constructor. In the body
4056 * we initialize the mesh refinement strategy and the output directory,
4057 * creating such a directory
if necessary.
4060 *
template <
int dim>
4061 * ElastoPlasticProblem<dim>::
4064 * mpi_communicator(MPI_COMM_WORLD),
4071 * n_initial_global_refinements (prm.
get_integer(
"number of initial refinements")),
4073 * fe_degree (prm.
get_integer(
"polynomial degree")),
4076 * quadrature_formula (fe_degree + 1),
4077 * face_quadrature_formula (fe_degree + 1),
4079 * e_modulus (prm.
get_double(
"elasticity modulus")),
4083 * constitutive_law (e_modulus,
4088 * base_mesh (prm.
get(
"base mesh")),
4090 * transfer_solution (prm.
get_bool(
"transfer solution")),
4092 * table_results_2(),
4093 * table_results_3(),
4094 * max_relative_error (prm.
get_double(
"maximum relative error")),
4095 * show_stresses (prm.
get_bool(
"show stresses"))
4097 * std::string strat = prm.
get(
"refinement strategy");
4098 *
if (strat ==
"global")
4099 * refinement_strategy = RefinementStrategy::refine_global;
4100 *
else if (strat ==
"percentage")
4101 * refinement_strategy = RefinementStrategy::refine_percentage;
4105 * strat = prm.
get(
"error estimation strategy");
4106 *
if (strat ==
"kelly_error")
4107 * error_estimation_strategy = ErrorEstimationStrategy::kelly_error;
4108 *
else if (strat ==
"residual_error")
4109 * error_estimation_strategy = ErrorEstimationStrategy::residual_error;
4110 *
else if (strat ==
"weighted_residual_error")
4111 * error_estimation_strategy = ErrorEstimationStrategy::weighted_residual_error;
4115 * output_dir = prm.
get(
"output directory");
4116 *
if (output_dir !=
"" && *(output_dir.rbegin()) !=
'/')
4117 * output_dir +=
"/";
4118 * mkdir(output_dir.c_str(), 0777);
4120 * pcout <<
" Using output directory '" << output_dir <<
"'" << std::endl;
4121 * pcout <<
" FE degree " << fe_degree << std::endl;
4122 * pcout <<
" transfer solution "
4123 * << (transfer_solution ?
"true" :
"false") << std::endl;
4131 * <a name=
"PlasticityContactProblemmake_grid"></a>
4132 * <h4>PlasticityContactProblem::make_grid</h4>
4136 * The next block deals with constructing the starting mesh.
4137 * We will use the following helper
function and the
first
4138 * block of the <code>make_grid()</code> to construct a
4139 * mesh that corresponds to a half sphere. deal.II has a
function
4140 * that creates such a mesh, but it is in the wrong location
4141 * and facing the wrong direction, so we need to
shift and
rotate
4142 * it a bit before
using it.
4146 * For later reference, as described in the documentation of
4148 * has boundary indicator
zero,
while the remainder has boundary
4153 * rotate_half_sphere (
const Point<3> &in)
4155 *
return Point<3>(in(2), in(1), -in(0));
4158 *
template <
int dim>
4160 * ElastoPlasticProblem<dim>::make_grid ()
4162 *
if (base_mesh ==
"Timoshenko beam")
4166 *
const double length = .48,
4170 * point_2(length,
depth/2);
4172 * std::vector<unsigned int> repetitions(2);
4173 * repetitions[0] = 4;
4174 * repetitions[1] = 1;
4180 * give the indicators to boundaries
for specification,
4187 * |________________|
4189 * 0 to essential boundary conditions (left edge) which are as
default
4190 * 100 to the
null boundaries (upper and lower edges) where we
do not need to take care of them
4191 * 5 to the natural boundaries (right edge)
for imposing the traction force
4197 *
for (; cell!=endc; ++cell)
4201 *
if (
std::fabs(cell->face(face)->center()(0)-length) < 1
e-12 )
4203 * cell->face(face)->set_manifold_id(5);
4205 *
else if ( (
std::fabs(cell->face(face)->center()(1)-(
depth/2)) < 1
e-12 )
4209 * cell->face(face)->set_manifold_id(100);
4215 *
triangulation.refine_global(n_initial_global_refinements);
4218 *
else if (base_mesh ==
"Thick_tube_internal_pressure")
4222 * Example 1 from the paper: Zhong Z., ....
A new numerical method
for determining
4223 * collapse load-carrying capacity of structure made of elasto-plastic material,
4224 * J. Cent. South Univ. (2014) 21: 398-404
4230 *
const double inner_radius = .1,
4231 * outer_radius = .2;
4233 *
center, inner_radius, outer_radius,
4238 * give the indicators to boundaries
for specification,
4256 * 0 - inner boundary - natural boundary condition - impose the traction force
4257 * 1 - outer boundary -
free boundary - we
do not need to take care of them
4258 * 2 - left boundary - essential boundary condition - constrained to move along the x direction
4259 * 3 - bottom boundary - essential boundary condition - constrained to move along the y direction
4266 *
triangulation.set_manifold (0, inner_boundary_description);
4269 *
triangulation.set_manifold (1, outer_boundary_description);
4271 *
triangulation.refine_global(n_initial_global_refinements);
4277 *
else if (base_mesh ==
"Perforated_strip_tension")
4281 * Example 2 from the paper: Zhong Z., ....
A new numerical method
for determining
4282 * collapse load-carrying capacity of structure made of elasto-plastic material,
4283 * J. Cent. South Univ. (2014) 21: 398-404
4288 *
const int dim_2d = 2;
4290 *
const double inner_radius = 0.05,
4291 * outer_radius = 0.1,
4293 * thickness = 0.004;
4306 *
const double eps = 1
e-7 * inner_radius;
4311 * center_2d, inner_radius, outer_radius,
4316 * Modify the triangulation_1
4320 * cell = triangulation_1.begin_active(),
4321 * endc = triangulation_1.end();
4322 * std::vector<bool> treated_vertices(triangulation_1.n_vertices(),
false);
4323 *
for (; cell != endc; ++cell)
4325 *
for (
unsigned int f=0; f<GeometryInfo<dim_2d>::faces_per_cell; ++f)
4326 *
if (cell->face(f)->at_boundary() && cell->face(f)->center()(0)>
eps &&
4327 * cell->face(f)->center()(1)>
eps )
4334 *
point(0) = cell->face(f)->center()(0) - center_2d(0);
4335 *
point(1) = cell->face(f)->center()(1) - center_2d(1);
4338 *
for (
unsigned int v=0; v < GeometryInfo<dim_2d>::vertices_per_face; ++v)
4340 *
unsigned int vv = cell->face(f)->vertex_index(v);
4341 *
if (treated_vertices[vv] ==
false)
4343 * treated_vertices[vv] =
true;
4346 * cell->face(f)->vertex(v) = center_2d+
Point<dim_2d>(outer_radius,outer_radius);
4359 * Make the triangulation_2, a rectangular above the triangulation_1
4364 * point2 (outer_radius, height);
4372 * make the triangulation_2d and
refine it
4378 * Merge the two triangulation_1 and triangulation_2
4385 * Assign boundary indicators to the boundary faces
4406 * cell = triangulation_2d.begin_active(),
4407 * endc = triangulation_2d.end();
4408 *
for (; cell != endc; ++cell)
4410 *
for (
unsigned int f=0; f<GeometryInfo<dim_2d>::faces_per_cell; ++f)
4412 *
if (cell->face(f)->at_boundary())
4416 * cell->face(f)->set_manifold_id(1);
4418 *
else if (
std::fabs(cell->face(f)->center()(0)-outer_radius) <
eps )
4420 * cell->face(f)->set_manifold_id(2);
4422 *
else if (
std::fabs(cell->face(f)->center()(1)-height) <
eps )
4424 * cell->face(f)->set_manifold_id(3);
4426 *
else if (
std::fabs(cell->face(f)->center()(0)) <
eps )
4428 * cell->face(f)->set_manifold_id(4);
4432 * cell->face(f)->set_all_boundary_ids(10);
4442 * triangulation_2d.set_manifold (10, inner_boundary_description);
4444 * triangulation_2d.refine_global(3);
4446 * triangulation_2d.reset_manifold (10);
4451 * Extrude the triangulation_2d and make it 3
d
4461 * Assign boundary indicators to the boundary faces
4487 *
for (; cell != endc; ++cell)
4489 *
for (
unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
4491 *
if (cell->face(f)->at_boundary())
4493 * dist_vector = cell->face(f)->center() -
center;
4497 * cell->face(f)->set_manifold_id(1);
4499 *
else if (
std::fabs(dist_vector[0]-outer_radius) <
eps )
4501 * cell->face(f)->set_manifold_id(2);
4505 * cell->face(f)->set_manifold_id(3);
4509 * cell->face(f)->set_manifold_id(4);
4513 * cell->face(f)->set_manifold_id(5);
4515 *
else if (
std::fabs(dist_vector[2]-thickness) <
eps )
4517 * cell->face(f)->set_manifold_id(6);
4521 * cell->face(f)->set_all_boundary_ids(10);
4531 *
triangulation.set_manifold (10, inner_boundary_description);
4533 *
triangulation.refine_global(n_initial_global_refinements);
4538 *
else if (base_mesh ==
"Cantiliver_beam_3d")
4542 *
A rectangular tube made of Aluminium
4544 * approximation of beam 17250
4545 * units are in meter
4553 *
const int dim_2d = 2;
4555 *
const double length = .7,
4558 * thickness_web = 10
e-3,
4559 * thickness_flange = 10
e-3;
4567 *
const double eps = 1
e-7 * width;
4570 * Make the triangulation_b, a rectangular at the bottom of rectangular tube
4575 * point2 (width/2, -(height/2)+thickness_flange);
4577 * std::vector<unsigned int> repetitions(dim_2d);
4578 * repetitions[0] = 8;
4579 * repetitions[1] = 1;
4586 * Make the triangulation_t, a rectangular at the top of rectangular tube
4590 *
const Point<dim_2d> point1 (-width/2, (height/2)-thickness_flange),
4591 * point2 (width/2, height/2);
4593 * std::vector<unsigned int> repetitions(dim_2d);
4594 * repetitions[0] = 8;
4595 * repetitions[1] = 1;
4602 * Make the triangulation_l, a rectangular at the left of rectangular tube
4606 *
const Point<dim_2d> point1 (-width/2, -(height/2)+thickness_flange),
4607 * point2 (-(width/2)+thickness_web, (height/2)-thickness_flange);
4609 * std::vector<unsigned int> repetitions(dim_2d);
4610 * repetitions[0] = 1;
4611 * repetitions[1] = 18;
4618 * Make the triangulation_r, a rectangular at the right of rectangular tube
4622 *
const Point<dim_2d> point1 ((width/2)-thickness_web, -(height/2)+thickness_flange),
4623 * point2 (width/2, (height/2)-thickness_flange);
4625 * std::vector<unsigned int> repetitions(dim_2d);
4626 * repetitions[0] = 1;
4627 * repetitions[1] = 18;
4634 * make the triangulation_2d
4640 * merging every two triangles to make triangulation_2d
4644 * triangulation_blr;
4653 * Extrude the triangulation_2d and make it 3
d
4656 *
const unsigned int n_slices = length*1000/20 + 1;
4662 * Assign boundary indicators to the boundary faces
4706 *
for (; cell != endc; ++cell)
4708 *
for (
unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
4710 *
if (cell->face(f)->at_boundary())
4712 * dist_vector = cell->face(f)->center() -
center;
4716 * cell->face(f)->set_manifold_id(1);
4718 *
else if (
std::fabs(dist_vector[1]-(height/2)) <
eps )
4720 * cell->face(f)->set_manifold_id(2);
4724 * cell->face(f)->set_all_boundary_ids(0);
4733 *
triangulation.refine_global(n_initial_global_refinements);
4741 * pcout <<
" Number of active cells: "
4751 * <a name=
"PlasticityContactProblemsetup_system"></a>
4752 * <h4>PlasticityContactProblem::setup_system</h4>
4756 * The next piece in the puzzle is to
set up the
DoFHandler, resize
4757 * vectors and take care of various other status variables such as
4758 * index sets and constraint matrices.
4762 * In the following, each group of operations is put into a brace-enclosed
4763 * block that is being timed by the variable declared at the top of the
4765 * timed section, the destructor that is called at the
end of the block
4769 *
template <
int dim>
4771 * ElastoPlasticProblem<dim>::setup_system ()
4778 * pcout <<
" Number of degrees of freedom: "
4779 * << dof_handler.
n_dofs()
4783 * locally_relevant_dofs.
clear();
4785 * locally_relevant_dofs);
4791 * constraints_hanging_nodes.
reinit(locally_relevant_dofs);
4793 * constraints_hanging_nodes);
4794 * constraints_hanging_nodes.
close();
4796 * pcout <<
" Number of active cells: "
4798 * <<
" Number of degrees of freedom: " << dof_handler.
n_dofs()
4801 * compute_dirichlet_constraints();
4807 *
if (timestep_no==1 || current_refinement_cycle!=0)
4809 * solution.
reinit(locally_relevant_dofs, mpi_communicator);
4811 * incremental_displacement.
reinit(locally_relevant_dofs, mpi_communicator);
4812 * newton_rhs.
reinit(locally_owned_dofs, mpi_communicator);
4813 * newton_rhs_residual.
reinit(locally_owned_dofs, mpi_communicator);
4814 * fraction_of_plastic_q_points_per_cell.reinit(
triangulation.n_active_cells());
4819 * Finally, we
set up sparsity patterns and matrices.
4820 * We temporarily (ab)use the system
matrix to also build the (
diagonal)
4821 *
matrix that we use in eliminating degrees of freedom that are in contact
4822 * with the obstacle, but we then immediately
set the Newton
matrix back
4829 * mpi_communicator);
4832 * constraints_dirichlet_and_hanging_nodes,
false,
4835 * newton_matrix.reinit(sp);
4843 * <a name=
"PlasticityContactProblemcompute_dirichlet_constraints"></a>
4844 * <h4>PlasticityContactProblem::compute_dirichlet_constraints</h4>
4848 * This
function, broken out of the preceding
one, computes the constraints
4849 * associated with Dirichlet-type boundary conditions and puts them into the
4850 * <code>constraints_dirichlet_and_hanging_nodes</code> variable by merging
4851 * with the constraints that come from hanging nodes.
4855 * As laid out in the introduction, we need to distinguish between two
4857 * - If the domain is a box, we
set the displacement to
zero at the bottom,
4858 * and allow vertical movement in z-direction along the sides. As
4859 * shown in the <code>make_grid()</code>
function, the former corresponds
4860 * to boundary indicator 6, the latter to 8.
4861 * - If the domain is a half sphere, then we impose
zero displacement along
4862 * the curved part of the boundary, associated with boundary indicator
zero.
4865 *
template <
int dim>
4867 * ElastoPlasticProblem<dim>::compute_dirichlet_constraints ()
4869 * constraints_dirichlet_and_hanging_nodes.
reinit(locally_relevant_dofs);
4870 * constraints_dirichlet_and_hanging_nodes.
merge(constraints_hanging_nodes);
4872 * std::vector<bool> component_mask(dim);
4874 *
if (base_mesh ==
"Timoshenko beam")
4878 * EquationData::IncrementalBoundaryValues<dim>(present_time, end_time),
4879 * constraints_dirichlet_and_hanging_nodes,
4882 *
else if (base_mesh ==
"Thick_tube_internal_pressure")
4886 * the boundary x = 0
4889 * component_mask[0] =
true;
4890 * component_mask[1] =
false;
4893 * EquationData::IncrementalBoundaryValues<dim>(present_time, end_time),
4894 * constraints_dirichlet_and_hanging_nodes,
4898 * the boundary y = 0
4901 * component_mask[0] =
false;
4902 * component_mask[1] =
true;
4905 * EquationData::IncrementalBoundaryValues<dim>(present_time, end_time),
4906 * constraints_dirichlet_and_hanging_nodes,
4909 *
else if (base_mesh ==
"Perforated_strip_tension")
4913 * the boundary x = 0
4916 * component_mask[0] =
true;
4917 * component_mask[1] =
false;
4918 * component_mask[2] =
false;
4921 * EquationData::IncrementalBoundaryValues<dim>(present_time, end_time),
4922 * constraints_dirichlet_and_hanging_nodes,
4926 * the boundary y = 0
4929 * component_mask[0] =
false;
4930 * component_mask[1] =
true;
4931 * component_mask[2] =
false;
4934 * EquationData::IncrementalBoundaryValues<dim>(present_time, end_time),
4935 * constraints_dirichlet_and_hanging_nodes,
4939 * the boundary y = imposed incremental displacement
4942 * component_mask[0] =
false;
4943 * component_mask[1] =
true;
4944 * component_mask[2] =
false;
4947 * EquationData::IncrementalBoundaryValues<dim>(present_time, end_time),
4948 * constraints_dirichlet_and_hanging_nodes,
4951 *
else if (base_mesh ==
"Cantiliver_beam_3d")
4955 * the boundary x = y = z = 0
4958 * component_mask[0] =
true;
4959 * component_mask[1] =
true;
4960 * component_mask[2] =
true;
4963 * EquationData::IncrementalBoundaryValues<dim>(present_time, end_time),
4964 * constraints_dirichlet_and_hanging_nodes,
4973 * constraints_dirichlet_and_hanging_nodes.
close();
4980 * <a name=
"PlasticityContactProblemassemble_newton_system"></a>
4981 * <h4>PlasticityContactProblem::assemble_newton_system</h4>
4985 * Given the complexity of the problem, it may come as a bit of a surprise
4986 * that assembling the linear system we have to solve in each Newton iteration
4987 * is actually fairly straightforward. The following
function builds the Newton
4988 * right hand side and Newton
matrix. It looks fairly innocent because the
4989 * heavy lifting happens in the
call to
4990 * <code>ConstitutiveLaw::get_linearized_stress_strain_tensors()</code> and in
4992 * constraints we have previously computed.
4995 *
template <
int dim>
4997 * ElastoPlasticProblem<dim>::
5004 *
if (base_mesh ==
"Timoshenko beam")
5006 * traction_surface_id = 5;
5008 *
else if (base_mesh ==
"Thick_tube_internal_pressure")
5010 * traction_surface_id = 0;
5012 *
else if (base_mesh ==
"Cantiliver_beam_3d")
5014 * traction_surface_id = 2;
5028 *
const unsigned int dofs_per_cell = fe.dofs_per_cell;
5029 *
const unsigned int n_q_points = quadrature_formula.size();
5030 *
const unsigned int n_face_q_points = face_quadrature_formula.size();
5033 *
const EquationData::BodyForce<dim> body_force;
5034 * std::vector<Vector<double> > body_force_values(n_q_points,
5037 *
const EquationData::
5038 * IncrementalBoundaryForce<dim> boundary_force(present_time, end_time);
5039 * std::vector<Vector<double> > boundary_force_values(n_face_q_points,
5045 * std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
5049 * std::vector<SymmetricTensor<2, dim> > strain_tensor(n_q_points);
5052 * std::vector<SymmetricTensor<2, dim> > incremental_strain_tensor(n_q_points);
5056 * endc = dof_handler.
end();
5060 *
for (; cell != endc; ++cell)
5061 *
if (cell->is_locally_owned())
5063 * fe_values.reinit(cell);
5067 * fe_values[displacement].get_function_symmetric_gradients(delta_linearization_point,
5068 * incremental_strain_tensor);
5072 * For assembling the local right hand side contributions, we need
5073 * to access the prior linearized stress
value in
this quadrature
5074 *
point. To get it, we use the user pointer of
this cell that
5075 * points into the global array to the quadrature
point data
5076 * corresponding to the
first quadrature
point of the present cell,
5077 * and then add an offset corresponding to the index of the
5078 * quadrature
point we presently consider:
5081 *
const PointHistory<dim> *local_quadrature_points_history
5082 * =
reinterpret_cast<PointHistory<dim>*
>(cell->user_pointer());
5083 *
Assert (local_quadrature_points_history >=
5084 * &quadrature_point_history.front(),
5086 *
Assert (local_quadrature_points_history <
5087 * &quadrature_point_history.back(),
5092 * In addition, we need the values of the external body forces at
5093 * the quadrature points on
this cell:
5096 * body_force.vector_value_list(fe_values.get_quadrature_points(),
5097 * body_force_values);
5099 *
for (
unsigned int q_point = 0; q_point < n_q_points; ++q_point)
5102 * tmp_strain_tensor_qpoint = local_quadrature_points_history[q_point].old_strain
5103 * + incremental_strain_tensor[q_point];
5107 * constitutive_law.get_linearized_stress_strain_tensors(tmp_strain_tensor_qpoint,
5108 * stress_strain_tensor_linearized,
5109 * stress_strain_tensor);
5112 *
for (
unsigned int i = 0; i < dim; ++i)
5114 * rhs_values_body_force[i] = body_force_values[q_point][i];
5117 *
for (
unsigned int i = 0; i < dofs_per_cell; ++i)
5121 * Having computed the stress-strain tensor and its linearization,
5122 * we can now put together the parts of the
matrix and right hand side.
5123 * In both, we need the linearized stress-strain tensor times the
5124 *
symmetric gradient of @f$\varphi_i@f$, i.e. the term @f$I_\Pi\varepsilon(\varphi_i)@f$,
5125 * so we introduce an abbreviation of
this term. Recall that the
5126 *
matrix corresponds to the bilinear form
5127 * @f$A_{ij}=(I_\Pi\varepsilon(\varphi_i),\varepsilon(\varphi_j))@f$ in the
5128 * notation of the accompanying publication, whereas the right
5129 * hand side is @f$F_i=([I_\Pi-P_\Pi
C]\varepsilon(\varphi_i),\varepsilon(\mathbf u))@f$
5130 * where @f$u@f$ is the current linearization points (typically the last solution).
5131 * This might suggest that the right hand side will be
zero if the material
5132 * is completely elastic (where @f$I_\Pi=P_\Pi@f$) but
this ignores the fact
5133 * that the right hand side will also contain contributions from
5134 * non-homogeneous constraints due to the contact.
5138 * The code block that follows
this adds contributions that are due to
5139 * boundary forces, should there be any.
5143 * stress_phi_i = stress_strain_tensor_linearized
5144 * * fe_values[displacement].symmetric_gradient(i, q_point);
5146 *
for (
unsigned int j = 0; j < dofs_per_cell; ++j)
5148 * * fe_values[displacement].symmetric_gradient(j, q_point)
5149 * * fe_values.JxW(q_point));
5153 * * incremental_strain_tensor[q_point] )
5155 * ( ( stress_strain_tensor
5156 * * fe_values[displacement].symmetric_gradient(i, q_point))
5157 * * tmp_strain_tensor_qpoint )
5159 * ( fe_values[displacement].
value(i, q_point)
5160 * * rhs_values_body_force )
5161 * ) * fe_values.JxW(q_point);
5166 *
for (
unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
5167 *
if (cell->face(face)->at_boundary()
5169 * cell->face(face)->boundary_id() == traction_surface_id)
5171 * fe_values_face.reinit(cell, face);
5173 * boundary_force.vector_value_list(fe_values_face.get_quadrature_points(),
5174 * boundary_force_values);
5176 *
for (
unsigned int q_point=0; q_point<n_face_q_points; ++q_point)
5179 *
for (
unsigned int i = 0; i < dim; ++i)
5181 * rhs_values[i] = boundary_force_values[q_point][i];
5183 *
for (
unsigned int i = 0; i < dofs_per_cell; ++i)
5184 * cell_rhs(i) += (fe_values_face[displacement].value(i, q_point)
5186 * * fe_values_face.JxW(q_point));
5190 * cell->get_dof_indices(local_dof_indices);
5192 * local_dof_indices,
5208 * <a name=
"PlasticityContactProblemcompute_nonlinear_residual"></a>
5209 * <h4>PlasticityContactProblem::compute_nonlinear_residual</h4>
5213 * The following
function computes the nonlinear residual of the equation
5214 * given the current solution (or any other linearization
point). This
5215 * is needed in the linear search algorithm where we need to
try various
5216 * linear combinations of previous and current (trial) solution to
5217 * compute the (real, globalized) solution of the current Newton step.
5221 * That said, in a slight abuse of the name of the
function, it actually
5222 * does significantly more. For example, it also computes the vector
5223 * that corresponds to the Newton residual but without eliminating
5224 * constrained degrees of freedom. We need
this vector to compute contact
5225 * forces and, ultimately, to compute the next active
set. Likewise, by
5226 * keeping track of how many quadrature points we encounter on each cell
5227 * that show plastic yielding, we also compute the
5228 * <code>fraction_of_plastic_q_points_per_cell</code> vector that we
5229 * can later output to visualize the plastic zone. In both of these cases,
5230 * the results are not necessary as part of the line search, and so we may
5231 * be wasting a small amount of time computing them. At the same time,
this
5232 * information appears as a natural by-product of what we need to
do here
5233 * anyway, and we want to collect it once at the
end of each Newton
5234 * step, so we may as well
do it here.
5238 * The actual implementation of
this function should be rather obvious:
5241 *
template <
int dim>
5243 * ElastoPlasticProblem<dim>::
5247 *
if (base_mesh ==
"Timoshenko beam")
5249 * traction_surface_id = 5;
5251 *
else if (base_mesh ==
"Thick_tube_internal_pressure")
5253 * traction_surface_id = 0;
5255 *
else if (base_mesh ==
"Cantiliver_beam_3d")
5257 * traction_surface_id = 2;
5272 *
const unsigned int dofs_per_cell = fe.dofs_per_cell;
5273 *
const unsigned int n_q_points = quadrature_formula.size();
5274 *
const unsigned int n_face_q_points = face_quadrature_formula.size();
5276 *
const EquationData::BodyForce<dim> body_force;
5277 * std::vector<Vector<double> > body_force_values(n_q_points,
5280 *
const EquationData::
5281 * IncrementalBoundaryForce<dim> boundary_force(present_time, end_time);
5282 * std::vector<Vector<double> > boundary_force_values(n_face_q_points,
5287 * std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
5291 * newton_rhs_residual = 0;
5293 * fraction_of_plastic_q_points_per_cell = 0;
5297 * endc = dof_handler.
end();
5298 *
unsigned int cell_number = 0;
5299 *
for (; cell != endc; ++cell, ++cell_number)
5300 *
if (cell->is_locally_owned())
5302 * fe_values.reinit(cell);
5305 * std::vector<SymmetricTensor<2, dim> > strain_tensors(n_q_points);
5306 * fe_values[displacement].get_function_symmetric_gradients(linearization_point,
5309 * body_force.vector_value_list(fe_values.get_quadrature_points(),
5310 * body_force_values);
5312 *
for (
unsigned int q_point = 0; q_point < n_q_points; ++q_point)
5315 *
const bool q_point_is_plastic
5316 * = constitutive_law.get_stress_strain_tensor(strain_tensors[q_point],
5317 * stress_strain_tensor);
5318 *
if (q_point_is_plastic)
5319 * ++fraction_of_plastic_q_points_per_cell(cell_number);
5322 *
for (
unsigned int i = 0; i < dim; ++i)
5324 * rhs_values_body_force[i] = body_force_values[q_point][i];
5327 *
for (
unsigned int i = 0; i < dofs_per_cell; ++i)
5329 * cell_rhs(i) += (fe_values[displacement].value(i, q_point)
5330 * * rhs_values_body_force
5332 * strain_tensors[q_point]
5333 * * stress_strain_tensor
5334 * * fe_values[displacement].symmetric_gradient(i, q_point)
5336 * * fe_values.JxW(q_point);
5340 * cell_rhs(i) += (fe_values[displacement].value(i, q_point)
5342 * * fe_values.JxW(q_point));
5346 *
for (
unsigned int face = 0; face < GeometryInfo<dim>::faces_per_cell; ++face)
5347 *
if (cell->face(face)->at_boundary()
5348 * && cell->face(face)->boundary_id() == traction_surface_id)
5350 * fe_values_face.reinit(cell, face);
5352 * boundary_force.vector_value_list(fe_values_face.get_quadrature_points(),
5353 * boundary_force_values);
5355 *
for (
unsigned int q_point = 0; q_point < n_face_q_points;
5359 *
for (
unsigned int i = 0; i < dim; ++i)
5361 * rhs_values[i] = boundary_force_values[q_point][i];
5363 *
for (
unsigned int i = 0; i < dofs_per_cell; ++i)
5364 * cell_rhs(i) += (fe_values_face[displacement].value(i, q_point) * rhs_values
5365 * * fe_values_face.JxW(q_point));
5369 * cell->get_dof_indices(local_dof_indices);
5371 * local_dof_indices,
5372 * newton_rhs_residual);
5376 * fraction_of_plastic_q_points_per_cell /= quadrature_formula.size();
5388 * <a name=
"PlasticityContactProblemsolve_newton_system"></a>
5389 * <h4>PlasticityContactProblem::solve_newton_system</h4>
5393 * The last piece before we can discuss the actual Newton iteration
5394 * on a single mesh is the solver
for the linear systems. There are
5395 * a couple of complications that slightly obscure the code, but
5396 * mostly it is just setup then solve. Among the complications are:
5400 * - For the hanging nodes we have to
apply
5402 * This is necessary
if a hanging node with solution
value @f$x_0@f$
5403 * has
one neighbor with
value @f$x_1@f$ which is in contact with the
5404 * obstacle and
one neighbor @f$x_2@f$ which is not in contact. Because
5405 * the update
for the former will be prescribed, the hanging node constraint
5406 * will have an inhomogeneity and will look like @f$x_0 = x_1/2 + \text{gap}/2@f$.
5407 * So the corresponding entries in the
5408 * ride-hang-side are non-
zero with a
5409 * meaningless
value. These values we have to
5411 * - Like in @ref step_40
"step-40", we need to shuffle between vectors that
do and
do
5412 *
do not have ghost elements when solving or
using the solution.
5416 * The rest of the
function is similar to @ref step_40
"step-40" and
5417 * @ref step_41
"step-41" except that we use a BiCGStab solver
5418 * instead of CG. This is due to the fact that
for very small hardening
5419 * parameters @f$
\gamma@f$, the linear system becomes almost semidefinite though
5420 * still
symmetric. BiCGStab appears to have an easier time with such linear
5424 *
template <
int dim>
5426 * ElastoPlasticProblem<dim>::solve_newton_system ()
5431 * distributed_solution = incremental_displacement;
5433 * constraints_hanging_nodes.
set_zero(distributed_solution);
5434 * constraints_hanging_nodes.
set_zero(newton_rhs);
5438 * -------
Solver Bicgstab --- Preconditioner AMG -------------------
5445 * std::vector<std::vector<bool> > constant_modes;
5455 * additional_data.
w_cycle =
false;
5462 * preconditioner.initialize(newton_matrix, additional_data);
5477 *
const double relative_accuracy = 1
e-2;
5478 *
const double solver_tolerance = relative_accuracy
5479 * * newton_matrix.residual(tmp, distributed_solution,
5485 * solver_tolerance);
5487 * solver.solve(newton_matrix, distributed_solution,
5488 * newton_rhs, preconditioner);
5492 * pcout <<
" Error: " << solver_control.initial_value()
5493 * <<
" -> " << solver_control.last_value() <<
" in "
5494 * << solver_control.last_step() <<
" Bicgstab iterations."
5500 * -------
Solver CG --- Preconditioner SSOR -------------------
5508 * preconditioner.initialize(newton_matrix, additional_data);
5518 *
const double relative_accuracy = 1
e-8;
5521 *
const double relative_accuracy = 1
e-2;
5522 *
const double solver_tolerance = relative_accuracy
5523 * * newton_matrix.residual(tmp, distributed_solution,
5529 * solver_tolerance);
5533 * solver_tolerance);
5535 * solver.solve(newton_matrix, distributed_solution,
5536 * newton_rhs, preconditioner);
5538 * pcout <<
" Error: " << solver_control.initial_value()
5539 * <<
" -> " << solver_control.last_value() <<
" in "
5540 * << solver_control.last_step() <<
" CG iterations."
5545 * ........................................................
5551 * constraints_dirichlet_and_hanging_nodes.
distribute(distributed_solution);
5553 * incremental_displacement = distributed_solution;
5560 * <a name=
"PlasticityContactProblemsolve_newton"></a>
5561 * <h4>PlasticityContactProblem::solve_newton</h4>
5565 * This is,
finally, the
function that implements the damped Newton method
5566 * on the current mesh. There are two nested loops: the outer
loop for the Newton
5567 * iteration and the inner
loop for the line search which
5568 * will be used only
if necessary. To obtain a good and reasonable
5569 * starting
value we solve an elastic problem in very
first Newton step on each
5570 * mesh (or only on the
first mesh
if we transfer solutions between meshes). We
5571 *
do so by setting the yield stress to an unreasonably large
value in these
5572 * iterations and then setting it back to the correct
value in subsequent
5577 * Other than
this, the top part of
this function should be reasonably
5581 *
template <
int dim>
5583 * ElastoPlasticProblem<dim>::solve_newton ()
5592 *
double residual_norm;
5596 * previous_disp_norm = 0;
5598 *
const double correct_sigma = sigma_0;
5600 *
const unsigned int max_newton_iter = 100;
5602 *
for (
unsigned int newton_step = 1; newton_step <= max_newton_iter; ++newton_step)
5604 *
if (newton_step == 1
5606 * ((transfer_solution && timestep_no == 1)
5608 * !transfer_solution))
5609 * constitutive_law.set_sigma_0(1
e+10);
5611 * constitutive_law.set_sigma_0(correct_sigma);
5613 * pcout <<
" " << std::endl;
5614 * pcout <<
" Newton iteration " << newton_step << std::endl;
5616 * pcout <<
" Assembling system... " << std::endl;
5617 * newton_matrix = 0;
5619 * newton_rhs_residual = 0;
5621 * tmp_solution = solution;
5622 * tmp_solution += incremental_displacement;
5623 * assemble_newton_system(tmp_solution,
5624 * incremental_displacement);
5626 * pcout <<
" Solving system... " << std::endl;
5627 * solve_newton_system();
5631 * It gets a bit more hairy after we have computed the
5632 * trial solution @f$\tilde{\mathbf u}@f$ of the current Newton step.
5633 * We handle a highly nonlinear problem so we have to damp
5634 * Newton
's method using a line search. To understand how we do this,
5635 * recall that in our formulation, we compute a trial solution
5636 * in each Newton step and not the update between old and new solution.
5637 * Since the solution set is a convex set, we will use a line
5638 * search that tries linear combinations of the
5639 * previous and the trial solution to guarantee that the
5640 * damped solution is in our solution set again.
5641 * At most we apply 5 damping steps.
5645 * There are exceptions to when we use a line search. First,
5646 * if this is the first Newton step on any mesh, then we don't have
5647 * any
point to compare the residual to, so we
always accept a full
5648 * step. Likewise,
if this is the
second Newton step on the
first mesh (or
5649 * the
second on any mesh
if we don
't transfer solutions from
5650 * mesh to mesh), then we have computed the first of these steps using
5651 * just an elastic model (see how we set the yield stress sigma to
5652 * an unreasonably large value above). In this case, the first Newton
5653 * solution was a purely elastic one, the second one a plastic one,
5654 * and any linear combination would not necessarily be expected to
5655 * lie in the feasible set -- so we just accept the solution we just
5660 * In either of these two cases, we bypass the line search and just
5661 * update residual and other vectors as necessary.
5664 * if ((newton_step==1)
5666 * (transfer_solution && newton_step == 2 && current_refinement_cycle == 0)
5668 * (!transfer_solution && newton_step == 2))
5670 * tmp_solution = solution;
5671 * tmp_solution += incremental_displacement;
5672 * compute_nonlinear_residual(tmp_solution);
5673 * old_solution = incremental_displacement;
5675 * residual = newton_rhs_residual;
5677 * residual.compress(VectorOperation::insert);
5679 * residual_norm = residual.l2_norm();
5681 * pcout << " Accepting Newton solution with residual: "
5682 * << residual_norm << std::endl;
5686 * for (unsigned int i = 0; i < 5; i++)
5688 * distributed_solution = incremental_displacement;
5690 * const double alpha = std::pow(0.5, static_cast<double>(i));
5691 * tmp_vector = old_solution;
5692 * tmp_vector.sadd(1 - alpha, alpha, distributed_solution);
5694 * TimerOutput::Scope t(computing_timer, "Residual and lambda");
5696 * locally_relevant_tmp_vector = tmp_vector;
5697 * tmp_solution = solution;
5698 * tmp_solution += locally_relevant_tmp_vector;
5699 * compute_nonlinear_residual(tmp_solution);
5700 * residual = newton_rhs_residual;
5702 * residual.compress(VectorOperation::insert);
5704 * residual_norm = residual.l2_norm();
5706 * pcout << " Residual of the system: "
5707 * << residual_norm << std::endl
5708 * << " with a damping parameter alpha = " << alpha
5711 * if (residual_norm < previous_residual_norm)
5715 * incremental_displacement = tmp_vector;
5716 * old_solution = incremental_displacement;
5719 * disp_norm = incremental_displacement.l2_norm();
5724 * The final step is to check for convergence. If the residual is
5725 * less than a threshold of @f$10^{-10}@f$, then we terminate
5726 * the iteration on the current mesh:
5727 * if (residual_norm < 1e-10)
5730 * if (residual_norm < 1e-7)
5733 * pcout << " difference of two consecutive incremental displacement l2 norm : "
5734 * << std::abs(disp_norm - previous_disp_norm) << std::endl;
5735 * if ( std::abs(disp_norm - previous_disp_norm) < 1e-10 &&
5736 * (residual_norm < 1e-5 || std::abs(residual_norm - previous_residual_norm)<1e-9) )
5738 * pcout << " Convergence by difference of two consecutive solution! " << std::endl;
5743 * previous_residual_norm = residual_norm;
5744 * previous_disp_norm = disp_norm;
5751 * <a name="PlasticityContactProblemcompute_error"></a>
5752 * <h4>PlasticityContactProblem::compute_error</h4>
5758 * template <int dim>
5760 * ElastoPlasticProblem<dim>::compute_error ()
5762 * TrilinosWrappers::MPI::Vector tmp_solution(locally_owned_dofs, mpi_communicator);
5763 * tmp_solution = solution;
5764 * tmp_solution += incremental_displacement;
5766 * estimated_error_per_cell.reinit (triangulation.n_active_cells());
5767 * if (error_estimation_strategy == ErrorEstimationStrategy::kelly_error)
5769 * using FunctionMap = std::map<types::boundary_id, const Function<dim> *>;
5771 * KellyErrorEstimator<dim>::estimate(dof_handler,
5772 * QGauss<dim - 1>(fe.degree + 2),
5775 * estimated_error_per_cell);
5778 * else if (error_estimation_strategy == ErrorEstimationStrategy::residual_error)
5780 * compute_error_residual(tmp_solution);
5783 * else if (error_estimation_strategy == ErrorEstimationStrategy::weighted_residual_error)
5787 * make a non-parallel copy of tmp_solution
5790 * Vector<double> copy_solution(tmp_solution);
5794 * the dual function definition (it should be defined previously, e.g. input file)
5797 * if (base_mesh == "Timoshenko beam")
5799 * double length = .48,
5802 * const Point<dim> evaluation_point(length, -depth/2);
5804 * DualFunctional::PointValuesEvaluation<dim> dual_functional(evaluation_point);
5806 * DualSolver<dim> dual_solver(triangulation, fe,
5808 * constitutive_law, dual_functional,
5809 * timestep_no, output_dir, base_mesh,
5810 * present_time, end_time);
5812 * dual_solver.compute_error_DWR (estimated_error_per_cell);
5815 * else if (base_mesh == "Thick_tube_internal_pressure")
5817 * const unsigned int face_id = 0;
5818 * std::vector<std::vector<unsigned int> > comp_stress(dim);
5819 * for (unsigned int i=0; i!=dim; ++i)
5821 * comp_stress[i].resize(dim);
5822 * for (unsigned int j=0; j!=dim; ++j)
5824 * comp_stress[i][j] = 1;
5828 * DualFunctional::MeanStressFace<dim> dual_functional(face_id, comp_stress);
5830 * DualSolver<dim> dual_solver(triangulation, fe,
5832 * constitutive_law, dual_functional,
5833 * timestep_no, output_dir, base_mesh,
5834 * present_time, end_time);
5836 * dual_solver.compute_error_DWR (estimated_error_per_cell);
5839 * else if (base_mesh == "Perforated_strip_tension")
5843 * .........................................
5844 * Mean stress_yy over the bottom boundary
5847 * const unsigned int face_id = 1;
5848 * std::vector<std::vector<unsigned int> > comp_stress(dim);
5849 * for (unsigned int i=0; i!=dim; ++i)
5851 * comp_stress[i].resize(dim);
5852 * for (unsigned int j=0; j!=dim; ++j)
5854 * comp_stress[i][j] = 0;
5857 * comp_stress[1][1] = 1;
5859 * DualFunctional::MeanStressFace<dim> dual_functional(face_id, comp_stress);
5863 * .........................................
5869 * DualSolver<dim> dual_solver(triangulation, fe,
5871 * constitutive_law, dual_functional,
5872 * timestep_no, output_dir, base_mesh,
5873 * present_time, end_time);
5875 * dual_solver.compute_error_DWR (estimated_error_per_cell);
5878 * else if (base_mesh == "Cantiliver_beam_3d")
5882 * Quantity of interest:
5883 * -----------------------------------------------------------
5884 * displacement at Point A (x=0, y=height/2, z=length)
5888 * const double length = .7,
5891 * const Point<dim> evaluation_point(0, height/2, length);
5893 * DualFunctional::PointValuesEvaluation<dim> dual_functional(evaluation_point);
5898 * -----------------------------------------------------------
5899 * Mean stress at the specified domain is of interest.
5900 * The interest domains are located on the bottom and top of the flanges
5901 * close to the clamped face, z = 0
5902 * top domain: height/2 - thickness_flange <= y <= height/2
5903 * 0 <= z <= 2 * thickness_flange
5904 * bottom domain: -height/2 <= y <= -height/2 + thickness_flange
5905 * 0 <= z <= 2 * thickness_flange
5911 * std::vector<std::vector<unsigned int> > comp_stress(dim);
5912 * for (unsigned int i=0; i!=dim; ++i)
5914 * comp_stress[i].resize(dim);
5915 * for (unsigned int j=0; j!=dim; ++j)
5917 * comp_stress[i][j] = 1;
5920 * DualFunctional::MeanStressDomain<dim> dual_functional(base_mesh, comp_stress);
5924 * -----------------------------------------------------------
5930 * DualSolver<dim> dual_solver(triangulation, fe,
5932 * constitutive_law, dual_functional,
5933 * timestep_no, output_dir, base_mesh,
5934 * present_time, end_time);
5936 * dual_solver.compute_error_DWR (estimated_error_per_cell);
5941 * AssertThrow(false, ExcNotImplemented());
5948 * AssertThrow(false, ExcNotImplemented());
5952 * relative_error = estimated_error_per_cell.l2_norm() / tmp_solution.l2_norm();
5954 * pcout << "Estimated relative error = " << relative_error << std::endl;
5958 * template <int dim>
5960 * ElastoPlasticProblem<dim>::compute_error_residual (const TrilinosWrappers::MPI::Vector &tmp_solution)
5962 * FEValues<dim> fe_values(fe, quadrature_formula,
5964 * update_gradients |
5966 * update_quadrature_points |
5967 * update_JxW_values);
5969 * const unsigned int n_q_points = quadrature_formula.size();
5970 * std::vector<SymmetricTensor<2, dim> > strain_tensor(n_q_points);
5971 * SymmetricTensor<4, dim> stress_strain_tensor_linearized;
5972 * SymmetricTensor<4, dim> stress_strain_tensor;
5973 * Tensor<5, dim> stress_strain_tensor_grad;
5974 * std::vector<std::vector<Tensor<2,dim> > > cell_hessians (n_q_points);
5975 * for (unsigned int i=0; i!=n_q_points; ++i)
5977 * cell_hessians[i].resize (dim);
5979 * const EquationData::BodyForce<dim> body_force;
5981 * std::vector<Vector<double> > body_force_values (n_q_points, Vector<double>(dim));
5982 * const FEValuesExtractors::Vector displacement(0);
5985 * FEFaceValues<dim> fe_face_values_cell(fe, face_quadrature_formula,
5987 * update_quadrature_points|
5988 * update_gradients |
5989 * update_JxW_values |
5990 * update_normal_vectors),
5991 * fe_face_values_neighbor (fe, face_quadrature_formula,
5993 * update_gradients |
5994 * update_JxW_values |
5995 * update_normal_vectors);
5996 * FESubfaceValues<dim> fe_subface_values_cell (fe, face_quadrature_formula,
5997 * update_gradients);
5999 * const unsigned int n_face_q_points = face_quadrature_formula.size();
6000 * std::vector<Vector<double> > jump_residual (n_face_q_points, Vector<double>(dim));
6001 * std::vector<std::vector<Tensor<1,dim> > > cell_grads(n_face_q_points);
6002 * for (unsigned int i=0; i!=n_face_q_points; ++i)
6004 * cell_grads[i].resize (dim);
6006 * std::vector<std::vector<Tensor<1,dim> > > neighbor_grads(n_face_q_points);
6007 * for (unsigned int i=0; i!=n_face_q_points; ++i)
6009 * neighbor_grads[i].resize (dim);
6011 * SymmetricTensor<2, dim> q_cell_strain_tensor;
6012 * SymmetricTensor<2, dim> q_neighbor_strain_tensor;
6013 * SymmetricTensor<4, dim> cell_stress_strain_tensor;
6014 * SymmetricTensor<4, dim> neighbor_stress_strain_tensor;
6017 * typename std::map<typename DoFHandler<dim>::face_iterator, Vector<double> >
6019 * typename DoFHandler<dim>::active_cell_iterator
6020 * cell = dof_handler.begin_active(),
6021 * endc = dof_handler.end();
6022 * for (; cell!=endc; ++cell)
6023 * if (cell->is_locally_owned())
6025 * for (unsigned int face_no=0;
6026 * face_no<GeometryInfo<dim>::faces_per_cell;
6029 * face_integrals[cell->face(face_no)].reinit (dim);
6030 * face_integrals[cell->face(face_no)] = -1e20;
6034 * std::vector<Vector<float> > error_indicators_vector;
6035 * error_indicators_vector.resize( triangulation.n_active_cells(),
6036 * Vector<float>(dim) );
6040 * ----------------- estimate_some -------------------------
6043 * cell = dof_handler.begin_active();
6044 * unsigned int present_cell = 0;
6045 * for (; cell!=endc; ++cell, ++present_cell)
6046 * if (cell->is_locally_owned())
6050 * --------------- integrate_over_cell -------------------
6053 * fe_values.reinit(cell);
6054 * body_force.vector_value_list(fe_values.get_quadrature_points(),
6055 * body_force_values);
6056 * fe_values[displacement].get_function_symmetric_gradients(tmp_solution,
6058 * fe_values.get_function_hessians(tmp_solution, cell_hessians);
6060 * for (unsigned int q_point = 0; q_point < n_q_points; ++q_point)
6062 * constitutive_law.get_linearized_stress_strain_tensors(strain_tensor[q_point],
6063 * stress_strain_tensor_linearized,
6064 * stress_strain_tensor);
6065 * constitutive_law.get_grad_stress_strain_tensor(strain_tensor[q_point],
6066 * cell_hessians[q_point],
6067 * stress_strain_tensor_grad);
6069 * for (unsigned int i=0; i!=dim; ++i)
6071 * error_indicators_vector[present_cell](i) +=
6072 * body_force_values[q_point](i)*fe_values.JxW(q_point);
6073 * for (unsigned int j=0; j!=dim; ++j)
6075 * for (unsigned int k=0; k!=dim; ++k)
6077 * for (unsigned int l=0; l!=dim; ++l)
6079 * error_indicators_vector[present_cell](i) +=
6080 * ( stress_strain_tensor[i][j][k][l]*
6081 * 0.5*(cell_hessians[q_point][k][l][j]
6083 * cell_hessians[q_point][l][k][j])
6084 * + stress_strain_tensor_grad[i][j][k][l][j] * strain_tensor[q_point][k][l]
6086 * fe_values.JxW(q_point);
6096 * -------------------------------------------------------
6097 * compute face_integrals
6100 * for (unsigned int face_no=0;
6101 * face_no<GeometryInfo<dim>::faces_per_cell;
6104 * if (cell->face(face_no)->at_boundary())
6106 * for (unsigned int id=0; id!=dim; ++id)
6108 * face_integrals[cell->face(face_no)](id) = 0;
6113 * if ((cell->neighbor(face_no)->has_children() == false) &&
6114 * (cell->neighbor(face_no)->level() == cell->level()) &&
6115 * (cell->neighbor(face_no)->index() < cell->index()))
6118 * if (cell->at_boundary(face_no) == false)
6119 * if (cell->neighbor(face_no)->level() < cell->level())
6123 * if (cell->face(face_no)->has_children() == false)
6127 * ------------- integrate_over_regular_face -----------
6130 * fe_face_values_cell.reinit(cell, face_no);
6131 * fe_face_values_cell.get_function_gradients (tmp_solution,
6134 * Assert (cell->neighbor(face_no).state() == IteratorState::valid,
6135 * ExcInternalError());
6136 * const unsigned int
6137 * neighbor_neighbor = cell->neighbor_of_neighbor (face_no);
6138 * const typename DoFHandler<dim>::active_cell_iterator
6139 * neighbor = cell->neighbor(face_no);
6141 * fe_face_values_neighbor.reinit(neighbor, neighbor_neighbor);
6142 * fe_face_values_neighbor.get_function_gradients (tmp_solution,
6145 * for (unsigned int q_point=0; q_point<n_face_q_points; ++q_point)
6147 * q_cell_strain_tensor = 0.;
6148 * q_neighbor_strain_tensor = 0.;
6149 * for (unsigned int i=0; i!=dim; ++i)
6151 * for (unsigned int j=0; j!=dim; ++j)
6153 * q_cell_strain_tensor[i][j] = 0.5*(cell_grads[q_point][i][j] +
6154 * cell_grads[q_point][j][i] );
6155 * q_neighbor_strain_tensor[i][j] = 0.5*(neighbor_grads[q_point][i][j] +
6156 * neighbor_grads[q_point][j][i] );
6160 * constitutive_law.get_stress_strain_tensor (q_cell_strain_tensor,
6161 * cell_stress_strain_tensor);
6162 * constitutive_law.get_stress_strain_tensor (q_neighbor_strain_tensor,
6163 * neighbor_stress_strain_tensor);
6165 * jump_residual[q_point] = 0.;
6166 * for (unsigned int i=0; i!=dim; ++i)
6168 * for (unsigned int j=0; j!=dim; ++j)
6170 * for (unsigned int k=0; k!=dim; ++k)
6172 * for (unsigned int l=0; l!=dim; ++l)
6174 * jump_residual[q_point](i) += (cell_stress_strain_tensor[i][j][k][l]*
6175 * q_cell_strain_tensor[k][l]
6177 * neighbor_stress_strain_tensor[i][j][k][l]*
6178 * q_neighbor_strain_tensor[k][l] )*
6179 * fe_face_values_cell.normal_vector(q_point)[j];
6187 * Vector<double> face_integral_vector(dim);
6188 * face_integral_vector = 0;
6189 * for (unsigned int q_point=0; q_point<n_face_q_points; ++q_point)
6191 * for (unsigned int i=0; i!=dim; ++i)
6193 * face_integral_vector(i) += jump_residual[q_point](i) *
6194 * fe_face_values_cell.JxW(q_point);
6198 * Assert (face_integrals.find (cell->face(face_no)) != face_integrals.end(),
6199 * ExcInternalError());
6201 * for (unsigned int i=0; i!=dim; ++i)
6203 * Assert (face_integrals[cell->face(face_no)](i) == -1e20,
6204 * ExcInternalError());
6205 * face_integrals[cell->face(face_no)](i) = face_integral_vector(i);
6211 * -----------------------------------------------------
6219 * ------------- integrate_over_irregular_face ---------
6222 * const typename DoFHandler<dim>::face_iterator
6223 * face = cell->face(face_no);
6224 * const typename DoFHandler<dim>::cell_iterator
6225 * neighbor = cell->neighbor(face_no);
6226 * Assert (neighbor.state() == IteratorState::valid,
6227 * ExcInternalError());
6228 * Assert (neighbor->has_children(),
6229 * ExcInternalError());
6231 * const unsigned int
6232 * neighbor_neighbor = cell->neighbor_of_neighbor (face_no);
6234 * for (unsigned int subface_no=0;
6235 * subface_no<face->n_children(); ++subface_no)
6237 * const typename DoFHandler<dim>::active_cell_iterator
6238 * neighbor_child = cell->neighbor_child_on_subface (face_no, subface_no);
6239 * Assert (neighbor_child->face(neighbor_neighbor) ==
6240 * cell->face(face_no)->child(subface_no),
6241 * ExcInternalError());
6243 * fe_subface_values_cell.reinit (cell, face_no, subface_no);
6244 * fe_subface_values_cell.get_function_gradients (tmp_solution,
6246 * fe_face_values_neighbor.reinit (neighbor_child,
6247 * neighbor_neighbor);
6248 * fe_face_values_neighbor.get_function_gradients (tmp_solution,
6251 * for (unsigned int q_point=0; q_point<n_face_q_points; ++q_point)
6253 * q_cell_strain_tensor = 0.;
6254 * q_neighbor_strain_tensor = 0.;
6255 * for (unsigned int i=0; i!=dim; ++i)
6257 * for (unsigned int j=0; j!=dim; ++j)
6259 * q_cell_strain_tensor[i][j] = 0.5*(cell_grads[q_point][i][j] +
6260 * cell_grads[q_point][j][i] );
6261 * q_neighbor_strain_tensor[i][j] = 0.5*(neighbor_grads[q_point][i][j] +
6262 * neighbor_grads[q_point][j][i] );
6266 * constitutive_law.get_stress_strain_tensor (q_cell_strain_tensor,
6267 * cell_stress_strain_tensor);
6268 * constitutive_law.get_stress_strain_tensor (q_neighbor_strain_tensor,
6269 * neighbor_stress_strain_tensor);
6271 * jump_residual[q_point] = 0.;
6272 * for (unsigned int i=0; i!=dim; ++i)
6274 * for (unsigned int j=0; j!=dim; ++j)
6276 * for (unsigned int k=0; k!=dim; ++k)
6278 * for (unsigned int l=0; l!=dim; ++l)
6280 * jump_residual[q_point](i) += (-cell_stress_strain_tensor[i][j][k][l]*
6281 * q_cell_strain_tensor[k][l]
6283 * neighbor_stress_strain_tensor[i][j][k][l]*
6284 * q_neighbor_strain_tensor[k][l] )*
6285 * fe_face_values_neighbor.normal_vector(q_point)[j];
6293 * Vector<double> face_integral_vector(dim);
6294 * face_integral_vector = 0;
6295 * for (unsigned int q_point=0; q_point<n_face_q_points; ++q_point)
6297 * for (unsigned int i=0; i!=dim; ++i)
6299 * face_integral_vector(i) += jump_residual[q_point](i) *
6300 * fe_face_values_neighbor.JxW(q_point);
6304 * for (unsigned int i=0; i!=dim; ++i)
6306 * face_integrals[neighbor_child->face(neighbor_neighbor)](i) = face_integral_vector(i);
6311 * Vector<double> sum (dim);
6313 * for (unsigned int subface_no=0;
6314 * subface_no<face->n_children(); ++subface_no)
6316 * Assert (face_integrals.find(face->child(subface_no)) !=
6317 * face_integrals.end(),
6318 * ExcInternalError());
6319 * for (unsigned int i=0; i!=dim; ++i)
6321 * Assert (face_integrals[face->child(subface_no)](i) != -1e20,
6322 * ExcInternalError());
6323 * sum(i) += face_integrals[face->child(subface_no)](i);
6326 * for (unsigned int i=0; i!=dim; ++i)
6328 * face_integrals[face](i) = sum(i);
6334 * -----------------------------------------------------
6344 * ----------------------------------------------------------
6351 * cell = dof_handler.begin_active();
6352 * for (; cell!=endc; ++cell, ++present_cell)
6353 * if (cell->is_locally_owned())
6355 * for (unsigned int face_no=0; face_no<GeometryInfo<dim>::faces_per_cell;
6358 * Assert(face_integrals.find(cell->face(face_no)) !=
6359 * face_integrals.end(),
6360 * ExcInternalError());
6362 * for (unsigned int id=0; id!=dim; ++id)
6364 * error_indicators_vector[present_cell](id)
6365 * -= 0.5*face_integrals[cell->face(face_no)](id);
6370 * estimated_error_per_cell(present_cell) = error_indicators_vector[present_cell].l2_norm();
6380 * <a name="PlasticityContactProblemrefine_grid"></a>
6381 * <h4>PlasticityContactProblem::refine_grid</h4>
6385 * If you've made it
this far into the deal.II tutorial, the following
6386 *
function refining the mesh should not pose any challenges to you
6387 * any more. It refines the mesh, either globally or
using the Kelly
6388 * error estimator, and
if so asked also transfers the solution from
6389 * the previous to the next mesh. In the latter
case, we also need
6390 * to compute the active
set and other quantities again,
for which we
6391 * need the information computed by <code>compute_nonlinear_residual()</code>.
6394 * template <int dim>
6396 * ElastoPlasticProblem<dim>::refine_grid ()
6400 * ---------------------------------------------------------------
6401 * Make a field variable
for history varibales to be able to
6402 * transfer the data to the quadrature points of the
new mesh
6407 * history_dof_handler.distribute_dofs (history_fe);
6408 * std::vector< std::vector< Vector<double> > >
6409 * history_stress_field (dim, std::vector<
Vector<double> >(dim)),
6410 * local_history_stress_values_at_qpoints (dim, std::vector<
Vector<double> >(dim)),
6411 * local_history_stress_fe_values (dim, std::vector<
Vector<double> >(dim));
6414 * std::vector< std::vector< Vector<double> > >
6415 * history_strain_field (dim, std::vector<
Vector<double> >(dim)),
6416 * local_history_strain_values_at_qpoints (dim, std::vector<
Vector<double> >(dim)),
6417 * local_history_strain_fe_values (dim, std::vector<
Vector<double> >(dim));
6419 *
for (
unsigned int i=0; i<dim; i++)
6420 *
for (
unsigned int j=0; j<dim; j++)
6422 * history_stress_field[i][j].reinit(history_dof_handler.n_dofs());
6423 * local_history_stress_values_at_qpoints[i][j].reinit(quadrature_formula.size());
6424 * local_history_stress_fe_values[i][j].reinit(history_fe.dofs_per_cell);
6426 * history_strain_field[i][j].reinit(history_dof_handler.n_dofs());
6427 * local_history_strain_values_at_qpoints[i][j].reinit(quadrature_formula.size());
6428 * local_history_strain_fe_values[i][j].reinit(history_fe.dofs_per_cell);
6431 * quadrature_formula.size());
6434 * quadrature_formula, quadrature_formula,
6435 * qpoint_to_dof_matrix);
6438 * endc = dof_handler.
end(),
6439 * dg_cell = history_dof_handler.begin_active();
6440 *
for (; cell!=endc; ++cell, ++dg_cell)
6441 *
if (cell->is_locally_owned())
6443 * PointHistory<dim> *local_quadrature_points_history
6444 * =
reinterpret_cast<PointHistory<dim> *
>(cell->user_pointer());
6445 *
Assert (local_quadrature_points_history >=
6446 * &quadrature_point_history.front(),
6448 *
Assert (local_quadrature_points_history <
6449 * &quadrature_point_history.back(),
6451 *
for (
unsigned int i=0; i<dim; i++)
6452 *
for (
unsigned int j=0; j<dim; j++)
6454 *
for (
unsigned int q=0; q<quadrature_formula.size(); ++q)
6456 * local_history_stress_values_at_qpoints[i][j](q)
6457 * = local_quadrature_points_history[q].old_stress[i][j];
6459 * local_history_strain_values_at_qpoints[i][j](q)
6460 * = local_quadrature_points_history[q].old_strain[i][j];
6462 * qpoint_to_dof_matrix.vmult (local_history_stress_fe_values[i][j],
6463 * local_history_stress_values_at_qpoints[i][j]);
6464 * dg_cell->set_dof_values (local_history_stress_fe_values[i][j],
6465 * history_stress_field[i][j]);
6467 * qpoint_to_dof_matrix.vmult (local_history_strain_fe_values[i][j],
6468 * local_history_strain_values_at_qpoints[i][j]);
6469 * dg_cell->set_dof_values (local_history_strain_fe_values[i][j],
6470 * history_strain_field[i][j]);
6477 * ---------------------------------------------------------------
6481 *
if (refinement_strategy == RefinementStrategy::refine_global)
6486 *
if (cell->is_locally_owned())
6487 * cell->set_refine_flag ();
6491 *
const double refine_fraction_cells = .3,
6492 * coarsen_fraction_cells = .03;
6495 *
const double refine_fraction_cells = .1,
6496 * coarsen_fraction_cells = .3;
6504 * estimated_error_per_cell,
6505 * refine_fraction_cells, coarsen_fraction_cells);
6512 * solution_transfer.prepare_for_coarsening_and_refinement(solution);
6517 *
if (transfer_solution)
6518 * incremental_displacement_transfer.prepare_for_coarsening_and_refinement(incremental_displacement);
6521 * history_stress_field_transfer1(history_dof_handler),
6522 * history_stress_field_transfer2(history_dof_handler);
6523 * history_stress_field_transfer0.prepare_for_coarsening_and_refinement(history_stress_field[0]);
6526 * history_stress_field_transfer1.prepare_for_coarsening_and_refinement(history_stress_field[1]);
6530 * history_stress_field_transfer2.prepare_for_coarsening_and_refinement(history_stress_field[2]);
6534 * history_strain_field_transfer1(history_dof_handler),
6535 * history_strain_field_transfer2(history_dof_handler);
6536 * history_strain_field_transfer0.prepare_for_coarsening_and_refinement(history_strain_field[0]);
6539 * history_strain_field_transfer1.prepare_for_coarsening_and_refinement(history_strain_field[1]);
6543 * history_strain_field_transfer2.prepare_for_coarsening_and_refinement(history_strain_field[2]);
6547 * pcout <<
" Number of active cells: "
6552 * setup_quadrature_point_history ();
6558 * distributed_solution = solution;
6561 * solution_transfer.interpolate(distributed_solution);
6562 * solution = distributed_solution;
6564 *
if (transfer_solution)
6569 * distributed_incremental_displacement = incremental_displacement;
6572 * incremental_displacement_transfer.interpolate(distributed_incremental_displacement);
6573 * incremental_displacement = distributed_incremental_displacement;
6576 * compute_nonlinear_residual(incremental_displacement);
6583 * ---------------------------------------------------
6586 * history_dof_handler.distribute_dofs (history_fe);
6592 * std::vector< std::vector< Vector<double> > >
6593 * distributed_history_stress_field (dim, std::vector<
Vector<double> >(dim));
6594 *
for (
unsigned int i=0; i<dim; i++)
6595 *
for (
unsigned int j=0; j<dim; j++)
6597 * distributed_history_stress_field[i][j].reinit(history_dof_handler.n_dofs());
6600 * history_stress_field_transfer0.interpolate(history_stress_field[0], distributed_history_stress_field[0]);
6603 * history_stress_field_transfer1.interpolate(history_stress_field[1], distributed_history_stress_field[1]);
6607 * history_stress_field_transfer2.interpolate(history_stress_field[2], distributed_history_stress_field[2]);
6610 * history_stress_field = distributed_history_stress_field;
6617 * std::vector< std::vector< Vector<double> > >
6618 * distributed_history_strain_field (dim, std::vector<
Vector<double> >(dim));
6619 *
for (
unsigned int i=0; i<dim; i++)
6620 *
for (
unsigned int j=0; j<dim; j++)
6622 * distributed_history_strain_field[i][j].reinit(history_dof_handler.n_dofs());
6625 * history_strain_field_transfer0.interpolate(history_strain_field[0], distributed_history_strain_field[0]);
6628 * history_strain_field_transfer1.interpolate(history_strain_field[1], distributed_history_strain_field[1]);
6632 * history_strain_field_transfer2.interpolate(history_strain_field[2], distributed_history_strain_field[2]);
6635 * history_strain_field = distributed_history_strain_field;
6639 * ---------------------------------------------------------------
6640 * Transfer the history data to the quadrature points of the
new mesh
6641 * In a
final step, we have to get the data back from the now
6642 * interpolated global field to the quadrature points on the
6643 *
new mesh. The following code will
do that:
6650 * history_fe.dofs_per_cell);
6653 * quadrature_formula,
6654 * dof_to_qpoint_matrix);
6656 * endc = dof_handler.
end();
6657 * dg_cell = history_dof_handler.begin_active();
6658 *
for (; cell != endc; ++cell, ++dg_cell)
6659 *
if (cell->is_locally_owned())
6661 * PointHistory<dim> *local_quadrature_points_history
6662 * =
reinterpret_cast<PointHistory<dim> *
>(cell->user_pointer());
6663 *
Assert (local_quadrature_points_history >=
6664 * &quadrature_point_history.front(),
6666 *
Assert (local_quadrature_points_history <
6667 * &quadrature_point_history.back(),
6669 *
for (
unsigned int i=0; i<dim; i++)
6670 *
for (
unsigned int j=0; j<dim; j++)
6672 * dg_cell->get_dof_values (history_stress_field[i][j],
6673 * local_history_stress_fe_values[i][j]);
6674 * dof_to_qpoint_matrix.vmult (local_history_stress_values_at_qpoints[i][j],
6675 * local_history_stress_fe_values[i][j]);
6677 * dg_cell->get_dof_values (history_strain_field[i][j],
6678 * local_history_strain_fe_values[i][j]);
6679 * dof_to_qpoint_matrix.vmult (local_history_strain_values_at_qpoints[i][j],
6680 * local_history_strain_fe_values[i][j]);
6681 *
for (
unsigned int q=0; q<quadrature_formula.size(); ++q)
6683 * local_quadrature_points_history[q].old_stress[i][j]
6684 * = local_history_stress_values_at_qpoints[i][j](q);
6686 * local_quadrature_points_history[q].old_strain[i][j]
6687 * = local_history_strain_values_at_qpoints[i][j](q);
6698 * <a name=
"ElastoPlasticProblemsetup_quadrature_point_history"></a>
6699 * <h4>ElastoPlasticProblem::setup_quadrature_point_history</h4>
6703 * At the beginning of our computations, we needed to
set up
initial values
6704 * of the history variables, such as the existing stresses in the material,
6705 * that we store in each quadrature
point. As mentioned above, we use the
6706 * <code>user_pointer</code>
for this that is available in each cell.
6710 * To put
this into larger perspective, we note that
if we had previously
6711 * available stresses in our model (which we assume
do not exist
for the
6712 * purpose of
this program), then we would need to
interpolate the field of
6713 * preexisting stresses to the quadrature points. Likewise,
if we were to
6714 * simulate elasto-plastic materials with hardening/softening, then we would
6715 * have to store additional history variables like the present yield stress
6716 * of the accumulated plastic strains in each quadrature
6717 * points. Pre-existing hardening or weakening would then be implemented by
6718 * interpolating these variables in the present
function as well.
6721 *
template <
int dim>
6722 *
void ElastoPlasticProblem<dim>::setup_quadrature_point_history ()
6726 * What we need to
do here is to
first count how many quadrature points
6727 * are within the responsibility of
this processor. This, of course,
6728 * equals the number of cells that belong to
this processor times the
6729 * number of quadrature points our quadrature formula has on each cell.
6733 * For good measure, we also
set all user pointers of all cells, whether
6734 * ours of not, to the
null pointer. This way,
if we ever access the user
6735 * pointer of a cell which we should not have accessed, a segmentation
6736 * fault will let us know that
this should not have happened:
6739 *
unsigned int our_cells = 0;
6743 *
if (cell->is_locally_owned())
6750 * Next, allocate as many quadrature objects as we need. Since the
6751 * <code>resize</code>
function does not actually shrink the amount of
6752 * allocated memory
if the requested
new size is smaller than the old
6753 * size, we resort to a trick to
first free all memory, and then
6754 * reallocate it: we declare an empty vector as a temporary variable and
6755 * then
swap the contents of the old vector and
this temporary
6756 * variable. This makes sure that the
6757 * <code>quadrature_point_history</code> is now really empty, and we can
6758 * let the temporary variable that now holds the previous contents of the
6759 * vector go out of scope and be destroyed. In the next step. we can then
6760 * re-allocate as many elements as we need, with the vector
6761 *
default-initializing the <code>PointHistory</code> objects, which
6762 * includes setting the stress variables to
zero.
6766 * std::vector<PointHistory<dim> > tmp;
6767 * tmp.swap (quadrature_point_history);
6769 * quadrature_point_history.resize (our_cells *
6770 * quadrature_formula.size());
6774 * Finally
loop over all cells again and
set the user pointers from the
6775 * cells that belong to the present processor to
point to the
first
6776 * quadrature
point objects corresponding to
this cell in the vector of
6780 *
unsigned int history_index = 0;
6784 *
if (cell->is_locally_owned())
6786 * cell->set_user_pointer (&quadrature_point_history[history_index]);
6787 * history_index += quadrature_formula.size();
6792 * At the
end,
for good measure make sure that our count of elements was
6793 * correct and that we have both used up all objects we allocated
6794 * previously, and not
point to any objects beyond the
end of the
6795 * vector. Such defensive programming strategies are
always good checks to
6796 * avoid accidental errors and to guard against future changes to
this
6797 *
function that forget to update all uses of a variable at the same
6798 * time. Recall that constructs
using the <code>
Assert</code> macro are
6799 * optimized away in optimized mode, so
do not affect the
run time of
6803 *
Assert (history_index == quadrature_point_history.size(),
6810 * <a name=
"ElastoPlasticProblemupdate_quadrature_point_history"></a>
6811 * <h4>ElastoPlasticProblem::update_quadrature_point_history</h4>
6815 * At the
end of each time step, we should have computed an incremental
6816 * displacement update so that the material in its
new configuration
6817 * accommodates
for the difference between the external body and boundary
6818 * forces applied during
this time step minus the forces exerted through
6819 * preexisting
internal stresses. In order to have the preexisting
6820 * stresses available at the next time step, we therefore have to update the
6821 * preexisting stresses with the stresses due to the incremental
6822 * displacement computed during the present time step. Ideally, the
6823 * resulting
sum of
internal stresses would exactly counter all external
6824 * forces. Indeed, a simple experiment can make sure that
this is so:
if we
6825 * choose boundary conditions and body forces to be time independent, then
6826 * the forcing terms (the
sum of external forces and
internal stresses)
6827 * should be exactly
zero. If you make
this experiment, you will realize
6828 * from the output of the
norm of the right hand side in each time step that
6829 *
this is almost the
case: it is not exactly
zero, since in the
first time
6830 * step the incremental displacement and stress updates were computed
6831 * relative to the undeformed mesh, which was then deformed. In the
second
6832 * time step, we again compute displacement and stress updates, but
this
6833 * time in the deformed mesh -- there, the resulting updates are very small
6834 * but not quite
zero. This can be iterated, and in each such iteration the
6835 * residual, i.e. the
norm of the right hand side vector, is reduced;
if one
6836 * makes
this little experiment,
one realizes that the
norm of
this residual
6837 * decays exponentially with the number of iterations, and after an
initial
6838 * very rapid decline is reduced by roughly a factor of about 3.5 in each
6839 * iteration (
for one testcase I looked at, other testcases, and other
6840 *
numbers of unknowns change the factor, but not the exponential decay).
6844 * In a sense,
this can then be considered as a quasi-timestepping scheme to
6845 * resolve the nonlinear problem of solving large-deformation elasticity on
6846 * a mesh that is moved along in a Lagrangian manner.
6850 * Another complication is that the existing (old) stresses are defined on
6851 * the old mesh, which we will move around after updating the stresses. If
6852 *
this mesh update involves rotations of the cell, then we need to also
6853 *
rotate the updated stress, since it was computed relative to the
6854 * coordinate system of the old cell.
6858 * Thus, what we need is the following: on each cell which the present
6859 * processor owns, we need to
extract the old stress from the data stored
6860 * with each quadrature
point, compute the stress update, add the two
6861 * together, and then
rotate the result together with the incremental
6862 * rotation computed from the incremental displacement at the present
6863 * quadrature
point. We will detail these steps below:
6866 *
template <
int dim>
6867 *
void ElastoPlasticProblem<dim>::
6868 * update_quadrature_point_history ()
6872 * First,
set up an <code>
FEValues</code>
object by which we will evaluate
6873 * the displacements and the gradients thereof at the
6874 * quadrature points, together with a vector that will hold
this
6882 *
const unsigned int n_q_points = quadrature_formula.size();
6884 * std::vector<SymmetricTensor<2, dim> > incremental_strain_tensor(n_q_points);
6890 * Then
loop over all cells and
do the job in the cells that belong to our
6899 * endc = dof_handler.
end();
6903 *
for (; cell != endc; ++cell)
6904 *
if (cell->is_locally_owned())
6908 * Next, get a pointer to the quadrature
point history data local to
6909 * the present cell, and, as a defensive measure, make sure that
6910 *
this pointer is within the bounds of the global array:
6913 * PointHistory<dim> *local_quadrature_points_history
6914 * =
reinterpret_cast<PointHistory<dim> *
>(cell->user_pointer());
6915 *
Assert (local_quadrature_points_history >=
6916 * &quadrature_point_history.front(),
6918 *
Assert (local_quadrature_points_history <
6919 * &quadrature_point_history.back(),
6924 * Then initialize the <code>
FEValues</code>
object on the present
6925 * cell, and
extract the strains of the displacement at the
6929 * fe_values.reinit (cell);
6930 * fe_values[displacement].get_function_symmetric_gradients(incremental_displacement,
6931 * incremental_strain_tensor);
6935 * Then
loop over the quadrature points of
this cell:
6938 *
for (
unsigned int q=0; q<quadrature_formula.size(); ++q)
6940 * local_quadrature_points_history[q].old_strain +=
6941 * incremental_strain_tensor[q];
6943 * constitutive_law.get_stress_strain_tensor(local_quadrature_points_history[q].old_strain,
6944 * stress_strain_tensor);
6948 * The result of these operations is then written back into
6949 * the original place:
6952 * local_quadrature_points_history[q].old_stress
6953 * = stress_strain_tensor * local_quadrature_points_history[q].old_strain;
6955 * local_quadrature_points_history[q].point
6956 * = fe_values.get_quadrature_points ()[q];
6965 * <a name=
"PlasticityContactProblemmove_mesh"></a>
6966 * <h4>PlasticityContactProblem::move_mesh</h4>
6970 * The remaining three
functions before we get to <code>
run()</code>
6971 * have to
do with generating output. The following
one is an attempt
6972 * at showing the deformed body in its deformed configuration. To
this
6973 *
end,
this function takes a displacement vector field and moves every
6974 * vertex of the (local part) of the mesh by the previously computed
6975 * displacement. We will
call this function with the current
6976 * displacement field before we generate graphical output, and we will
6977 *
call it again after generating graphical output with the negative
6978 * displacement field to undo the changes to the mesh so made.
6982 * The
function itself is pretty straightforward. All we have to
do
6983 * is keep track which
vertices we have already touched, as we
6984 * encounter the same
vertices multiple times as we
loop over cells.
6987 *
template <
int dim>
6989 * ElastoPlasticProblem<dim>::
6992 * std::vector<bool> vertex_touched(
triangulation.n_vertices(),
false);
6996 * cell != dof_handler.
end(); ++cell)
6997 *
if (cell->is_locally_owned())
6998 *
for (
unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_cell; ++v)
6999 *
if (vertex_touched[cell->vertex_index(v)] ==
false)
7001 * vertex_touched[cell->vertex_index(v)] =
true;
7004 *
for (
unsigned int d = 0;
d < dim; ++
d)
7005 * vertex_displacement[
d] = displacement(cell->vertex_dof_index(v,
d));
7007 * cell->vertex(v) += vertex_displacement;
7016 * <a name=
"PlasticityContactProblemoutput_results"></a>
7017 * <h4>PlasticityContactProblem::output_results</h4>
7021 * Next is the
function we use to actually generate graphical output. The
7022 *
function is a bit tedious, but not actually particularly complicated.
7023 * It moves the mesh at the top (and moves it back at the
end), then
7024 * computes the contact forces along the contact surface. We can
do
7025 * so (as shown in the accompanying paper) by taking the untreated
7026 * residual vector and identifying which degrees of freedom
7027 * correspond to those with contact by asking whether they have an
7028 * inhomogeneous constraints associated with them. As
always, we need
7029 * to be mindful that we can only write into completely distributed
7030 * vectors (i.e., vectors without ghost elements) but that when we
7031 * want to generate output, we need vectors that
do indeed have
7032 * ghost entries
for all locally relevant degrees of freedom.
7035 *
template <
int dim>
7037 * ElastoPlasticProblem<dim>::output_results (
const std::string &filename_base)
7041 * pcout <<
" Writing graphical output... " << std::flush;
7045 *
const double magnified_factor = 3;
7046 * magnified_solution *= magnified_factor;
7048 * move_mesh(magnified_solution);
7055 *
const std::vector<DataComponentInterpretation::DataComponentInterpretation>
7058 * std::vector<std::string> (dim,
"displacement"),
7062 * std::vector<std::string> solution_names;
7067 * solution_names.push_back (
"displacement");
7070 * solution_names.push_back (
"x_displacement");
7071 * solution_names.push_back (
"y_displacement");
7074 * solution_names.push_back (
"x_displacement");
7075 * solution_names.push_back (
"y_displacement");
7076 * solution_names.push_back (
"z_displacement");
7087 *
for (
unsigned int i = 0; i < subdomain.size(); ++i)
7093 *
"fraction_of_plastic_q_points");
7100 * In the remainder of the
function, we generate
one VTU file on
7101 * every processor, indexed by the subdomain
id of
this processor.
7102 * On the
first processor, we then also create a <code>.pvtu</code>
7103 * file that indexes <i>all</i> of the VTU files so that the entire
7104 *
set of output files can be read at once. These <code>.pvtu</code>
7105 * are used by Paraview to describe an entire
parallel computation
's
7106 * output files. We then do the same again for the competitor of
7107 * Paraview, the Visit visualization program, by creating a matching
7108 * <code>.visit</code> file.
7111 * const std::string filename =
7112 * (output_dir + filename_base + "-"
7113 * + Utilities::int_to_string(triangulation.locally_owned_subdomain(), 4));
7115 * std::ofstream output_vtu((filename + ".vtu").c_str());
7116 * data_out.write_vtu(output_vtu);
7117 * pcout << output_dir + filename_base << ".pvtu" << std::endl;
7120 * if (this_mpi_process == 0)
7122 * std::vector<std::string> filenames;
7123 * for (unsigned int i = 0; i < n_mpi_processes; ++i)
7124 * filenames.push_back(filename_base + "-" +
7125 * Utilities::int_to_string(i, 4) +
7128 * std::ofstream pvtu_master_output((output_dir + filename_base + ".pvtu").c_str());
7129 * data_out.write_pvtu_record(pvtu_master_output, filenames);
7131 * std::ofstream visit_master_output((output_dir + filename_base + ".visit").c_str());
7132 * data_out.write_pvtu_record(visit_master_output, filenames);
7136 * produce eps files for mesh illustration
7139 * std::ofstream output_eps((filename + ".eps").c_str());
7141 * grid_out.write_eps(triangulation, output_eps);
7146 * Extrapolate the stresses from Gauss point to the nodes
7149 * SymmetricTensor<2, dim> stress_at_qpoint;
7151 * FE_DGQ<dim> history_fe (1);
7152 * DoFHandler<dim> history_dof_handler (triangulation);
7153 * history_dof_handler.distribute_dofs (history_fe);
7154 * std::vector< std::vector< Vector<double> > >
7155 * history_stress_field (dim, std::vector< Vector<double> >(dim)),
7156 * local_history_stress_values_at_qpoints (dim, std::vector< Vector<double> >(dim)),
7157 * local_history_stress_fe_values (dim, std::vector< Vector<double> >(dim));
7158 * for (unsigned int i=0; i<dim; i++)
7159 * for (unsigned int j=0; j<dim; j++)
7161 * history_stress_field[i][j].reinit(history_dof_handler.n_dofs());
7162 * local_history_stress_values_at_qpoints[i][j].reinit(quadrature_formula.size());
7163 * local_history_stress_fe_values[i][j].reinit(history_fe.dofs_per_cell);
7166 * Vector<double> VM_stress_field (history_dof_handler.n_dofs()),
7167 * local_VM_stress_values_at_qpoints (quadrature_formula.size()),
7168 * local_VM_stress_fe_values (history_fe.dofs_per_cell);
7170 * FullMatrix<double> qpoint_to_dof_matrix (history_fe.dofs_per_cell,
7171 * quadrature_formula.size());
7172 * FETools::compute_projection_from_quadrature_points_matrix
7174 * quadrature_formula, quadrature_formula,
7175 * qpoint_to_dof_matrix);
7177 * typename DoFHandler<dim>::active_cell_iterator
7178 * cell = dof_handler.begin_active(),
7179 * endc = dof_handler.end(),
7180 * dg_cell = history_dof_handler.begin_active();
7182 * const FEValuesExtractors::Vector displacement(0);
7184 * for (; cell!=endc; ++cell, ++dg_cell)
7185 * if (cell->is_locally_owned())
7187 * PointHistory<dim> *local_quadrature_points_history
7188 * = reinterpret_cast<PointHistory<dim> *>(cell->user_pointer());
7189 * Assert (local_quadrature_points_history >=
7190 * &quadrature_point_history.front(),
7191 * ExcInternalError());
7192 * Assert (local_quadrature_points_history <
7193 * &quadrature_point_history.back(),
7194 * ExcInternalError());
7198 * Then loop over the quadrature points of this cell:
7201 * for (unsigned int q=0; q<quadrature_formula.size(); ++q)
7203 * stress_at_qpoint = local_quadrature_points_history[q].old_stress;
7205 * for (unsigned int i=0; i<dim; i++)
7206 * for (unsigned int j=i; j<dim; j++)
7208 * local_history_stress_values_at_qpoints[i][j](q) = stress_at_qpoint[i][j];
7211 * local_VM_stress_values_at_qpoints(q) = Evaluation::get_von_Mises_stress(stress_at_qpoint);
7216 * for (unsigned int i=0; i<dim; i++)
7217 * for (unsigned int j=i; j<dim; j++)
7219 * qpoint_to_dof_matrix.vmult (local_history_stress_fe_values[i][j],
7220 * local_history_stress_values_at_qpoints[i][j]);
7221 * dg_cell->set_dof_values (local_history_stress_fe_values[i][j],
7222 * history_stress_field[i][j]);
7225 * qpoint_to_dof_matrix.vmult (local_VM_stress_fe_values,
7226 * local_VM_stress_values_at_qpoints);
7227 * dg_cell->set_dof_values (local_VM_stress_fe_values,
7235 * Save stresses on nodes by nodal averaging
7236 * construct a DoFHandler object based on FE_Q with 1 degree of freedom
7237 * in order to compute stresses on nodes (by applying nodal averaging)
7238 * Therefore, each vertex has one degree of freedom
7241 * FE_Q<dim> fe_1 (1);
7242 * DoFHandler<dim> dof_handler_1 (triangulation);
7243 * dof_handler_1.distribute_dofs (fe_1);
7245 * AssertThrow(dof_handler_1.n_dofs() == triangulation.n_vertices(),
7246 * ExcDimensionMismatch(dof_handler_1.n_dofs(),triangulation.n_vertices()));
7248 * std::vector< std::vector< Vector<double> > >
7249 * history_stress_on_vertices (dim, std::vector< Vector<double> >(dim));
7250 * for (unsigned int i=0; i<dim; i++)
7251 * for (unsigned int j=0; j<dim; j++)
7253 * history_stress_on_vertices[i][j].reinit(dof_handler_1.n_dofs());
7256 * Vector<double> VM_stress_on_vertices (dof_handler_1.n_dofs()),
7257 * counter_on_vertices (dof_handler_1.n_dofs());
7258 * VM_stress_on_vertices = 0;
7259 * counter_on_vertices = 0;
7261 * cell = dof_handler.begin_active();
7262 * dg_cell = history_dof_handler.begin_active();
7263 * typename DoFHandler<dim>::active_cell_iterator
7264 * cell_1 = dof_handler_1.begin_active();
7265 * for (; cell!=endc; ++cell, ++dg_cell, ++cell_1)
7266 * if (cell->is_locally_owned())
7268 * dg_cell->get_dof_values (VM_stress_field,
7269 * local_VM_stress_fe_values);
7271 * for (unsigned int i=0; i<dim; i++)
7272 * for (unsigned int j=0; j<dim; j++)
7274 * dg_cell->get_dof_values (history_stress_field[i][j],
7275 * local_history_stress_fe_values[i][j]);
7278 * for (unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_cell; ++v)
7280 * types::global_dof_index dof_1_vertex = cell_1->vertex_dof_index(v, 0);
7285 * Point<dim> point1, point2;
7286 * point1 = cell_1->vertex(v);
7287 * point2 = dg_cell->vertex(v);
7288 * AssertThrow(point1.distance(point2) < cell->diameter()*1e-8, ExcInternalError());
7295 * counter_on_vertices (dof_1_vertex) += 1;
7297 * VM_stress_on_vertices (dof_1_vertex) += local_VM_stress_fe_values (v);
7299 * for (unsigned int i=0; i<dim; i++)
7300 * for (unsigned int j=0; j<dim; j++)
7302 * history_stress_on_vertices[i][j](dof_1_vertex) +=
7303 * local_history_stress_fe_values[i][j](v);
7309 * for (unsigned int id=0; id<dof_handler_1.n_dofs(); ++id)
7311 * VM_stress_on_vertices(id) /= counter_on_vertices(id);
7313 * for (unsigned int i=0; i<dim; i++)
7314 * for (unsigned int j=0; j<dim; j++)
7316 * history_stress_on_vertices[i][j](id) /= counter_on_vertices(id);
7322 * Save figures of stresses
7325 * if (show_stresses)
7328 * DataOut<dim> data_out;
7329 * data_out.attach_dof_handler (history_dof_handler);
7332 * data_out.add_data_vector (history_stress_field[0][0], "stress_xx");
7333 * data_out.add_data_vector (history_stress_field[1][1], "stress_yy");
7334 * data_out.add_data_vector (history_stress_field[0][1], "stress_xy");
7335 * data_out.add_data_vector (VM_stress_field, "Von_Mises_stress");
7339 * data_out.add_data_vector (history_stress_field[0][2], "stress_xz");
7340 * data_out.add_data_vector (history_stress_field[1][2], "stress_yz");
7341 * data_out.add_data_vector (history_stress_field[2][2], "stress_zz");
7344 * data_out.build_patches ();
7346 * const std::string filename_base_stress = ("stress-" + filename_base);
7348 * const std::string filename =
7349 * (output_dir + filename_base_stress + "-"
7350 * + Utilities::int_to_string(triangulation.locally_owned_subdomain(), 4));
7352 * std::ofstream output_vtu((filename + ".vtu").c_str());
7353 * data_out.write_vtu(output_vtu);
7354 * pcout << output_dir + filename_base_stress << ".pvtu" << std::endl;
7356 * if (this_mpi_process == 0)
7358 * std::vector<std::string> filenames;
7359 * for (unsigned int i = 0; i < n_mpi_processes; ++i)
7360 * filenames.push_back(filename_base_stress + "-" +
7361 * Utilities::int_to_string(i, 4) +
7364 * std::ofstream pvtu_master_output((output_dir + filename_base_stress + ".pvtu").c_str());
7365 * data_out.write_pvtu_record(pvtu_master_output, filenames);
7367 * std::ofstream visit_master_output((output_dir + filename_base_stress + ".visit").c_str());
7368 * data_out.write_pvtu_record(visit_master_output, filenames);
7375 * DataOut<dim> data_out;
7376 * data_out.attach_dof_handler (dof_handler_1);
7379 * data_out.add_data_vector (history_stress_on_vertices[0][0], "stress_xx_averaged");
7380 * data_out.add_data_vector (history_stress_on_vertices[1][1], "stress_yy_averaged");
7381 * data_out.add_data_vector (history_stress_on_vertices[0][1], "stress_xy_averaged");
7382 * data_out.add_data_vector (VM_stress_on_vertices, "Von_Mises_stress_averaged");
7386 * data_out.add_data_vector (history_stress_on_vertices[0][2], "stress_xz_averaged");
7387 * data_out.add_data_vector (history_stress_on_vertices[1][2], "stress_yz_averaged");
7388 * data_out.add_data_vector (history_stress_on_vertices[2][2], "stress_zz_averaged");
7391 * data_out.build_patches ();
7393 * const std::string filename_base_stress = ("averaged-stress-" + filename_base);
7395 * const std::string filename =
7396 * (output_dir + filename_base_stress + "-"
7397 * + Utilities::int_to_string(triangulation.locally_owned_subdomain(), 4));
7399 * std::ofstream output_vtu((filename + ".vtu").c_str());
7400 * data_out.write_vtu(output_vtu);
7401 * pcout << output_dir + filename_base_stress << ".pvtu" << std::endl;
7403 * if (this_mpi_process == 0)
7405 * std::vector<std::string> filenames;
7406 * for (unsigned int i = 0; i < n_mpi_processes; ++i)
7407 * filenames.push_back(filename_base_stress + "-" +
7408 * Utilities::int_to_string(i, 4) +
7411 * std::ofstream pvtu_master_output((output_dir + filename_base_stress + ".pvtu").c_str());
7412 * data_out.write_pvtu_record(pvtu_master_output, filenames);
7414 * std::ofstream visit_master_output((output_dir + filename_base_stress + ".visit").c_str());
7415 * data_out.write_pvtu_record(visit_master_output, filenames);
7422 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7430 * magnified_solution *= -1;
7431 * move_mesh(magnified_solution);
7438 * if (base_mesh == "Timoshenko beam")
7440 * const double length = .48,
7443 * Point<dim> intersted_point(length, -depth/2);
7444 * Point<dim> vertex_displacement;
7445 * bool vertex_found = false;
7447 * for (typename DoFHandler<dim>::active_cell_iterator cell =
7448 * dof_handler.begin_active();
7449 * cell != dof_handler.end(); ++cell)
7450 * if (cell->is_locally_owned() && !vertex_found)
7451 * for (unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_cell; ++v)
7452 * if ( std::fabs(cell->vertex(v)[0] - intersted_point[0])<1e-6 &&
7453 * std::fabs(cell->vertex(v)[1] - intersted_point[1])<1e-6)
7455 * vertex_found = true;
7457 * for (unsigned int d = 0; d < dim; ++d)
7458 * vertex_displacement[d] = solution(cell->vertex_dof_index(v, d));
7463 * pcout << " Number of active cells: "
7464 * << triangulation.n_global_active_cells() << std::endl
7465 * << " Number of degrees of freedom: " << dof_handler.n_dofs()
7468 * AssertThrow(vertex_found, ExcInternalError());
7469 * std::cout << "Displacement at the point (" << intersted_point[0]
7470 * << ", " << intersted_point[1] << ") is "
7471 * << "(" << vertex_displacement[0]
7472 * << ", " << vertex_displacement[1] << ").\n";
7474 * Vector<double> vertex_exact_displacement(dim);
7475 * EquationData::IncrementalBoundaryValues<dim> incremental_boundary_values(present_time, end_time);
7476 * incremental_boundary_values.vector_value (intersted_point, vertex_exact_displacement);
7478 * std::cout << "Exact displacement at the point (" << intersted_point[0]
7479 * << ", " << intersted_point[1] << ") is "
7480 * << "(" << vertex_exact_displacement[0]
7481 * << ", " << vertex_exact_displacement[1] << ").\n\n";
7484 * else if (base_mesh == "Thick_tube_internal_pressure")
7486 * const double pressure (0.6*2.4e8),
7487 * inner_radius (.1);
7490 * const double pressure (1.94e8),
7491 * inner_radius (.1);
7499 * const double mu (((e_modulus*(1+2*nu)) / (std::pow((1+nu),2))) / (2 * (1 + (nu / (1+nu)))));
7500 * 3d and plane strain
7503 * const double mu (e_modulus / (2 * (1 + nu)));
7505 * const Point<dim> point_A(inner_radius, 0.);
7506 * Vector<double> disp_A(dim);
7510 * make a non-parallel copy of solution
7513 * Vector<double> copy_solution(solution);
7515 * Evaluation::PointValuesEvaluation<dim> point_values_evaluation(point_A);
7517 * point_values_evaluation.compute (dof_handler, copy_solution, disp_A);
7519 * table_results.add_value("time step", timestep_no);
7520 * table_results.add_value("Cells", triangulation.n_global_active_cells());
7521 * table_results.add_value("DoFs", dof_handler.n_dofs());
7522 * table_results.add_value("pressure/sigma_0", (pressure*present_time/end_time)/sigma_0);
7523 * table_results.add_value("4*mu*u_A/(sigma_0*a)", 4*mu*disp_A(0)/(sigma_0*inner_radius));
7527 * Compute stresses in the POLAR coordinates, 1- save it on Gauss points,
7528 * 2- extrapolate them to nodes and taking their avarages (nodal avaraging)
7531 * AssertThrow (dim == 2, ExcNotImplemented());
7535 * we define a rotation matrix to be able to transform the stress
7536 * from the Cartesian coordinate to the polar coordinate
7539 * Tensor<2, dim> rotation_matrix; // [cos sin; -sin cos] , sigma_r = rot * sigma * rot^T
7541 * FEValues<dim> fe_values (fe, quadrature_formula, update_quadrature_points |
7542 * update_values | update_gradients);
7544 * const unsigned int n_q_points = quadrature_formula.size();
7546 * std::vector<SymmetricTensor<2, dim> > strain_tensor(n_q_points);
7547 * SymmetricTensor<4, dim> stress_strain_tensor;
7548 * Tensor<2, dim> stress_at_qpoint;
7550 * FE_DGQ<dim> history_fe (1);
7551 * DoFHandler<dim> history_dof_handler (triangulation);
7552 * history_dof_handler.distribute_dofs (history_fe);
7553 * std::vector< std::vector< Vector<double> > >
7554 * history_stress_field (dim, std::vector< Vector<double> >(dim)),
7555 * local_history_stress_values_at_qpoints (dim, std::vector< Vector<double> >(dim)),
7556 * local_history_stress_fe_values (dim, std::vector< Vector<double> >(dim));
7557 * for (unsigned int i=0; i<dim; i++)
7558 * for (unsigned int j=0; j<dim; j++)
7560 * history_stress_field[i][j].reinit(history_dof_handler.n_dofs());
7561 * local_history_stress_values_at_qpoints[i][j].reinit(quadrature_formula.size());
7562 * local_history_stress_fe_values[i][j].reinit(history_fe.dofs_per_cell);
7565 * FullMatrix<double> qpoint_to_dof_matrix (history_fe.dofs_per_cell,
7566 * quadrature_formula.size());
7567 * FETools::compute_projection_from_quadrature_points_matrix
7569 * quadrature_formula, quadrature_formula,
7570 * qpoint_to_dof_matrix);
7572 * typename DoFHandler<dim>::active_cell_iterator
7573 * cell = dof_handler.begin_active(),
7574 * endc = dof_handler.end(),
7575 * dg_cell = history_dof_handler.begin_active();
7577 * const FEValuesExtractors::Vector displacement(0);
7579 * for (; cell!=endc; ++cell, ++dg_cell)
7580 * if (cell->is_locally_owned())
7582 * PointHistory<dim> *local_quadrature_points_history
7583 * = reinterpret_cast<PointHistory<dim> *>(cell->user_pointer());
7584 * Assert (local_quadrature_points_history >=
7585 * &quadrature_point_history.front(),
7586 * ExcInternalError());
7587 * Assert (local_quadrature_points_history <
7588 * &quadrature_point_history.back(),
7589 * ExcInternalError());
7593 * Then loop over the quadrature points of this cell:
7596 * for (unsigned int q=0; q<quadrature_formula.size(); ++q)
7598 * stress_at_qpoint = local_quadrature_points_history[q].old_stress;
7602 * transform the stress from the Cartesian coordinate to the polar coordinate
7605 * const Point<dim> point = local_quadrature_points_history[q].point;
7606 * const double theta = std::atan2(point(1),point(0));
7613 * rotation_matrix[0][0] = std::cos(theta);
7614 * rotation_matrix[0][1] = std::sin(theta);
7615 * rotation_matrix[1][0] = -std::sin(theta);
7616 * rotation_matrix[1][1] = std::cos(theta);
7620 * stress in polar coordinate
7623 * stress_at_qpoint = rotation_matrix * stress_at_qpoint * transpose(rotation_matrix);
7625 * for (unsigned int i=0; i<dim; i++)
7626 * for (unsigned int j=i; j<dim; j++)
7628 * local_history_stress_values_at_qpoints[i][j](q) = stress_at_qpoint[i][j];
7634 * for (unsigned int i=0; i<dim; i++)
7635 * for (unsigned int j=i; j<dim; j++)
7637 * qpoint_to_dof_matrix.vmult (local_history_stress_fe_values[i][j],
7638 * local_history_stress_values_at_qpoints[i][j]);
7639 * dg_cell->set_dof_values (local_history_stress_fe_values[i][j],
7640 * history_stress_field[i][j]);
7646 * DataOut<dim> data_out;
7647 * data_out.attach_dof_handler (history_dof_handler);
7650 * data_out.add_data_vector (history_stress_field[0][0], "stress_rr");
7651 * data_out.add_data_vector (history_stress_field[1][1], "stress_tt");
7652 * data_out.add_data_vector (history_stress_field[0][1], "stress_rt");
7654 * data_out.build_patches ();
7656 * const std::string filename_base_stress = ("stress-polar-" + filename_base);
7658 * const std::string filename =
7659 * (output_dir + filename_base_stress + "-"
7660 * + Utilities::int_to_string(triangulation.locally_owned_subdomain(), 4));
7662 * std::ofstream output_vtu((filename + ".vtu").c_str());
7663 * data_out.write_vtu(output_vtu);
7664 * pcout << output_dir + filename_base_stress << ".pvtu" << std::endl;
7666 * if (this_mpi_process == 0)
7668 * std::vector<std::string> filenames;
7669 * for (unsigned int i = 0; i < n_mpi_processes; ++i)
7670 * filenames.push_back(filename_base_stress + "-" +
7671 * Utilities::int_to_string(i, 4) +
7674 * std::ofstream pvtu_master_output((output_dir + filename_base_stress + ".pvtu").c_str());
7675 * data_out.write_pvtu_record(pvtu_master_output, filenames);
7677 * std::ofstream visit_master_output((output_dir + filename_base_stress + ".visit").c_str());
7678 * data_out.write_pvtu_record(visit_master_output, filenames);
7686 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7687 * construct a DoFHandler object based on FE_Q with 1 degree of freedom
7688 * in order to compute stresses on nodes (by applying nodal averaging)
7689 * Therefore, each vertex has one degree of freedom
7692 * FE_Q<dim> fe_1 (1);
7693 * DoFHandler<dim> dof_handler_1 (triangulation);
7694 * dof_handler_1.distribute_dofs (fe_1);
7696 * AssertThrow(dof_handler_1.n_dofs() == triangulation.n_vertices(),
7697 * ExcDimensionMismatch(dof_handler_1.n_dofs(),triangulation.n_vertices()));
7699 * std::vector< std::vector< Vector<double> > >
7700 * history_stress_on_vertices (dim, std::vector< Vector<double> >(dim));
7701 * for (unsigned int i=0; i<dim; i++)
7702 * for (unsigned int j=0; j<dim; j++)
7704 * history_stress_on_vertices[i][j].reinit(dof_handler_1.n_dofs());
7707 * Vector<double> counter_on_vertices (dof_handler_1.n_dofs());
7708 * counter_on_vertices = 0;
7710 * cell = dof_handler.begin_active();
7711 * dg_cell = history_dof_handler.begin_active();
7712 * typename DoFHandler<dim>::active_cell_iterator
7713 * cell_1 = dof_handler_1.begin_active();
7714 * for (; cell!=endc; ++cell, ++dg_cell, ++cell_1)
7715 * if (cell->is_locally_owned())
7718 * for (unsigned int i=0; i<dim; i++)
7719 * for (unsigned int j=0; j<dim; j++)
7721 * dg_cell->get_dof_values (history_stress_field[i][j],
7722 * local_history_stress_fe_values[i][j]);
7725 * for (unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_cell; ++v)
7727 * types::global_dof_index dof_1_vertex = cell_1->vertex_dof_index(v, 0);
7732 * Point<dim> point1, point2;
7733 * point1 = cell_1->vertex(v);
7734 * point2 = dg_cell->vertex(v);
7735 * AssertThrow(point1.distance(point2) < cell->diameter()*1e-8, ExcInternalError());
7742 * counter_on_vertices (dof_1_vertex) += 1;
7744 * for (unsigned int i=0; i<dim; i++)
7745 * for (unsigned int j=0; j<dim; j++)
7747 * history_stress_on_vertices[i][j](dof_1_vertex) +=
7748 * local_history_stress_fe_values[i][j](v);
7754 * for (unsigned int id=0; id<dof_handler_1.n_dofs(); ++id)
7756 * for (unsigned int i=0; i<dim; i++)
7757 * for (unsigned int j=0; j<dim; j++)
7759 * history_stress_on_vertices[i][j](id) /= counter_on_vertices(id);
7765 * DataOut<dim> data_out;
7766 * data_out.attach_dof_handler (dof_handler_1);
7769 * data_out.add_data_vector (history_stress_on_vertices[0][0], "stress_rr_averaged");
7770 * data_out.add_data_vector (history_stress_on_vertices[1][1], "stress_tt_averaged");
7771 * data_out.add_data_vector (history_stress_on_vertices[0][1], "stress_rt_averaged");
7773 * data_out.build_patches ();
7775 * const std::string filename_base_stress = ("averaged-stress-polar-" + filename_base);
7777 * const std::string filename =
7778 * (output_dir + filename_base_stress + "-"
7779 * + Utilities::int_to_string(triangulation.locally_owned_subdomain(), 4));
7781 * std::ofstream output_vtu((filename + ".vtu").c_str());
7782 * data_out.write_vtu(output_vtu);
7783 * pcout << output_dir + filename_base_stress << ".pvtu" << std::endl;
7785 * if (this_mpi_process == 0)
7787 * std::vector<std::string> filenames;
7788 * for (unsigned int i = 0; i < n_mpi_processes; ++i)
7789 * filenames.push_back(filename_base_stress + "-" +
7790 * Utilities::int_to_string(i, 4) +
7793 * std::ofstream pvtu_master_output((output_dir + filename_base_stress + ".pvtu").c_str());
7794 * data_out.write_pvtu_record(pvtu_master_output, filenames);
7796 * std::ofstream visit_master_output((output_dir + filename_base_stress + ".visit").c_str());
7797 * data_out.write_pvtu_record(visit_master_output, filenames);
7804 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7810 * if ( std::abs( (present_time/end_time)*(pressure/sigma_0) - 0.6 ) <
7811 * .501*(present_timestep/end_time)*(pressure/sigma_0) )
7816 * table_results_2: presenting the stress_rr and stress_tt on the nodes of bottom edge
7819 * const unsigned int face_id = 3;
7821 * std::vector<bool> vertices_found (dof_handler_1.n_dofs(), false);
7823 * bool evaluation_face_found = false;
7825 * typename DoFHandler<dim>::active_cell_iterator
7826 * cell = dof_handler.begin_active(),
7827 * endc = dof_handler.end(),
7828 * cell_1 = dof_handler_1.begin_active();
7829 * for (; cell!=endc; ++cell, ++cell_1)
7830 * if (cell->is_locally_owned())
7832 * for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
7834 * if (cell->face(face)->at_boundary()
7836 * cell->face(face)->boundary_id() == face_id)
7838 * if (!evaluation_face_found)
7840 * evaluation_face_found = true;
7844 * for (unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_face; ++v)
7846 * types::global_dof_index dof_1_vertex =
7847 * cell_1->face(face)->vertex_dof_index(v, 0);
7848 * if (!vertices_found[dof_1_vertex])
7851 * const Point<dim> vertex_coordinate = cell_1->face(face)->vertex(v);
7853 * table_results_2.add_value("x coordinate", vertex_coordinate[0]);
7854 * table_results_2.add_value("stress_rr", history_stress_on_vertices[0][0](dof_1_vertex));
7855 * table_results_2.add_value("stress_tt", history_stress_on_vertices[1][1](dof_1_vertex));
7856 * table_results_2.add_value("pressure/sigma_0", (pressure*present_time/end_time)/sigma_0);
7858 * vertices_found[dof_1_vertex] = true;
7867 * AssertThrow(evaluation_face_found, ExcInternalError());
7871 * table_results_3: presenting the mean stress_rr of the nodes on the inner radius
7874 * const unsigned int face_id_2 = 0;
7876 * Tensor<2, dim> stress_node,
7877 * mean_stress_polar;
7878 * mean_stress_polar = 0;
7880 * std::vector<bool> vertices_found_2 (dof_handler_1.n_dofs(), false);
7881 * unsigned int no_vertices_found = 0;
7883 * evaluation_face_found = false;
7885 * cell = dof_handler.begin_active(),
7886 * endc = dof_handler.end(),
7887 * cell_1 = dof_handler_1.begin_active();
7888 * for (; cell!=endc; ++cell, ++cell_1)
7889 * if (cell->is_locally_owned())
7891 * for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
7893 * if (cell->face(face)->at_boundary()
7895 * cell->face(face)->boundary_id() == face_id_2)
7897 * if (!evaluation_face_found)
7899 * evaluation_face_found = true;
7903 * for (unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_face; ++v)
7905 * types::global_dof_index dof_1_vertex =
7906 * cell_1->face(face)->vertex_dof_index(v, 0);
7907 * if (!vertices_found_2[dof_1_vertex])
7909 * for (unsigned int ir=0; ir<dim; ++ir)
7910 * for (unsigned int ic=0; ic<dim; ++ic)
7911 * stress_node[ir][ic] = history_stress_on_vertices[ir][ic](dof_1_vertex);
7913 * mean_stress_polar += stress_node;
7915 * vertices_found_2[dof_1_vertex] = true;
7916 * ++no_vertices_found;
7925 * AssertThrow(evaluation_face_found, ExcInternalError());
7927 * mean_stress_polar /= no_vertices_found;
7929 * table_results_3.add_value("time step", timestep_no);
7930 * table_results_3.add_value("pressure/sigma_0", (pressure*present_time/end_time)/sigma_0);
7931 * table_results_3.add_value("Cells", triangulation.n_global_active_cells());
7932 * table_results_3.add_value("DoFs", dof_handler.n_dofs());
7933 * table_results_3.add_value("radius", inner_radius);
7934 * table_results_3.add_value("mean stress_rr", mean_stress_polar[0][0]);
7935 * table_results_3.add_value("mean stress_tt", mean_stress_polar[1][1]);
7942 * else if (base_mesh == "Perforated_strip_tension")
7944 * const double imposed_displacement (0.00055),
7945 * inner_radius (0.05);
7950 * const double mu (((e_modulus*(1+2*nu)) / (std::pow((1+nu),2))) / (2 * (1 + (nu / (1+nu)))));
7951 * 3d and plane strain
7955 * table_results: Demonstrates the result of displacement at the top left corner versus imposed tension
7960 * const Point<dim> point_C(0., height);
7961 * Vector<double> disp_C(dim);
7965 * make a non-parallel copy of solution
7968 * Vector<double> copy_solution(solution);
7970 * typename Evaluation::PointValuesEvaluation<dim>::
7971 * PointValuesEvaluation point_values_evaluation(point_C);
7973 * point_values_evaluation.compute (dof_handler, copy_solution, disp_C);
7975 * table_results.add_value("time step", timestep_no);
7976 * table_results.add_value("Cells", triangulation.n_global_active_cells());
7977 * table_results.add_value("DoFs", dof_handler.n_dofs());
7978 * table_results.add_value("4*mu*u_C/(sigma_0*r)", 4*mu*disp_C(1)/(sigma_0*inner_radius));
7984 * compute average sigma_yy on the bottom edge
7987 * double stress_yy_av;
7990 * const unsigned int face_id = 1;
7992 * std::vector<bool> vertices_found (dof_handler_1.n_dofs(), false);
7993 * unsigned int no_vertices_in_face = 0;
7995 * bool evaluation_face_found = false;
7997 * typename DoFHandler<dim>::active_cell_iterator
7998 * cell = dof_handler.begin_active(),
7999 * endc = dof_handler.end(),
8000 * cell_1 = dof_handler_1.begin_active();
8001 * for (; cell!=endc; ++cell, ++cell_1)
8002 * if (cell->is_locally_owned())
8004 * for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
8006 * if (cell->face(face)->at_boundary()
8008 * cell->face(face)->boundary_id() == face_id)
8010 * if (!evaluation_face_found)
8012 * evaluation_face_found = true;
8016 * for (unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_face; ++v)
8018 * types::global_dof_index dof_1_vertex =
8019 * cell_1->face(face)->vertex_dof_index(v, 0);
8020 * if (!vertices_found[dof_1_vertex])
8022 * stress_yy_av += history_stress_on_vertices[1][1](dof_1_vertex);
8023 * ++no_vertices_in_face;
8025 * vertices_found[dof_1_vertex] = true;
8034 * AssertThrow(evaluation_face_found, ExcInternalError());
8036 * stress_yy_av /= no_vertices_in_face;
8042 * table_results_2: Demonstrate the stress_yy on the nodes of bottom edge
8046 * if ( std::abs( (stress_yy_av/sigma_0) - .91 ) < .2 )
8049 * if ( (timestep_no) % 19 == 0 )
8056 * const unsigned int face_id = 1;
8058 * std::vector<bool> vertices_found (dof_handler_1.n_dofs(), false);
8060 * bool evaluation_face_found = false;
8062 * typename DoFHandler<dim>::active_cell_iterator
8063 * cell = dof_handler.begin_active(),
8064 * endc = dof_handler.end(),
8065 * cell_1 = dof_handler_1.begin_active();
8066 * for (; cell!=endc; ++cell, ++cell_1)
8067 * if (cell->is_locally_owned())
8069 * for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
8071 * if (cell->face(face)->at_boundary()
8073 * cell->face(face)->boundary_id() == face_id)
8075 * if (!evaluation_face_found)
8077 * evaluation_face_found = true;
8081 * for (unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_face; ++v)
8083 * types::global_dof_index dof_1_vertex =
8084 * cell_1->face(face)->vertex_dof_index(v, 0);
8086 * const Point<dim> vertex_coordinate = cell_1->face(face)->vertex(v);
8088 * if (!vertices_found[dof_1_vertex] && std::abs(vertex_coordinate[2])<1.e-8)
8090 * table_results_2.add_value("x", vertex_coordinate[0]);
8091 * table_results_2.add_value("x/r", vertex_coordinate[0]/inner_radius);
8092 * table_results_2.add_value("stress_xx/sigma_0", history_stress_on_vertices[0][0](dof_1_vertex)/sigma_0);
8093 * table_results_2.add_value("stress_yy/sigma_0", history_stress_on_vertices[1][1](dof_1_vertex)/sigma_0);
8094 * table_results_2.add_value("stress_yy_av/sigma_0", stress_yy_av/sigma_0);
8095 * table_results_2.add_value("Imposed u_y", (imposed_displacement*present_time/end_time));
8097 * vertices_found[dof_1_vertex] = true;
8106 * AssertThrow(evaluation_face_found, ExcInternalError());
8112 * table_results_3: Demonstrate the Stress_mean (average tensile stress)
8113 * on the bottom edge versus epsilon_yy on the bottom left corner
8117 * double strain_yy_A = 0.;
8121 * compute strain_yy_A
8122 * Since the point A is the node on the bottom left corner,
8123 * we need to work just with one element
8127 * const Point<dim> point_A(inner_radius, 0, 0);
8129 * Vector<double> local_strain_yy_values_at_qpoints (quadrature_formula.size()),
8130 * local_strain_yy_fe_values (history_fe.dofs_per_cell);
8132 * SymmetricTensor<2, dim> strain_at_qpoint;
8134 * typename DoFHandler<dim>::active_cell_iterator
8135 * cell = dof_handler.begin_active(),
8136 * endc = dof_handler.end(),
8137 * dg_cell = history_dof_handler.begin_active();
8139 * bool cell_found = false;
8141 * for (; cell!=endc; ++cell, ++dg_cell)
8142 * if (cell->is_locally_owned() && !cell_found)
8144 * for (unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_cell; ++v)
8145 * if ( std::fabs(cell->vertex(v)[0] - point_A[0])<1e-6 &&
8146 * std::fabs(cell->vertex(v)[1] - point_A[1])<1e-6 &&
8147 * std::fabs(cell->vertex(v)[2] - point_A[2])<1e-6)
8149 * PointHistory<dim> *local_quadrature_points_history
8150 * = reinterpret_cast<PointHistory<dim> *>(cell->user_pointer());
8151 * Assert (local_quadrature_points_history >=
8152 * &quadrature_point_history.front(),
8153 * ExcInternalError());
8154 * Assert (local_quadrature_points_history <
8155 * &quadrature_point_history.back(),
8156 * ExcInternalError());
8160 * Then loop over the quadrature points of this cell:
8163 * for (unsigned int q=0; q<quadrature_formula.size(); ++q)
8165 * strain_at_qpoint = local_quadrature_points_history[q].old_strain;
8167 * local_strain_yy_values_at_qpoints(q) = strain_at_qpoint[1][1];
8170 * qpoint_to_dof_matrix.vmult (local_strain_yy_fe_values,
8171 * local_strain_yy_values_at_qpoints);
8173 * strain_yy_A = local_strain_yy_fe_values (v);
8175 * cell_found = true;
8183 * table_results_3.add_value("time step", timestep_no);
8184 * table_results_3.add_value("Cells", triangulation.n_global_active_cells());
8185 * table_results_3.add_value("DoFs", dof_handler.n_dofs());
8186 * table_results_3.add_value("Imposed u_y", (imposed_displacement*present_time/end_time));
8187 * table_results_3.add_value("mean_tensile_stress/sigma_0", stress_yy_av/sigma_0);
8188 * table_results_3.add_value("E*strain_yy-A/sigma_0", e_modulus*strain_yy_A/sigma_0);
8193 * if (std::abs(present_time-end_time) < 1.e-7)
8195 * table_results_2.set_precision("Imposed u_y", 6);
8196 * table_results_3.set_precision("Imposed u_y", 6);
8200 * else if (base_mesh == "Cantiliver_beam_3d")
8202 * const double pressure (6e6),
8208 * table_results: Demonstrates the result of displacement at the top front point, Point A
8214 * Quantity of interest:
8215 * displacement at Point A (x=0, y=height/2, z=length)
8221 * const Point<dim> point_A(0, height/2, length);
8222 * Vector<double> disp_A(dim);
8226 * make a non-parallel copy of solution
8229 * Vector<double> copy_solution(solution);
8231 * Evaluation::PointValuesEvaluation<dim> point_values_evaluation(point_A);
8233 * point_values_evaluation.compute (dof_handler, copy_solution, disp_A);
8235 * table_results.add_value("time step", timestep_no);
8236 * table_results.add_value("Cells", triangulation.n_global_active_cells());
8237 * table_results.add_value("DoFs", dof_handler.n_dofs());
8238 * table_results.add_value("pressure", pressure*present_time/end_time);
8239 * table_results.add_value("u_A", disp_A(1));
8245 * demonstrate the location and maximum von-Mises stress in the
8246 * specified domain close to the clamped face, z = 0
8247 * top domain: height/2 - thickness_flange <= y <= height/2
8248 * 0 <= z <= 2 * thickness_flange
8249 * bottom domain: -height/2 <= y <= -height/2 + thickness_flange
8250 * 0 <= z <= 2 * thickness_flange
8256 * double VM_stress_max (0);
8257 * Point<dim> point_max;
8259 * SymmetricTensor<2, dim> stress_at_qpoint;
8261 * typename DoFHandler<dim>::active_cell_iterator
8262 * cell = dof_handler.begin_active(),
8263 * endc = dof_handler.end();
8265 * const FEValuesExtractors::Vector displacement(0);
8267 * for (; cell!=endc; ++cell)
8268 * if (cell->is_locally_owned())
8270 * PointHistory<dim> *local_quadrature_points_history
8271 * = reinterpret_cast<PointHistory<dim> *>(cell->user_pointer());
8272 * Assert (local_quadrature_points_history >=
8273 * &quadrature_point_history.front(),
8274 * ExcInternalError());
8275 * Assert (local_quadrature_points_history <
8276 * &quadrature_point_history.back(),
8277 * ExcInternalError());
8281 * Then loop over the quadrature points of this cell:
8284 * for (unsigned int q=0; q<quadrature_formula.size(); ++q)
8286 * stress_at_qpoint = local_quadrature_points_history[q].old_stress;
8288 * const double VM_stress = Evaluation::get_von_Mises_stress(stress_at_qpoint);
8289 * if (VM_stress > VM_stress_max)
8291 * VM_stress_max = VM_stress;
8292 * point_max = local_quadrature_points_history[q].point;
8298 * table_results.add_value("maximum von_Mises stress", VM_stress_max);
8299 * table_results.add_value("x", point_max[0]);
8300 * table_results.add_value("y", point_max[1]);
8301 * table_results.add_value("z", point_max[2]);
8314 * <a name="PlasticityContactProblemrun"></a>
8315 * <h4>PlasticityContactProblem::run</h4>
8319 * As in all other tutorial programs, the <code>run()</code> function contains
8320 * the overall logic. There is not very much to it here: in essence, it
8321 * performs the loops over all mesh refinement cycles, and within each, hands
8322 * things over to the Newton solver in <code>solve_newton()</code> on the
8323 * current mesh and calls the function that creates graphical output for
8324 * the so-computed solution. It then outputs some statistics concerning both
8325 * run times and memory consumption that has been collected over the course of
8326 * computations on this mesh.
8329 * template <int dim>
8331 * ElastoPlasticProblem<dim>::run ()
8333 * computing_timer.reset();
8336 * present_timestep = 1;
8344 * ----------------------------------------------------------------
8345 * base_mesh == "Thick_tube_internal_pressure"
8349 * const Point<dim> center(0, 0);
8350 * const double inner_radius = .1,
8351 * outer_radius = .2;
8353 * const SphericalManifold<dim> inner_boundary_description(center, inner_radius);
8354 * triangulation.set_manifold (0, inner_boundary_description);
8356 * const SphericalManifold<dim> outer_boundary_description(center, outer_radius);
8357 * triangulation.set_manifold (1, outer_boundary_description);
8361 * ----------------------------------------------------------------
8362 * base_mesh == "Perforated_strip_tension"
8366 * const double inner_radius = 0.05;
8368 * const CylinderBoundary<dim> inner_boundary_description(inner_radius, 2);
8369 * triangulation.set_manifold (10, inner_boundary_description);
8373 * ----------------------------------------------------------------
8379 * setup_quadrature_point_history ();
8381 * while (present_time < end_time)
8383 * present_time += present_timestep;
8386 * if (present_time > end_time)
8388 * present_timestep -= (present_time - end_time);
8389 * present_time = end_time;
8391 * pcout << std::endl;
8392 * pcout << "Time step " << timestep_no << " at time " << present_time
8395 * relative_error = max_relative_error * 10;
8396 * current_refinement_cycle = 0;
8403 * ------------------------ Refinement based on the relative error -------------------------------
8409 * while (relative_error >= max_relative_error)
8414 * if ( (timestep_no > 1) && (current_refinement_cycle>0) && (relative_error >= max_relative_error) )
8416 * pcout << "The relative error, " << relative_error
8417 * << " , is still more than maximum relative error, "
8418 * << max_relative_error << ", but we move to the next increment.\n";
8419 * relative_error = .1 * max_relative_error;
8422 * if (relative_error >= max_relative_error)
8424 * TimerOutput::Scope t(computing_timer, "Setup: refine mesh");
8425 * ++current_refinement_cycle;
8433 * ------------------------ Refinement based on the number of refinement --------------------------
8437 * bool continue_loop = true;
8438 * while (continue_loop)
8443 * if ( (timestep_no == 1) && (current_refinement_cycle < 1) )
8445 * TimerOutput::Scope t(computing_timer, "Setup: refine mesh");
8446 * ++current_refinement_cycle;
8450 * continue_loop = false;
8458 * -------------------------------------------------------------------------------------------------
8464 * solution += incremental_displacement;
8466 * update_quadrature_point_history ();
8468 * output_results((std::string("solution-") +
8469 * Utilities::int_to_string(timestep_no, 4)).c_str());
8471 * computing_timer.print_summary();
8472 * computing_timer.reset();
8474 * Utilities::System::MemoryStats stats;
8475 * Utilities::System::get_memory_stats(stats);
8476 * pcout << "Peak virtual memory used, resident in kB: " << stats.VmSize << " "
8477 * << stats.VmRSS << std::endl;
8480 * if (std::abs(present_time-end_time) < 1.e-7)
8482 * const std::string filename = (output_dir + "Results");
8484 * std::ofstream output_txt((filename + ".txt").c_str());
8486 * pcout << std::endl;
8487 * table_results.write_text(output_txt);
8488 * pcout << std::endl;
8489 * table_results_2.write_text(output_txt);
8490 * pcout << std::endl;
8491 * table_results_3.write_text(output_txt);
8492 * pcout << std::endl;
8497 * if (base_mesh == "Thick_tube_internal_pressure")
8499 * triangulation.reset_manifold (0);
8500 * triangulation.reset_manifold (1);
8502 * else if (base_mesh == "Perforated_strip_tension")
8504 * triangulation.reset_manifold (10);
8513 * <a name="Thecodemaincodefunction"></a>
8514 * <h3>The <code>main</code> function</h3>
8518 * There really isn't much to the <code>main()</code>
function. It looks
8522 *
int main (
int argc,
char *argv[])
8524 *
using namespace dealii;
8525 *
using namespace ElastoPlastic;
8531 *
const int dim = 3;
8532 * ElastoPlasticProblem<dim>::declare_parameters(prm);
8535 * std::cerr <<
"*** Call this program as <./elastoplastic input.prm>" << std::endl;
8542 * ElastoPlasticProblem<dim> problem(prm);
8546 *
catch (std::exception &exc)
8548 * std::cerr << std::endl << std::endl
8549 * <<
"----------------------------------------------------"
8551 * std::cerr <<
"Exception on processing: " << std::endl
8552 * << exc.what() << std::endl
8553 * <<
"Aborting!" << std::endl
8554 * <<
"----------------------------------------------------"
8561 * std::cerr << std::endl << std::endl
8562 * <<
"----------------------------------------------------"
8564 * std::cerr <<
"Unknown exception!" << std::endl
8565 * <<
"Aborting!" << std::endl
8566 * <<
"----------------------------------------------------"