deal.II version GIT relicensing-2173-gae8fc9d14b 2024-11-24 06:40:00+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
Quasi_static_Finite_strain_Quasi_incompressible_ViscoElasticity.h
Go to the documentation of this file.
1
223 *  
224 *   #include <deal.II/base/mpi.h>
225 *   #include <deal.II/base/function.h>
226 *   #include <deal.II/base/parameter_handler.h>
227 *   #include <deal.II/base/point.h>
228 *   #include <deal.II/base/quadrature_lib.h>
229 *   #include <deal.II/base/symmetric_tensor.h>
230 *   #include <deal.II/base/tensor.h>
231 *   #include <deal.II/base/timer.h>
232 *   #include <deal.II/base/work_stream.h>
233 *   #include <deal.II/dofs/dof_renumbering.h>
234 *   #include <deal.II/dofs/dof_tools.h>
235 *   #include <deal.II/base/quadrature_point_data.h>
236 *   #include <deal.II/grid/filtered_iterator.h>
237 *   #include <deal.II/grid/grid_generator.h>
238 *   #include <deal.II/grid/grid_tools.h>
239 *   #include <deal.II/grid/grid_in.h>
240 *   #include <deal.II/grid/manifold_lib.h>
241 *   #include <deal.II/grid/tria.h>
242 *   #include <deal.II/fe/fe_dgp_monomial.h>
243 *   #include <deal.II/fe/fe_q.h>
244 *   #include <deal.II/fe/fe_system.h>
245 *   #include <deal.II/fe/fe_tools.h>
246 *   #include <deal.II/fe/fe_values.h>
247 *   #include <deal.II/fe/mapping_q_eulerian.h>
248 *   #include <deal.II/lac/block_sparsity_pattern.h>
249 *   #include <deal.II/lac/dynamic_sparsity_pattern.h>
250 *   #include <deal.II/lac/affine_constraints.h>
251 *   #include <deal.II/lac/full_matrix.h>
252 *   #include <deal.II/lac/solver_selector.h>
253 *   #include <deal.II/lac/trilinos_block_sparse_matrix.h>
254 *   #include <deal.II/lac/trilinos_precondition.h>
255 *   #include <deal.II/lac/trilinos_sparsity_pattern.h>
256 *   #include <deal.II/lac/trilinos_sparse_matrix.h>
257 *   #include <deal.II/lac/trilinos_vector.h>
258 *   #include <deal.II/lac/linear_operator.h>
259 *   #include <deal.II/lac/packaged_operation.h>
260 *   #include <deal.II/lac/trilinos_linear_operator.h>
261 *   #include <deal.II/numerics/data_out.h>
262 *   #include <deal.II/numerics/vector_tools.h>
263 *   #include <deal.II/physics/transformations.h>
264 *   #include <deal.II/physics/elasticity/kinematics.h>
265 *   #include <deal.II/physics/elasticity/standard_tensors.h>
266 *   #include <iostream>
267 *   #include <fstream>
268 *   #include <numeric>
269 *  
270 *   #include <deal.II/grid/grid_out.h>
271 *  
272 *   namespace ViscoElasStripHole
273 *   {
274 *   using namespace dealii;
275 *   namespace LA = TrilinosWrappers;
276 *   namespace Parameters
277 *   {
278 *   struct BoundaryConditions
279 *   {
280 *   BoundaryConditions();
281 *  
282 *   std::string driver;
283 *   double stretch;
284 *   double pressure;
285 *   double load_time;
286 *  
287 *   const types::boundary_id boundary_id_minus_X;
288 *   const types::boundary_id boundary_id_plus_X;
289 *   const types::boundary_id boundary_id_minus_Y;
290 *   const types::boundary_id boundary_id_plus_Y;
291 *   const types::boundary_id boundary_id_minus_Z;
292 *   const types::boundary_id boundary_id_plus_Z;
293 *   const types::boundary_id boundary_id_hole;
294 *   const types::manifold_id manifold_id_hole;
295 *  
296 *   static void
297 *   declare_parameters(ParameterHandler &prm);
298 *   void
299 *   parse_parameters(ParameterHandler &prm);
300 *   };
301 *   BoundaryConditions::BoundaryConditions()
302 *   :
303 *   driver ("Neumann"),
304 *   stretch (2.0),
305 *   pressure(0.0),
306 *   load_time(2.5),
307 *   boundary_id_minus_X (1),
308 *   boundary_id_plus_X (2),
309 *   boundary_id_minus_Y (3),
310 *   boundary_id_plus_Y (4),
311 *   boundary_id_minus_Z (5),
312 *   boundary_id_plus_Z (6),
313 *   boundary_id_hole (10),
314 *   manifold_id_hole (10)
315 *   { }
316 *   void BoundaryConditions::declare_parameters(ParameterHandler &prm)
317 *   {
318 *   prm.enter_subsection("Boundary conditions");
319 *   {
320 *   prm.declare_entry("Driver", "Dirichlet",
321 *   Patterns::Selection("Dirichlet|Neumann"),
322 *   "Driver boundary condition for the problem");
323 *   prm.declare_entry("Final stretch", "2.0",
324 *   Patterns::Double(1.0),
325 *   "Positive stretch applied length-ways to the strip");
326 *   prm.declare_entry("Applied pressure", "0.0",
327 *   Patterns::Double(-1e3,1e3),
328 *   "Hydrostatic pressure applied (in the referential configuration) to the interior surface of the hole");
329 *   prm.declare_entry("Load time", "2.5",
330 *   Patterns::Double(0.0),
331 *   "Total time over which the stretch/pressure is ramped up");
332 *   }
333 *   prm.leave_subsection();
334 *   }
335 *   void BoundaryConditions::parse_parameters(ParameterHandler &prm)
336 *   {
337 *   prm.enter_subsection("Boundary conditions");
338 *   {
339 *   driver = prm.get("Driver");
340 *   stretch = prm.get_double("Final stretch");
341 *   pressure = prm.get_double("Applied pressure");
342 *   load_time = prm.get_double("Load time");
343 *   }
344 *   prm.leave_subsection();
345 *   }
346 *   struct FESystem
347 *   {
348 *   unsigned int poly_degree;
349 *   unsigned int quad_order;
350 *   static void
351 *   declare_parameters(ParameterHandler &prm);
352 *   void
353 *   parse_parameters(ParameterHandler &prm);
354 *   };
355 *   void FESystem::declare_parameters(ParameterHandler &prm)
356 *   {
357 *   prm.enter_subsection("Finite element system");
358 *   {
359 *   prm.declare_entry("Polynomial degree", "2",
360 *   Patterns::Integer(0),
361 *   "Displacement system polynomial order");
362 *   prm.declare_entry("Quadrature order", "3",
363 *   Patterns::Integer(0),
364 *   "Gauss quadrature order");
365 *   }
366 *   prm.leave_subsection();
367 *   }
368 *   void FESystem::parse_parameters(ParameterHandler &prm)
369 *   {
370 *   prm.enter_subsection("Finite element system");
371 *   {
372 *   poly_degree = prm.get_integer("Polynomial degree");
373 *   quad_order = prm.get_integer("Quadrature order");
374 *   }
375 *   prm.leave_subsection();
376 *   }
377 *   struct Geometry
378 *   {
379 *   double length;
380 *   double width;
381 *   double thickness;
382 *   double hole_diameter;
383 *   double hole_division_fraction;
384 *   unsigned int n_repetitions_xy;
385 *   unsigned int n_repetitions_z;
386 *   unsigned int global_refinement;
387 *   double scale;
388 *   static void
389 *   declare_parameters(ParameterHandler &prm);
390 *   void
391 *   parse_parameters(ParameterHandler &prm);
392 *   };
393 *   void Geometry::declare_parameters(ParameterHandler &prm)
394 *   {
395 *   prm.enter_subsection("Geometry");
396 *   {
397 *   prm.declare_entry("Length", "100.0",
398 *   Patterns::Double(0.0),
399 *   "Total sample length");
400 *   prm.declare_entry("Width", "50.0",
401 *   Patterns::Double(0.0),
402 *   "Total sample width");
403 *   prm.declare_entry("Thickness", "5.0",
404 *   Patterns::Double(0.0),
405 *   "Total sample thickness");
406 *   prm.declare_entry("Hole diameter", "20.0",
407 *   Patterns::Double(0.0),
408 *   "Hole diameter");
409 *   prm.declare_entry("Hole division fraction", "0.5",
410 *   Patterns::Double(0.0,1.0),
411 *   "A geometric factor affecting the discretisation near the hole");
412 *   prm.declare_entry("Number of subdivisions in cross-section", "2",
413 *   Patterns::Integer(1.0),
414 *   "A factor defining the number of initial grid subdivisions in the cross-section");
415 *   prm.declare_entry("Number of subdivisions thickness", "6",
416 *   Patterns::Integer(1.0),
417 *   "A factor defining the number of initial grid subdivisions through the thickness");
418 *   prm.declare_entry("Global refinement", "2",
419 *   Patterns::Integer(0),
420 *   "Global refinement level");
421 *   prm.declare_entry("Grid scale", "1e-3",
422 *   Patterns::Double(0.0),
423 *   "Global grid scaling factor");
424 *   }
425 *   prm.leave_subsection();
426 *   }
427 *   void Geometry::parse_parameters(ParameterHandler &prm)
428 *   {
429 *   prm.enter_subsection("Geometry");
430 *   {
431 *   length = prm.get_double("Length");
432 *   width = prm.get_double("Width");
433 *   thickness = prm.get_double("Thickness");
434 *   hole_diameter = prm.get_double("Hole diameter");
435 *   hole_division_fraction = prm.get_double("Hole division fraction");
436 *   n_repetitions_xy = prm.get_integer("Number of subdivisions in cross-section");
437 *   n_repetitions_z = prm.get_integer("Number of subdivisions thickness");
438 *   global_refinement = prm.get_integer("Global refinement");
439 *   scale = prm.get_double("Grid scale");
440 *   }
441 *   prm.leave_subsection();
442 *   }
443 *   struct Materials
444 *   {
445 *   double nu_e;
446 *   double mu_e;
447 *   double mu_v;
448 *   double tau_v;
449 *   static void
450 *   declare_parameters(ParameterHandler &prm);
451 *   void
452 *   parse_parameters(ParameterHandler &prm);
453 *   };
454 *   void Materials::declare_parameters(ParameterHandler &prm)
455 *   {
456 *   prm.enter_subsection("Material properties");
457 *   {
458 *   prm.declare_entry("Poisson's ratio", "0.4999",
459 *   Patterns::Double(-1.0,0.5),
460 *   "Poisson's ratio");
461 *   prm.declare_entry("Elastic shear modulus", "80.194e6",
462 *   Patterns::Double(0.0),
463 *   "Elastic shear modulus");
464 *   prm.declare_entry("Viscous shear modulus", "80.194e6",
465 *   Patterns::Double(0.0),
466 *   "Viscous shear modulus");
467 *   prm.declare_entry("Viscous relaxation time", "2.0",
468 *   Patterns::Double(0.0),
469 *   "Viscous relaxation time");
470 *   }
471 *   prm.leave_subsection();
472 *   }
473 *   void Materials::parse_parameters(ParameterHandler &prm)
474 *   {
475 *   prm.enter_subsection("Material properties");
476 *   {
477 *   nu_e = prm.get_double("Poisson's ratio");
478 *   mu_e = prm.get_double("Elastic shear modulus");
479 *   mu_v = prm.get_double("Viscous shear modulus");
480 *   tau_v = prm.get_double("Viscous relaxation time");
481 *   }
482 *   prm.leave_subsection();
483 *   }
484 *   struct LinearSolver
485 *   {
486 *   std::string type_lin;
487 *   double tol_lin;
488 *   double max_iterations_lin;
489 *   static void
490 *   declare_parameters(ParameterHandler &prm);
491 *   void
492 *   parse_parameters(ParameterHandler &prm);
493 *   };
494 *   void LinearSolver::declare_parameters(ParameterHandler &prm)
495 *   {
496 *   prm.enter_subsection("Linear solver");
497 *   {
498 *   prm.declare_entry("Solver type", "cg",
500 *   "Type of solver used to solve the linear system");
501 *   prm.declare_entry("Residual", "1e-6",
502 *   Patterns::Double(0.0),
503 *   "Linear solver residual (scaled by residual norm)");
504 *   prm.declare_entry("Max iteration multiplier", "1",
505 *   Patterns::Double(1.0),
506 *   "Linear solver iterations (multiples of the system matrix size)");
507 *   }
508 *   prm.leave_subsection();
509 *   }
510 *   void LinearSolver::parse_parameters(ParameterHandler &prm)
511 *   {
512 *   prm.enter_subsection("Linear solver");
513 *   {
514 *   type_lin = prm.get("Solver type");
515 *   tol_lin = prm.get_double("Residual");
516 *   max_iterations_lin = prm.get_double("Max iteration multiplier");
517 *   }
518 *   prm.leave_subsection();
519 *   }
520 *   struct NonlinearSolver
521 *   {
522 *   unsigned int max_iterations_NR;
523 *   double tol_f;
524 *   double tol_u;
525 *   static void
526 *   declare_parameters(ParameterHandler &prm);
527 *   void
528 *   parse_parameters(ParameterHandler &prm);
529 *   };
530 *   void NonlinearSolver::declare_parameters(ParameterHandler &prm)
531 *   {
532 *   prm.enter_subsection("Nonlinear solver");
533 *   {
534 *   prm.declare_entry("Max iterations Newton-Raphson", "10",
535 *   Patterns::Integer(0),
536 *   "Number of Newton-Raphson iterations allowed");
537 *   prm.declare_entry("Tolerance displacement", "1.0e-6",
538 *   Patterns::Double(0.0),
539 *   "Displacement error tolerance");
540 *   prm.declare_entry("Tolerance force", "1.0e-9",
541 *   Patterns::Double(0.0),
542 *   "Force residual tolerance");
543 *   }
544 *   prm.leave_subsection();
545 *   }
546 *   void NonlinearSolver::parse_parameters(ParameterHandler &prm)
547 *   {
548 *   prm.enter_subsection("Nonlinear solver");
549 *   {
550 *   max_iterations_NR = prm.get_integer("Max iterations Newton-Raphson");
551 *   tol_f = prm.get_double("Tolerance force");
552 *   tol_u = prm.get_double("Tolerance displacement");
553 *   }
554 *   prm.leave_subsection();
555 *   }
556 *   struct Time
557 *   {
558 *   double delta_t;
559 *   double end_time;
560 *   static void
561 *   declare_parameters(ParameterHandler &prm);
562 *   void
563 *   parse_parameters(ParameterHandler &prm);
564 *   };
565 *   void Time::declare_parameters(ParameterHandler &prm)
566 *   {
567 *   prm.enter_subsection("Time");
568 *   {
569 *   prm.declare_entry("End time", "1",
570 *   Patterns::Double(),
571 *   "End time");
572 *   prm.declare_entry("Time step size", "0.1",
573 *   Patterns::Double(),
574 *   "Time step size");
575 *   }
576 *   prm.leave_subsection();
577 *   }
578 *   void Time::parse_parameters(ParameterHandler &prm)
579 *   {
580 *   prm.enter_subsection("Time");
581 *   {
582 *   end_time = prm.get_double("End time");
583 *   delta_t = prm.get_double("Time step size");
584 *   }
585 *   prm.leave_subsection();
586 *   }
587 *   struct AllParameters
588 *   : public BoundaryConditions,
589 *   public FESystem,
590 *   public Geometry,
591 *   public Materials,
592 *   public LinearSolver,
593 *   public NonlinearSolver,
594 *   public Time
595 *   {
596 *   AllParameters(const std::string &input_file);
597 *   static void
598 *   declare_parameters(ParameterHandler &prm);
599 *   void
600 *   parse_parameters(ParameterHandler &prm);
601 *   };
602 *   AllParameters::AllParameters(const std::string &input_file)
603 *   {
604 *   ParameterHandler prm;
605 *   declare_parameters(prm);
606 *   prm.parse_input(input_file);
607 *   parse_parameters(prm);
608 *   }
609 *   void AllParameters::declare_parameters(ParameterHandler &prm)
610 *   {
611 *   BoundaryConditions::declare_parameters(prm);
612 *   FESystem::declare_parameters(prm);
613 *   Geometry::declare_parameters(prm);
614 *   Materials::declare_parameters(prm);
615 *   LinearSolver::declare_parameters(prm);
616 *   NonlinearSolver::declare_parameters(prm);
617 *   Time::declare_parameters(prm);
618 *   }
619 *   void AllParameters::parse_parameters(ParameterHandler &prm)
620 *   {
621 *   BoundaryConditions::parse_parameters(prm);
622 *   FESystem::parse_parameters(prm);
623 *   Geometry::parse_parameters(prm);
624 *   Materials::parse_parameters(prm);
625 *   LinearSolver::parse_parameters(prm);
626 *   NonlinearSolver::parse_parameters(prm);
627 *   Time::parse_parameters(prm);
628 *   }
629 *   }
630 *   class Time
631 *   {
632 *   public:
633 *   Time (const double time_end,
634 *   const double delta_t)
635 *   :
636 *   timestep(0),
637 *   time_current(0.0),
638 *   time_end(time_end),
639 *   delta_t(delta_t)
640 *   {}
641 *   virtual ~Time()
642 *   {}
643 *   double current() const
644 *   {
645 *   return time_current;
646 *   }
647 *   double end() const
648 *   {
649 *   return time_end;
650 *   }
651 *   double get_delta_t() const
652 *   {
653 *   return delta_t;
654 *   }
655 *   unsigned int get_timestep() const
656 *   {
657 *   return timestep;
658 *   }
659 *   void increment()
660 *   {
661 *   time_current += delta_t;
662 *   ++timestep;
663 *   }
664 *   private:
665 *   unsigned int timestep;
666 *   double time_current;
667 *   const double time_end;
668 *   const double delta_t;
669 *   };
670 *   template <int dim>
671 *   class Material_Compressible_Three_Field_Linear_Viscoelastic
672 *   {
673 *   public:
674 *   Material_Compressible_Three_Field_Linear_Viscoelastic(const double mu_e,
675 *   const double nu_e,
676 *   const double mu_v,
677 *   const double tau_v,
678 *   const Time &time)
679 *   :
680 *   kappa((2.0 * mu_e * (1.0 + nu_e)) / (3.0 * (1.0 - 2.0 * nu_e))),
681 *   mu_e(mu_e),
682 *   mu_v(mu_v),
683 *   tau_v(tau_v),
684 *   time(time),
687 *   {
688 *   Assert(kappa > 0, ExcInternalError());
689 *   }
690 *   ~Material_Compressible_Three_Field_Linear_Viscoelastic()
691 *   {}
692 *  
694 *   get_tau(const Tensor<2,dim> &F,
695 *   const double &p_tilde) const
696 *   {
697 *   return get_tau_iso(F) + get_tau_vol(F,p_tilde);
698 *   }
699 *   SymmetricTensor<4,dim> get_Jc(const Tensor<2,dim> &F,
700 *   const double &p_tilde) const
701 *   {
702 *   return get_Jc_iso(F) + get_Jc_vol(F,p_tilde);
703 *   }
704 *   double
705 *   get_dPsi_vol_dJ(const double &J_tilde) const
706 *   {
707 *   return (kappa / 2.0) * (J_tilde - 1.0 / J_tilde);
708 *   }
709 *   double
710 *   get_d2Psi_vol_dJ2(const double &J_tilde) const
711 *   {
712 *   return ( (kappa / 2.0) * (1.0 + 1.0 / (J_tilde * J_tilde)));
713 *   }
714 *   void
715 *   update_internal_equilibrium(const Tensor<2, dim> &F,
716 *   const double &/*p_tilde*/,
717 *   const double &/*J_tilde*/)
718 *   {
719 *   const double det_F = determinant(F);
720 *   const SymmetricTensor<2,dim> C_bar = std::pow(det_F, -2.0 / dim) * Physics::Elasticity::Kinematics::C(F);
721 * @endcode
722 *
723 * Linder2011 eq 54
724 * Assumes first-oder backward Euler time discretisation
725 *
726 * @code
727 *   Q_n_t = (1.0/(1.0 + time.get_delta_t()/tau_v))*(Q_t1 + (time.get_delta_t()/tau_v)*invert(C_bar));
728 *   }
729 *   void
730 *   update_end_timestep()
731 *   {
732 *   Q_t1 = Q_n_t;
733 *   }
734 *  
735 *   protected:
736 *   const double kappa;
737 *   const double mu_e;
738 *   const double mu_v;
739 *   const double tau_v;
740 *   const Time &time;
741 *   SymmetricTensor<2,dim> Q_n_t; // Value of internal variable at this Newton step and timestep
742 *   SymmetricTensor<2,dim> Q_t1; // Value of internal variable at the previous timestep
743 *  
745 *   get_tau_vol(const Tensor<2,dim> &F,
746 *   const double &p_tilde) const
747 *   {
748 *   const double det_F = determinant(F);
749 *  
750 *   return p_tilde * det_F * Physics::Elasticity::StandardTensors<dim>::I;
751 *   }
753 *   get_tau_iso(const Tensor<2,dim> &F) const
754 *   {
755 *   return Physics::Elasticity::StandardTensors<dim>::dev_P * get_tau_bar(F);
756 *   }
758 *   get_tau_bar(const Tensor<2,dim> &F) const
759 *   {
760 *   const double det_F = determinant(F);
761 *   const Tensor<2,dim> F_bar = std::pow(det_F, -1.0 / dim) * F;
762 *   const SymmetricTensor<2,dim> b_bar = std::pow(det_F, -2.0 / dim) * symmetrize(F * transpose(F));
763 * @endcode
764 *
765 * Elastic Neo-Hookean + Linder2011 eq 47
766 *
767 * @code
768 *   return mu_e * b_bar
769 *   + mu_v * symmetrize(F_bar*static_cast<Tensor<2,dim> >(Q_n_t)*transpose(F_bar));
770 *   }
771 *   SymmetricTensor<4, dim> get_Jc_vol(const Tensor<2,dim> &F,
772 *   const double &p_tilde) const
773 *   {
774 *   const double det_F = determinant(F);
775 *   return p_tilde * det_F
778 *   }
779 *   SymmetricTensor<4, dim> get_Jc_iso(const Tensor<2,dim> &F) const
780 *   {
781 *   const SymmetricTensor<2, dim> tau_bar = get_tau_bar(F);
782 *   const SymmetricTensor<2, dim> tau_iso = get_tau_iso(F);
783 *   const SymmetricTensor<4, dim> tau_iso_x_I
784 *   = outer_product(tau_iso,
786 *   const SymmetricTensor<4, dim> I_x_tau_iso
788 *   tau_iso);
789 *   const SymmetricTensor<4, dim> c_bar = get_c_bar(F);
790 *   return (2.0 / dim) * trace(tau_bar)
792 *   - (2.0 / dim) * (tau_iso_x_I + I_x_tau_iso)
795 *   }
796 *   SymmetricTensor<4, dim> get_c_bar(const Tensor<2,dim> &/*F*/) const
797 *   {
798 * @endcode
799 *
800 * Elastic Neo-Hookean + Linder2011 eq 56
801 *
802 * @code
803 *   return -2.0*mu_v*((time.get_delta_t()/tau_v)/(1.0 + time.get_delta_t()/tau_v))*Physics::Elasticity::StandardTensors<dim>::S;
804 *   }
805 *   };
806 *   template <int dim>
807 *   class PointHistory
808 *   {
809 *   public:
810 *   PointHistory()
811 *   {}
812 *   virtual ~PointHistory()
813 *   {}
814 *   void
815 *   setup_lqp (const Parameters::AllParameters &parameters,
816 *   const Time &time)
817 *   {
818 *   material.reset(new Material_Compressible_Three_Field_Linear_Viscoelastic<dim>(
819 *   parameters.mu_e, parameters.nu_e,
820 *   parameters.mu_v, parameters.tau_v,
821 *   time));
822 *   }
823 *  
825 *   get_tau(const Tensor<2, dim> &F,
826 *   const double &p_tilde) const
827 *   {
828 *   return material->get_tau(F, p_tilde);
829 *   }
831 *   get_Jc(const Tensor<2, dim> &F,
832 *   const double &p_tilde) const
833 *   {
834 *   return material->get_Jc(F, p_tilde);
835 *   }
836 *   double
837 *   get_dPsi_vol_dJ(const double &J_tilde) const
838 *   {
839 *   return material->get_dPsi_vol_dJ(J_tilde);
840 *   }
841 *   double
842 *   get_d2Psi_vol_dJ2(const double &J_tilde) const
843 *   {
844 *   return material->get_d2Psi_vol_dJ2(J_tilde);
845 *   }
846 *   void
847 *   update_internal_equilibrium(const Tensor<2, dim> &F,
848 *   const double &p_tilde,
849 *   const double &J_tilde)
850 *   {
851 *   material->update_internal_equilibrium(F,p_tilde,J_tilde);
852 *   }
853 *   void
854 *   update_end_timestep()
855 *   {
856 *   material->update_end_timestep();
857 *   }
858 *   private:
859 *   std::shared_ptr< Material_Compressible_Three_Field_Linear_Viscoelastic<dim> > material;
860 *   };
861 *   template <int dim>
862 *   class Solid
863 *   {
864 *   public:
865 *   Solid(const std::string &input_file);
866 *   virtual
867 *   ~Solid();
868 *   void
869 *   run();
870 *   private:
871 *   struct PerTaskData_ASM;
872 *   struct ScratchData_ASM;
873 *   void
874 *   make_grid();
875 *   void
876 *   make_2d_quarter_plate_with_hole(Triangulation<2> &tria_2d,
877 *   const double half_length,
878 *   const double half_width,
879 *   const double hole_radius,
880 *   const unsigned int n_repetitions_xy = 1,
881 *   const double hole_division_fraction = 0.25);
882 *   void
883 *   setup_system(LA::MPI::BlockVector &solution_delta);
884 *   void
885 *   determine_component_extractors();
886 *   void
887 *   assemble_system(const LA::MPI::BlockVector &solution_delta);
888 *   void
889 *   assemble_system_one_cell(const typename DoFHandler<dim>::active_cell_iterator &cell,
890 *   ScratchData_ASM &scratch,
891 *   PerTaskData_ASM &data) const;
892 *   void
893 *   copy_local_to_global_system(const PerTaskData_ASM &data);
894 *   void
895 *   make_constraints(const int &it_nr);
896 *   void
897 *   setup_qph();
898 *   void
899 *   solve_nonlinear_timestep(LA::MPI::BlockVector &solution_delta);
900 *   std::pair<unsigned int, double>
901 *   solve_linear_system(LA::MPI::BlockVector &newton_update);
902 *   LA::MPI::BlockVector
903 *   get_solution_total(const LA::MPI::BlockVector &solution_delta) const;
904 *   void
905 *   update_end_timestep();
906 *   void
907 *   output_results(const unsigned int timestep,
908 *   const double current_time) const;
909 *   void
910 *   compute_vertex_positions(std::vector<double> &real_time,
911 *   std::vector<std::vector<Point<dim> > > &tracked_vertices,
912 *   const LA::MPI::BlockVector &solution_total) const;
913 *  
914 * @endcode
915 *
916 * Parallel communication
917 *
918 * @code
919 *   MPI_Comm mpi_communicator;
920 *   const unsigned int n_mpi_processes;
921 *   const unsigned int this_mpi_process;
922 *   mutable ConditionalOStream pcout;
923 *  
924 *   Parameters::AllParameters parameters;
926 *   Time time;
927 *   mutable TimerOutput timer;
929 *   PointHistory<dim> > quadrature_point_history;
930 *   const unsigned int degree;
931 *   const FESystem<dim> fe;
932 *   DoFHandler<dim> dof_handler;
933 *   const unsigned int dofs_per_cell;
934 *   const FEValuesExtractors::Vector u_fe;
935 *   const FEValuesExtractors::Scalar p_fe;
936 *   const FEValuesExtractors::Scalar J_fe;
937 *   static const unsigned int n_blocks = 3;
938 *   static const unsigned int n_components = dim + 2;
939 *   static const unsigned int first_u_component = 0;
940 *   static const unsigned int p_component = dim;
941 *   static const unsigned int J_component = dim + 1;
942 *   enum
943 *   {
944 *   u_block = 0,
945 *   p_block = 1,
946 *   J_block = 2
947 *   };
948 * @endcode
949 *
950 * Block data
951 *
952 * @code
953 *   std::vector<unsigned int> block_component;
954 *  
955 * @endcode
956 *
957 * DoF index data
958 *
959 * @code
960 *   std::vector<IndexSet> all_locally_owned_dofs;
961 *   IndexSet locally_owned_dofs;
962 *   IndexSet locally_relevant_dofs;
963 *   std::vector<IndexSet> locally_owned_partitioning;
964 *   std::vector<IndexSet> locally_relevant_partitioning;
965 *   std::vector<types::global_dof_index> dofs_per_block;
966 *   std::vector<types::global_dof_index> element_indices_u;
967 *   std::vector<types::global_dof_index> element_indices_p;
968 *   std::vector<types::global_dof_index> element_indices_J;
969 *   const QGauss<dim> qf_cell;
970 *   const QGauss<dim - 1> qf_face;
971 *   const unsigned int n_q_points;
972 *   const unsigned int n_q_points_f;
973 *   AffineConstraints<double> constraints;
974 *   LA::BlockSparseMatrix tangent_matrix;
975 *   LA::MPI::BlockVector system_rhs;
976 *   LA::MPI::BlockVector solution_n;
977 *   struct Errors
978 *   {
979 *   Errors()
980 *   :
981 *   norm(1.0), u(1.0), p(1.0), J(1.0)
982 *   {}
983 *   void reset()
984 *   {
985 *   norm = 1.0;
986 *   u = 1.0;
987 *   p = 1.0;
988 *   J = 1.0;
989 *   }
990 *   void normalise(const Errors &rhs)
991 *   {
992 *   if (rhs.norm != 0.0)
993 *   norm /= rhs.norm;
994 *   if (rhs.u != 0.0)
995 *   u /= rhs.u;
996 *   if (rhs.p != 0.0)
997 *   p /= rhs.p;
998 *   if (rhs.J != 0.0)
999 *   J /= rhs.J;
1000 *   }
1001 *   double norm, u, p, J;
1002 *   };
1003 *   Errors error_residual, error_residual_0, error_residual_norm, error_update,
1004 *   error_update_0, error_update_norm;
1005 *   void
1006 *   get_error_residual(Errors &error_residual);
1007 *   void
1008 *   get_error_update(const LA::MPI::BlockVector &newton_update,
1009 *   Errors &error_update);
1010 *   std::pair<double, std::pair<double,double> >
1011 *   get_error_dilation(const LA::MPI::BlockVector &solution_total) const;
1012 *   void
1013 *   print_conv_header();
1014 *   void
1015 *   print_conv_footer(const LA::MPI::BlockVector &solution_delta);
1016 *   };
1017 *   template <int dim>
1018 *   Solid<dim>::Solid(const std::string &input_file)
1019 *   :
1020 *   mpi_communicator(MPI_COMM_WORLD),
1021 *   n_mpi_processes (Utilities::MPI::n_mpi_processes(mpi_communicator)),
1022 *   this_mpi_process (Utilities::MPI::this_mpi_process(mpi_communicator)),
1023 *   pcout(std::cout, this_mpi_process == 0),
1024 *   parameters(input_file),
1026 *   time(parameters.end_time, parameters.delta_t),
1027 *   timer(mpi_communicator,
1028 *   pcout,
1031 *   degree(parameters.poly_degree),
1032 *   fe(FE_Q<dim>(parameters.poly_degree), dim, // displacement
1033 *   FE_DGPMonomial<dim>(parameters.poly_degree - 1), 1, // pressure
1034 *   FE_DGPMonomial<dim>(parameters.poly_degree - 1), 1), // dilatation
1035 *   dof_handler(triangulation),
1036 *   dofs_per_cell (fe.dofs_per_cell),
1037 *   u_fe(first_u_component),
1038 *   p_fe(p_component),
1039 *   J_fe(J_component),
1040 *   dofs_per_block(n_blocks),
1041 *   qf_cell(parameters.quad_order),
1042 *   qf_face(parameters.quad_order),
1043 *   n_q_points (qf_cell.size()),
1044 *   n_q_points_f (qf_face.size())
1045 *   {
1046 *   Assert(dim==2 || dim==3, ExcMessage("This problem only works in 2 or 3 space dimensions."));
1047 *   determine_component_extractors();
1048 *   }
1049 *   template <int dim>
1050 *   Solid<dim>::~Solid()
1051 *   {
1052 *   dof_handler.clear();
1053 *   }
1054 *   template <int dim>
1055 *   void Solid<dim>::run()
1056 *   {
1057 *   LA::MPI::BlockVector solution_delta;
1058 *  
1059 *   make_grid();
1060 *   setup_system(solution_delta);
1061 *   {
1062 *   AffineConstraints<double> constraints;
1063 *   constraints.close();
1065 *   J_mask (J_component, n_components);
1066 *   VectorTools::project (dof_handler,
1067 *   constraints,
1068 *   QGauss<dim>(degree+2),
1069 *   J_mask,
1070 *   solution_n);
1071 *   }
1072 *   output_results(time.get_timestep(), time.current());
1073 *   time.increment();
1074 *  
1075 * @endcode
1076 *
1077 * Some points for post-processing
1078 *
1079 * @code
1080 *   std::vector<double> real_time;
1081 *   real_time.push_back(0);
1082 *   std::vector<std::vector<Point<dim> > > tracked_vertices (4);
1083 *   {
1084 *   Point<dim> p;
1085 *   p[1] = parameters.length/2.0;
1086 *   tracked_vertices[0].push_back(p*parameters.scale);
1087 *   }
1088 *   {
1089 *   Point<dim> p;
1090 *   p[1] = parameters.hole_diameter/2.0;
1091 *   tracked_vertices[1].push_back(p*parameters.scale);
1092 *   }
1093 *   {
1094 *   Point<dim> p;
1095 *   p[0] = parameters.hole_diameter/2.0;
1096 *   tracked_vertices[2].push_back(p*parameters.scale);
1097 *   }
1098 *   {
1099 *   Point<dim> p;
1100 *   p[0] = parameters.width/2.0;
1101 *   tracked_vertices[3].push_back(p*parameters.scale);
1102 *   }
1103 *  
1104 *   while (time.current() < time.end()+0.01*time.get_delta_t())
1105 *   {
1106 *   solve_nonlinear_timestep(solution_delta);
1107 *   solution_n += solution_delta;
1108 *   solution_delta = 0.0;
1109 *   output_results(time.get_timestep(), time.current());
1110 *   compute_vertex_positions(real_time,
1111 *   tracked_vertices,
1112 *   get_solution_total(solution_delta));
1113 *   update_end_timestep();
1114 *   time.increment();
1115 *   }
1116 *  
1117 *   pcout << "\n\n*** Spatial position history for tracked vertices ***" << std::endl;
1118 *   for (unsigned int t=0; t<real_time.size(); ++t)
1119 *   {
1120 *   if (t == 0)
1121 *   {
1122 *   pcout << "Time,";
1123 *   for (unsigned int p=0; p<tracked_vertices.size(); ++p)
1124 *   {
1125 *   for (unsigned int d=0; d<dim; ++d)
1126 *   {
1127 *   pcout << "Point " << p << " [" << d << "]";
1128 *   if (!(p == tracked_vertices.size()-1 && d == dim-1))
1129 *   pcout << ",";
1130 *   }
1131 *   }
1132 *   pcout << std::endl;
1133 *   }
1134 *  
1135 *   pcout << std::setprecision(6);
1136 *   pcout << real_time[t] << ",";
1137 *   for (unsigned int p=0; p<tracked_vertices.size(); ++p)
1138 *   {
1139 *   Assert(tracked_vertices[p].size() == real_time.size(),
1140 *   ExcMessage("Vertex not tracked at each timestep"));
1141 *   for (unsigned int d=0; d<dim; ++d)
1142 *   {
1143 *   pcout << tracked_vertices[p][t][d];
1144 *   if (!(p == tracked_vertices.size()-1 && d == dim-1))
1145 *   pcout << ",";
1146 *   }
1147 *   }
1148 *   pcout << std::endl;
1149 *   }
1150 *   }
1151 *   template <int dim>
1152 *   struct Solid<dim>::PerTaskData_ASM
1153 *   {
1155 *   Vector<double> cell_rhs;
1156 *   std::vector<types::global_dof_index> local_dof_indices;
1157 *   PerTaskData_ASM(const unsigned int dofs_per_cell)
1158 *   :
1159 *   cell_matrix(dofs_per_cell, dofs_per_cell),
1160 *   cell_rhs(dofs_per_cell),
1161 *   local_dof_indices(dofs_per_cell)
1162 *   {}
1163 *   void reset()
1164 *   {
1165 *   cell_matrix = 0.0;
1166 *   cell_rhs = 0.0;
1167 *   }
1168 *   };
1169 *   template <int dim>
1170 *   struct Solid<dim>::ScratchData_ASM
1171 *   {
1172 *   const LA::MPI::BlockVector &solution_total;
1173 *  
1174 * @endcode
1175 *
1176 * Integration helper
1177 *
1178 * @code
1179 *   FEValues<dim> fe_values_ref;
1180 *   FEFaceValues<dim> fe_face_values_ref;
1181 *  
1182 * @endcode
1183 *
1184 * Quadrature point solution
1185 *
1186 * @code
1187 *   std::vector<Tensor<2, dim> > solution_grads_u_total;
1188 *   std::vector<double> solution_values_p_total;
1189 *   std::vector<double> solution_values_J_total;
1190 *  
1191 * @endcode
1192 *
1193 * Shape function values and gradients
1194 *
1195 * @code
1196 *   std::vector<std::vector<double> > Nx;
1197 *   std::vector<std::vector<Tensor<2, dim> > > grad_Nx;
1198 *   std::vector<std::vector<SymmetricTensor<2, dim> > > symm_grad_Nx;
1199 *  
1200 *   ScratchData_ASM(const FiniteElement<dim> &fe_cell,
1201 *   const QGauss<dim> &qf_cell, const UpdateFlags uf_cell,
1202 *   const QGauss<dim - 1> & qf_face, const UpdateFlags uf_face,
1203 *   const LA::MPI::BlockVector &solution_total)
1204 *   :
1205 *   solution_total (solution_total),
1206 *   fe_values_ref(fe_cell, qf_cell, uf_cell),
1207 *   fe_face_values_ref(fe_cell, qf_face, uf_face),
1208 *   solution_grads_u_total(qf_cell.size()),
1209 *   solution_values_p_total(qf_cell.size()),
1210 *   solution_values_J_total(qf_cell.size()),
1211 *   Nx(qf_cell.size(),
1212 *   std::vector<double>(fe_cell.dofs_per_cell)),
1213 *   grad_Nx(qf_cell.size(),
1214 *   std::vector<Tensor<2, dim> >(fe_cell.dofs_per_cell)),
1215 *   symm_grad_Nx(qf_cell.size(),
1216 *   std::vector<SymmetricTensor<2, dim> >
1217 *   (fe_cell.dofs_per_cell))
1218 *   {}
1219 *   ScratchData_ASM(const ScratchData_ASM &rhs)
1220 *   :
1221 *   solution_total (rhs.solution_total),
1222 *   fe_values_ref(rhs.fe_values_ref.get_fe(),
1223 *   rhs.fe_values_ref.get_quadrature(),
1224 *   rhs.fe_values_ref.get_update_flags()),
1225 *   fe_face_values_ref(rhs.fe_face_values_ref.get_fe(),
1226 *   rhs.fe_face_values_ref.get_quadrature(),
1227 *   rhs.fe_face_values_ref.get_update_flags()),
1228 *   solution_grads_u_total(rhs.solution_grads_u_total),
1229 *   solution_values_p_total(rhs.solution_values_p_total),
1230 *   solution_values_J_total(rhs.solution_values_J_total),
1231 *   Nx(rhs.Nx),
1232 *   grad_Nx(rhs.grad_Nx),
1233 *   symm_grad_Nx(rhs.symm_grad_Nx)
1234 *   {}
1235 *   void reset()
1236 *   {
1237 *   const unsigned int n_q_points = solution_grads_u_total.size();
1238 *   const unsigned int n_dofs_per_cell = Nx[0].size();
1239 *  
1240 *   Assert(solution_grads_u_total.size() == n_q_points,
1241 *   ExcInternalError());
1242 *   Assert(solution_values_p_total.size() == n_q_points,
1243 *   ExcInternalError());
1244 *   Assert(solution_values_J_total.size() == n_q_points,
1245 *   ExcInternalError());
1246 *   Assert(Nx.size() == n_q_points,
1247 *   ExcInternalError());
1248 *   Assert(grad_Nx.size() == n_q_points,
1249 *   ExcInternalError());
1250 *   Assert(symm_grad_Nx.size() == n_q_points,
1251 *   ExcInternalError());
1252 *  
1253 *   for (unsigned int q_point = 0; q_point < n_q_points; ++q_point)
1254 *   {
1255 *   Assert( Nx[q_point].size() == n_dofs_per_cell, ExcInternalError());
1256 *   Assert( grad_Nx[q_point].size() == n_dofs_per_cell,
1257 *   ExcInternalError());
1258 *   Assert( symm_grad_Nx[q_point].size() == n_dofs_per_cell,
1259 *   ExcInternalError());
1260 *  
1261 *   solution_grads_u_total[q_point] = 0.0;
1262 *   solution_values_p_total[q_point] = 0.0;
1263 *   solution_values_J_total[q_point] = 0.0;
1264 *   for (unsigned int k = 0; k < n_dofs_per_cell; ++k)
1265 *   {
1266 *   Nx[q_point][k] = 0.0;
1267 *   grad_Nx[q_point][k] = 0.0;
1268 *   symm_grad_Nx[q_point][k] = 0.0;
1269 *   }
1270 *   }
1271 *   }
1272 *   };
1273 *   template <>
1274 *   void Solid<2>::make_grid()
1275 *   {
1276 *   const int dim = 2;
1277 *   const double tol = 1e-12;
1278 *   make_2d_quarter_plate_with_hole(triangulation,
1279 *   parameters.length/2.0,
1280 *   parameters.width/2.0,
1281 *   parameters.hole_diameter/2.0,
1282 *   parameters.n_repetitions_xy,
1283 *   parameters.hole_division_fraction);
1284 *  
1285 * @endcode
1286 *
1287 * Clear boundary ID's
1288 *
1289 * @code
1290 *   for (typename Triangulation<dim>::active_cell_iterator
1291 *   cell = triangulation.begin_active();
1292 *   cell != triangulation.end(); ++cell)
1293 *   {
1294 *   for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
1295 *   if (cell->face(face)->at_boundary())
1296 *   {
1297 *   cell->face(face)->set_all_boundary_ids(0);
1298 *   }
1299 *   }
1300 *  
1301 * @endcode
1302 *
1303 * Set boundary IDs and and manifolds
1304 *
1305 * @code
1306 *   const Point<dim> centre (0,0);
1307 *   for (typename Triangulation<dim>::active_cell_iterator
1308 *   cell = triangulation.begin_active();
1309 *   cell != triangulation.end(); ++cell)
1310 *   {
1311 *   for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
1312 *   if (cell->face(face)->at_boundary())
1313 *   {
1314 * @endcode
1315 *
1316 * Set boundary IDs
1317 *
1318 * @code
1319 *   if (std::abs(cell->face(face)->center()[0] - 0.0) < tol)
1320 *   {
1321 *   cell->face(face)->set_boundary_id(parameters.boundary_id_minus_X);
1322 *   }
1323 *   else if (std::abs(cell->face(face)->center()[0] - parameters.width/2.0) < tol)
1324 *   {
1325 *   cell->face(face)->set_boundary_id(parameters.boundary_id_plus_X);
1326 *   }
1327 *   else if (std::abs(cell->face(face)->center()[1] - 0.0) < tol)
1328 *   {
1329 *   cell->face(face)->set_boundary_id(parameters.boundary_id_minus_Y);
1330 *   }
1331 *   else if (std::abs(cell->face(face)->center()[1] - parameters.length/2.0) < tol)
1332 *   {
1333 *   cell->face(face)->set_boundary_id(parameters.boundary_id_plus_Y);
1334 *   }
1335 *   else
1336 *   {
1337 *   for (unsigned int vertex=0; vertex<GeometryInfo<dim>::vertices_per_face; ++vertex)
1338 *   if (std::abs(cell->vertex(vertex).distance(centre) - parameters.hole_diameter/2.0) < tol)
1339 *   {
1340 *   cell->face(face)->set_boundary_id(parameters.boundary_id_hole);
1341 *   break;
1342 *   }
1343 *   }
1344 *  
1345 * @endcode
1346 *
1347 * Set manifold IDs
1348 *
1349 * @code
1350 *   for (unsigned int vertex=0; vertex<GeometryInfo<dim>::vertices_per_face; ++vertex)
1351 *   if (std::abs(cell->vertex(vertex).distance(centre) - parameters.hole_diameter/2.0) < tol)
1352 *   {
1353 *   cell->face(face)->set_manifold_id(parameters.manifold_id_hole);
1354 *   break;
1355 *   }
1356 *   }
1357 *   }
1358 *   static SphericalManifold<dim> spherical_manifold (centre);
1359 *   triangulation.set_manifold(parameters.manifold_id_hole,spherical_manifold);
1360 *   triangulation.refine_global(parameters.global_refinement);
1361 *   GridTools::scale(parameters.scale,triangulation);
1362 *   }
1363 *   template <>
1364 *   void Solid<3>::make_grid()
1365 *   {
1366 *   const int dim = 3;
1367 *   const double tol = 1e-12;
1368 *   Triangulation<2> tria_2d;
1369 *   make_2d_quarter_plate_with_hole(tria_2d,
1370 *   parameters.length/2.0,
1371 *   parameters.width/2.0,
1372 *   parameters.hole_diameter/2.0,
1373 *   parameters.n_repetitions_xy,
1374 *   parameters.hole_division_fraction);
1375 *   GridGenerator::extrude_triangulation(tria_2d,
1376 *   parameters.n_repetitions_z+1,
1377 *   parameters.thickness/2.0,
1378 *   triangulation);
1379 *  
1380 * @endcode
1381 *
1382 * Clear boundary ID's
1383 *
1384 * @code
1386 *   cell = triangulation.begin_active();
1387 *   cell != triangulation.end(); ++cell)
1388 *   {
1389 *   for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
1390 *   if (cell->face(face)->at_boundary())
1391 *   {
1392 *   cell->face(face)->set_all_boundary_ids(0);
1393 *   }
1394 *   }
1395 *  
1396 * @endcode
1397 *
1398 * Set boundary IDs and and manifolds
1399 *
1400 * @code
1401 *   const Point<dim> direction (0,0,1);
1402 *   const Point<dim> centre (0,0,0);
1404 *   cell = triangulation.begin_active();
1405 *   cell != triangulation.end(); ++cell)
1406 *   {
1407 *   for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
1408 *   if (cell->face(face)->at_boundary())
1409 *   {
1410 * @endcode
1411 *
1412 * Set boundary IDs
1413 *
1414 * @code
1415 *   if (std::abs(cell->face(face)->center()[0] - 0.0) < tol)
1416 *   {
1417 *   cell->face(face)->set_boundary_id(parameters.boundary_id_minus_X);
1418 *   }
1419 *   else if (std::abs(cell->face(face)->center()[0] - parameters.width/2.0) < tol)
1420 *   {
1421 *   cell->face(face)->set_boundary_id(parameters.boundary_id_plus_X);
1422 *   }
1423 *   else if (std::abs(cell->face(face)->center()[1] - 0.0) < tol)
1424 *   {
1425 *   cell->face(face)->set_boundary_id(parameters.boundary_id_minus_Y);
1426 *   }
1427 *   else if (std::abs(cell->face(face)->center()[1] - parameters.length/2.0) < tol)
1428 *   {
1429 *   cell->face(face)->set_boundary_id(parameters.boundary_id_plus_Y);
1430 *   }
1431 *   else if (std::abs(cell->face(face)->center()[2] - 0.0) < tol)
1432 *   {
1433 *   cell->face(face)->set_boundary_id(parameters.boundary_id_minus_Z);
1434 *   }
1435 *   else if (std::abs(cell->face(face)->center()[2] - parameters.thickness/2.0) < tol)
1436 *   {
1437 *   cell->face(face)->set_boundary_id(parameters.boundary_id_plus_Z);
1438 *   }
1439 *   else
1440 *   {
1441 *   for (unsigned int vertex=0; vertex<GeometryInfo<dim>::vertices_per_face; ++vertex)
1442 *   {
1443 * @endcode
1444 *
1445 * Project the cell vertex to the XY plane and
1446 * test the distance from the cylinder axis
1447 *
1448 * @code
1449 *   Point<dim> vertex_proj = cell->vertex(vertex);
1450 *   vertex_proj[2] = 0.0;
1451 *   if (std::abs(vertex_proj.distance(centre) - parameters.hole_diameter/2.0) < tol)
1452 *   {
1453 *   cell->face(face)->set_boundary_id(parameters.boundary_id_hole);
1454 *   break;
1455 *   }
1456 *   }
1457 *   }
1458 *  
1459 * @endcode
1460 *
1461 * Set manifold IDs
1462 *
1463 * @code
1464 *   for (unsigned int vertex=0; vertex<GeometryInfo<dim>::vertices_per_face; ++vertex)
1465 *   {
1466 * @endcode
1467 *
1468 * Project the cell vertex to the XY plane and
1469 * test the distance from the cylinder axis
1470 *
1471 * @code
1472 *   Point<dim> vertex_proj = cell->vertex(vertex);
1473 *   vertex_proj[2] = 0.0;
1474 *   if (std::abs(vertex_proj.distance(centre) - parameters.hole_diameter/2.0) < 1e-12)
1475 *   {
1476 * @endcode
1477 *
1478 * Set manifold ID on face and edges
1479 *
1480 * @code
1481 *   cell->face(face)->set_all_manifold_ids(parameters.manifold_id_hole);
1482 *   break;
1483 *   }
1484 *   }
1485 *   }
1486 *   }
1487 *   static CylindricalManifold<dim> cylindrical_manifold (direction,centre);
1488 *   triangulation.set_manifold(parameters.manifold_id_hole,cylindrical_manifold);
1489 *   triangulation.refine_global(parameters.global_refinement);
1490 *   GridTools::scale(parameters.scale,triangulation);
1491 *   }
1492 *   template <int dim>
1493 *   void Solid<dim>::make_2d_quarter_plate_with_hole(Triangulation<2> &tria_2d,
1494 *   const double half_length,
1495 *   const double half_width,
1496 *   const double hole_radius,
1497 *   const unsigned int n_repetitions_xy,
1498 *   const double hole_division_fraction)
1499 *   {
1500 *   const double length = 2.0*half_length;
1501 *   const double width = 2.0*half_width;
1502 *   const double hole_diameter = 2.0*hole_radius;
1503 *  
1504 *   const double internal_width = hole_diameter + hole_division_fraction*(width - hole_diameter);
1505 *   Triangulation<2> tria_quarter_plate_hole;
1506 *   {
1507 *   Triangulation<2> tria_plate_hole;
1509 *   hole_diameter/2.0,
1510 *   internal_width/2.0);
1511 *  
1512 *   std::set<typename Triangulation<2>::active_cell_iterator > cells_to_remove;
1514 *   cell = tria_plate_hole.begin_active();
1515 *   cell != tria_plate_hole.end(); ++cell)
1516 *   {
1517 * @endcode
1518 *
1519 * Remove all cells that are not in the first quadrant
1520 *
1521 * @code
1522 *   if (cell->center()[0] < 0.0 || cell->center()[1] < 0.0)
1523 *   cells_to_remove.insert(cell);
1524 *   }
1525 *   Assert(cells_to_remove.size() > 0, ExcInternalError());
1526 *   Assert(cells_to_remove.size() != tria_plate_hole.n_active_cells(), ExcInternalError());
1527 *   GridGenerator::create_triangulation_with_removed_cells(tria_plate_hole,cells_to_remove,tria_quarter_plate_hole);
1528 *   }
1529 *  
1530 *   Triangulation<2> tria_cut_plate;
1531 *   {
1532 *   Triangulation<2> tria_plate;
1533 * @endcode
1534 *
1535 * Subdivide the plate so that we're left one
1536 * cell to remove (we'll replace this with the
1537 * plate with the hole) and then make the
1538 * rest of the subdivisions so that we're left
1539 * with cells with a decent aspect ratio
1540 *
1541 * @code
1542 *   std::vector<std::vector<double> > step_sizes;
1543 *   {
1544 *   std::vector<double> subdivision_width;
1545 *   subdivision_width.push_back(internal_width/2.0);
1546 *   const double width_remaining = (width - internal_width)/2.0;
1547 *   const unsigned int n_subs = static_cast<unsigned int>(std::max(1.0,std::ceil(width_remaining/(internal_width/2.0))));
1548 *   Assert(n_subs>0, ExcInternalError());
1549 *   for (unsigned int s=0; s<n_subs; ++s)
1550 *   subdivision_width.push_back(width_remaining/n_subs);
1551 *   step_sizes.push_back(subdivision_width);
1552 *  
1553 *   const double sum_half_width = std::accumulate(subdivision_width.begin(), subdivision_width.end(), 0.0);
1554 *   (void)sum_half_width;
1555 *   Assert(std::abs(sum_half_width-width/2.0) < 1e-12, ExcInternalError());
1556 *   }
1557 *   {
1558 *   std::vector<double> subdivision_length;
1559 *   subdivision_length.push_back(internal_width/2.0);
1560 *   const double length_remaining = (length - internal_width)/2.0;
1561 *   const unsigned int n_subs = static_cast<unsigned int>(std::max(1.0,std::ceil(length_remaining/(internal_width/2.0))));
1562 *   Assert(n_subs>0, ExcInternalError());
1563 *   for (unsigned int s=0; s<n_subs; ++s)
1564 *   subdivision_length.push_back(length_remaining/n_subs);
1565 *   step_sizes.push_back(subdivision_length);
1566 *  
1567 *   const double sum_half_length = std::accumulate(subdivision_length.begin(), subdivision_length.end(), 0.0);
1568 *   (void)sum_half_length;
1569 *   Assert(std::abs(sum_half_length-length/2.0) < 1e-12, ExcInternalError());
1570 *   }
1571 *  
1572 *   GridGenerator::subdivided_hyper_rectangle(tria_plate,
1573 *   step_sizes,
1574 *   Point<2>(0.0, 0.0),
1575 *   Point<2>(width/2.0, length/2.0));
1576 *  
1577 *   std::set<typename Triangulation<2>::active_cell_iterator > cells_to_remove;
1578 *   for (typename Triangulation<2>::active_cell_iterator
1579 *   cell = tria_plate.begin_active();
1580 *   cell != tria_plate.end(); ++cell)
1581 *   {
1582 * @endcode
1583 *
1584 * Remove all cells that are in the first quadrant
1585 *
1586 * @code
1587 *   if (cell->center()[0] < internal_width/2.0 && cell->center()[1] < internal_width/2.0)
1588 *   cells_to_remove.insert(cell);
1589 *   }
1590 *   Assert(cells_to_remove.size() > 0, ExcInternalError());
1591 *   Assert(cells_to_remove.size() != tria_plate.n_active_cells(), ExcInternalError());
1592 *   GridGenerator::create_triangulation_with_removed_cells(tria_plate,cells_to_remove,tria_cut_plate);
1593 *   }
1594 *  
1595 *   Triangulation<2> tria_2d_not_flat;
1596 *   GridGenerator::merge_triangulations(tria_quarter_plate_hole,
1597 *   tria_cut_plate,
1598 *   tria_2d_not_flat);
1599 *  
1600 * @endcode
1601 *
1602 * Attach a manifold to the curved boundary and refine
1603 * Note: We can only guarantee that the vertices sit on
1604 * the curve, so we must test with their position instead
1605 * of the cell centre.
1606 *
1607 * @code
1608 *   const Point<2> centre_2d (0,0);
1609 *   for (typename Triangulation<2>::active_cell_iterator
1610 *   cell = tria_2d_not_flat.begin_active();
1611 *   cell != tria_2d_not_flat.end(); ++cell)
1612 *   {
1613 *   for (unsigned int face=0; face<GeometryInfo<2>::faces_per_cell; ++face)
1614 *   if (cell->face(face)->at_boundary())
1615 *   for (unsigned int vertex=0; vertex<GeometryInfo<2>::vertices_per_face; ++vertex)
1616 *   if (std::abs(cell->vertex(vertex).distance(centre_2d) - hole_diameter/2.0) < 1e-12)
1617 *   {
1618 *   cell->face(face)->set_manifold_id(10);
1619 *   break;
1620 *   }
1621 *   }
1622 *   SphericalManifold<2> spherical_manifold_2d (centre_2d);
1623 *   tria_2d_not_flat.set_manifold(10,spherical_manifold_2d);
1624 *   tria_2d_not_flat.refine_global(std::max (1U, n_repetitions_xy));
1625 *   tria_2d_not_flat.reset_manifold(10); // Clear manifold
1626 *  
1627 *   GridGenerator::flatten_triangulation(tria_2d_not_flat,tria_2d);
1628 *   }
1629 *   template <int dim>
1630 *   void Solid<dim>::setup_system(LA::MPI::BlockVector &solution_delta)
1631 *   {
1632 *   timer.enter_subsection("Setup system");
1633 *   pcout << "Setting up linear system..." << std::endl;
1634 *  
1635 * @endcode
1636 *
1637 * Partition triangulation
1638 *
1639 * @code
1640 *   GridTools::partition_triangulation (n_mpi_processes,
1641 *   triangulation);
1642 *  
1643 *   block_component = std::vector<unsigned int> (n_components, u_block); // Displacement
1644 *   block_component[p_component] = p_block; // Pressure
1645 *   block_component[J_component] = J_block; // Dilatation
1646 *   dof_handler.distribute_dofs(fe);
1647 *   DoFRenumbering::Cuthill_McKee(dof_handler);
1648 *   DoFRenumbering::component_wise(dof_handler, block_component);
1649 *  
1650 * @endcode
1651 *
1652 * Count DoFs in each block
1653 *
1654 * @code
1655 *   dofs_per_block = DoFTools::count_dofs_per_fe_block(dof_handler, block_component);
1656 *  
1657 *   all_locally_owned_dofs = DoFTools::locally_owned_dofs_per_subdomain (dof_handler);
1658 *   std::vector<IndexSet> all_locally_relevant_dofs
1659 *   = DoFTools::locally_relevant_dofs_per_subdomain (dof_handler);
1660 *  
1661 *   locally_owned_dofs.clear();
1662 *   locally_owned_partitioning.clear();
1663 *   Assert(all_locally_owned_dofs.size() > this_mpi_process, ExcInternalError());
1664 *   locally_owned_dofs = all_locally_owned_dofs[this_mpi_process];
1665 *  
1666 *   locally_relevant_dofs.clear();
1667 *   locally_relevant_partitioning.clear();
1668 *   Assert(all_locally_relevant_dofs.size() > this_mpi_process, ExcInternalError());
1669 *   locally_relevant_dofs = all_locally_relevant_dofs[this_mpi_process];
1670 *  
1671 *   locally_owned_partitioning.reserve(n_blocks);
1672 *   locally_relevant_partitioning.reserve(n_blocks);
1673 *   for (unsigned int b=0; b<n_blocks; ++b)
1674 *   {
1675 *   const types::global_dof_index idx_begin
1676 *   = std::accumulate(dofs_per_block.begin(),
1677 *   std::next(dofs_per_block.begin(),b), 0);
1678 *   const types::global_dof_index idx_end
1679 *   = std::accumulate(dofs_per_block.begin(),
1680 *   std::next(dofs_per_block.begin(),b+1), 0);
1681 *   locally_owned_partitioning.push_back(locally_owned_dofs.get_view(idx_begin, idx_end));
1682 *   locally_relevant_partitioning.push_back(locally_relevant_dofs.get_view(idx_begin, idx_end));
1683 *   }
1684 *  
1685 *   pcout
1686 *   << " Number of active cells: " << triangulation.n_active_cells()
1687 *   << " (by partition:";
1688 *   for (unsigned int p=0; p<n_mpi_processes; ++p)
1689 *   pcout
1690 *   << (p==0 ? ' ' : '+')
1691 *   << (GridTools::count_cells_with_subdomain_association (triangulation,p));
1692 *   pcout << ")" << std::endl;
1693 *  
1694 *   pcout
1695 *   << " Number of degrees of freedom: " << dof_handler.n_dofs()
1696 *   << " (by partition:";
1697 *   for (unsigned int p=0; p<n_mpi_processes; ++p)
1698 *   pcout
1699 *   << (p==0 ? ' ' : '+')
1700 *   << (DoFTools::count_dofs_with_subdomain_association (dof_handler,p));
1701 *   pcout << ")" << std::endl;
1702 *   pcout
1703 *   << " Number of degrees of freedom per block: "
1704 *   << "[n_u, n_p, n_J] = ["
1705 *   << dofs_per_block[u_block] << ", "
1706 *   << dofs_per_block[p_block] << ", "
1707 *   << dofs_per_block[J_block] << "]"
1708 *   << std::endl;
1709 *  
1710 *  
1711 *   Table<2, DoFTools::Coupling> coupling(n_components, n_components);
1712 *   for (unsigned int ii = 0; ii < n_components; ++ii)
1713 *   for (unsigned int jj = 0; jj < n_components; ++jj)
1714 *   if (((ii < p_component) && (jj == J_component))
1715 *   || ((ii == J_component) && (jj < p_component))
1716 *   || ((ii == p_component) && (jj == p_component)))
1717 *   coupling[ii][jj] = DoFTools::none;
1718 *   else
1719 *   coupling[ii][jj] = DoFTools::always;
1720 *  
1721 *   TrilinosWrappers::BlockSparsityPattern bsp (locally_owned_partitioning,
1722 *   locally_owned_partitioning,
1723 *   locally_relevant_partitioning,
1724 *   mpi_communicator);
1725 *   DoFTools::make_sparsity_pattern (dof_handler, bsp,
1726 *   constraints, false,
1727 *   this_mpi_process);
1728 *   bsp.compress();
1729 *   tangent_matrix.reinit (bsp);
1730 *  
1731 * @endcode
1732 *
1733 * We then set up storage vectors
1734 *
1735 * @code
1736 *   system_rhs.reinit(locally_owned_partitioning,
1737 *   mpi_communicator);
1738 *   solution_n.reinit(locally_owned_partitioning,
1739 *   mpi_communicator);
1740 *   solution_delta.reinit(locally_owned_partitioning,
1741 *   mpi_communicator);
1742 *   setup_qph();
1743 *   timer.leave_subsection();
1744 *   }
1745 *   template <int dim>
1746 *   void
1747 *   Solid<dim>::determine_component_extractors()
1748 *   {
1749 *   element_indices_u.clear();
1750 *   element_indices_p.clear();
1751 *   element_indices_J.clear();
1752 *   for (unsigned int k = 0; k < fe.dofs_per_cell; ++k)
1753 *   {
1754 *   const unsigned int k_group = fe.system_to_base_index(k).first.first;
1755 *   if (k_group == u_block)
1756 *   element_indices_u.push_back(k);
1757 *   else if (k_group == p_block)
1758 *   element_indices_p.push_back(k);
1759 *   else if (k_group == J_block)
1760 *   element_indices_J.push_back(k);
1761 *   else
1762 *   {
1763 *   Assert(k_group <= J_block, ExcInternalError());
1764 *   }
1765 *   }
1766 *   }
1767 *   template <int dim>
1768 *   void Solid<dim>::setup_qph()
1769 *   {
1770 *   pcout << "Setting up quadrature point data..." << std::endl;
1771 *   quadrature_point_history.initialize(triangulation.begin_active(),
1772 *   triangulation.end(),
1773 *   n_q_points);
1774 *   FilteredIterator<typename DoFHandler<dim>::active_cell_iterator>
1775 *   cell (IteratorFilters::SubdomainEqualTo(this_mpi_process),
1776 *   dof_handler.begin_active()),
1777 *   endc (IteratorFilters::SubdomainEqualTo(this_mpi_process),
1778 *   dof_handler.end());
1779 *   for (; cell!=endc; ++cell)
1780 *   {
1781 *   Assert(cell->subdomain_id()==this_mpi_process, ExcInternalError());
1782 *   const std::vector<std::shared_ptr<PointHistory<dim> > > lqph =
1783 *   quadrature_point_history.get_data(cell);
1784 *   Assert(lqph.size() == n_q_points, ExcInternalError());
1785 *   for (unsigned int q_point = 0; q_point < n_q_points; ++q_point)
1786 *   lqph[q_point]->setup_lqp(parameters, time);
1787 *   }
1788 *   }
1789 *   template <int dim>
1790 *   void
1791 *   Solid<dim>::solve_nonlinear_timestep(LA::MPI::BlockVector &solution_delta)
1792 *   {
1793 *   pcout << std::endl
1794 *   << "Timestep " << time.get_timestep() << " @ "
1795 *   << time.current() << "s of "
1796 *   << time.end() << "s" << std::endl;
1797 *   LA::MPI::BlockVector newton_update(locally_owned_partitioning,
1798 *   mpi_communicator);
1799 *   error_residual.reset();
1800 *   error_residual_0.reset();
1801 *   error_residual_norm.reset();
1802 *   error_update.reset();
1803 *   error_update_0.reset();
1804 *   error_update_norm.reset();
1805 *   print_conv_header();
1806 *   unsigned int newton_iteration = 0;
1807 *   for (; newton_iteration < parameters.max_iterations_NR;
1808 *   ++newton_iteration)
1809 *   {
1810 *   pcout << " " << std::setw(2) << newton_iteration << " " << std::flush;
1811 *   make_constraints(newton_iteration);
1812 *   assemble_system(solution_delta);
1813 *   get_error_residual(error_residual);
1814 *   if (newton_iteration == 0)
1815 *   error_residual_0 = error_residual;
1816 *   error_residual_norm = error_residual;
1817 *   error_residual_norm.normalise(error_residual_0);
1818 *   if (newton_iteration > 0 &&
1819 *   (error_update_norm.u <= parameters.tol_u &&
1820 *   error_residual_norm.u <= parameters.tol_f) )
1821 *   {
1822 *   pcout << " CONVERGED! " << std::endl;
1823 *   print_conv_footer(solution_delta);
1824 *   break;
1825 *   }
1826 *   const std::pair<unsigned int, double>
1827 *   lin_solver_output = solve_linear_system(newton_update);
1828 *   get_error_update(newton_update, error_update);
1829 *   if (newton_iteration == 0)
1830 *   error_update_0 = error_update;
1831 *   error_update_norm = error_update;
1832 *   error_update_norm.normalise(error_update_0);
1833 *   solution_delta += newton_update;
1834 *   newton_update = 0.0;
1835 *   pcout << " | " << std::fixed << std::setprecision(3) << std::setw(7)
1836 *   << std::scientific << lin_solver_output.first << " "
1837 *   << lin_solver_output.second << " " << error_residual_norm.norm
1838 *   << " " << error_residual_norm.u << " "
1839 *   << error_residual_norm.p << " " << error_residual_norm.J
1840 *   << " " << error_update_norm.norm << " " << error_update_norm.u
1841 *   << " " << error_update_norm.p << " " << error_update_norm.J
1842 *   << " " << std::endl;
1843 *   }
1844 *   AssertThrow (newton_iteration <= parameters.max_iterations_NR,
1845 *   ExcMessage("No convergence in nonlinear solver!"));
1846 *   }
1847 *   template <int dim>
1848 *   void Solid<dim>::print_conv_header()
1849 *   {
1850 *   pcout << std::string(132,'_') << std::endl;
1851 *   pcout << " SOLVER STEP "
1852 *   << " | LIN_IT LIN_RES RES_NORM "
1853 *   << " RES_U RES_P RES_J NU_NORM "
1854 *   << " NU_U NU_P NU_J " << std::endl;
1855 *   pcout << std::string(132,'_') << std::endl;
1856 *   }
1857 *   template <int dim>
1858 *   void Solid<dim>::print_conv_footer(const LA::MPI::BlockVector &solution_delta)
1859 *   {
1860 *   pcout << std::string(132,'_') << std::endl;
1861 *   const std::pair<double,std::pair<double,double> > error_dil = get_error_dilation(get_solution_total(solution_delta));
1862 *   pcout << "Relative errors:" << std::endl
1863 *   << "Displacement:\t" << error_update.u / error_update_0.u << std::endl
1864 *   << "Force: \t\t" << error_residual.u / error_residual_0.u << std::endl
1865 *   << "Dilatation:\t" << error_dil.first << std::endl
1866 *   << "v / V_0:\t" << error_dil.second.second << " / " << error_dil.second.first
1867 *   << " = " << (error_dil.second.second/error_dil.second.first) << std::endl;
1868 *   }
1869 *   template <int dim>
1870 *   std::pair<double,std::pair<double,double> >
1871 *   Solid<dim>::get_error_dilation(const LA::MPI::BlockVector &solution_total) const
1872 *   {
1873 *   double vol_reference = 0.0;
1874 *   double vol_current = 0.0;
1875 *   double dil_L2_error = 0.0;
1876 *   FEValues<dim> fe_values_ref(fe, qf_cell,
1877 *   update_values | update_gradients | update_JxW_values);
1878 *   std::vector<Tensor<2, dim> > solution_grads_u_total (qf_cell.size());
1879 *   std::vector<double> solution_values_J_total (qf_cell.size());
1880 *   FilteredIterator<typename DoFHandler<dim>::active_cell_iterator>
1881 *   cell (IteratorFilters::SubdomainEqualTo(this_mpi_process),
1882 *   dof_handler.begin_active()),
1883 *   endc (IteratorFilters::SubdomainEqualTo(this_mpi_process),
1884 *   dof_handler.end());
1885 *   for (; cell != endc; ++cell)
1886 *   {
1887 *   Assert(cell->subdomain_id()==this_mpi_process, ExcInternalError());
1888 *   fe_values_ref.reinit(cell);
1889 *   fe_values_ref[u_fe].get_function_gradients(solution_total,
1890 *   solution_grads_u_total);
1891 *   fe_values_ref[J_fe].get_function_values(solution_total,
1892 *   solution_values_J_total);
1893 *   const std::vector<std::shared_ptr<const PointHistory<dim> > > lqph =
1894 *   quadrature_point_history.get_data(cell);
1895 *   Assert(lqph.size() == n_q_points, ExcInternalError());
1896 *   for (unsigned int q_point = 0; q_point < n_q_points; ++q_point)
1897 *   {
1898 *   const double det_F_qp = determinant(Physics::Elasticity::Kinematics::F(solution_grads_u_total[q_point]));
1899 *   const double J_tilde_qp = solution_values_J_total[q_point];
1900 *   const double the_error_qp_squared = std::pow((det_F_qp - J_tilde_qp),
1901 *   2);
1902 *   const double JxW = fe_values_ref.JxW(q_point);
1903 *   dil_L2_error += the_error_qp_squared * JxW;
1904 *   vol_reference += JxW;
1905 *   vol_current += det_F_qp * JxW;
1906 *   }
1907 *   }
1908 *   Assert(vol_current > 0.0, ExcInternalError());
1909 * @endcode
1910 *
1911 * Sum across all processors
1912 *
1913 * @code
1914 *   dil_L2_error = Utilities::MPI::sum(dil_L2_error,mpi_communicator);
1915 *   vol_reference = Utilities::MPI::sum(vol_reference,mpi_communicator);
1916 *   vol_current = Utilities::MPI::sum(vol_current,mpi_communicator);
1917 *  
1918 *   return std::make_pair(std::sqrt(dil_L2_error),
1919 *   std::make_pair(vol_reference,vol_current));
1920 *   }
1921 *   template <int dim>
1922 *   void Solid<dim>::get_error_residual(Errors &error_residual)
1923 *   {
1924 * @endcode
1925 *
1926 * Construct a residual vector that has the values for all of its
1927 * constrained DoFs set to zero.
1928 *
1929 * @code
1930 *   LA::MPI::BlockVector error_res (system_rhs);
1931 *   constraints.set_zero(error_res);
1932 *   error_residual.norm = error_res.l2_norm();
1933 *   error_residual.u = error_res.block(u_block).l2_norm();
1934 *   error_residual.p = error_res.block(p_block).l2_norm();
1935 *   error_residual.J = error_res.block(J_block).l2_norm();
1936 *   }
1937 *   template <int dim>
1938 *   void Solid<dim>::get_error_update(const LA::MPI::BlockVector &newton_update,
1939 *   Errors &error_update)
1940 *   {
1941 * @endcode
1942 *
1943 * Construct a update vector that has the values for all of its
1944 * constrained DoFs set to zero.
1945 *
1946 * @code
1947 *   LA::MPI::BlockVector error_ud (newton_update);
1948 *   constraints.set_zero(error_ud);
1949 *   error_update.norm = error_ud.l2_norm();
1950 *   error_update.u = error_ud.block(u_block).l2_norm();
1951 *   error_update.p = error_ud.block(p_block).l2_norm();
1952 *   error_update.J = error_ud.block(J_block).l2_norm();
1953 *   }
1954 *   template <int dim>
1955 *   LA::MPI::BlockVector
1956 *   Solid<dim>::get_solution_total(const LA::MPI::BlockVector &solution_delta) const
1957 *   {
1958 * @endcode
1959 *
1960 * Cell interpolation -> Ghosted vector
1961 *
1962 * @code
1963 *   LA::MPI::BlockVector solution_total (locally_owned_partitioning,
1964 *   locally_relevant_partitioning,
1965 *   mpi_communicator,
1966 *   /*vector_writable = */ false);
1967 *   LA::MPI::BlockVector tmp (solution_total);
1968 *   solution_total = solution_n;
1969 *   tmp = solution_delta;
1970 *   solution_total += tmp;
1971 *   return solution_total;
1972 *   }
1973 *   template <int dim>
1974 *   void Solid<dim>::assemble_system(const LA::MPI::BlockVector &solution_delta)
1975 *   {
1976 *   timer.enter_subsection("Assemble system");
1977 *   pcout << " ASM_SYS " << std::flush;
1978 *   tangent_matrix = 0.0;
1979 *   system_rhs = 0.0;
1980 *   const LA::MPI::BlockVector solution_total(get_solution_total(solution_delta));
1981 *   const UpdateFlags uf_cell(update_values |
1982 *   update_gradients |
1983 *   update_JxW_values);
1984 *   const UpdateFlags uf_face(update_values |
1985 *   update_normal_vectors |
1986 *   update_JxW_values);
1987 *   PerTaskData_ASM per_task_data(dofs_per_cell);
1988 *   ScratchData_ASM scratch_data(fe, qf_cell, uf_cell, qf_face, uf_face, solution_total);
1989 *  
1990 *   FilteredIterator<typename DoFHandler<dim>::active_cell_iterator>
1991 *   cell (IteratorFilters::SubdomainEqualTo(this_mpi_process),
1992 *   dof_handler.begin_active()),
1993 *   endc (IteratorFilters::SubdomainEqualTo(this_mpi_process),
1994 *   dof_handler.end());
1995 *   for (; cell != endc; ++cell)
1996 *   {
1997 *   Assert(cell->subdomain_id()==this_mpi_process, ExcInternalError());
1998 *   assemble_system_one_cell(cell, scratch_data, per_task_data);
1999 *   copy_local_to_global_system(per_task_data);
2000 *   }
2001 *   tangent_matrix.compress(VectorOperation::add);
2002 *   system_rhs.compress(VectorOperation::add);
2003 *   timer.leave_subsection();
2004 *   }
2005 *   template <int dim>
2006 *   void Solid<dim>::copy_local_to_global_system(const PerTaskData_ASM &data)
2007 *   {
2008 *   constraints.distribute_local_to_global(data.cell_matrix, data.cell_rhs,
2009 *   data.local_dof_indices,
2010 *   tangent_matrix, system_rhs);
2011 *   }
2012 *   template <int dim>
2013 *   void
2014 *   Solid<dim>::assemble_system_one_cell(const typename DoFHandler<dim>::active_cell_iterator &cell,
2015 *   ScratchData_ASM &scratch,
2016 *   PerTaskData_ASM &data) const
2017 *   {
2018 *   Assert(cell->subdomain_id()==this_mpi_process, ExcInternalError());
2019 *  
2020 *   data.reset();
2021 *   scratch.reset();
2022 *   scratch.fe_values_ref.reinit(cell);
2023 *   cell->get_dof_indices(data.local_dof_indices);
2024 *   const std::vector<std::shared_ptr<const PointHistory<dim> > > lqph =
2025 *   quadrature_point_history.get_data(cell);
2026 *   Assert(lqph.size() == n_q_points, ExcInternalError());
2027 *  
2028 * @endcode
2029 *
2030 * Update quadrature point solution
2031 *
2032 * @code
2033 *   scratch.fe_values_ref[u_fe].get_function_gradients(scratch.solution_total,
2034 *   scratch.solution_grads_u_total);
2035 *   scratch.fe_values_ref[p_fe].get_function_values(scratch.solution_total,
2036 *   scratch.solution_values_p_total);
2037 *   scratch.fe_values_ref[J_fe].get_function_values(scratch.solution_total,
2038 *   scratch.solution_values_J_total);
2039 *  
2040 * @endcode
2041 *
2042 * Update shape functions and their gradients (push-forward)
2043 *
2044 * @code
2045 *   for (unsigned int q_point = 0; q_point < n_q_points; ++q_point)
2046 *   {
2047 *   const Tensor<2, dim> F = Physics::Elasticity::Kinematics::F(scratch.solution_grads_u_total[q_point]);
2048 *   const Tensor<2, dim> F_inv = invert(F);
2049 *  
2050 *   for (unsigned int k = 0; k < dofs_per_cell; ++k)
2051 *   {
2052 *   const unsigned int k_group = fe.system_to_base_index(k).first.first;
2053 *   if (k_group == u_block)
2054 *   {
2055 *   scratch.grad_Nx[q_point][k] = scratch.fe_values_ref[u_fe].gradient(k, q_point)
2056 *   * F_inv;
2057 *   scratch.symm_grad_Nx[q_point][k] = symmetrize(scratch.grad_Nx[q_point][k]);
2058 *   }
2059 *   else if (k_group == p_block)
2060 *   scratch.Nx[q_point][k] = scratch.fe_values_ref[p_fe].value(k,
2061 *   q_point);
2062 *   else if (k_group == J_block)
2063 *   scratch.Nx[q_point][k] = scratch.fe_values_ref[J_fe].value(k,
2064 *   q_point);
2065 *   else
2066 *   Assert(k_group <= J_block, ExcInternalError());
2067 *   }
2068 *   }
2069 *   for (unsigned int q_point = 0; q_point < n_q_points; ++q_point)
2070 *   {
2071 *   const SymmetricTensor<2, dim> &I = Physics::Elasticity::StandardTensors<dim>::I;
2072 *   const Tensor<2, dim> F = Physics::Elasticity::Kinematics::F(scratch.solution_grads_u_total[q_point]);
2073 *   const double det_F = determinant(F);
2074 *   const double &p_tilde = scratch.solution_values_p_total[q_point];
2075 *   const double &J_tilde = scratch.solution_values_J_total[q_point];
2076 *   Assert(det_F > 0, ExcInternalError());
2077 *  
2078 *   {
2079 *   PointHistory<dim> *lqph_q_point_nc = const_cast<PointHistory<dim>*>(lqph[q_point].get());
2080 *   lqph_q_point_nc->update_internal_equilibrium(F,p_tilde,J_tilde);
2081 *   }
2082 *  
2083 *   const SymmetricTensor<2, dim> tau = lqph[q_point]->get_tau(F,p_tilde);
2084 *   const Tensor<2, dim> tau_ns (tau);
2085 *   const SymmetricTensor<4, dim> Jc = lqph[q_point]->get_Jc(F,p_tilde);
2086 *   const double dPsi_vol_dJ = lqph[q_point]->get_dPsi_vol_dJ(J_tilde);
2087 *   const double d2Psi_vol_dJ2 = lqph[q_point]->get_d2Psi_vol_dJ2(J_tilde);
2088 *  
2089 *   const std::vector<double> &Nx = scratch.Nx[q_point];
2090 *   const std::vector<Tensor<2, dim> > &grad_Nx = scratch.grad_Nx[q_point];
2091 *   const std::vector<SymmetricTensor<2, dim> > &symm_grad_Nx = scratch.symm_grad_Nx[q_point];
2092 *   const double JxW = scratch.fe_values_ref.JxW(q_point);
2093 *  
2094 *   for (unsigned int i = 0; i < dofs_per_cell; ++i)
2095 *   {
2096 *   const unsigned int component_i = fe.system_to_component_index(i).first;
2097 *   const unsigned int i_group = fe.system_to_base_index(i).first.first;
2098 *   if (i_group == u_block)
2099 *   data.cell_rhs(i) -= (symm_grad_Nx[i] * tau) * JxW;
2100 *   else if (i_group == p_block)
2101 *   data.cell_rhs(i) -= Nx[i] * (det_F - J_tilde) * JxW;
2102 *   else if (i_group == J_block)
2103 *   data.cell_rhs(i) -= Nx[i] * (dPsi_vol_dJ - p_tilde) * JxW;
2104 *   else
2105 *   Assert(i_group <= J_block, ExcInternalError());
2106 *  
2107 *   for (unsigned int j = 0; j <= i; ++j)
2108 *   {
2109 *   const unsigned int component_j = fe.system_to_component_index(j).first;
2110 *   const unsigned int j_group = fe.system_to_base_index(j).first.first;
2111 *   if ((i_group == u_block) && (j_group == u_block))
2112 *   {
2113 *   data.cell_matrix(i, j) += symm_grad_Nx[i] * Jc // The material contribution:
2114 *   * symm_grad_Nx[j] * JxW;
2115 *   if (component_i == component_j) // geometrical stress contribution
2116 *   data.cell_matrix(i, j) += grad_Nx[i][component_i] * tau_ns
2117 *   * grad_Nx[j][component_j] * JxW;
2118 *   }
2119 *   else if ((i_group == u_block) && (j_group == p_block))
2120 *   {
2121 *   data.cell_matrix(i, j) += (symm_grad_Nx[i] * I)
2122 *   * Nx[j] * det_F
2123 *   * JxW;
2124 *   }
2125 *   else if ((i_group == p_block) && (j_group == u_block))
2126 *   {
2127 *   data.cell_matrix(i, j) += Nx[i] * det_F
2128 *   * (symm_grad_Nx[j] * I)
2129 *   * JxW;
2130 *   }
2131 *   else if ((i_group == p_block) && (j_group == J_block))
2132 *   data.cell_matrix(i, j) -= Nx[i] * Nx[j] * JxW;
2133 *   else if ((i_group == J_block) && (j_group == p_block))
2134 *   data.cell_matrix(i, j) -= Nx[i] * Nx[j] * JxW;
2135 *   else if ((i_group == J_block) && (j_group == J_block))
2136 *   data.cell_matrix(i, j) += Nx[i] * d2Psi_vol_dJ2 * Nx[j] * JxW;
2137 *   else
2138 *   Assert((i_group <= J_block) && (j_group <= J_block),
2139 *   ExcInternalError());
2140 *   }
2141 *   }
2142 *   }
2143 *  
2144 *   for (unsigned int i = 0; i < dofs_per_cell; ++i)
2145 *   for (unsigned int j = i + 1; j < dofs_per_cell; ++j)
2146 *   data.cell_matrix(i, j) = data.cell_matrix(j, i);
2147 *  
2148 *   if (parameters.driver == "Neumann")
2149 *   for (unsigned int face = 0; face < GeometryInfo<dim>::faces_per_cell;
2150 *   ++face)
2151 *   if (cell->face(face)->at_boundary() == true
2152 *   && cell->face(face)->boundary_id() == parameters.boundary_id_plus_Y)
2153 *   {
2154 *   scratch.fe_face_values_ref.reinit(cell, face);
2155 *   for (unsigned int f_q_point = 0; f_q_point < n_q_points_f;
2156 *   ++f_q_point)
2157 *   {
2158 *   const Tensor<1, dim> &N =
2159 *   scratch.fe_face_values_ref.normal_vector(f_q_point);
2160 *   static const double pressure_nom = parameters.pressure
2161 *   / (parameters.scale * parameters.scale);
2162 *   const double time_ramp = (time.current() < parameters.load_time ?
2163 *   time.current() / parameters.load_time : 1.0);
2164 *   const double pressure = -pressure_nom * time_ramp;
2165 *   const Tensor<1, dim> traction = pressure * N;
2166 *   for (unsigned int i = 0; i < dofs_per_cell; ++i)
2167 *   {
2168 *   const unsigned int i_group =
2169 *   fe.system_to_base_index(i).first.first;
2170 *   if (i_group == u_block)
2171 *   {
2172 *   const unsigned int component_i =
2173 *   fe.system_to_component_index(i).first;
2174 *   const double Ni =
2175 *   scratch.fe_face_values_ref.shape_value(i,
2176 *   f_q_point);
2177 *   const double JxW = scratch.fe_face_values_ref.JxW(
2178 *   f_q_point);
2179 *   data.cell_rhs(i) += (Ni * traction[component_i])
2180 *   * JxW;
2181 *   }
2182 *   }
2183 *   }
2184 *   }
2185 *   }
2186 *   template <int dim>
2187 *   void Solid<dim>::make_constraints(const int &it_nr)
2188 *   {
2189 *   pcout << " CST " << std::flush;
2190 *   if (it_nr > 1)
2191 *   return;
2192 *   constraints.clear();
2193 *   const bool apply_dirichlet_bc = (it_nr == 0);
2194 *   const FEValuesExtractors::Scalar x_displacement(0);
2195 *   const FEValuesExtractors::Scalar y_displacement(1);
2196 *   {
2197 *   const int boundary_id = parameters.boundary_id_minus_X;
2198 *   if (apply_dirichlet_bc == true)
2199 *   VectorTools::interpolate_boundary_values(dof_handler,
2200 *   boundary_id,
2201 *   Functions::ZeroFunction<dim>(n_components),
2202 *   constraints,
2203 *   fe.component_mask(x_displacement));
2204 *   else
2205 *   VectorTools::interpolate_boundary_values(dof_handler,
2206 *   boundary_id,
2207 *   Functions::ZeroFunction<dim>(n_components),
2208 *   constraints,
2209 *   fe.component_mask(x_displacement));
2210 *   }
2211 *   {
2212 *   const int boundary_id = parameters.boundary_id_minus_Y;
2213 *   if (apply_dirichlet_bc == true)
2214 *   VectorTools::interpolate_boundary_values(dof_handler,
2215 *   boundary_id,
2216 *   Functions::ZeroFunction<dim>(n_components),
2217 *   constraints,
2218 *   fe.component_mask(y_displacement));
2219 *   else
2220 *   VectorTools::interpolate_boundary_values(dof_handler,
2221 *   boundary_id,
2222 *   Functions::ZeroFunction<dim>(n_components),
2223 *   constraints,
2224 *   fe.component_mask(y_displacement));
2225 *   }
2226 *   if (dim==3)
2227 *   {
2228 *   const FEValuesExtractors::Scalar z_displacement(2);
2229 *   {
2230 *   const int boundary_id = parameters.boundary_id_minus_Z;
2231 *   if (apply_dirichlet_bc == true)
2232 *   VectorTools::interpolate_boundary_values(dof_handler,
2233 *   boundary_id,
2234 *   Functions::ZeroFunction<dim>(n_components),
2235 *   constraints,
2236 *   fe.component_mask(z_displacement));
2237 *   else
2238 *   VectorTools::interpolate_boundary_values(dof_handler,
2239 *   boundary_id,
2240 *   Functions::ZeroFunction<dim>(n_components),
2241 *   constraints,
2242 *   fe.component_mask(z_displacement));
2243 *   }
2244 *   {
2245 *   const int boundary_id = parameters.boundary_id_plus_Z;
2246 *   if (apply_dirichlet_bc == true)
2247 *   VectorTools::interpolate_boundary_values(dof_handler,
2248 *   boundary_id,
2249 *   Functions::ZeroFunction<dim>(n_components),
2250 *   constraints,
2251 *   fe.component_mask(z_displacement));
2252 *   else
2253 *   VectorTools::interpolate_boundary_values(dof_handler,
2254 *   boundary_id,
2255 *   Functions::ZeroFunction<dim>(n_components),
2256 *   constraints,
2257 *   fe.component_mask(z_displacement));
2258 *   }
2259 *   }
2260 *   if (parameters.driver == "Dirichlet")
2261 *   {
2262 *   const int boundary_id = parameters.boundary_id_plus_Y;
2263 *   if (apply_dirichlet_bc == true)
2264 *   {
2265 *  
2266 *   if (time.current() < parameters.load_time+0.01*time.get_delta_t())
2267 *   {
2268 *   const double delta_length = parameters.length*(parameters.stretch - 1.0)*parameters.scale;
2269 *   const unsigned int n_stretch_steps = static_cast<unsigned int>(parameters.load_time/time.get_delta_t());
2270 *   const double delta_u_y = delta_length/2.0/n_stretch_steps;
2271 *   VectorTools::interpolate_boundary_values(dof_handler,
2272 *   boundary_id,
2273 *   Functions::ConstantFunction<dim>(delta_u_y,n_components),
2274 *   constraints,
2275 *   fe.component_mask(y_displacement));
2276 *   }
2277 *   else
2278 *   VectorTools::interpolate_boundary_values(dof_handler,
2279 *   boundary_id,
2280 *   Functions::ZeroFunction<dim>(n_components),
2281 *   constraints,
2282 *   fe.component_mask(y_displacement));
2283 *   }
2284 *   else
2285 *   VectorTools::interpolate_boundary_values(dof_handler,
2286 *   boundary_id,
2287 *   Functions::ZeroFunction<dim>(n_components),
2288 *   constraints,
2289 *   fe.component_mask(y_displacement));
2290 *   }
2291 *   constraints.close();
2292 *   }
2293 *   template <int dim>
2294 *   std::pair<unsigned int, double>
2295 *   Solid<dim>::solve_linear_system(LA::MPI::BlockVector &newton_update)
2296 *   {
2297 *   unsigned int lin_it = 0;
2298 *   double lin_res = 0.0;
2299 *  
2300 *   timer.enter_subsection("Linear solver");
2301 *   pcout << " SLV " << std::flush;
2302 *  
2303 *   const LA::MPI::Vector &f_u = system_rhs.block(u_block);
2304 *   const LA::MPI::Vector &f_p = system_rhs.block(p_block);
2305 *   const LA::MPI::Vector &f_J = system_rhs.block(J_block);
2306 *   LA::MPI::Vector &d_u = newton_update.block(u_block);
2307 *   LA::MPI::Vector &d_p = newton_update.block(p_block);
2308 *   LA::MPI::Vector &d_J = newton_update.block(J_block);
2309 *   const auto K_uu = linear_operator<LA::MPI::Vector>(tangent_matrix.block(u_block, u_block));
2310 *   const auto K_up = linear_operator<LA::MPI::Vector>(tangent_matrix.block(u_block, p_block));
2311 *   const auto K_pu = linear_operator<LA::MPI::Vector>(tangent_matrix.block(p_block, u_block));
2312 *   const auto K_Jp = linear_operator<LA::MPI::Vector>(tangent_matrix.block(J_block, p_block));
2313 *   const auto K_JJ = linear_operator<LA::MPI::Vector>(tangent_matrix.block(J_block, J_block));
2314 *  
2315 *   LA::PreconditionJacobi preconditioner_K_Jp_inv;
2316 *   preconditioner_K_Jp_inv.initialize(
2317 *   tangent_matrix.block(J_block, p_block),
2318 *   LA::PreconditionJacobi::AdditionalData());
2319 *   ReductionControl solver_control_K_Jp_inv (
2320 *   static_cast<unsigned int>(tangent_matrix.block(J_block, p_block).m()
2321 *   * parameters.max_iterations_lin),
2322 *   1.0e-30, 1e-6);
2323 *   ::SolverCG<LA::MPI::Vector> solver_K_Jp_inv (solver_control_K_Jp_inv);
2324 *  
2325 *   const auto K_Jp_inv = inverse_operator(K_Jp,
2326 *   solver_K_Jp_inv,
2327 *   preconditioner_K_Jp_inv);
2328 *   const auto K_pJ_inv = transpose_operator(K_Jp_inv);
2329 *   const auto K_pp_bar = K_Jp_inv * K_JJ * K_pJ_inv;
2330 *   const auto K_uu_bar_bar = K_up * K_pp_bar * K_pu;
2331 *   const auto K_uu_con = K_uu + K_uu_bar_bar;
2332 *  
2333 *   LA::PreconditionAMG preconditioner_K_con_inv;
2334 *   preconditioner_K_con_inv.initialize(
2335 *   tangent_matrix.block(u_block, u_block),
2336 *   LA::PreconditionAMG::AdditionalData(
2337 *   true /*elliptic*/,
2338 *   (parameters.poly_degree > 1 /*higher_order_elements*/)) );
2339 *   ReductionControl solver_control_K_con_inv (
2340 *   static_cast<unsigned int>(tangent_matrix.block(u_block, u_block).m()
2341 *   * parameters.max_iterations_lin),
2342 *   1.0e-30, parameters.tol_lin);
2343 *   ::SolverSelector<LA::MPI::Vector> solver_K_con_inv;
2344 *   solver_K_con_inv.select(parameters.type_lin);
2345 *   solver_K_con_inv.set_control(solver_control_K_con_inv);
2346 *   const auto K_uu_con_inv = inverse_operator(K_uu_con,
2347 *   solver_K_con_inv,
2348 *   preconditioner_K_con_inv);
2349 *  
2350 *   d_u = K_uu_con_inv*(f_u - K_up*(K_Jp_inv*f_J - K_pp_bar*f_p));
2351 *   lin_it = solver_control_K_con_inv.last_step();
2352 *   lin_res = solver_control_K_con_inv.last_value();
2353 *   timer.leave_subsection();
2354 *  
2355 *   timer.enter_subsection("Linear solver postprocessing");
2356 *   d_J = K_pJ_inv*(f_p - K_pu*d_u);
2357 *   d_p = K_Jp_inv*(f_J - K_JJ*d_J);
2358 *   timer.leave_subsection();
2359 *  
2360 *   constraints.distribute(newton_update);
2361 *   return std::make_pair(lin_it, lin_res);
2362 *   }
2363 *   template <int dim>
2364 *   void
2365 *   Solid<dim>::update_end_timestep ()
2366 *   {
2367 *   FilteredIterator<typename DoFHandler<dim>::active_cell_iterator>
2368 *   cell (IteratorFilters::SubdomainEqualTo(this_mpi_process),
2369 *   dof_handler.begin_active()),
2370 *   endc (IteratorFilters::SubdomainEqualTo(this_mpi_process),
2371 *   dof_handler.end());
2372 *   for (; cell != endc; ++cell)
2373 *   {
2374 *   Assert(cell->subdomain_id()==this_mpi_process, ExcInternalError());
2375 *   const std::vector<std::shared_ptr<PointHistory<dim> > > lqph =
2376 *   quadrature_point_history.get_data(cell);
2377 *   Assert(lqph.size() == n_q_points, ExcInternalError());
2378 *   for (unsigned int q_point = 0; q_point < n_q_points; ++q_point)
2379 *   lqph[q_point]->update_end_timestep();
2380 *   }
2381 *   }
2382 *  
2383 *   template<int dim>
2384 *   class FilteredDataOut : public DataOut<dim>
2385 *   {
2386 *   public:
2387 *   FilteredDataOut (const unsigned int subdomain_id)
2388 *   :
2389 *   subdomain_id (subdomain_id)
2390 *   {}
2391 *  
2392 *   virtual ~FilteredDataOut() {}
2393 *  
2394 *   virtual typename DataOut<dim>::cell_iterator
2395 *   first_cell ()
2396 *   {
2397 *   auto cell = this->dofs->begin_active();
2398 *   while ((cell != this->dofs->end()) &&
2399 *   (cell->subdomain_id() != subdomain_id))
2400 *   ++cell;
2401 *   return cell;
2402 *   }
2403 *  
2404 *   virtual typename DataOut<dim>::cell_iterator
2405 *   next_cell (const typename DataOut<dim>::cell_iterator &old_cell)
2406 *   {
2407 *   if (old_cell != this->dofs->end())
2408 *   {
2409 *   const IteratorFilters::SubdomainEqualTo predicate(subdomain_id);
2410 *   return
2411 *   ++(FilteredIterator
2412 *   <typename DataOut<dim>::cell_iterator>
2413 *   (predicate,old_cell));
2414 *   }
2415 *   else
2416 *   return old_cell;
2417 *   }
2418 *  
2419 *   private:
2420 *   const unsigned int subdomain_id;
2421 *   };
2422 *  
2423 *   template <int dim>
2424 *   void Solid<dim>::output_results(const unsigned int timestep,
2425 *   const double current_time) const
2426 *   {
2427 * @endcode
2428 *
2429 * Output -> Ghosted vector
2430 *
2431 * @code
2432 *   LA::MPI::BlockVector solution_total (locally_owned_partitioning,
2433 *   locally_relevant_partitioning,
2434 *   mpi_communicator,
2435 *   /*vector_writable = */ false);
2436 *   LA::MPI::BlockVector residual (locally_owned_partitioning,
2437 *   locally_relevant_partitioning,
2438 *   mpi_communicator,
2439 *   /*vector_writable = */ false);
2440 *   solution_total = solution_n;
2441 *   residual = system_rhs;
2442 *   residual *= -1.0;
2443 *  
2444 * @endcode
2445 *
2446 * --- Additional data ---
2447 *
2448 * @code
2449 *   Vector<double> material_id;
2450 *   Vector<double> polynomial_order;
2451 *   material_id.reinit(triangulation.n_active_cells());
2452 *   polynomial_order.reinit(triangulation.n_active_cells());
2453 *   std::vector<types::subdomain_id> partition_int (triangulation.n_active_cells());
2454 *  
2455 *   FilteredDataOut<dim> data_out(this_mpi_process);
2456 *   std::vector<DataComponentInterpretation::DataComponentInterpretation>
2457 *   data_component_interpretation(dim,
2458 *   DataComponentInterpretation::component_is_part_of_vector);
2459 *   data_component_interpretation.push_back(DataComponentInterpretation::component_is_scalar);
2460 *   data_component_interpretation.push_back(DataComponentInterpretation::component_is_scalar);
2461 *  
2462 *   GridTools::get_subdomain_association (triangulation, partition_int);
2463 *  
2464 * @endcode
2465 *
2466 * Can't use filtered iterators here because the cell
2467 * count "c" is incorrect for the parallel case
2468 *
2469 * @code
2470 *   unsigned int c = 0;
2472 *   cell = dof_handler.begin_active(),
2473 *   endc = dof_handler.end();
2474 *   for (; cell!=endc; ++cell, ++c)
2475 *   {
2476 *   if (cell->subdomain_id() != this_mpi_process) continue;
2477 *  
2478 *   material_id(c) = static_cast<int>(cell->material_id());
2479 *   }
2480 *  
2481 *   std::vector<std::string> solution_name(n_components, "solution_");
2482 *   std::vector<std::string> residual_name(n_components, "residual_");
2483 *   for (unsigned int c=0; c<n_components; ++c)
2484 *   {
2485 *   if (block_component[c] == u_block)
2486 *   {
2487 *   solution_name[c] += "u";
2488 *   residual_name[c] += "u";
2489 *   }
2490 *   else if (block_component[c] == p_block)
2491 *   {
2492 *   solution_name[c] += "p";
2493 *   residual_name[c] += "p";
2494 *   }
2495 *   else if (block_component[c] == J_block)
2496 *   {
2497 *   solution_name[c] += "J";
2498 *   residual_name[c] += "J";
2499 *   }
2500 *   else
2501 *   {
2502 *   Assert(c <= J_block, ExcInternalError());
2503 *   }
2504 *   }
2505 *  
2506 *   data_out.attach_dof_handler(dof_handler);
2507 *   data_out.add_data_vector(solution_total,
2508 *   solution_name,
2510 *   data_component_interpretation);
2511 *   data_out.add_data_vector(residual,
2512 *   residual_name,
2514 *   data_component_interpretation);
2515 *   const Vector<double> partitioning(partition_int.begin(),
2516 *   partition_int.end());
2517 *   data_out.add_data_vector (material_id, "material_id");
2518 *   data_out.add_data_vector (partitioning, "partitioning");
2519 *   data_out.build_patches(degree);
2520 *  
2521 *   struct Filename
2522 *   {
2523 *   static std::string get_filename_vtu (unsigned int process,
2524 *   unsigned int timestep,
2525 *   const unsigned int n_digits = 4)
2526 *   {
2527 *   std::ostringstream filename_vtu;
2528 *   filename_vtu
2529 *   << "solution-"
2530 *   << (std::to_string(dim) + "d")
2531 *   << "."
2532 *   << Utilities::int_to_string (process, n_digits)
2533 *   << "."
2534 *   << Utilities::int_to_string(timestep, n_digits)
2535 *   << ".vtu";
2536 *   return filename_vtu.str();
2537 *   }
2538 *  
2539 *   static std::string get_filename_pvtu (unsigned int timestep,
2540 *   const unsigned int n_digits = 4)
2541 *   {
2542 *   std::ostringstream filename_vtu;
2543 *   filename_vtu
2544 *   << "solution-"
2545 *   << (std::to_string(dim) + "d")
2546 *   << "."
2547 *   << Utilities::int_to_string(timestep, n_digits)
2548 *   << ".pvtu";
2549 *   return filename_vtu.str();
2550 *   }
2551 *  
2552 *   static std::string get_filename_pvd (void)
2553 *   {
2554 *   std::ostringstream filename_vtu;
2555 *   filename_vtu
2556 *   << "solution-"
2557 *   << (std::to_string(dim) + "d")
2558 *   << ".pvd";
2559 *   return filename_vtu.str();
2560 *   }
2561 *   };
2562 *  
2563 * @endcode
2564 *
2565 * Write out main data file
2566 *
2567 * @code
2568 *   const std::string filename_vtu = Filename::get_filename_vtu(this_mpi_process, timestep);
2569 *   std::ofstream output(filename_vtu.c_str());
2570 *   data_out.write_vtu(output);
2571 *  
2572 * @endcode
2573 *
2574 * Collection of files written in parallel
2575 * This next set of steps should only be performed
2576 * by master process
2577 *
2578 * @code
2579 *   if (this_mpi_process == 0)
2580 *   {
2581 * @endcode
2582 *
2583 * List of all files written out at this timestep by all processors
2584 *
2585 * @code
2586 *   std::vector<std::string> parallel_filenames_vtu;
2587 *   for (unsigned int p=0; p < n_mpi_processes; ++p)
2588 *   {
2589 *   parallel_filenames_vtu.push_back(Filename::get_filename_vtu(p, timestep));
2590 *   }
2591 *  
2592 *   const std::string filename_pvtu (Filename::get_filename_pvtu(timestep));
2593 *   std::ofstream pvtu_master(filename_pvtu.c_str());
2594 *   data_out.write_pvtu_record(pvtu_master,
2595 *   parallel_filenames_vtu);
2596 *  
2597 * @endcode
2598 *
2599 * Time dependent data master file
2600 *
2601 * @code
2602 *   static std::vector<std::pair<double,std::string> > time_and_name_history;
2603 *   time_and_name_history.push_back (std::make_pair (current_time,
2604 *   filename_pvtu));
2605 *   const std::string filename_pvd (Filename::get_filename_pvd());
2606 *   std::ofstream pvd_output (filename_pvd.c_str());
2607 *   DataOutBase::write_pvd_record (pvd_output, time_and_name_history);
2608 *   }
2609 *   }
2610 *   template <int dim>
2611 *   void Solid<dim>::compute_vertex_positions(std::vector<double> &real_time,
2612 *   std::vector<std::vector<Point<dim> > > &tracked_vertices,
2613 *   const LA::MPI::BlockVector &solution_total) const
2614 *   {
2615 *   real_time.push_back(time.current());
2616 *  
2617 *   std::vector<bool> vertex_found (tracked_vertices.size(), false);
2618 *   std::vector<Tensor<1,dim> > vertex_update (tracked_vertices.size());
2619 *  
2621 *   cell (IteratorFilters::SubdomainEqualTo(this_mpi_process),
2622 *   dof_handler.begin_active()),
2623 *   endc (IteratorFilters::SubdomainEqualTo(this_mpi_process),
2624 *   dof_handler.end());
2625 *   for (; cell != endc; ++cell)
2626 *   {
2627 *   Assert(cell->subdomain_id()==this_mpi_process, ExcInternalError());
2628 *   for (unsigned int v=0; v<GeometryInfo<dim>::vertices_per_cell; ++v)
2629 *   {
2630 *   for (unsigned int p=0; p<tracked_vertices.size(); ++p)
2631 *   {
2632 *   if (vertex_found[p] == true) continue;
2633 *  
2634 *   const Point<dim> pt_ref = tracked_vertices[p][0];
2635 *   if (cell->vertex(v).distance(pt_ref) < 1e-6*parameters.scale)
2636 *   {
2637 *   for (unsigned int d=0; d<dim; ++d)
2638 *   vertex_update[p][d] = solution_total(cell->vertex_dof_index(v,u_block+d));
2639 *  
2640 *   vertex_found[p] = true;
2641 *   }
2642 *   }
2643 *   }
2644 *   }
2645 *  
2646 *   for (unsigned int p=0; p<tracked_vertices.size(); ++p)
2647 *   {
2648 *   const int found_on_n_processes = Utilities::MPI::sum(int(vertex_found[p]), mpi_communicator);
2649 *   Assert(found_on_n_processes>0, ExcMessage("Vertex not found on any processor"));
2650 *   Tensor<1,dim> update;
2651 *   for (unsigned int d=0; d<dim; ++d)
2652 *   update[d] = Utilities::MPI::sum(vertex_update[p][d], mpi_communicator);
2653 *   update /= found_on_n_processes;
2654 *   tracked_vertices[p].push_back(tracked_vertices[p][0] + update);
2655 *   }
2656 *  
2657 *   }
2658 *   }
2659 *   int main (int argc, char *argv[])
2660 *   {
2661 *   using namespace dealii;
2662 *   using namespace ViscoElasStripHole;
2663 *  
2664 *   Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv);
2665 *  
2666 *   try
2667 *   {
2668 *   const unsigned int dim = 2; // Works in both 2d and 3d
2669 *   Solid<dim> solid("parameters.prm");
2670 *   solid.run();
2671 *   }
2672 *   catch (std::exception &exc)
2673 *   {
2674 *   if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0)
2675 *   {
2676 *   std::cerr << std::endl << std::endl
2677 *   << "----------------------------------------------------"
2678 *   << std::endl;
2679 *   std::cerr << "Exception on processing: " << std::endl << exc.what()
2680 *   << std::endl << "Aborting!" << std::endl
2681 *   << "----------------------------------------------------"
2682 *   << std::endl;
2683 *   return 1;
2684 *   }
2685 *   }
2686 *   catch (...)
2687 *   {
2688 *   if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0)
2689 *   {
2690 *   std::cerr << std::endl << std::endl
2691 *   << "----------------------------------------------------"
2692 *   << std::endl;
2693 *   std::cerr << "Unknown exception!" << std::endl << "Aborting!"
2694 *   << std::endl
2695 *   << "----------------------------------------------------"
2696 *   << std::endl;
2697 *   return 1;
2698 *   }
2699 *   }
2700 *   return 0;
2701 *   }
2702 * @endcode
2703
2704
2705*/
Definition fe_q.h:554
Definition point.h:111
@ wall_times
Definition timer.h:651
DerivativeForm< 1, spacedim, dim, Number > transpose(const DerivativeForm< 1, dim, spacedim, Number > &DF)
Point< 2 > first
Definition grid_out.cc:4623
#define Assert(cond, exc)
typename ActiveSelector::active_cell_iterator active_cell_iterator
LinearOperator< Range, Domain, Payload > linear_operator(const OperatorExemplar &, const Matrix &)
UpdateFlags
std::vector< index_type > data
Definition mpi.cc:735
std::size_t size
Definition mpi.cc:734
void write_pvd_record(std::ostream &out, const std::vector< std::pair< double, std::string > > &times_and_names)
void hyper_cube_with_cylindrical_hole(Triangulation< dim, spacedim > &triangulation, const double inner_radius=.25, const double outer_radius=.5, const double L=.5, const unsigned int repetitions=1, const bool colorize=false)
void cylinder(Triangulation< dim > &tria, const double radius=1., const double half_length=1.)
void create_triangulation_with_removed_cells(const Triangulation< dim, spacedim > &input_triangulation, const std::set< typename Triangulation< dim, spacedim >::active_cell_iterator > &cells_to_remove, Triangulation< dim, spacedim > &result)
void scale(const double scaling_factor, Triangulation< dim, spacedim > &triangulation)
void cell_matrix(FullMatrix< double > &M, const FEValuesBase< dim > &fe, const FEValuesBase< dim > &fetest, const ArrayView< const std::vector< double > > &velocity, const double factor=1.)
Definition advection.h:74
double norm(const FEValuesBase< dim > &fe, const ArrayView< const std::vector< Tensor< 1, dim > > > &Du)
Definition divergence.h:471
std::enable_if_t< IsBlockVector< VectorType >::value, unsigned int > n_blocks(const VectorType &vector)
Definition operators.h:49
Point< spacedim > point(const gp_Pnt &p, const double tolerance=1e-10)
Definition utilities.cc:191
SymmetricTensor< 2, dim, Number > C(const Tensor< 2, dim, Number > &F)
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
Tensor< 2, dim, Number > F(const Tensor< 2, dim, Number > &Grad_u)
VectorType::value_type * end(VectorType &V)
T sum(const T &t, const MPI_Comm mpi_communicator)
unsigned int n_mpi_processes(const MPI_Comm mpi_communicator)
Definition mpi.cc:92
unsigned int this_mpi_process(const MPI_Comm mpi_communicator)
Definition mpi.cc:107
std::string int_to_string(const unsigned int value, const unsigned int digits=numbers::invalid_unsigned_int)
Definition utilities.cc:470
void project(const Mapping< dim, spacedim > &mapping, const DoFHandler< dim, spacedim > &dof, const AffineConstraints< typename VectorType::value_type > &constraints, const Quadrature< dim > &quadrature, const Function< spacedim, typename VectorType::value_type > &function, VectorType &vec, const bool enforce_zero_boundary=false, const Quadrature< dim - 1 > &q_boundary=(dim > 1 ? QGauss< dim - 1 >(2) :Quadrature< dim - 1 >()), const bool project_to_boundary_first=false)
void run(const Iterator &begin, const std_cxx20::type_identity_t< Iterator > &end, Worker worker, Copier copier, const ScratchData &sample_scratch_data, const CopyData &sample_copy_data, const unsigned int queue_length, const unsigned int chunk_size)
::VectorizedArray< Number, width > pow(const ::VectorizedArray< Number, width > &, const Number p)
::VectorizedArray< Number, width > abs(const ::VectorizedArray< Number, width > &)
unsigned int material_id
Definition types.h:167
const ::parallel::distributed::Triangulation< dim, spacedim > * triangulation
DEAL_II_HOST constexpr Number determinant(const SymmetricTensor< 2, dim, Number > &)
DEAL_II_HOST constexpr SymmetricTensor< 2, dim, Number > symmetrize(const Tensor< 2, dim, Number > &t)
DEAL_II_HOST constexpr SymmetricTensor< 2, dim, Number > invert(const SymmetricTensor< 2, dim, Number > &)
DEAL_II_HOST constexpr SymmetricTensor< 4, dim, Number > outer_product(const SymmetricTensor< 2, dim, Number > &t1, const SymmetricTensor< 2, dim, Number > &t2)
DEAL_II_HOST constexpr Number trace(const SymmetricTensor< 2, dim2, Number > &)