1890 * Solve
for the displacement
using a Newton-Raphson method. We
break this
1891 * function into the nonlinear
loop and the function that solves the
1892 * linearized Newton-Raphson step:
1897 * std::pair<unsigned int, double>
1902 * Solution retrieval as well as post-processing and writing data to file :
1908 *
void output_results()
const;
1912 * Finally, some member variables that describe the current state:
A
1913 * collection of the parameters used to describe the problem setup...
1916 * Parameters::AllParameters parameters;
1920 * ...the
volume of the reference configuration...
1923 *
double vol_reference;
1927 * ...and description of the geometry on which the problem is solved:
1934 * Also, keep track of the current time and the time spent evaluating
1943 *
A storage
object for quadrature
point information. As opposed to
1944 * @ref step_18
"step-18", deal.II
's native quadrature point data manager is employed
1948 * CellDataStorage<typename Triangulation<dim>::cell_iterator,
1949 * PointHistory<dim>>
1950 * quadrature_point_history;
1954 * A description of the finite-element system including the displacement
1955 * polynomial degree, the degree-of-freedom handler, number of DoFs per
1956 * cell and the extractor objects used to retrieve information from the
1960 * const unsigned int degree;
1961 * const FESystem<dim> fe;
1962 * DoFHandler<dim> dof_handler;
1963 * const unsigned int dofs_per_cell;
1964 * const FEValuesExtractors::Vector u_fe;
1965 * const FEValuesExtractors::Scalar p_fe;
1966 * const FEValuesExtractors::Scalar J_fe;
1970 * Description of how the block-system is arranged. There are 3 blocks,
1971 * the first contains a vector DOF @f$\mathbf{u}@f$ while the other two
1972 * describe scalar DOFs, @f$\widetilde{p}@f$ and @f$\widetilde{J}@f$.
1975 * static const unsigned int n_blocks = 3;
1976 * static const unsigned int n_components = dim + 2;
1977 * static const unsigned int first_u_component = 0;
1978 * static const unsigned int p_component = dim;
1979 * static const unsigned int J_component = dim + 1;
1988 * std::vector<types::global_dof_index> dofs_per_block;
1989 * std::vector<types::global_dof_index> element_indices_u;
1990 * std::vector<types::global_dof_index> element_indices_p;
1991 * std::vector<types::global_dof_index> element_indices_J;
1995 * Rules for Gauss-quadrature on both the cell and faces. The number of
1996 * quadrature points on both cells and faces is recorded.
1999 * const QGauss<dim> qf_cell;
2000 * const QGauss<dim - 1> qf_face;
2001 * const unsigned int n_q_points;
2002 * const unsigned int n_q_points_f;
2006 * Objects that store the converged solution and right-hand side vectors,
2007 * as well as the tangent matrix. There is an AffineConstraints object used
2008 * to keep track of constraints. We make use of a sparsity pattern
2009 * designed for a block system.
2012 * AffineConstraints<double> constraints;
2013 * BlockSparsityPattern sparsity_pattern;
2014 * BlockSparseMatrix<double> tangent_matrix;
2015 * BlockVector<double> system_rhs;
2016 * BlockVector<double> solution_n;
2020 * Then define a number of variables to store norms and update norms and
2021 * normalization factors.
2040 * void normalize(const Errors &rhs)
2042 * if (rhs.norm != 0.0)
2052 * double norm, u, p, J;
2055 * Errors error_residual, error_residual_0, error_residual_norm, error_update,
2056 * error_update_0, error_update_norm;
2060 * Methods to calculate error measures
2063 * void get_error_residual(Errors &error_residual);
2065 * void get_error_update(const BlockVector<double> &newton_update,
2066 * Errors & error_update);
2068 * std::pair<double, double> get_error_dilation() const;
2072 * Compute the volume in the spatial configuration
2075 * double compute_vol_current() const;
2079 * Print information to screen in a pleasing way...
2082 * static void print_conv_header();
2084 * void print_conv_footer();
2090 * <a name="ImplementationofthecodeSolidcodeclass"></a>
2091 * <h3>Implementation of the <code>Solid</code> class</h3>
2096 * <a name="Publicinterface"></a>
2097 * <h4>Public interface</h4>
2101 * We initialize the Solid class using data extracted from the parameter file.
2104 * template <int dim>
2105 * Solid<dim>::Solid(const std::string &input_file)
2106 * : parameters(input_file)
2107 * , vol_reference(0.)
2108 * , triangulation(Triangulation<dim>::maximum_smoothing)
2109 * , time(parameters.end_time, parameters.delta_t)
2110 * , timer(std::cout, TimerOutput::summary, TimerOutput::wall_times)
2111 * , degree(parameters.poly_degree)
2115 * The Finite Element System is composed of dim continuous displacement
2116 * DOFs, and discontinuous pressure and dilatation DOFs. In an attempt to
2117 * satisfy the Babuska-Brezzi or LBB stability conditions (see Hughes
2118 * (2000)), we setup a @f$Q_n \times DGPM_{n-1} \times DGPM_{n-1}@f$
2119 * system. @f$Q_2 \times DGPM_1 \times DGPM_1@f$ elements satisfy this
2120 * condition, while @f$Q_1 \times DGPM_0 \times DGPM_0@f$ elements do
2121 * not. However, it has been shown that the latter demonstrate good
2122 * convergence characteristics nonetheless.
2125 * fe(FE_Q<dim>(parameters.poly_degree),
2126 * dim, // displacement
2127 * FE_DGPMonomial<dim>(parameters.poly_degree - 1),
2129 * FE_DGPMonomial<dim>(parameters.poly_degree - 1),
2132 * dof_handler(triangulation)
2133 * , dofs_per_cell(fe.n_dofs_per_cell())
2134 * , u_fe(first_u_component)
2135 * , p_fe(p_component)
2136 * , J_fe(J_component)
2137 * , dofs_per_block(n_blocks)
2138 * , qf_cell(parameters.quad_order)
2139 * , qf_face(parameters.quad_order)
2140 * , n_q_points(qf_cell.size())
2141 * , n_q_points_f(qf_face.size())
2143 * Assert(dim == 2 || dim == 3,
2144 * ExcMessage("This problem only works in 2 or 3 space dimensions."));
2145 * determine_component_extractors();
2151 * In solving the quasi-static problem, the time becomes a loading parameter,
2152 * i.e. we increasing the loading linearly with time, making the two concepts
2153 * interchangeable. We choose to increment time linearly using a constant time
2158 * We start the function with preprocessing, setting the initial dilatation
2159 * values, and then output the initial grid before starting the simulation
2160 * proper with the first time (and loading)
2165 * Care must be taken (or at least some thought given) when imposing the
2166 * constraint @f$\widetilde{J}=1@f$ on the initial solution field. The constraint
2167 * corresponds to the determinant of the deformation gradient in the
2168 * undeformed configuration, which is the identity tensor. We use
2169 * FE_DGPMonomial bases to interpolate the dilatation field, thus we can't
2170 * simply
set the corresponding dof to unity as they correspond to the
2173 * indicating the hanging node constraints. We have
none in
this program
2174 * So we have to create a constraint
object. In its original state, constraint
2175 * objects are unsorted, and have to be sorted (
using the
2177 * @ref step_21
"step-21" for more information. We only need to enforce the
initial condition
2178 * on the dilatation. In order to
do this, we make use of a
2180 * n_components to 1. This is exactly what we want. Have a look at its usage
2181 * in @ref step_20
"step-20" for more information.
2184 *
template <
int dim>
2191 * constraints.
close();
2196 * dof_handler, constraints,
QGauss<dim>(degree + 2), J_mask, solution_n);
2203 * We then declare the incremental solution update @f$\varDelta
2204 * \mathbf{\Xi} \dealcoloneq \{\varDelta \mathbf{u},\varDelta \widetilde{p},
2205 * \varDelta \widetilde{J} \}@f$ and start the
loop over the time domain.
2209 * At the beginning, we reset the solution update
for this time step...
2213 *
while (time.current() < time.end())
2215 * solution_delta = 0.0;
2219 * ...solve the current time step and update total solution vector
2220 * @f$\mathbf{\Xi}_{\textrm{n}} = \mathbf{\Xi}_{\textrm{n-1}} +
2221 * \varDelta \mathbf{\Xi}@f$...
2224 * solve_nonlinear_timestep(solution_delta);
2225 * solution_n += solution_delta;
2229 * ...and plot the results before moving on happily to the next time
2242 * <a name=
"Privateinterface"></a>
2243 * <h3>Private interface</h3>
2248 * <a name=
"Threadingbuildingblocksstructures"></a>
2249 * <h4>Threading-building-blocks structures</h4>
2253 * The
first group of
private member
functions is related to parallelization.
2254 * We use the Threading Building Blocks library (TBB) to perform as many
2255 * computationally intensive distributed tasks as possible. In particular, we
2256 *
assemble the tangent
matrix and right hand side vector, the
static
2257 * condensation contributions, and update data stored at the quadrature points
2258 *
using TBB. Our main tool
for this is the
WorkStream class (see the @ref
2259 * threads module
for more information).
2263 * Firstly we deal with the tangent
matrix and right-hand side assembly
2264 * structures. The PerTaskData
object stores local contributions to the global
2268 * template <int dim>
2269 *
struct Solid<dim>::PerTaskData_ASM
2273 * std::vector<types::global_dof_index> local_dof_indices;
2275 * PerTaskData_ASM(
const unsigned int dofs_per_cell)
2277 * , cell_rhs(dofs_per_cell)
2278 * , local_dof_indices(dofs_per_cell)
2291 * On the other hand, the ScratchData
object stores the larger objects such as
2292 * the shape-function
values array (<code>Nx</code>) and a shape function
2297 *
template <
int dim>
2298 *
struct Solid<dim>::ScratchData_ASM
2303 * std::vector<std::vector<double>> Nx;
2304 * std::vector<std::vector<Tensor<2, dim>>> grad_Nx;
2305 * std::vector<std::vector<SymmetricTensor<2, dim>>> symm_grad_Nx;
2312 * : fe_values(fe_cell, qf_cell, uf_cell)
2313 * , fe_face_values(fe_cell, qf_face, uf_face)
2314 * , Nx(qf_cell.size(), std::vector<double>(fe_cell.n_dofs_per_cell()))
2315 * , grad_Nx(qf_cell.size(),
2317 * , symm_grad_Nx(qf_cell.size(),
2319 * fe_cell.n_dofs_per_cell()))
2322 * ScratchData_ASM(
const ScratchData_ASM &rhs)
2323 * : fe_values(rhs.fe_values.get_fe(),
2324 * rhs.fe_values.get_quadrature(),
2325 * rhs.fe_values.get_update_flags())
2326 * , fe_face_values(rhs.fe_face_values.get_fe(),
2327 * rhs.fe_face_values.get_quadrature(),
2328 * rhs.fe_face_values.get_update_flags())
2330 * , grad_Nx(rhs.grad_Nx)
2331 * , symm_grad_Nx(rhs.symm_grad_Nx)
2336 *
const unsigned int n_q_points = Nx.size();
2337 *
const unsigned int n_dofs_per_cell = Nx[0].size();
2338 *
for (
unsigned int q_point = 0; q_point < n_q_points; ++q_point)
2341 *
Assert(grad_Nx[q_point].size() == n_dofs_per_cell,
2343 *
Assert(symm_grad_Nx[q_point].size() == n_dofs_per_cell,
2345 *
for (
unsigned int k = 0; k < n_dofs_per_cell; ++k)
2347 * Nx[q_point][k] = 0.0;
2348 * grad_Nx[q_point][k] = 0.0;
2349 * symm_grad_Nx[q_point][k] = 0.0;
2358 * Then we define structures to
assemble the statically condensed tangent
2359 *
matrix. Recall that we wish to solve
for a displacement-based formulation.
2360 * We
do the condensation at the element
level as the @f$\widetilde{p}@f$ and
2361 * @f$\widetilde{J}@f$ fields are element-wise discontinuous. As these operations
2362 * are
matrix-based, we need to setup a number of matrices to store the local
2363 * contributions from a number of the tangent
matrix sub-blocks. We place
2364 * these in the PerTaskData
struct.
2368 * We choose not to reset any data in the <code>reset()</code> function as the
2369 *
matrix extraction and replacement tools will take care of
this
2372 *
template <
int dim>
2373 *
struct Solid<dim>::PerTaskData_SC
2376 * std::vector<types::global_dof_index> local_dof_indices;
2388 * PerTaskData_SC(
const unsigned int dofs_per_cell,
2389 *
const unsigned int n_u,
2390 *
const unsigned int n_p,
2391 *
const unsigned int n_J)
2393 * , local_dof_indices(dofs_per_cell)
2394 * , k_orig(dofs_per_cell, dofs_per_cell)
2398 * , k_pJ_inv(n_p, n_J)
2399 * , k_bbar(n_u, n_u)
2412 * The ScratchData
object for the operations we wish to perform here is empty
2413 * since we need no temporary data, but it still needs to be defined
for the
2414 * current implementation of TBB in deal.II. So we create a dummy
struct for
2418 *
template <
int dim>
2419 *
struct Solid<dim>::ScratchData_SC
2428 * And
finally we define the structures to assist with updating the quadrature
2429 *
point information. Similar to the SC assembly process, we
do not need the
2430 * PerTaskData object (since there is
nothing to store here) but must define
2431 *
one nonetheless. Note that
this is because
for the operation that we have
2432 * here -- updating the data on quadrature points -- the operation is purely
2433 * local: the things we
do on every cell get consumed on every cell, without
2434 * any global aggregation operation as is usually the
case when
using the
2435 *
WorkStream class. The fact that we still have to define a per-task data
2436 * structure points to the fact that the
WorkStream class may be ill-suited to
2437 *
this operation (we could, in principle simply create a
new task
using
2439 * it
this way anyway.
2440 * Furthermore, should there be different material models associated with a
2441 * quadrature
point, requiring varying levels of computational expense, then
2442 * the method used here could be advantageous.
2445 *
template <
int dim>
2446 *
struct Solid<dim>::PerTaskData_UQPH
2455 * The ScratchData
object will be used to store an alias
for the solution
2456 * vector so that we don
't have to copy this large data structure. We then
2457 * define a number of vectors to extract the solution values and gradients at
2458 * the quadrature points.
2461 * template <int dim>
2462 * struct Solid<dim>::ScratchData_UQPH
2464 * const BlockVector<double> &solution_total;
2466 * std::vector<Tensor<2, dim>> solution_grads_u_total;
2467 * std::vector<double> solution_values_p_total;
2468 * std::vector<double> solution_values_J_total;
2470 * FEValues<dim> fe_values;
2472 * ScratchData_UQPH(const FiniteElement<dim> & fe_cell,
2473 * const QGauss<dim> & qf_cell,
2474 * const UpdateFlags uf_cell,
2475 * const BlockVector<double> &solution_total)
2476 * : solution_total(solution_total)
2477 * , solution_grads_u_total(qf_cell.size())
2478 * , solution_values_p_total(qf_cell.size())
2479 * , solution_values_J_total(qf_cell.size())
2480 * , fe_values(fe_cell, qf_cell, uf_cell)
2483 * ScratchData_UQPH(const ScratchData_UQPH &rhs)
2484 * : solution_total(rhs.solution_total)
2485 * , solution_grads_u_total(rhs.solution_grads_u_total)
2486 * , solution_values_p_total(rhs.solution_values_p_total)
2487 * , solution_values_J_total(rhs.solution_values_J_total)
2488 * , fe_values(rhs.fe_values.get_fe(),
2489 * rhs.fe_values.get_quadrature(),
2490 * rhs.fe_values.get_update_flags())
2495 * const unsigned int n_q_points = solution_grads_u_total.size();
2496 * for (unsigned int q = 0; q < n_q_points; ++q)
2498 * solution_grads_u_total[q] = 0.0;
2499 * solution_values_p_total[q] = 0.0;
2500 * solution_values_J_total[q] = 0.0;
2509 * <a name="Solidmake_grid"></a>
2510 * <h4>Solid::make_grid</h4>
2514 * On to the first of the private member functions. Here we create the
2515 * triangulation of the domain, for which we choose the scaled cube with each
2516 * face given a boundary ID number. The grid must be refined at least once
2517 * for the indentation problem.
2521 * We then determine the volume of the reference configuration and print it
2525 * template <int dim>
2526 * void Solid<dim>::make_grid()
2528 * GridGenerator::hyper_rectangle(
2530 * (dim == 3 ? Point<dim>(0.0, 0.0, 0.0) : Point<dim>(0.0, 0.0)),
2531 * (dim == 3 ? Point<dim>(1.0, 1.0, 1.0) : Point<dim>(1.0, 1.0)),
2533 * GridTools::scale(parameters.scale, triangulation);
2534 * triangulation.refine_global(std::max(1U, parameters.global_refinement));
2536 * vol_reference = GridTools::volume(triangulation);
2537 * std::cout << "Grid:\n\t Reference volume: " << vol_reference << std::endl;
2541 * Since we wish to apply a Neumann BC to a patch on the top surface, we
2542 * must find the cell faces in this part of the domain and mark them with
2543 * a distinct boundary ID number. The faces we are looking for are on the
2544 * +y surface and will get boundary ID 6 (zero through five are already
2545 * used when creating the six faces of the cube domain):
2548 * for (const auto &cell : triangulation.active_cell_iterators())
2549 * for (const auto &face : cell->face_iterators())
2551 * if (face->at_boundary() == true &&
2552 * face->center()[1] == 1.0 * parameters.scale)
2556 * if (face->center()[0] < 0.5 * parameters.scale &&
2557 * face->center()[2] < 0.5 * parameters.scale)
2558 * face->set_boundary_id(6);
2562 * if (face->center()[0] < 0.5 * parameters.scale)
2563 * face->set_boundary_id(6);
2573 * <a name="Solidsystem_setup"></a>
2574 * <h4>Solid::system_setup</h4>
2578 * Next we describe how the FE system is setup. We first determine the number
2579 * of components per block. Since the displacement is a vector component, the
2580 * first dim components belong to it, while the next two describe scalar
2581 * pressure and dilatation DOFs.
2584 * template <int dim>
2585 * void Solid<dim>::system_setup()
2587 * timer.enter_subsection("Setup system");
2589 * std::vector<unsigned int> block_component(n_components,
2590 * u_dof); // Displacement
2591 * block_component[p_component] = p_dof; // Pressure
2592 * block_component[J_component] = J_dof; // Dilatation
2596 * The DOF handler is then initialized and we renumber the grid in an
2597 * efficient manner. We also record the number of DOFs per block.
2600 * dof_handler.distribute_dofs(fe);
2601 * DoFRenumbering::Cuthill_McKee(dof_handler);
2602 * DoFRenumbering::component_wise(dof_handler, block_component);
2605 * DoFTools::count_dofs_per_fe_block(dof_handler, block_component);
2607 * std::cout << "Triangulation:"
2608 * << "\n\t Number of active cells: "
2609 * << triangulation.n_active_cells()
2610 * << "\n\t Number of degrees of freedom: " << dof_handler.n_dofs()
2615 * Setup the sparsity pattern and tangent matrix
2618 * tangent_matrix.clear();
2620 * const types::global_dof_index n_dofs_u = dofs_per_block[u_dof];
2621 * const types::global_dof_index n_dofs_p = dofs_per_block[p_dof];
2622 * const types::global_dof_index n_dofs_J = dofs_per_block[J_dof];
2624 * BlockDynamicSparsityPattern dsp(n_blocks, n_blocks);
2626 * dsp.block(u_dof, u_dof).reinit(n_dofs_u, n_dofs_u);
2627 * dsp.block(u_dof, p_dof).reinit(n_dofs_u, n_dofs_p);
2628 * dsp.block(u_dof, J_dof).reinit(n_dofs_u, n_dofs_J);
2630 * dsp.block(p_dof, u_dof).reinit(n_dofs_p, n_dofs_u);
2631 * dsp.block(p_dof, p_dof).reinit(n_dofs_p, n_dofs_p);
2632 * dsp.block(p_dof, J_dof).reinit(n_dofs_p, n_dofs_J);
2634 * dsp.block(J_dof, u_dof).reinit(n_dofs_J, n_dofs_u);
2635 * dsp.block(J_dof, p_dof).reinit(n_dofs_J, n_dofs_p);
2636 * dsp.block(J_dof, J_dof).reinit(n_dofs_J, n_dofs_J);
2637 * dsp.collect_sizes();
2641 * The global system matrix initially has the following structure
2643 * \underbrace{\begin{bmatrix}
2644 * \mathsf{\mathbf{K}}_{uu} & \mathsf{\mathbf{K}}_{u\widetilde{p}} &
2646 * \\ \mathsf{\mathbf{K}}_{\widetilde{p}u} & \mathbf{0} &
2647 * \mathsf{\mathbf{K}}_{\widetilde{p}\widetilde{J}}
2648 * \\ \mathbf{0} & \mathsf{\mathbf{K}}_{\widetilde{J}\widetilde{p}} &
2649 * \mathsf{\mathbf{K}}_{\widetilde{J}\widetilde{J}}
2650 * \end{bmatrix}}_{\mathsf{\mathbf{K}}(\mathbf{\Xi}_{\textrm{i}})}
2651 * \underbrace{\begin{bmatrix}
2653 * \\ d \widetilde{\mathsf{\mathbf{p}}}
2654 * \\ d \widetilde{\mathsf{\mathbf{J}}}
2655 * \end{bmatrix}}_{d \mathbf{\Xi}}
2657 * \underbrace{\begin{bmatrix}
2658 * \mathsf{\mathbf{F}}_{u}(\mathbf{u}_{\textrm{i}})
2659 * \\ \mathsf{\mathbf{F}}_{\widetilde{p}}(\widetilde{p}_{\textrm{i}})
2660 * \\ \mathsf{\mathbf{F}}_{\widetilde{J}}(\widetilde{J}_{\textrm{i}})
2661 * \end{bmatrix}}_{ \mathsf{\mathbf{F}}(\mathbf{\Xi}_{\textrm{i}}) } \, .
2663 * We optimize the sparsity pattern to reflect this structure
2664 * and prevent unnecessary data creation for the right-diagonal
2668 * Table<2, DoFTools::Coupling> coupling(n_components, n_components);
2669 * for (unsigned int ii = 0; ii < n_components; ++ii)
2670 * for (unsigned int jj = 0; jj < n_components; ++jj)
2671 * if (((ii < p_component) && (jj == J_component)) ||
2672 * ((ii == J_component) && (jj < p_component)) ||
2673 * ((ii == p_component) && (jj == p_component)))
2674 * coupling[ii][jj] = DoFTools::none;
2676 * coupling[ii][jj] = DoFTools::always;
2677 * DoFTools::make_sparsity_pattern(
2678 * dof_handler, coupling, dsp, constraints, false);
2679 * sparsity_pattern.copy_from(dsp);
2682 * tangent_matrix.reinit(sparsity_pattern);
2686 * We then set up storage vectors
2689 * system_rhs.reinit(dofs_per_block);
2690 * system_rhs.collect_sizes();
2692 * solution_n.reinit(dofs_per_block);
2693 * solution_n.collect_sizes();
2697 * ...and finally set up the quadrature
2703 * timer.leave_subsection();
2710 * <a name="Soliddetermine_component_extractors"></a>
2711 * <h4>Solid::determine_component_extractors</h4>
2712 * Next we compute some information from the FE system that describes which
2713 * local element DOFs are attached to which block component. This is used
2714 * later to extract sub-blocks from the global matrix.
2718 * In essence, all we need is for the FESystem object to indicate to which
2719 * block component a DOF on the reference cell is attached to. Currently, the
2720 * interpolation fields are setup such that 0 indicates a displacement DOF, 1
2721 * a pressure DOF and 2 a dilatation DOF.
2724 * template <int dim>
2725 * void Solid<dim>::determine_component_extractors()
2727 * element_indices_u.clear();
2728 * element_indices_p.clear();
2729 * element_indices_J.clear();
2731 * for (unsigned int k = 0; k < fe.n_dofs_per_cell(); ++k)
2733 * const unsigned int k_group = fe.system_to_base_index(k).first.first;
2734 * if (k_group == u_dof)
2735 * element_indices_u.push_back(k);
2736 * else if (k_group == p_dof)
2737 * element_indices_p.push_back(k);
2738 * else if (k_group == J_dof)
2739 * element_indices_J.push_back(k);
2742 * Assert(k_group <= J_dof, ExcInternalError());
2750 * <a name="Solidsetup_qph"></a>
2751 * <h4>Solid::setup_qph</h4>
2752 * The method used to store quadrature information is already described in
2753 * @ref step_18 "step-18". Here we implement a similar setup for a SMP machine.
2757 * Firstly the actual QPH data objects are created. This must be done only
2758 * once the grid is refined to its finest level.
2761 * template <int dim>
2762 * void Solid<dim>::setup_qph()
2764 * std::cout << " Setting up quadrature point data..." << std::endl;
2766 * quadrature_point_history.initialize(triangulation.begin_active(),
2767 * triangulation.end(),
2772 * Next we setup the initial quadrature point data.
2773 * Note that when the quadrature point data is retrieved,
2774 * it is returned as a vector of smart pointers.
2777 * for (const auto &cell : triangulation.active_cell_iterators())
2779 * const std::vector<std::shared_ptr<PointHistory<dim>>> lqph =
2780 * quadrature_point_history.get_data(cell);
2781 * Assert(lqph.size() == n_q_points, ExcInternalError());
2783 * for (unsigned int q_point = 0; q_point < n_q_points; ++q_point)
2784 * lqph[q_point]->setup_lqp(parameters);
2791 * <a name="Solidupdate_qph_incremental"></a>
2792 * <h4>Solid::update_qph_incremental</h4>
2793 * As the update of QP information occurs frequently and involves a number of
2794 * expensive operations, we define a multithreaded approach to distributing
2795 * the task across a number of CPU cores.
2799 * To start this, we first we need to obtain the total solution as it stands
2800 * at this Newton increment and then create the initial copy of the scratch
2801 * and copy data objects:
2804 * template <int dim>
2806 * Solid<dim>::update_qph_incremental(const BlockVector<double> &solution_delta)
2808 * timer.enter_subsection("Update QPH data");
2809 * std::cout << " UQPH " << std::flush;
2811 * const BlockVector<double> solution_total(
2812 * get_total_solution(solution_delta));
2814 * const UpdateFlags uf_UQPH(update_values | update_gradients);
2815 * PerTaskData_UQPH per_task_data_UQPH;
2816 * ScratchData_UQPH scratch_data_UQPH(fe, qf_cell, uf_UQPH, solution_total);
2820 * We then pass them and the one-cell update function to the WorkStream to
2824 * WorkStream::run(dof_handler.active_cell_iterators(),
2826 * &Solid::update_qph_incremental_one_cell,
2827 * &Solid::copy_local_to_global_UQPH,
2828 * scratch_data_UQPH,
2829 * per_task_data_UQPH);
2831 * timer.leave_subsection();
2837 * Now we describe how we extract data from the solution vector and pass it
2838 * along to each QP storage object for processing.
2841 * template <int dim>
2842 * void Solid<dim>::update_qph_incremental_one_cell(
2843 * const typename DoFHandler<dim>::active_cell_iterator &cell,
2844 * ScratchData_UQPH & scratch,
2845 * PerTaskData_UQPH & /*data*/)
2847 * const std::vector<std::shared_ptr<PointHistory<dim>>> lqph =
2848 * quadrature_point_history.get_data(cell);
2849 * Assert(lqph.size() == n_q_points, ExcInternalError());
2851 * Assert(scratch.solution_grads_u_total.size() == n_q_points,
2852 * ExcInternalError());
2853 * Assert(scratch.solution_values_p_total.size() == n_q_points,
2854 * ExcInternalError());
2855 * Assert(scratch.solution_values_J_total.size() == n_q_points,
2856 * ExcInternalError());
2862 * We first need to find the values and gradients at quadrature points
2863 * inside the current cell and then we update each local QP using the
2864 * displacement gradient and total pressure and dilatation solution
2868 * scratch.fe_values.reinit(cell);
2869 * scratch.fe_values[u_fe].get_function_gradients(
2870 * scratch.solution_total, scratch.solution_grads_u_total);
2871 * scratch.fe_values[p_fe].get_function_values(
2872 * scratch.solution_total, scratch.solution_values_p_total);
2873 * scratch.fe_values[J_fe].get_function_values(
2874 * scratch.solution_total, scratch.solution_values_J_total);
2876 * for (const unsigned int q_point :
2877 * scratch.fe_values.quadrature_point_indices())
2878 * lqph[q_point]->update_values(scratch.solution_grads_u_total[q_point],
2879 * scratch.solution_values_p_total[q_point],
2880 * scratch.solution_values_J_total[q_point]);
2887 * <a name="Solidsolve_nonlinear_timestep"></a>
2888 * <h4>Solid::solve_nonlinear_timestep</h4>
2892 * The next function is the driver method for the Newton-Raphson scheme. At
2893 * its top we create a new vector to store the current Newton update step,
2894 * reset the error storage objects and print solver header.
2897 * template <int dim>
2898 * void Solid<dim>::solve_nonlinear_timestep(BlockVector<double> &solution_delta)
2900 * std::cout << std::endl
2901 * << "Timestep " << time.get_timestep() << " @ " << time.current()
2902 * << "s" << std::endl;
2904 * BlockVector<double> newton_update(dofs_per_block);
2906 * error_residual.reset();
2907 * error_residual_0.reset();
2908 * error_residual_norm.reset();
2909 * error_update.reset();
2910 * error_update_0.reset();
2911 * error_update_norm.reset();
2913 * print_conv_header();
2917 * We now perform a number of Newton iterations to iteratively solve the
2918 * nonlinear problem. Since the problem is fully nonlinear and we are
2919 * using a full Newton method, the data stored in the tangent matrix and
2920 * right-hand side vector is not reusable and must be cleared at each
2921 * Newton step. We then initially build the linear system and
2922 * check for convergence (and store this value in the first iteration).
2923 * The unconstrained DOFs of the rhs vector hold the out-of-balance
2924 * forces, and collectively determine whether or not the equilibrium
2925 * solution has been attained.
2929 * Although for this particular problem we could potentially construct the
2930 * RHS vector before assembling the system matrix, for the sake of
2931 * extensibility we choose not to do so. The benefit to assembling the RHS
2932 * vector and system matrix separately is that the latter is an expensive
2933 * operation and we can potentially avoid an extra assembly process by not
2934 * assembling the tangent matrix when convergence is attained. However, this
2935 * makes parallelizing the code using MPI more difficult. Furthermore, when
2936 * extending the problem to the transient case additional contributions to
2937 * the RHS may result from the time discretization and application of
2938 * constraints for the velocity and acceleration fields.
2941 * unsigned int newton_iteration = 0;
2942 * for (; newton_iteration < parameters.max_iterations_NR; ++newton_iteration)
2944 * std::cout << " " << std::setw(2) << newton_iteration << " "
2949 * We construct the linear system, but hold off on solving it
2950 * (a step that should be significantly more expensive than assembly):
2953 * make_constraints(newton_iteration);
2954 * assemble_system();
2958 * We can now determine the normalized residual error and check for
2959 * solution convergence:
2962 * get_error_residual(error_residual);
2963 * if (newton_iteration == 0)
2964 * error_residual_0 = error_residual;
2966 * error_residual_norm = error_residual;
2967 * error_residual_norm.normalize(error_residual_0);
2969 * if (newton_iteration > 0 && error_update_norm.u <= parameters.tol_u &&
2970 * error_residual_norm.u <= parameters.tol_f)
2972 * std::cout << " CONVERGED! " << std::endl;
2973 * print_conv_footer();
2980 * If we have decided that we want to continue with the iteration, we
2981 * solve the linearized system:
2984 * const std::pair<unsigned int, double> lin_solver_output =
2985 * solve_linear_system(newton_update);
2989 * We can now determine the normalized Newton update error:
2992 * get_error_update(newton_update, error_update);
2993 * if (newton_iteration == 0)
2994 * error_update_0 = error_update;
2996 * error_update_norm = error_update;
2997 * error_update_norm.normalize(error_update_0);
3001 * Lastly, since we implicitly accept the solution step we can perform
3002 * the actual update of the solution increment for the current time
3003 * step, update all quadrature point information pertaining to
3004 * this new displacement and stress state and continue iterating:
3007 * solution_delta += newton_update;
3008 * update_qph_incremental(solution_delta);
3010 * std::cout << " | " << std::fixed << std::setprecision(3) << std::setw(7)
3011 * << std::scientific << lin_solver_output.first << " "
3012 * << lin_solver_output.second << " "
3013 * << error_residual_norm.norm << " " << error_residual_norm.u
3014 * << " " << error_residual_norm.p << " "
3015 * << error_residual_norm.J << " " << error_update_norm.norm
3016 * << " " << error_update_norm.u << " " << error_update_norm.p
3017 * << " " << error_update_norm.J << " " << std::endl;
3022 * At the end, if it turns out that we have in fact done more iterations
3023 * than the parameter file allowed, we raise an exception that can be
3024 * caught in the main() function. The call <code>AssertThrow(condition,
3025 * exc_object)</code> is in essence equivalent to <code>if (!cond) throw
3026 * exc_object;</code> but the former form fills certain fields in the
3027 * exception object that identify the location (filename and line number)
3028 * where the exception was raised to make it simpler to identify where the
3032 * AssertThrow(newton_iteration < parameters.max_iterations_NR,
3033 * ExcMessage("No convergence in nonlinear solver!"));
3040 * <a name="Solidprint_conv_headerandSolidprint_conv_footer"></a>
3041 * <h4>Solid::print_conv_header and Solid::print_conv_footer</h4>
3045 * This program prints out data in a nice table that is updated
3046 * on a per-iteration basis. The next two functions set up the table
3047 * header and footer:
3050 * template <int dim>
3051 * void Solid<dim>::print_conv_header()
3053 * static const unsigned int l_width = 150;
3055 * for (unsigned int i = 0; i < l_width; ++i)
3057 * std::cout << std::endl;
3059 * std::cout << " SOLVER STEP "
3060 * << " | LIN_IT LIN_RES RES_NORM "
3061 * << " RES_U RES_P RES_J NU_NORM "
3062 * << " NU_U NU_P NU_J " << std::endl;
3064 * for (unsigned int i = 0; i < l_width; ++i)
3066 * std::cout << std::endl;
3071 * template <int dim>
3072 * void Solid<dim>::print_conv_footer()
3074 * static const unsigned int l_width = 150;
3076 * for (unsigned int i = 0; i < l_width; ++i)
3078 * std::cout << std::endl;
3080 * const std::pair<double, double> error_dil = get_error_dilation();
3082 * std::cout << "Relative errors:" << std::endl
3083 * << "Displacement:\t" << error_update.u / error_update_0.u
3085 * << "Force: \t\t" << error_residual.u / error_residual_0.u
3087 * << "Dilatation:\t" << error_dil.first << std::endl
3088 * << "v / V_0:\t" << error_dil.second * vol_reference << " / "
3089 * << vol_reference << " = " << error_dil.second << std::endl;
3096 * <a name="Solidget_error_dilation"></a>
3097 * <h4>Solid::get_error_dilation</h4>
3101 * Calculate the volume of the domain in the spatial configuration
3104 * template <int dim>
3105 * double Solid<dim>::compute_vol_current() const
3107 * double vol_current = 0.0;
3109 * FEValues<dim> fe_values(fe, qf_cell, update_JxW_values);
3111 * for (const auto &cell : triangulation.active_cell_iterators())
3113 * fe_values.reinit(cell);
3117 * In contrast to that which was previously called for,
3118 * in this instance the quadrature point data is specifically
3119 * non-modifiable since we will only be accessing data.
3120 * We ensure that the right get_data function is called by
3121 * marking this update function as constant.
3124 * const std::vector<std::shared_ptr<const PointHistory<dim>>> lqph =
3125 * quadrature_point_history.get_data(cell);
3126 * Assert(lqph.size() == n_q_points, ExcInternalError());
3128 * for (const unsigned int q_point : fe_values.quadrature_point_indices())
3130 * const double det_F_qp = lqph[q_point]->get_det_F();
3131 * const double JxW = fe_values.JxW(q_point);
3133 * vol_current += det_F_qp * JxW;
3136 * Assert(vol_current > 0.0, ExcInternalError());
3137 * return vol_current;
3142 * Calculate how well the dilatation @f$\widetilde{J}@f$ agrees with @f$J
3143 * \dealcoloneq \textrm{det}\ \mathbf{F}@f$ from the @f$L^2@f$ error @f$ \bigl[
3144 * \int_{\Omega_0} {[ J - \widetilde{J}]}^{2}\textrm{d}V \bigr]^{1/2}@f$.
3145 * We also return the ratio of the current volume of the
3146 * domain to the reference volume. This is of interest for incompressible
3147 * media where we want to check how well the isochoric constraint has been
3151 * template <int dim>
3152 * std::pair<double, double> Solid<dim>::get_error_dilation() const
3154 * double dil_L2_error = 0.0;
3156 * FEValues<dim> fe_values(fe, qf_cell, update_JxW_values);
3158 * for (const auto &cell : triangulation.active_cell_iterators())
3160 * fe_values.reinit(cell);
3162 * const std::vector<std::shared_ptr<const PointHistory<dim>>> lqph =
3163 * quadrature_point_history.get_data(cell);
3164 * Assert(lqph.size() == n_q_points, ExcInternalError());
3166 * for (const unsigned int q_point : fe_values.quadrature_point_indices())
3168 * const double det_F_qp = lqph[q_point]->get_det_F();
3169 * const double J_tilde_qp = lqph[q_point]->get_J_tilde();
3170 * const double the_error_qp_squared =
3171 * std::pow((det_F_qp - J_tilde_qp), 2);
3172 * const double JxW = fe_values.JxW(q_point);
3174 * dil_L2_error += the_error_qp_squared * JxW;
3178 * return std::make_pair(std::sqrt(dil_L2_error),
3179 * compute_vol_current() / vol_reference);
3186 * <a name="Solidget_error_residual"></a>
3187 * <h4>Solid::get_error_residual</h4>
3191 * Determine the true residual error for the problem. That is, determine the
3192 * error in the residual for the unconstrained degrees of freedom. Note that
3193 * to do so, we need to ignore constrained DOFs by setting the residual in
3194 * these vector components to zero.
3197 * template <int dim>
3198 * void Solid<dim>::get_error_residual(Errors &error_residual)
3200 * BlockVector<double> error_res(dofs_per_block);
3202 * for (unsigned int i = 0; i < dof_handler.n_dofs(); ++i)
3203 * if (!constraints.is_constrained(i))
3204 * error_res(i) = system_rhs(i);
3206 * error_residual.norm = error_res.l2_norm();
3207 * error_residual.u = error_res.block(u_dof).l2_norm();
3208 * error_residual.p = error_res.block(p_dof).l2_norm();
3209 * error_residual.J = error_res.block(J_dof).l2_norm();
3216 * <a name="Solidget_error_update"></a>
3217 * <h4>Solid::get_error_update</h4>
3221 * Determine the true Newton update error for the problem
3224 * template <int dim>
3225 * void Solid<dim>::get_error_update(const BlockVector<double> &newton_update,
3226 * Errors & error_update)
3228 * BlockVector<double> error_ud(dofs_per_block);
3229 * for (unsigned int i = 0; i < dof_handler.n_dofs(); ++i)
3230 * if (!constraints.is_constrained(i))
3231 * error_ud(i) = newton_update(i);
3233 * error_update.norm = error_ud.l2_norm();
3234 * error_update.u = error_ud.block(u_dof).l2_norm();
3235 * error_update.p = error_ud.block(p_dof).l2_norm();
3236 * error_update.J = error_ud.block(J_dof).l2_norm();
3244 * <a name="Solidget_total_solution"></a>
3245 * <h4>Solid::get_total_solution</h4>
3249 * This function provides the total solution, which is valid at any Newton
3250 * step. This is required as, to reduce computational error, the total
3251 * solution is only updated at the end of the timestep.
3254 * template <int dim>
3255 * BlockVector<double> Solid<dim>::get_total_solution(
3256 * const BlockVector<double> &solution_delta) const
3258 * BlockVector<double> solution_total(solution_n);
3259 * solution_total += solution_delta;
3260 * return solution_total;
3267 * <a name="Solidassemble_system"></a>
3268 * <h4>Solid::assemble_system</h4>
3272 * Since we use TBB for assembly, we simply setup a copy of the
3273 * data structures required for the process and pass them, along
3274 * with the assembly functions to the WorkStream object for processing. Note
3275 * that we must ensure that the matrix and RHS vector are reset before any
3276 * assembly operations can occur. Furthermore, since we are describing a
3277 * problem with Neumann BCs, we will need the face normals and so must specify
3278 * this in the face update flags.
3281 * template <int dim>
3282 * void Solid<dim>::assemble_system()
3284 * timer.enter_subsection("Assemble system");
3285 * std::cout << " ASM_SYS " << std::flush;
3287 * tangent_matrix = 0.0;
3290 * const UpdateFlags uf_cell(update_values | update_gradients |
3291 * update_JxW_values);
3292 * const UpdateFlags uf_face(update_values | update_normal_vectors |
3293 * update_JxW_values);
3295 * PerTaskData_ASM per_task_data(dofs_per_cell);
3296 * ScratchData_ASM scratch_data(fe, qf_cell, uf_cell, qf_face, uf_face);
3300 * The syntax used here to pass data to the WorkStream class
3301 * is discussed in @ref step_13 "step-13".
3305 * dof_handler.active_cell_iterators(),
3306 * [this](const typename DoFHandler<dim>::active_cell_iterator &cell,
3307 * ScratchData_ASM & scratch,
3308 * PerTaskData_ASM & data) {
3309 * this->assemble_system_one_cell(cell, scratch, data);
3311 * [this](const PerTaskData_ASM &data) {
3312 * this->constraints.distribute_local_to_global(data.cell_matrix,
3314 * data.local_dof_indices,
3321 * timer.leave_subsection();
3326 * Of course, we still have to define how we assemble the tangent matrix
3327 * contribution for a single cell. We first need to reset and initialize some
3328 * of the scratch data structures and retrieve some basic information
3329 * regarding the DOF numbering on this cell. We can precalculate the cell
3330 * shape function values and gradients. Note that the shape function gradients
3331 * are defined with regard to the current configuration. That is
3332 * @f$\textrm{grad}\ \boldsymbol{\varphi} = \textrm{Grad}\ \boldsymbol{\varphi}
3333 * \ \mathbf{F}^{-1}@f$.
3336 * template <int dim>
3337 * void Solid<dim>::assemble_system_one_cell(
3338 * const typename DoFHandler<dim>::active_cell_iterator &cell,
3339 * ScratchData_ASM & scratch,
3340 * PerTaskData_ASM & data) const
3344 * scratch.fe_values.reinit(cell);
3345 * cell->get_dof_indices(data.local_dof_indices);
3347 * const std::vector<std::shared_ptr<const PointHistory<dim>>> lqph =
3348 * quadrature_point_history.get_data(cell);
3349 * Assert(lqph.size() == n_q_points, ExcInternalError());
3351 * for (const unsigned int q_point :
3352 * scratch.fe_values.quadrature_point_indices())
3354 * const Tensor<2, dim> F_inv = lqph[q_point]->get_F_inv();
3355 * for (const unsigned int k : scratch.fe_values.dof_indices())
3357 * const unsigned int k_group = fe.system_to_base_index(k).first.first;
3359 * if (k_group == u_dof)
3361 * scratch.grad_Nx[q_point][k] =
3362 * scratch.fe_values[u_fe].gradient(k, q_point) * F_inv;
3363 * scratch.symm_grad_Nx[q_point][k] =
3364 * symmetrize(scratch.grad_Nx[q_point][k]);
3366 * else if (k_group == p_dof)
3367 * scratch.Nx[q_point][k] =
3368 * scratch.fe_values[p_fe].value(k, q_point);
3369 * else if (k_group == J_dof)
3370 * scratch.Nx[q_point][k] =
3371 * scratch.fe_values[J_fe].value(k, q_point);
3373 * Assert(k_group <= J_dof, ExcInternalError());
3379 * Now we build the local cell stiffness matrix and RHS vector. Since the
3380 * global and local system matrices are symmetric, we can exploit this
3381 * property by building only the lower half of the local matrix and copying
3382 * the values to the upper half. So we only assemble half of the
3383 * @f$\mathsf{\mathbf{k}}_{uu}@f$, @f$\mathsf{\mathbf{k}}_{\widetilde{p}
3384 * \widetilde{p}} = \mathbf{0}@f$, @f$\mathsf{\mathbf{k}}_{\widetilde{J}
3385 * \widetilde{J}}@f$ blocks, while the whole
3386 * @f$\mathsf{\mathbf{k}}_{\widetilde{p} \widetilde{J}}@f$,
3387 * @f$\mathsf{\mathbf{k}}_{u \widetilde{J}} = \mathbf{0}@f$,
3388 * @f$\mathsf{\mathbf{k}}_{u \widetilde{p}}@f$ blocks are built.
3392 * In doing so, we first extract some configuration dependent variables
3393 * from our quadrature history objects for the current quadrature point.
3396 * for (const unsigned int q_point :
3397 * scratch.fe_values.quadrature_point_indices())
3399 * const SymmetricTensor<2, dim> tau = lqph[q_point]->get_tau();
3400 * const Tensor<2, dim> tau_ns = lqph[q_point]->get_tau();
3401 * const SymmetricTensor<4, dim> Jc = lqph[q_point]->get_Jc();
3402 * const double det_F = lqph[q_point]->get_det_F();
3403 * const double p_tilde = lqph[q_point]->get_p_tilde();
3404 * const double J_tilde = lqph[q_point]->get_J_tilde();
3405 * const double dPsi_vol_dJ = lqph[q_point]->get_dPsi_vol_dJ();
3406 * const double d2Psi_vol_dJ2 = lqph[q_point]->get_d2Psi_vol_dJ2();
3407 * const SymmetricTensor<2, dim> &I =
3408 * Physics::Elasticity::StandardTensors<dim>::I;
3412 * These two tensors store some precomputed data. Their use will
3413 * explained shortly.
3416 * SymmetricTensor<2, dim> symm_grad_Nx_i_x_Jc;
3417 * Tensor<1, dim> grad_Nx_i_comp_i_x_tau;
3421 * Next we define some aliases to make the assembly process easier to
3425 * const std::vector<double> & N = scratch.Nx[q_point];
3426 * const std::vector<SymmetricTensor<2, dim>> &symm_grad_Nx =
3427 * scratch.symm_grad_Nx[q_point];
3428 * const std::vector<Tensor<2, dim>> &grad_Nx = scratch.grad_Nx[q_point];
3429 * const double JxW = scratch.fe_values.JxW(q_point);
3431 * for (const unsigned int i : scratch.fe_values.dof_indices())
3433 * const unsigned int component_i =
3434 * fe.system_to_component_index(i).first;
3435 * const unsigned int i_group = fe.system_to_base_index(i).first.first;
3439 * We first compute the contributions
3440 * from the internal forces. Note, by
3441 * definition of the rhs as the negative
3442 * of the residual, these contributions
3446 * if (i_group == u_dof)
3447 * data.cell_rhs(i) -= (symm_grad_Nx[i] * tau) * JxW;
3448 * else if (i_group == p_dof)
3449 * data.cell_rhs(i) -= N[i] * (det_F - J_tilde) * JxW;
3450 * else if (i_group == J_dof)
3451 * data.cell_rhs(i) -= N[i] * (dPsi_vol_dJ - p_tilde) * JxW;
3453 * Assert(i_group <= J_dof, ExcInternalError());
3457 * Before we go into the inner loop, we have one final chance to
3458 * introduce some optimizations. We've already taken into account
3459 * the symmetry of the system, and we can now precompute some
3460 * common terms that are repeatedly applied in the inner
loop.
3461 * We won
't be excessive here, but will rather focus on expensive
3462 * operations, namely those involving the rank-4 material stiffness
3463 * tensor and the rank-2 stress tensor.
3467 * What we may observe is that both of these tensors are contracted
3468 * with shape function gradients indexed on the "i" DoF. This
3469 * implies that this particular operation remains constant as we
3470 * loop over the "j" DoF. For that reason, we can extract this from
3471 * the inner loop and save the many operations that, for each
3472 * quadrature point and DoF index "i" and repeated over index "j"
3473 * are required to double contract a rank-2 symmetric tensor with a
3474 * rank-4 symmetric tensor, and a rank-1 tensor with a rank-2
3479 * At the loss of some readability, this small change will reduce
3480 * the assembly time of the symmetrized system by about half when
3481 * using the simulation default parameters, and becomes more
3482 * significant as the h-refinement level increases.
3485 * if (i_group == u_dof)
3487 * symm_grad_Nx_i_x_Jc = symm_grad_Nx[i] * Jc;
3488 * grad_Nx_i_comp_i_x_tau = grad_Nx[i][component_i] * tau_ns;
3493 * Now we're prepared to compute the tangent
matrix contributions:
3496 *
for (
const unsigned int j :
3497 * scratch.fe_values.dof_indices_ending_at(i))
3499 *
const unsigned int component_j =
3500 * fe.system_to_component_index(j).first;
3501 *
const unsigned int j_group =
3502 * fe.system_to_base_index(j).first.first;
3506 * This is the @f$\mathsf{\mathbf{k}}_{uu}@f$
3507 * contribution. It comprises a material contribution, and a
3508 * geometrical stress contribution which is only added along
3509 * the local
matrix diagonals:
3512 *
if ((i_group == j_group) && (i_group == u_dof))
3516 * The material contribution:
3519 * data.cell_matrix(i, j) += symm_grad_Nx_i_x_Jc *
3520 * symm_grad_Nx[j] * JxW;
3524 * The geometrical stress contribution:
3527 *
if (component_i == component_j)
3528 * data.cell_matrix(i, j) +=
3529 * grad_Nx_i_comp_i_x_tau * grad_Nx[j][component_j] * JxW;
3533 * Next is the @f$\mathsf{\mathbf{k}}_{ \widetilde{p} u}@f$
3537 *
else if ((i_group == p_dof) && (j_group == u_dof))
3539 * data.cell_matrix(i, j) +=
N[i] * det_F *
3540 * (symm_grad_Nx[j] * I) * JxW;
3544 * and lastly the @f$\mathsf{\mathbf{k}}_{ \widetilde{J}
3545 * \widetilde{p}}@f$ and @f$\mathsf{\mathbf{k}}_{ \widetilde{J}
3546 * \widetilde{J}}@f$ contributions:
3549 *
else if ((i_group == J_dof) && (j_group == p_dof))
3550 * data.cell_matrix(i, j) -=
N[i] *
N[j] * JxW;
3551 *
else if ((i_group == j_group) && (i_group == J_dof))
3552 * data.cell_matrix(i, j) +=
N[i] * d2Psi_vol_dJ2 *
N[j] * JxW;
3554 *
Assert((i_group <= J_dof) && (j_group <= J_dof),
3562 * Next we
assemble the Neumann contribution. We
first check to see it the
3563 * cell face exists on a boundary on which a traction is applied and add
3564 * the contribution
if this is the
case.
3567 *
for (
const auto &face : cell->face_iterators())
3568 *
if (face->at_boundary() && face->boundary_id() == 6)
3570 * scratch.fe_face_values.reinit(cell, face);
3572 *
for (
const unsigned int f_q_point :
3573 * scratch.fe_face_values.quadrature_point_indices())
3576 * scratch.fe_face_values.normal_vector(f_q_point);
3580 * Using the face normal at
this quadrature
point we specify the
3581 * traction in reference configuration. For
this problem, a
3582 * defined pressure is applied in the reference configuration.
3583 * The direction of the applied traction is assumed not to
3584 * evolve with the deformation of the domain. The traction is
3585 * defined
using the
first Piola-Kirchhoff stress is simply
3586 * @f$\mathbf{t} = \mathbf{P}\mathbf{
N} = [p_0 \mathbf{I}]
3587 * \mathbf{
N} = p_0 \mathbf{
N}@f$ We use the time variable to
3588 * linearly ramp up the pressure load.
3592 * Note that the contributions to the right hand side vector we
3593 * compute here only exist in the displacement components of the
3597 *
static const double p0 =
3598 * -4.0 / (parameters.scale * parameters.scale);
3599 *
const double time_ramp = (time.current() / time.end());
3600 *
const double pressure = p0 * parameters.p_p0 * time_ramp;
3603 *
for (
const unsigned int i : scratch.fe_values.dof_indices())
3605 *
const unsigned int i_group =
3606 * fe.system_to_base_index(i).first.first;
3608 *
if (i_group == u_dof)
3610 *
const unsigned int component_i =
3611 * fe.system_to_component_index(i).first;
3613 * scratch.fe_face_values.shape_value(i, f_q_point);
3614 *
const double JxW = scratch.fe_face_values.JxW(f_q_point);
3616 * data.cell_rhs(i) += (Ni * traction[component_i]) * JxW;
3624 * Finally, we need to
copy the lower half of the local
matrix into the
3628 *
for (
const unsigned int i : scratch.fe_values.dof_indices())
3629 *
for (
const unsigned int j :
3630 * scratch.fe_values.dof_indices_starting_at(i + 1))
3631 * data.cell_matrix(i, j) = data.cell_matrix(j, i);
3639 * <a name=
"Solidmake_constraints"></a>
3640 * <h4>Solid::make_constraints</h4>
3641 * The constraints
for this problem are simple to describe.
3642 * In
this particular example, the boundary
values will be calculated
for
3643 * the two
first iterations of Newton
's algorithm. In general, one would
3644 * build non-homogeneous constraints in the zeroth iteration (that is, when
3645 * `apply_dirichlet_bc == true` in the code block that follows) and build
3646 * only the corresponding homogeneous constraints in the following step. While
3647 * the current example has only homogeneous constraints, previous experiences
3648 * have shown that a common error is forgetting to add the extra condition
3649 * when refactoring the code to specific uses. This could lead to errors that
3650 * are hard to debug. In this spirit, we choose to make the code more verbose
3651 * in terms of what operations are performed at each Newton step.
3654 * template <int dim>
3655 * void Solid<dim>::make_constraints(const int it_nr)
3659 * Since we (a) are dealing with an iterative Newton method, (b) are using
3660 * an incremental formulation for the displacement, and (c) apply the
3661 * constraints to the incremental displacement field, any non-homogeneous
3662 * constraints on the displacement update should only be specified at the
3663 * zeroth iteration. No subsequent contributions are to be made since the
3664 * constraints will be exactly satisfied after that iteration.
3667 * const bool apply_dirichlet_bc = (it_nr == 0);
3671 * Furthermore, after the first Newton iteration within a timestep, the
3672 * constraints remain the same and we do not need to modify or rebuild them
3673 * so long as we do not clear the @p constraints object.
3678 * std::cout << " --- " << std::flush;
3682 * std::cout << " CST " << std::flush;
3684 * if (apply_dirichlet_bc)
3688 * At the zeroth Newton iteration we wish to apply the full set of
3689 * non-homogeneous and homogeneous constraints that represent the
3690 * boundary conditions on the displacement increment. Since in general
3691 * the constraints may be different at each time step, we need to clear
3692 * the constraints matrix and completely rebuild it. An example case
3693 * would be if a surface is accelerating; in such a scenario the change
3694 * in displacement is non-constant between each time step.
3697 * constraints.clear();
3701 * The boundary conditions for the indentation problem in 3D are as
3702 * follows: On the -x, -y and -z faces (IDs 0,2,4) we set up a symmetry
3703 * condition to allow only planar movement while the +x and +z faces
3704 * (IDs 1,5) are traction free. In this contrived problem, part of the
3705 * +y face (ID 3) is set to have no motion in the x- and z-component.
3706 * Finally, as described earlier, the other part of the +y face has an
3707 * the applied pressure but is also constrained in the x- and
3712 * In the following, we will have to tell the function interpolation
3713 * boundary values which components of the solution vector should be
3714 * constrained (i.e., whether it's the x-, y-, z-displacements or
3715 * combinations thereof). This is done
using ComponentMask objects (see
3716 * @ref GlossComponentMask) which we can get from the finite element
if we
3717 * provide it with an extractor
object for the component we wish to
3718 * select. To
this end we
first set up such extractor objects and later
3719 * use it when generating the relevant component masks:
3733 * fe.component_mask(x_displacement));
3743 * fe.component_mask(y_displacement));
3758 * (fe.component_mask(x_displacement) |
3759 * fe.component_mask(z_displacement)));
3769 * fe.component_mask(z_displacement));
3780 * (fe.component_mask(x_displacement) |
3781 * fe.component_mask(z_displacement)));
3794 * (fe.component_mask(x_displacement)));
3804 * (fe.component_mask(x_displacement)));
3812 * As all Dirichlet constraints are fulfilled exactly after the zeroth
3813 * Newton iteration, we want to ensure that no further modification are
3814 * made to those entries. This implies that we want to convert
3815 * all non-homogeneous Dirichlet constraints into homogeneous ones.
3819 * In
this example the procedure to
do this is quite straightforward,
3820 * and in fact we can (and will) circumvent any unnecessary operations
3821 * when only homogeneous boundary conditions are applied.
3822 * In a more
general problem
one should be mindful of hanging node
3823 * and periodic constraints, which may also introduce some
3824 * inhomogeneities. It might then be advantageous to keep disparate
3825 * objects
for the different
types of constraints, and
merge them
3826 * together once the homogeneous Dirichlet constraints have been
3830 *
if (constraints.has_inhomogeneities())
3834 * Since the
affine constraints were finalized at the previous
3835 * Newton iteration, they may not be modified directly. So
3836 * we need to
copy them to another temporary
object and make
3837 * modification there. Once we
're done, we'll transfer them
3838 * back to the main @p constraints
object.
3842 *
for (
unsigned int dof = 0; dof != dof_handler.n_dofs(); ++dof)
3843 *
if (homogeneous_constraints.is_inhomogeneously_constrained(dof))
3844 * homogeneous_constraints.set_inhomogeneity(dof, 0.0);
3846 * constraints.clear();
3847 * constraints.copy_from(homogeneous_constraints);
3851 * constraints.close();
3857 * <a name=
"Solidassemble_sc"></a>
3858 * <h4>Solid::assemble_sc</h4>
3859 * Solving the entire block system is a bit problematic as there are no
3860 * contributions to the @f$\mathsf{\mathbf{K}}_{ \widetilde{J} \widetilde{J}}@f$
3861 * block, rendering it noninvertible (when
using an iterative solver).
3862 * Since the pressure and dilatation variables DOFs are discontinuous, we can
3863 * condense them out to form a smaller displacement-only system which
3864 * we will then solve and subsequently post-process to retrieve the
3865 * pressure and dilatation solutions.
3869 * The
static condensation process could be performed at a global
level but we
3870 * need the inverse of
one of the blocks. However, since the pressure and
3871 * dilatation variables are discontinuous, the
static condensation (SC)
3872 * operation can also be done on a per-cell basis and we can produce the
3874 * @f$\mathsf{\mathbf{K}}_{\widetilde{p}\widetilde{J}}@f$ block by inverting the
3875 * local blocks. We can again use TBB to
do this since each operation will be
3876 * independent of
one another.
3883 * \mathsf{\mathbf{K}}_{\textrm{con}}
3884 * = \bigl[ \mathsf{\mathbf{K}}_{uu} +
3885 * \overline{\overline{\mathsf{\mathbf{K}}}}~ \bigr]
3887 * from each element
's contributions. These contributions are then added to
3888 * the global stiffness matrix. Given this description, the following two
3889 * functions should be clear:
3892 * template <int dim>
3893 * void Solid<dim>::assemble_sc()
3895 * timer.enter_subsection("Perform static condensation");
3896 * std::cout << " ASM_SC " << std::flush;
3898 * PerTaskData_SC per_task_data(dofs_per_cell,
3899 * element_indices_u.size(),
3900 * element_indices_p.size(),
3901 * element_indices_J.size());
3902 * ScratchData_SC scratch_data;
3904 * WorkStream::run(dof_handler.active_cell_iterators(),
3906 * &Solid::assemble_sc_one_cell,
3907 * &Solid::copy_local_to_global_sc,
3911 * timer.leave_subsection();
3915 * template <int dim>
3916 * void Solid<dim>::copy_local_to_global_sc(const PerTaskData_SC &data)
3918 * for (unsigned int i = 0; i < dofs_per_cell; ++i)
3919 * for (unsigned int j = 0; j < dofs_per_cell; ++j)
3920 * tangent_matrix.add(data.local_dof_indices[i],
3921 * data.local_dof_indices[j],
3922 * data.cell_matrix(i, j));
3928 * Now we describe the static condensation process. As per usual, we must
3929 * first find out which global numbers the degrees of freedom on this cell
3930 * have and reset some data structures:
3933 * template <int dim>
3934 * void Solid<dim>::assemble_sc_one_cell(
3935 * const typename DoFHandler<dim>::active_cell_iterator &cell,
3936 * ScratchData_SC & scratch,
3937 * PerTaskData_SC & data)
3941 * cell->get_dof_indices(data.local_dof_indices);
3945 * We now extract the contribution of the dofs associated with the current
3946 * cell to the global stiffness matrix. The discontinuous nature of the
3947 * @f$\widetilde{p}@f$ and @f$\widetilde{J}@f$ interpolations mean that their is
3948 * no coupling of the local contributions at the global level. This is not
3949 * the case with the @f$\mathbf{u}@f$ dof. In other words,
3950 * @f$\mathsf{\mathbf{k}}_{\widetilde{J} \widetilde{p}}@f$,
3951 * @f$\mathsf{\mathbf{k}}_{\widetilde{p} \widetilde{p}}@f$ and
3952 * @f$\mathsf{\mathbf{k}}_{\widetilde{J} \widetilde{p}}@f$, when extracted
3953 * from the global stiffness matrix are the element contributions. This
3954 * is not the case for @f$\mathsf{\mathbf{k}}_{uu}@f$.
3958 * Note: A lower-case symbol is used to denote element stiffness matrices.
3962 * Currently the matrix corresponding to
3963 * the dof associated with the current element
3964 * (denoted somewhat loosely as @f$\mathsf{\mathbf{k}}@f$)
3968 * \mathsf{\mathbf{k}}_{uu} & \mathsf{\mathbf{k}}_{u\widetilde{p}}
3970 * \\ \mathsf{\mathbf{k}}_{\widetilde{p}u} & \mathbf{0} &
3971 * \mathsf{\mathbf{k}}_{\widetilde{p}\widetilde{J}}
3972 * \\ \mathbf{0} & \mathsf{\mathbf{k}}_{\widetilde{J}\widetilde{p}} &
3973 * \mathsf{\mathbf{k}}_{\widetilde{J}\widetilde{J}} \end{bmatrix}
3978 * We now need to modify it such that it appear as
3981 * \mathsf{\mathbf{k}}_{\textrm{con}} &
3982 * \mathsf{\mathbf{k}}_{u\widetilde{p}} & \mathbf{0}
3983 * \\ \mathsf{\mathbf{k}}_{\widetilde{p}u} & \mathbf{0} &
3984 * \mathsf{\mathbf{k}}_{\widetilde{p}\widetilde{J}}^{-1}
3985 * \\ \mathbf{0} & \mathsf{\mathbf{k}}_{\widetilde{J}\widetilde{p}} &
3986 * \mathsf{\mathbf{k}}_{\widetilde{J}\widetilde{J}} \end{bmatrix}
3988 * with @f$\mathsf{\mathbf{k}}_{\textrm{con}} = \bigl[
3989 * \mathsf{\mathbf{k}}_{uu} +\overline{\overline{\mathsf{\mathbf{k}}}}~
3990 * \bigr]@f$ where @f$ \overline{\overline{\mathsf{\mathbf{k}}}}
3991 * \dealcoloneq \mathsf{\mathbf{k}}_{u\widetilde{p}}
3992 * \overline{\mathsf{\mathbf{k}}} \mathsf{\mathbf{k}}_{\widetilde{p}u}
3996 * \overline{\mathsf{\mathbf{k}}} =
3997 * \mathsf{\mathbf{k}}_{\widetilde{J}\widetilde{p}}^{-1}
3998 * \mathsf{\mathbf{k}}_{\widetilde{J}\widetilde{J}}
3999 * \mathsf{\mathbf{k}}_{\widetilde{p}\widetilde{J}}^{-1}
4004 * At this point, we need to take note of
4005 * the fact that global data already exists
4006 * in the @f$\mathsf{\mathbf{K}}_{uu}@f$,
4007 * @f$\mathsf{\mathbf{K}}_{\widetilde{p} \widetilde{J}}@f$
4009 * @f$\mathsf{\mathbf{K}}_{\widetilde{J} \widetilde{p}}@f$
4010 * sub-blocks. So if we are to modify them, we must account for the data
4011 * that is already there (i.e. simply add to it or remove it if
4012 * necessary). Since the copy_local_to_global operation is a "+="
4013 * operation, we need to take this into account
4017 * For the @f$\mathsf{\mathbf{K}}_{uu}@f$ block in particular, this means that
4018 * contributions have been added from the surrounding cells, so we need to
4019 * be careful when we manipulate this block. We can't just erase the
4024 * This is the strategy we will employ to get the sub-blocks we want:
4028 * - @f$ {\mathsf{\mathbf{k}}}_{\textrm{store}}@f$:
4029 * Since we don
't have access to @f$\mathsf{\mathbf{k}}_{uu}@f$,
4030 * but we know its contribution is added to
4031 * the global @f$\mathsf{\mathbf{K}}_{uu}@f$ matrix, we just want
4032 * to add the element wise
4033 * static-condensation @f$\overline{\overline{\mathsf{\mathbf{k}}}}@f$.
4037 * - @f$\mathsf{\mathbf{k}}^{-1}_{\widetilde{p} \widetilde{J}}@f$:
4038 * Similarly, @f$\mathsf{\mathbf{k}}_{\widetilde{p}
4039 * \widetilde{J}}@f$ exists in
4040 * the subblock. Since the copy
4041 * operation is a += operation, we
4042 * need to subtract the existing
4043 * @f$\mathsf{\mathbf{k}}_{\widetilde{p} \widetilde{J}}@f$
4044 * submatrix in addition to
4045 * "adding" that which we wish to
4050 * - @f$\mathsf{\mathbf{k}}^{-1}_{\widetilde{J} \widetilde{p}}@f$:
4051 * Since the global matrix
4052 * is symmetric, this block is the
4053 * same as the one above and we
4055 * @f$\mathsf{\mathbf{k}}^{-1}_{\widetilde{p} \widetilde{J}}@f$
4056 * as a substitute for this one.
4060 * We first extract element data from the
4061 * system matrix. So first we get the
4062 * entire subblock for the cell, then
4063 * extract @f$\mathsf{\mathbf{k}}@f$
4064 * for the dofs associated with
4065 * the current element
4068 * data.k_orig.extract_submatrix_from(tangent_matrix,
4069 * data.local_dof_indices,
4070 * data.local_dof_indices);
4073 * and next the local matrices for
4074 * @f$\mathsf{\mathbf{k}}_{ \widetilde{p} u}@f$
4075 * @f$\mathsf{\mathbf{k}}_{ \widetilde{p} \widetilde{J}}@f$
4077 * @f$\mathsf{\mathbf{k}}_{ \widetilde{J} \widetilde{J}}@f$:
4080 * data.k_pu.extract_submatrix_from(data.k_orig,
4081 * element_indices_p,
4082 * element_indices_u);
4083 * data.k_pJ.extract_submatrix_from(data.k_orig,
4084 * element_indices_p,
4085 * element_indices_J);
4086 * data.k_JJ.extract_submatrix_from(data.k_orig,
4087 * element_indices_J,
4088 * element_indices_J);
4092 * To get the inverse of @f$\mathsf{\mathbf{k}}_{\widetilde{p}
4093 * \widetilde{J}}@f$, we invert it directly. This operation is relatively
4094 * inexpensive since @f$\mathsf{\mathbf{k}}_{\widetilde{p} \widetilde{J}}@f$
4095 * since block-diagonal.
4098 * data.k_pJ_inv.invert(data.k_pJ);
4102 * Now we can make condensation terms to
4103 * add to the @f$\mathsf{\mathbf{k}}_{uu}@f$
4104 * block and put them in
4105 * the cell local matrix
4107 * \mathsf{\mathbf{A}}
4109 * \mathsf{\mathbf{k}}^{-1}_{\widetilde{p} \widetilde{J}}
4110 * \mathsf{\mathbf{k}}_{\widetilde{p} u}
4114 * data.k_pJ_inv.mmult(data.A, data.k_pu);
4118 * \mathsf{\mathbf{B}}
4120 * \mathsf{\mathbf{k}}^{-1}_{\widetilde{J} \widetilde{J}}
4121 * \mathsf{\mathbf{k}}^{-1}_{\widetilde{p} \widetilde{J}}
4122 * \mathsf{\mathbf{k}}_{\widetilde{p} u}
4126 * data.k_JJ.mmult(data.B, data.A);
4130 * \mathsf{\mathbf{C}}
4132 * \mathsf{\mathbf{k}}^{-1}_{\widetilde{J} \widetilde{p}}
4133 * \mathsf{\mathbf{k}}^{-1}_{\widetilde{J} \widetilde{J}}
4134 * \mathsf{\mathbf{k}}^{-1}_{\widetilde{p} \widetilde{J}}
4135 * \mathsf{\mathbf{k}}_{\widetilde{p} u}
4139 * data.k_pJ_inv.Tmmult(data.C, data.B);
4143 * \overline{\overline{\mathsf{\mathbf{k}}}}
4145 * \mathsf{\mathbf{k}}_{u \widetilde{p}}
4146 * \mathsf{\mathbf{k}}^{-1}_{\widetilde{J} \widetilde{p}}
4147 * \mathsf{\mathbf{k}}^{-1}_{\widetilde{J} \widetilde{J}}
4148 * \mathsf{\mathbf{k}}^{-1}_{\widetilde{p} \widetilde{J}}
4149 * \mathsf{\mathbf{k}}_{\widetilde{p} u}
4153 * data.k_pu.Tmmult(data.k_bbar, data.C);
4154 * data.k_bbar.scatter_matrix_to(element_indices_u,
4155 * element_indices_u,
4156 * data.cell_matrix);
4161 * @f$\mathsf{\mathbf{k}}^{-1}_{ \widetilde{p} \widetilde{J}}@f$
4163 * @f$\mathsf{\mathbf{k}}_{ \widetilde{p} \widetilde{J}}@f$
4164 * block for post-processing. Note again
4165 * that we need to remove the
4166 * contribution that already exists there.
4169 * data.k_pJ_inv.add(-1.0, data.k_pJ);
4170 * data.k_pJ_inv.scatter_matrix_to(element_indices_p,
4171 * element_indices_J,
4172 * data.cell_matrix);
4178 * <a name="Solidsolve_linear_system"></a>
4179 * <h4>Solid::solve_linear_system</h4>
4180 * We now have all of the necessary components to use one of two possible
4181 * methods to solve the linearised system. The first is to perform static
4182 * condensation on an element level, which requires some alterations
4183 * to the tangent matrix and RHS vector. Alternatively, the full block
4184 * system can be solved by performing condensation on a global level.
4185 * Below we implement both approaches.
4188 * template <int dim>
4189 * std::pair<unsigned int, double>
4190 * Solid<dim>::solve_linear_system(BlockVector<double> &newton_update)
4192 * unsigned int lin_it = 0;
4193 * double lin_res = 0.0;
4195 * if (parameters.use_static_condensation == true)
4199 * Firstly, here is the approach using the (permanent) augmentation of
4200 * the tangent matrix. For the following, recall that
4202 * \mathsf{\mathbf{K}}_{\textrm{store}}
4205 * \mathsf{\mathbf{K}}_{\textrm{con}} &
4206 * \mathsf{\mathbf{K}}_{u\widetilde{p}} & \mathbf{0}
4207 * \\ \mathsf{\mathbf{K}}_{\widetilde{p}u} & \mathbf{0} &
4208 * \mathsf{\mathbf{K}}_{\widetilde{p}\widetilde{J}}^{-1}
4210 * \mathsf{\mathbf{K}}_{\widetilde{J}\widetilde{p}} &
4211 * \mathsf{\mathbf{K}}_{\widetilde{J}\widetilde{J}} \end{bmatrix} \, .
4215 * d \widetilde{\mathsf{\mathbf{p}}}
4217 * \mathsf{\mathbf{K}}_{\widetilde{J}\widetilde{p}}^{-1}
4219 * \mathsf{\mathbf{F}}_{\widetilde{J}}
4221 * \mathsf{\mathbf{K}}_{\widetilde{J}\widetilde{J}}
4222 * d \widetilde{\mathsf{\mathbf{J}}} \bigr]
4223 * \\ d \widetilde{\mathsf{\mathbf{J}}}
4225 * \mathsf{\mathbf{K}}_{\widetilde{p}\widetilde{J}}^{-1}
4227 * \mathsf{\mathbf{F}}_{\widetilde{p}}
4228 * - \mathsf{\mathbf{K}}_{\widetilde{p}u} d
4229 * \mathsf{\mathbf{u}} \bigr]
4230 * \\ \Rightarrow d \widetilde{\mathsf{\mathbf{p}}}
4231 * &= \mathsf{\mathbf{K}}_{\widetilde{J}\widetilde{p}}^{-1}
4232 * \mathsf{\mathbf{F}}_{\widetilde{J}}
4234 * \underbrace{\bigl[\mathsf{\mathbf{K}}_{\widetilde{J}\widetilde{p}}^{-1}
4235 * \mathsf{\mathbf{K}}_{\widetilde{J}\widetilde{J}}
4236 * \mathsf{\mathbf{K}}_{\widetilde{p}\widetilde{J}}^{-1}\bigr]}_{\overline{\mathsf{\mathbf{K}}}}\bigl[
4237 * \mathsf{\mathbf{F}}_{\widetilde{p}}
4238 * - \mathsf{\mathbf{K}}_{\widetilde{p}u} d
4239 * \mathsf{\mathbf{u}} \bigr]
4243 * \underbrace{\bigl[ \mathsf{\mathbf{K}}_{uu} +
4244 * \overline{\overline{\mathsf{\mathbf{K}}}}~ \bigr]
4245 * }_{\mathsf{\mathbf{K}}_{\textrm{con}}} d
4246 * \mathsf{\mathbf{u}}
4250 * \mathsf{\mathbf{F}}_{u}
4251 * - \mathsf{\mathbf{K}}_{u\widetilde{p}} \bigl[
4252 * \mathsf{\mathbf{K}}_{\widetilde{J}\widetilde{p}}^{-1}
4253 * \mathsf{\mathbf{F}}_{\widetilde{J}}
4255 * \overline{\mathsf{\mathbf{K}}}\mathsf{\mathbf{F}}_{\widetilde{p}}
4257 * \Bigr]}_{\mathsf{\mathbf{F}}_{\textrm{con}}}
4261 * \overline{\overline{\mathsf{\mathbf{K}}}} \dealcoloneq
4262 * \mathsf{\mathbf{K}}_{u\widetilde{p}}
4263 * \overline{\mathsf{\mathbf{K}}}
4264 * \mathsf{\mathbf{K}}_{\widetilde{p}u} \, .
4269 * At the top, we allocate two temporary vectors to help with the
4270 * static condensation, and variables to store the number of
4271 * linear solver iterations and the (hopefully converged) residual.
4274 * BlockVector<double> A(dofs_per_block);
4275 * BlockVector<double> B(dofs_per_block);
4280 * In the first step of this function, we solve for the incremental
4281 * displacement @f$d\mathbf{u}@f$. To this end, we perform static
4282 * condensation to make
4283 * @f$\mathsf{\mathbf{K}}_{\textrm{con}}
4284 * = \bigl[ \mathsf{\mathbf{K}}_{uu} +
4285 * \overline{\overline{\mathsf{\mathbf{K}}}}~ \bigr]@f$
4287 * @f$\mathsf{\mathbf{K}}^{-1}_{\widetilde{p} \widetilde{J}}@f$
4288 * in the original @f$\mathsf{\mathbf{K}}_{\widetilde{p} \widetilde{J}}@f$
4289 * block. That is, we make @f$\mathsf{\mathbf{K}}_{\textrm{store}}@f$.
4298 * \mathsf{\mathbf{A}}_{\widetilde{J}}
4300 * \mathsf{\mathbf{K}}^{-1}_{\widetilde{p} \widetilde{J}}
4301 * \mathsf{\mathbf{F}}_{\widetilde{p}}
4305 * tangent_matrix.block(p_dof, J_dof)
4306 * .vmult(A.block(J_dof), system_rhs.block(p_dof));
4310 * \mathsf{\mathbf{B}}_{\widetilde{J}}
4312 * \mathsf{\mathbf{K}}_{\widetilde{J} \widetilde{J}}
4313 * \mathsf{\mathbf{K}}^{-1}_{\widetilde{p} \widetilde{J}}
4314 * \mathsf{\mathbf{F}}_{\widetilde{p}}
4318 * tangent_matrix.block(J_dof, J_dof)
4319 * .vmult(B.block(J_dof), A.block(J_dof));
4323 * \mathsf{\mathbf{A}}_{\widetilde{J}}
4325 * \mathsf{\mathbf{F}}_{\widetilde{J}}
4327 * \mathsf{\mathbf{K}}_{\widetilde{J} \widetilde{J}}
4328 * \mathsf{\mathbf{K}}^{-1}_{\widetilde{p} \widetilde{J}}
4329 * \mathsf{\mathbf{F}}_{\widetilde{p}}
4333 * A.block(J_dof) = system_rhs.block(J_dof);
4334 * A.block(J_dof) -= B.block(J_dof);
4338 * \mathsf{\mathbf{A}}_{\widetilde{J}}
4340 * \mathsf{\mathbf{K}}^{-1}_{\widetilde{J} \widetilde{p}}
4342 * \mathsf{\mathbf{F}}_{\widetilde{J}}
4344 * \mathsf{\mathbf{K}}_{\widetilde{J} \widetilde{J}}
4345 * \mathsf{\mathbf{K}}^{-1}_{\widetilde{p} \widetilde{J}}
4346 * \mathsf{\mathbf{F}}_{\widetilde{p}}
4351 * tangent_matrix.block(p_dof, J_dof)
4352 * .Tvmult(A.block(p_dof), A.block(J_dof));
4356 * \mathsf{\mathbf{A}}_{u}
4358 * \mathsf{\mathbf{K}}_{u \widetilde{p}}
4359 * \mathsf{\mathbf{K}}^{-1}_{\widetilde{J} \widetilde{p}}
4361 * \mathsf{\mathbf{F}}_{\widetilde{J}}
4363 * \mathsf{\mathbf{K}}_{\widetilde{J} \widetilde{J}}
4364 * \mathsf{\mathbf{K}}^{-1}_{\widetilde{p} \widetilde{J}}
4365 * \mathsf{\mathbf{F}}_{\widetilde{p}}
4370 * tangent_matrix.block(u_dof, p_dof)
4371 * .vmult(A.block(u_dof), A.block(p_dof));
4375 * \mathsf{\mathbf{F}}_{\text{con}}
4377 * \mathsf{\mathbf{F}}_{u}
4379 * \mathsf{\mathbf{K}}_{u \widetilde{p}}
4380 * \mathsf{\mathbf{K}}^{-1}_{\widetilde{J} \widetilde{p}}
4382 * \mathsf{\mathbf{F}}_{\widetilde{J}}
4384 * \mathsf{\mathbf{K}}_{\widetilde{J} \widetilde{J}}
4385 * \mathsf{\mathbf{K}}^{-1}_{\widetilde{p} \widetilde{J}}
4386 * \mathsf{\mathbf{F}}_{\widetilde{p}}
4391 * system_rhs.block(u_dof) -= A.block(u_dof);
4393 * timer.enter_subsection("Linear solver");
4394 * std::cout << " SLV " << std::flush;
4395 * if (parameters.type_lin == "CG")
4397 * const auto solver_its = static_cast<unsigned int>(
4398 * tangent_matrix.block(u_dof, u_dof).m() *
4399 * parameters.max_iterations_lin);
4400 * const double tol_sol =
4401 * parameters.tol_lin * system_rhs.block(u_dof).l2_norm();
4403 * SolverControl solver_control(solver_its, tol_sol);
4405 * GrowingVectorMemory<Vector<double>> GVM;
4406 * SolverCG<Vector<double>> solver_CG(solver_control, GVM);
4410 * We've chosen by
default a SSOR preconditioner as it appears to
4411 * provide the fastest solver convergence characteristics
for this
4412 * problem on a single-thread machine. However,
this might not be
4413 *
true for different problem sizes.
4417 * preconditioner(parameters.preconditioner_type,
4418 * parameters.preconditioner_relaxation);
4419 * preconditioner.use_matrix(tangent_matrix.block(u_dof, u_dof));
4421 * solver_CG.solve(tangent_matrix.block(u_dof, u_dof),
4422 * newton_update.block(u_dof),
4423 * system_rhs.block(u_dof),
4426 * lin_it = solver_control.last_step();
4427 * lin_res = solver_control.last_value();
4429 *
else if (parameters.type_lin ==
"Direct")
4433 * Otherwise
if the problem is small
4434 * enough, a direct solver can be
4439 * A_direct.
initialize(tangent_matrix.block(u_dof, u_dof));
4440 * A_direct.vmult(newton_update.block(u_dof),
4441 * system_rhs.block(u_dof));
4454 * Now that we have the displacement update, distribute the constraints
4455 * back to the Newton update:
4458 * constraints.distribute(newton_update);
4461 * std::cout <<
" PP " << std::flush;
4465 * The next step after solving the displacement
4466 * problem is to post-process to get the
4467 * dilatation solution from the
4470 * d \widetilde{\mathsf{\mathbf{J}}}
4471 * = \mathsf{\mathbf{K}}_{\widetilde{p}\widetilde{J}}^{-1} \bigl[
4472 * \mathsf{\mathbf{
F}}_{\widetilde{p}}
4473 * - \mathsf{\mathbf{K}}_{\widetilde{p}u} d \mathsf{\mathbf{u}}
4482 * \mathsf{\mathbf{
A}}_{\widetilde{p}}
4484 * \mathsf{\mathbf{K}}_{\widetilde{p}u} d \mathsf{\mathbf{u}}
4488 * tangent_matrix.block(p_dof, u_dof)
4489 * .vmult(
A.block(p_dof), newton_update.block(u_dof));
4493 * \mathsf{\mathbf{
A}}_{\widetilde{p}}
4495 * -\mathsf{\mathbf{K}}_{\widetilde{p}u} d \mathsf{\mathbf{u}}
4499 *
A.block(p_dof) *= -1.0;
4503 * \mathsf{\mathbf{
A}}_{\widetilde{p}}
4505 * \mathsf{\mathbf{
F}}_{\widetilde{p}}
4506 * -\mathsf{\mathbf{K}}_{\widetilde{p}u} d \mathsf{\mathbf{u}}
4510 *
A.block(p_dof) += system_rhs.block(p_dof);
4514 * d\mathsf{\mathbf{\widetilde{J}}}
4516 * \mathsf{\mathbf{K}}^{-1}_{\widetilde{p}\widetilde{J}}
4518 * \mathsf{\mathbf{
F}}_{\widetilde{p}}
4519 * -\mathsf{\mathbf{K}}_{\widetilde{p}u} d \mathsf{\mathbf{u}}
4524 * tangent_matrix.block(p_dof, J_dof)
4525 * .vmult(newton_update.block(J_dof),
A.block(p_dof));
4530 * we ensure here that any Dirichlet constraints
4531 * are distributed on the updated solution:
4534 * constraints.distribute(newton_update);
4538 * Finally we solve
for the pressure
4539 * update with the substitution:
4541 * d \widetilde{\mathsf{\mathbf{p}}}
4543 * \mathsf{\mathbf{K}}_{\widetilde{J}\widetilde{p}}^{-1}
4545 * \mathsf{\mathbf{
F}}_{\widetilde{J}}
4546 * - \mathsf{\mathbf{K}}_{\widetilde{J}\widetilde{J}}
4547 * d \widetilde{\mathsf{\mathbf{J}}}
4556 * \mathsf{\mathbf{
A}}_{\widetilde{J}}
4558 * \mathsf{\mathbf{K}}_{\widetilde{J}\widetilde{J}}
4559 * d \widetilde{\mathsf{\mathbf{J}}}
4563 * tangent_matrix.block(J_dof, J_dof)
4564 * .vmult(
A.block(J_dof), newton_update.block(J_dof));
4568 * \mathsf{\mathbf{
A}}_{\widetilde{J}}
4570 * -\mathsf{\mathbf{K}}_{\widetilde{J}\widetilde{J}}
4571 * d \widetilde{\mathsf{\mathbf{J}}}
4575 *
A.block(J_dof) *= -1.0;
4579 * \mathsf{\mathbf{
A}}_{\widetilde{J}}
4581 * \mathsf{\mathbf{
F}}_{\widetilde{J}}
4583 * \mathsf{\mathbf{K}}_{\widetilde{J}\widetilde{J}}
4584 * d \widetilde{\mathsf{\mathbf{J}}}
4588 *
A.block(J_dof) += system_rhs.block(J_dof);
4593 * d \widetilde{\mathsf{\mathbf{p}}}
4595 * \mathsf{\mathbf{K}}_{\widetilde{J}\widetilde{p}}^{-1}
4597 * \mathsf{\mathbf{
F}}_{\widetilde{J}}
4598 * - \mathsf{\mathbf{K}}_{\widetilde{J}\widetilde{J}}
4599 * d \widetilde{\mathsf{\mathbf{J}}}
4604 * tangent_matrix.block(p_dof, J_dof)
4605 * .Tvmult(newton_update.block(p_dof),
A.block(J_dof));
4610 * We are now at the
end, so we distribute all
4611 * constrained dofs back to the Newton
4615 * constraints.distribute(newton_update);
4621 * std::cout <<
" ------ " << std::flush;
4624 * std::cout <<
" SLV " << std::flush;
4626 *
if (parameters.type_lin ==
"CG")
4630 * Manual condensation of the dilatation and pressure fields on
4631 * a local
level, and subsequent post-processing, took quite a
4632 * bit of effort to achieve. To recap, we had to produce the
4634 * @f$\mathsf{\mathbf{K}}_{\widetilde{p}\widetilde{J}}^{-1}@f$, which
4635 * was permanently written into the global tangent
matrix. We then
4636 * permanently modified @f$\mathsf{\mathbf{K}}_{uu}@f$ to produce
4637 * @f$\mathsf{\mathbf{K}}_{\textrm{con}}@f$. This involved the
4638 * extraction and manipulation of local sub-blocks of the tangent
4639 *
matrix. After solving
for the displacement, the individual
4640 *
matrix-vector operations required to solve
for dilatation and
4641 * pressure were carefully implemented. Contrast these many sequence
4642 * of steps to the much simpler and transparent implementation
using
4647 * For ease of later use, we define some aliases
for
4648 * blocks in the RHS vector
4657 * ... and
for blocks in the Newton update vector.
4666 * We next define some linear operators
for the tangent
matrix
4667 * sub-blocks We will exploit the symmetry of the system, so not all
4668 * blocks are required.
4684 * We then construct a
LinearOperator that represents the inverse of
4686 * @f$\mathsf{\mathbf{K}}_{\widetilde{J}\widetilde{p}}@f$. Since it is
4687 *
diagonal (or, when a higher order ansatz it used, nearly
4688 *
diagonal), a Jacobi preconditioner is suitable.
4692 * preconditioner_K_Jp_inv(
"jacobi");
4693 * preconditioner_K_Jp_inv.use_matrix(
4694 * tangent_matrix.block(J_dof, p_dof));
4696 *
static_cast<unsigned int>(tangent_matrix.block(J_dof, p_dof).m() *
4697 * parameters.max_iterations_lin),
4699 * parameters.tol_lin);
4701 * solver_K_Jp_inv.
select(
"cg");
4702 * solver_K_Jp_inv.
set_control(solver_control_K_Jp_inv);
4703 *
const auto K_Jp_inv =
4708 * Now we can construct that
transpose of
4709 * @f$\mathsf{\mathbf{K}}_{\widetilde{J}\widetilde{p}}^{-1}@f$ and a
4710 * linear
operator that represents the condensed operations
4711 * @f$\overline{\mathsf{\mathbf{K}}}@f$ and
4712 * @f$\overline{\overline{\mathsf{\mathbf{K}}}}@f$ and the
final
4714 * @f$\mathsf{\mathbf{K}}_{\textrm{con}}@f$.
4716 * here, but for clarity and the purpose of demonstrating the
4717 * similarities between the formulation and implementation of the
4718 * linear solution scheme, we will perform these operations
4723 * const auto K_pp_bar = K_Jp_inv * K_JJ * K_pJ_inv;
4724 * const auto K_uu_bar_bar = K_up * K_pp_bar * K_pu;
4725 * const auto K_uu_con = K_uu + K_uu_bar_bar;
4729 * Lastly, we define an operator for inverse of augmented stiffness
4730 *
matrix, namely @f$\mathsf{\mathbf{K}}_{\textrm{con}}^{-1}@f$. Note
4731 * that the preconditioner
for the augmented stiffness
matrix is
4732 * different to the
case when we use
static condensation. In
this
4733 * instance, the preconditioner is based on a non-modified
4734 * @f$\mathsf{\mathbf{K}}_{uu}@f$,
while with the
first approach we
4735 * actually modified the entries of
this sub-block. However, since
4736 * @f$\mathsf{\mathbf{K}}_{\textrm{con}}@f$ and
4737 * @f$\mathsf{\mathbf{K}}_{uu}@f$ operate on the same space, it remains
4738 * adequate
for this problem.
4742 * preconditioner_K_con_inv(parameters.preconditioner_type,
4743 * parameters.preconditioner_relaxation);
4744 * preconditioner_K_con_inv.use_matrix(
4745 * tangent_matrix.block(u_dof, u_dof));
4747 *
static_cast<unsigned int>(tangent_matrix.block(u_dof, u_dof).m() *
4748 * parameters.max_iterations_lin),
4750 * parameters.tol_lin);
4752 * solver_K_con_inv.
select(
"cg");
4753 * solver_K_con_inv.
set_control(solver_control_K_con_inv);
4754 *
const auto K_uu_con_inv =
4757 * preconditioner_K_con_inv);
4761 * Now we are in a position to solve
for the displacement field.
4762 * We can nest the linear operations, and the result is immediately
4763 * written to the Newton update vector.
4764 * It is clear that the implementation closely mimics the derivation
4765 * stated in the introduction.
4769 * K_uu_con_inv * (f_u - K_up * (K_Jp_inv * f_J - K_pp_bar * f_p));
4775 * The operations need to post-process
for the dilatation and
4776 * pressure fields are just as easy to express.
4780 * std::cout <<
" PP " << std::flush;
4782 * d_J = K_pJ_inv * (f_p - K_pu * d_u);
4783 * d_p = K_Jp_inv * (f_J - K_JJ * d_J);
4785 * lin_it = solver_control_K_con_inv.last_step();
4786 * lin_res = solver_control_K_con_inv.last_value();
4788 *
else if (parameters.type_lin ==
"Direct")
4792 * Solve the full block system with
4793 * a direct solver. As it is relatively
4794 * robust, it may be immune to problem
4795 * arising from the presence of the
zero
4796 * @f$\mathsf{\mathbf{K}}_{ \widetilde{J} \widetilde{J}}@f$
4802 * A_direct.vmult(newton_update, system_rhs);
4807 * std::cout <<
" -- " << std::flush;
4816 * Finally, we again ensure here that any Dirichlet
4817 * constraints are distributed on the updated solution:
4820 * constraints.distribute(newton_update);
4823 *
return std::make_pair(lin_it, lin_res);
4829 * <a name=
"Solidoutput_results"></a>
4830 * <h4>Solid::output_results</h4>
4831 * Here we present how the results are written to file to be viewed
4832 *
using ParaView or VisIt. The method is similar to that shown in previous
4833 * tutorials so will not be discussed in detail.
4836 *
template <
int dim>
4837 *
void Solid<dim>::output_results() const
4840 * std::vector<DataComponentInterpretation::DataComponentInterpretation>
4841 * data_component_interpretation(
4843 * data_component_interpretation.push_back(
4845 * data_component_interpretation.push_back(
4848 * std::vector<std::string> solution_name(dim,
"displacement");
4849 * solution_name.emplace_back(
"pressure");
4850 * solution_name.emplace_back(
"dilatation");
4860 * data_component_interpretation);
4864 * Since we are dealing with a large deformation problem, it would be nice
4866 * linked with the
DataOut class provides an interface through which this
4867 * can be achieved without physically moving the grid points in the
4869 * a temporary vector and then create the Eulerian mapping. We also
4870 * specify the polynomial degree to the
DataOut object in order to produce
4871 * a more refined output data
set when higher order polynomials are used.
4875 *
for (
unsigned int i = 0; i < soln.size(); ++i)
4876 * soln(i) = solution_n(i);
4880 * std::ofstream output(
"solution-" +
std::to_string(dim) +
"d-" +
4891 * <a name=
"Mainfunction"></a>
4892 * <h3>Main function</h3>
4893 * Lastly we provide the main driver function which appears
4894 * no different to the other tutorials.
4899 *
using namespace Step44;
4903 *
const unsigned int dim = 3;
4904 * Solid<dim> solid(
"parameters.prm");
4907 *
catch (std::exception &exc)
4909 * std::cerr << std::endl
4911 * <<
"----------------------------------------------------"
4913 * std::cerr <<
"Exception on processing: " << std::endl
4914 * << exc.what() << std::endl
4915 * <<
"Aborting!" << std::endl
4916 * <<
"----------------------------------------------------"
4923 * std::cerr << std::endl
4925 * <<
"----------------------------------------------------"
4927 * std::cerr <<
"Unknown exception!" << std::endl
4928 * <<
"Aborting!" << std::endl
4929 * <<
"----------------------------------------------------"
4937<a name=
"Results"></a><h1>Results</h1>
4940Firstly, we present a comparison of a series of 3-
d results with those
4941in the literature (see Reese et al (2000)) to demonstrate that the program works as expected.
4943We
begin with a comparison of the convergence with mesh refinement for the @f$Q_1-DGPM_0-DGPM_0@f$ and
4944@f$Q_2-DGPM_1-DGPM_1@f$ formulations, as summarised in the figure below.
4945The vertical displacement of the midpoint of the upper surface of the block is used to assess convergence.
4946Both schemes demonstrate good convergence properties for varying
values of the load parameter @f$p/p_0@f$.
4947The results agree with those in the literature.
4948The lower-order formulation typically overestimates the displacement for low levels of refinement,
4949while the higher-order interpolation scheme underestimates it, but be a lesser degree.
4950This benchmark, and a series of others not shown here, give us confidence that the code is working
4953<table align="
center" class="tutorial" cellspacing="3" cellpadding="3">
4958 Convergence of the @f$Q_1-DGPM_0-DGPM_0@f$ formulation in 3-
d.
4964 Convergence of the @f$Q_2-DGPM_1-DGPM_1@f$ formulation in 3-
d.
4971A typical screen output generated by running the problem is shown below.
4972The particular case demonstrated is that of the @f$Q_2-DGPM_1-DGPM_1@f$ formulation.
4973It is clear that, using the Newton-Raphson method, quadratic convergence of the solution is obtained.
4974Solution convergence is achieved within 5 Newton increments for all time-steps.
4975The converged displacement's @f$L_2@f$-
norm is several orders of magnitude less than the geometry
scale.
4981 Number of active cells: 64
4982 Number of degrees of freedom: 2699
4983 Setting up quadrature
point data...
4986___________________________________________________________________________________________________________________________________________________________
4987 SOLVER STEP | LIN_IT LIN_RES RES_NORM RES_U RES_P RES_J NU_NORM NU_U NU_P NU_J
4988___________________________________________________________________________________________________________________________________________________________
4989 0 ASM_R ASM_K CST ASM_SC SLV PP UQPH | 786 2.118
e-06 1.000
e+00 1.000
e+00 0.000
e+00 0.000
e+00 1.000
e+00 1.000
e+00 1.000
e+00 1.000
e+00
4990 1 ASM_R ASM_K CST ASM_SC SLV PP UQPH | 552 1.031
e-03 8.563
e-02 8.563
e-02 9.200
e-13 3.929
e-08 1.060
e-01 3.816
e-02 1.060
e-01 1.060
e-01
4991 2 ASM_R ASM_K CST ASM_SC SLV PP UQPH | 667 5.602
e-06 2.482
e-03 2.482
e-03 3.373
e-15 2.982
e-10 2.936
e-03 2.053
e-04 2.936
e-03 2.936
e-03
4992 3 ASM_R ASM_K CST ASM_SC SLV PP UQPH | 856 6.469
e-10 2.129
e-06 2.129
e-06 2.245
e-19 1.244
e-13 1.887
e-06 7.289
e-07 1.887
e-06 1.887
e-06
4994___________________________________________________________________________________________________________________________________________________________
4996Displacement: 7.289
e-07
4998Dilatation: 1.353
e-07
4999v / V_0: 1.000
e-09 / 1.000
e-09 = 1.000
e+00
5004Timestep 10 @ 1.000
e+00s
5005___________________________________________________________________________________________________________________________________________________________
5006 SOLVER STEP | LIN_IT LIN_RES RES_NORM RES_U RES_P RES_J NU_NORM NU_U NU_P NU_J
5007___________________________________________________________________________________________________________________________________________________________
5008 0 ASM_R ASM_K CST ASM_SC SLV PP UQPH | 874 2.358
e-06 1.000
e+00 1.000
e+00 1.000
e+00 1.000
e+00 1.000
e+00 1.000
e+00 1.000
e+00 1.000
e+00
5009 1 ASM_R ASM_K CST ASM_SC SLV PP UQPH | 658 2.942
e-04 1.544
e-01 1.544
e-01 1.208
e+13 1.855
e+06 6.014
e-02 7.398
e-02 6.014
e-02 6.014
e-02
5010 2 ASM_R ASM_K CST ASM_SC SLV PP UQPH | 790 2.206
e-06 2.908
e-03 2.908
e-03 7.302
e+10 2.067
e+03 2.716
e-03 1.433
e-03 2.716
e-03 2.717
e-03
5011 3 ASM_R ASM_K CST ASM_SC SLV PP UQPH | 893 2.374
e-09 1.919
e-06 1.919
e-06 4.527
e+07 4.100
e+00 1.672
e-06 6.842
e-07 1.672
e-06 1.672
e-06
5013___________________________________________________________________________________________________________________________________________________________
5015Displacement: 6.842
e-07
5017Dilatation: 1.528
e-06
5018v / V_0: 1.000
e-09 / 1.000
e-09 = 1.000
e+00
5023Using the
Timer class, we can discern which parts of the code require the highest computational expense.
5024For a case with a large number of degrees-of-freedom (i.
e. a high
level of refinement), a typical output of the
Timer is given below.
5025Much of the code in the tutorial has been developed based on the optimizations described,
5026discussed and demonstrated in @ref step_18 "step-18" and others.
5027With over 93% of the time being spent in the linear solver, it is obvious that it may be necessary
5028to invest in a better solver for large three-dimensional problems.
5029The SSOR preconditioner is not multithreaded but is effective for this class of solid problems.
5030It may be beneficial to investigate the use of another solver such as those available through the Trilinos library.
5034+---------------------------------------------+------------+------------+
5035| Total wallclock time elapsed since start | 9.874
e+02s | |
5037| Section | no. calls | wall time | % of total |
5038+---------------------------------+-----------+------------+------------+
5039| Assemble system right-hand side | 53 | 1.727
e+00s | 1.75
e-01% |
5040| Assemble tangent
matrix | 43 | 2.707
e+01s | 2.74
e+00% |
5041| Linear solver | 43 | 9.248
e+02s | 9.37
e+01% |
5042| Linear solver postprocessing | 43 | 2.743
e-02s | 2.78
e-03% |
5043| Perform static condensation | 43 | 1.437
e+01s | 1.46
e+00% |
5044| Setup system | 1 | 3.897
e-01s | 3.95
e-02% |
5045| Update QPH data | 43 | 5.770
e-01s | 5.84
e-02% |
5046+---------------------------------+-----------+------------+------------+
5050We then used ParaView to visualize the results for two cases.
5051The
first was for the coarsest grid and the lowest-order interpolation method: @f$Q_1-DGPM_0-DGPM_0@f$.
5052The
second was on a refined grid using a @f$Q_2-DGPM_1-DGPM_1@f$ formulation.
5053The vertical component of the displacement, the pressure @f$\widetilde{p}@f$ and the dilatation @f$\widetilde{J}@f$ fields
5057For the
first case it is clear that the coarse spatial discretization coupled with large displacements leads to a low quality solution
5058(the loading ratio is @f$p/p_0=80@f$).
5059Additionally, the pressure difference between elements is very large.
5060The constant pressure field on the element means that the large pressure
gradient is not captured.
5061However, it should be noted that locking, which would be present in a standard @f$Q_1@f$ displacement formulation does not arise
5062even in
this poorly discretised
case.
5063The
final vertical displacement of the tracked node on the top surface of the block is still within 12.5% of the converged solution.
5064The pressure solution is very coarse and has large jumps between adjacent cells.
5065It is clear that the
volume nearest to the applied traction undergoes compression
while the outer extents
5066of the domain are in a state of expansion.
5067The dilatation solution field and pressure field are clearly linked,
5068with positive dilatation indicating regions of positive pressure and negative showing regions placed in compression.
5069As discussed in the Introduction, a compressive pressure has a negative
sign
5070while an expansive pressure takes a positive
sign.
5071This stems from the definition of the volumetric strain energy function
5072and is opposite to the physically realistic interpretation of pressure.
5075<table align=
"center" class=
"tutorial" cellspacing=
"3" cellpadding=
"3">
5078 <img src=
"https://www.dealii.org/images/steps/developer/step-44.Q1-P0_gr_1_p_ratio_80-displacement.png" alt=
"">
5080 Z-displacement solution
for the 3-
d problem.
5084 <img src=
"https://www.dealii.org/images/steps/developer/step-44.Q1-P0_gr_1_p_ratio_80-pressure.png" alt=
"">
5086 Discontinuous piece-wise constant pressure field.
5090 <img src=
"https://www.dealii.org/images/steps/developer/step-44.Q1-P0_gr_1_p_ratio_80-dilatation.png" alt=
"">
5092 Discontinuous piece-wise constant dilatation field.
5098Combining spatial refinement and a higher-order interpolation scheme results in a high-quality solution.
5099Three grid refinements coupled with a @f$Q_2-DGPM_1-DGPM_1@f$ formulation produces
5100a result that clearly captures the mechanics of the problem.
5101The deformation of the traction surface is well resolved.
5102We can now observe the actual extent of the applied traction, with the maximum force being applied
5103at the central
point of the surface causing the largest compression.
5104Even though very high strains are experienced in the domain,
5105especially at the boundary of the region of applied traction,
5106the solution remains accurate.
5107The pressure field is captured in far greater detail than before.
5108There is a clear distinction and transition between regions of compression and expansion,
5109and the linear approximation of the pressure field allows a refined visualization
5110of the pressure at the sub-element
scale.
5111It should however be noted that the pressure field remains discontinuous
5112and could be smoothed on a continuous grid
for the post-processing purposes.
5116<table align=
"center" class=
"tutorial" cellspacing=
"3" cellpadding=
"3">
5119 <img src=
"https://www.dealii.org/images/steps/developer/step-44.Q2-P1_gr_3_p_ratio_80-displacement.png" alt=
"">
5121 Z-displacement solution
for the 3-
d problem.
5125 <img src=
"https://www.dealii.org/images/steps/developer/step-44.Q2-P1_gr_3_p_ratio_80-pressure.png" alt=
"">
5127 Discontinuous linear pressure field.
5131 <img src=
"https://www.dealii.org/images/steps/developer/step-44.Q2-P1_gr_3_p_ratio_80-dilatation.png" alt=
"">
5133 Discontinuous linear dilatation field.
5139This brief analysis of the results demonstrates that the three-field formulation is effective
5140in circumventing volumetric locking
for highly-incompressible media.
5141The mixed formulation is able to accurately simulate the displacement of a
5142near-incompressible block under compression.
5143The command-line output indicates that the volumetric change under extreme compression resulted in
5144less than 0.01%
volume change
for a Poisson
's ratio of 0.4999.
5146In terms of run-time, the @f$Q_2-DGPM_1-DGPM_1@f$ formulation tends to be more computationally expensive
5147than the @f$Q_1-DGPM_0-DGPM_0@f$ for a similar number of degrees-of-freedom
5148(produced by adding an extra grid refinement level for the lower-order interpolation).
5149This is shown in the graph below for a batch of tests run consecutively on a single 4-core (8-thread) machine.
5150The increase in computational time for the higher-order method is likely due to
5151the increased band-width required for the higher-order elements.
5152As previously mentioned, the use of a better solver and preconditioner may mitigate the
5153expense of using a higher-order formulation.
5154It was observed that for the given problem using the multithreaded Jacobi preconditioner can reduce the
5155computational runtime by up to 72% (for the worst case being a higher-order formulation with a large number
5156of degrees-of-freedom) in comparison to the single-thread SSOR preconditioner.
5157However, it is the author's experience that the Jacobi method of preconditioning may not be suitable
for
5158some finite-strain problems involving alternative constitutive models.
5161<table align=
"center" class=
"tutorial" cellspacing=
"3" cellpadding=
"3">
5164 <img src=
"https://www.dealii.org/images/steps/developer/step-44.Normalised_runtime.png" alt=
"">
5166 Runtime on a 4-core machine, normalised against the lowest grid resolution @f$Q_1-DGPM_0-DGPM_0@f$ solution that utilised a SSOR preconditioner.
5173Lastly, results
for the displacement solution
for the 2-
d problem are showcased below
for
5174two different levels of grid refinement.
5175It is clear that due to the extra constraints imposed by simulating in 2-
d that the resulting
5176displacement field, although qualitatively similar, is different to that of the 3-
d case.
5179<table align=
"center" class=
"tutorial" cellspacing=
"3" cellpadding=
"3">
5182 <img src=
"https://www.dealii.org/images/steps/developer/step-44.2d-gr_2.png" alt=
"">
5184 Y-displacement solution in 2-
d for 2 global grid refinement levels.
5188 <img src=
"https://www.dealii.org/images/steps/developer/step-44.2d-gr_5.png" alt=
"">
5190 Y-displacement solution in 2-
d for 5 global grid refinement levels.
5196<a name=
"extensions"></a>
5197<a name=
"Possibilitiesforextensions"></a><h3>Possibilities
for extensions</h3>
5200There are a number of obvious extensions
for this work:
5202- Firstly, an additional constraint could be added to the
free-energy
5203 function in order to enforce a high degree of incompressibility in
5204 materials. An additional Lagrange multiplier would be introduced,
5205 but
this could most easily be dealt with
using the principle of
5206 augmented Lagrange multipliers. This is demonstrated in <em>Simo and
5207 Taylor (1991) </em>.
5208- The constitutive relationship used in
this
5209 model is relatively basic. It may be beneficial to
split the material
5210 class into two separate classes,
one dealing with the volumetric
5211 response and the other the isochoric response, and produce a generic
5212 materials class (i.
e. having abstract virtual
functions that derived
5213 classes have to implement) that would allow for the addition of more complex
5214 material models. Such models could include other hyperelastic
5215 materials, plasticity and viscoelastic materials and others.
5216- The program has been developed for solving problems on single-node
5217 multicore machines. With a little effort, the program could be
5218 extended to a large-
scale computing environment through the use of
5219 Petsc or Trilinos, using a similar technique to that demonstrated in
5220 @ref step_40 "step-40". This would mostly involve changes to the setup, assembly,
5221 <code>PointHistory</code> and linear solver routines.
5222- As this program assumes quasi-static equilibrium, extensions to
5223 include dynamic effects would be necessary to study problems where
5224 inertial effects are important,
e.g. problems involving impact.
5225- Load and solution limiting procedures may be necessary for highly
5226 nonlinear problems. It is possible to add a linesearch algorithm to
5227 limit the step size within a Newton increment to ensure optimum
5228 convergence. It may also be necessary to use a load limiting method,
5229 such as the Riks method, to solve unstable problems involving
5230 geometric instability such as buckling and snap-through.
5231- Many physical problems involve contact. It is possible to include
5232 the effect of frictional or frictionless contact between objects
5233 into this program. This would involve the addition of an extra term
5234 in the
free-energy functional and therefore an addition to the
5235 assembly routine. One would also need to manage the contact problem
5236 (detection and stress calculations) itself. An alternative to
5237 additional penalty terms in the
free-energy functional would be to
5238 use active
set methods such as the
one used in @ref step_41 "step-41".
5239- The complete condensation procedure using LinearOperators has been
5240 coded into the linear solver routine. This could also have been
5242 operator to condense out
one or more of the fields in a more
5244- Finally, adaptive mesh refinement, as demonstrated in @ref step_6 "step-6" and
5245 @ref step_18 "step-18", could provide additional solution accuracy.
5248<a name=
"PlainProg"></a>
5249<h1> The plain program</h1>
5250@include
"step-44.cc"
void attach_dof_handler(const DoFHandlerType &)
void add_data_vector(const VectorType &data, const std::vector< std::string > &names, const DataVectorType type=type_automatic, const std::vector< DataComponentInterpretation::DataComponentInterpretation > &data_component_interpretation=std::vector< DataComponentInterpretation::DataComponentInterpretation >())
virtual void build_patches(const unsigned int n_subdivisions=0)
void select(const std::string &name)
void set_control(SolverControl &ctrl)
void initialize(const SparsityPattern &sparsity_pattern)
void leave_subsection(const std::string §ion_name="")
void enter_subsection(const std::string §ion_name)
__global__ void set(Number *val, const Number s, const size_type N)
#define Assert(cond, exc)
std::string to_string(const T &t)
void write_vtu(std::ostream &out) const
bool write_higher_order_cells
static ::ExceptionBase & ExcInternalError()
void set_flags(const FlagType &flags)
static ::ExceptionBase & ExcMessage(std::string arg1)
LinearOperator< Range, Domain, Payload > linear_operator(const Matrix &matrix)
LinearOperator< Domain, Range, Payload > transpose_operator(const LinearOperator< Range, Domain, Payload > &op)
LinearOperator< Range_2, Domain_2, Payload > schur_complement(const LinearOperator< Domain_1, Range_1, Payload > &A_inv, const LinearOperator< Range_1, Domain_2, Payload > &B, const LinearOperator< Range_2, Domain_1, Payload > &C, const LinearOperator< Range_2, Domain_2, Payload > &D)
LinearOperator< Domain, Range, Payload > inverse_operator(const LinearOperator< Range, Domain, Payload > &op, Solver &solver, const Preconditioner &preconditioner)
void loop(ITERATOR begin, typename identity< ITERATOR >::type end, DOFINFO &dinfo, INFOBOX &info, const std::function< void(DOFINFO &, typename INFOBOX::CellInfo &)> &cell_worker, const std::function< void(DOFINFO &, typename INFOBOX::CellInfo &)> &boundary_worker, const std::function< void(DOFINFO &, DOFINFO &, typename INFOBOX::CellInfo &, typename INFOBOX::CellInfo &)> &face_worker, ASSEMBLER &assembler, const LoopControl &lctrl=LoopControl())
Task< RT > new_task(const std::function< RT()> &function)
std::vector< value_type > split(const typename ::Triangulation< dim, spacedim >::cell_iterator &parent, const value_type parent_value)
@ component_is_part_of_vector
Expression sign(const Expression &x)
static const types::blas_int zero
@ matrix
Contents is actually a matrix.
@ symmetric
Matrix is symmetric.
@ diagonal
Matrix is diagonal.
@ general
No special properties.
static const types::blas_int one
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.)
double norm(const FEValuesBase< dim > &fe, const ArrayView< const std::vector< Tensor< 1, dim > > > &Du)
Point< spacedim > point(const gp_Pnt &p, const double tolerance=1e-10)
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)
VectorType::value_type * begin(VectorType &V)
void run(const Iterator &begin, const typename identity< Iterator >::type &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)
constexpr TableIndices< 2 > merge(const TableIndices< 2 > &previous_indices, const unsigned int new_index, const unsigned int position)
void copy(const T *begin, const T *end, U *dest)
int(&) functions(const void *v1, const void *v2)
void assemble(const MeshWorker::DoFInfoBox< dim, DOFINFO > &dinfo, A *assembler)
const ::parallel::distributed::Triangulation< dim, spacedim > * triangulation