From 3cf8da320c71521b78f9a61736a28e32fbd2136a Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 27 Jan 2020 10:42:04 -0700 Subject: [PATCH] Avoid the use of deprecated functions in tutorials. --- examples/doxygen/block_dynamic_sparsity_pattern.cc | 4 ++-- examples/step-20/step-20.cc | 12 ++++++------ examples/step-21/step-21.cc | 4 ++-- examples/step-22/step-22.cc | 10 ++++------ examples/step-31/step-31.cc | 6 ++---- examples/step-32/step-32.cc | 6 ++---- examples/step-43/step-43.cc | 7 +++---- examples/step-44/step-44.cc | 6 +++--- examples/step-45/step-45.cc | 6 ++---- examples/step-46/doc/intro.dox | 2 +- examples/step-55/step-55.cc | 9 ++++----- examples/step-56/step-56.cc | 9 ++++----- examples/step-57/step-57.cc | 6 ++---- 13 files changed, 37 insertions(+), 50 deletions(-) diff --git a/examples/doxygen/block_dynamic_sparsity_pattern.cc b/examples/doxygen/block_dynamic_sparsity_pattern.cc index 9b9b76653a..b82fcdff20 100644 --- a/examples/doxygen/block_dynamic_sparsity_pattern.cc +++ b/examples/doxygen/block_dynamic_sparsity_pattern.cc @@ -53,8 +53,8 @@ int main() DoFTools::make_hanging_node_constraints(dof, constraints); constraints.close(); - std::vector dofs_per_block(fe.n_blocks()); - DoFTools::count_dofs_per_block(dof, dofs_per_block); + const std::vector dofs_per_block = + DoFTools::count_dofs_per_fe_block(dof); BlockDynamicSparsityPattern dsp(fe.n_blocks(), fe.n_blocks()); for (unsigned int i = 0; i < fe.n_blocks(); ++i) diff --git a/examples/step-20/step-20.cc b/examples/step-20/step-20.cc index 98d412490b..4447d85ca0 100644 --- a/examples/step-20/step-20.cc +++ b/examples/step-20/step-20.cc @@ -341,11 +341,11 @@ namespace Step20 // The next thing is that we want to figure out the sizes of these blocks // so that we can allocate an appropriate amount of space. To this end, we - // call the DoFTools::count_dofs_per_component() function that + // call the DoFTools::count_dofs_per_fe_component() function that // counts how many shape functions are non-zero for a particular vector // component. We have dim+1 vector components, and - // DoFTools::count_dofs_per_component() will count how many shape functions - // belong to each of these components. + // DoFTools::count_dofs_per_fe_component() will count how many shape + // functions belong to each of these components. // // There is one problem here. As described in the documentation of that // function, it wants to put the number of $x$-velocity shape @@ -369,13 +369,13 @@ namespace Step20 // the vector and matrix block sizes, as well as create output. // // @note If you find this concept difficult to understand, you may - // want to consider using the function DoFTools::count_dofs_per_block() + // want to consider using the function DoFTools::count_dofs_per_fe_block() // instead, as we do in the corresponding piece of code in step-22. // You might also want to read up on the difference between // @ref GlossBlock "blocks" and @ref GlossComponent "components" // in the glossary. - std::vector dofs_per_component(dim + 1); - DoFTools::count_dofs_per_component(dof_handler, dofs_per_component); + const std::vector dofs_per_component = + DoFTools::count_dofs_per_fe_component(dof_handler); const unsigned int n_u = dofs_per_component[0], n_p = dofs_per_component[dim]; diff --git a/examples/step-21/step-21.cc b/examples/step-21/step-21.cc index 4104101f0e..9a188bbeeb 100644 --- a/examples/step-21/step-21.cc +++ b/examples/step-21/step-21.cc @@ -534,8 +534,8 @@ namespace Step21 dof_handler.distribute_dofs(fe); DoFRenumbering::component_wise(dof_handler); - std::vector dofs_per_component(dim + 2); - DoFTools::count_dofs_per_component(dof_handler, dofs_per_component); + const std::vector dofs_per_component = + DoFTools::count_dofs_per_fe_component(dof_handler); const unsigned int n_u = dofs_per_component[0], n_p = dofs_per_component[dim], n_s = dofs_per_component[dim + 1]; diff --git a/examples/step-22/step-22.cc b/examples/step-22/step-22.cc index e49db80492..93551f5812 100644 --- a/examples/step-22/step-22.cc +++ b/examples/step-22/step-22.cc @@ -492,13 +492,11 @@ namespace Step22 // In analogy to step-20, we count the dofs in the individual components. // We could do this in the same way as there, but we want to operate on // the block structure we used already for the renumbering: The function - // DoFTools::count_dofs_per_block does the same as - // DoFTools::count_dofs_per_component, but now grouped as + // DoFTools::count_dofs_per_fe_block does the same as + // DoFTools::count_dofs_per_fe_component, but now grouped as // velocity and pressure block via block_component. - std::vector dofs_per_block(2); - DoFTools::count_dofs_per_block(dof_handler, - dofs_per_block, - block_component); + const std::vector dofs_per_block = + DoFTools::count_dofs_per_fe_block(dof_handler, block_component); const unsigned int n_u = dofs_per_block[0]; const unsigned int n_p = dofs_per_block[1]; diff --git a/examples/step-31/step-31.cc b/examples/step-31/step-31.cc index a36fdd2709..03226e91de 100644 --- a/examples/step-31/step-31.cc +++ b/examples/step-31/step-31.cc @@ -866,10 +866,8 @@ namespace Step31 temperature_constraints.close(); } - std::vector stokes_dofs_per_block(2); - DoFTools::count_dofs_per_block(stokes_dof_handler, - stokes_dofs_per_block, - stokes_sub_blocks); + const std::vector stokes_dofs_per_block = + DoFTools::count_dofs_per_fe_block(stokes_dof_handler, stokes_sub_blocks); const unsigned int n_u = stokes_dofs_per_block[0], n_p = stokes_dofs_per_block[1], diff --git a/examples/step-32/step-32.cc b/examples/step-32/step-32.cc index 9aef5bbe70..fe04f1040f 100644 --- a/examples/step-32/step-32.cc +++ b/examples/step-32/step-32.cc @@ -1860,10 +1860,8 @@ namespace Step32 temperature_dof_handler.distribute_dofs(temperature_fe); - std::vector stokes_dofs_per_block(2); - DoFTools::count_dofs_per_block(stokes_dof_handler, - stokes_dofs_per_block, - stokes_sub_blocks); + const std::vector stokes_dofs_per_block = + DoFTools::count_dofs_per_fe_block(stokes_dof_handler, stokes_sub_blocks); const unsigned int n_u = stokes_dofs_per_block[0], n_p = stokes_dofs_per_block[1], diff --git a/examples/step-43/step-43.cc b/examples/step-43/step-43.cc index f40725c55a..88ad89c8db 100644 --- a/examples/step-43/step-43.cc +++ b/examples/step-43/step-43.cc @@ -693,10 +693,9 @@ namespace Step43 } - std::vector darcy_dofs_per_block(2); - DoFTools::count_dofs_per_block(darcy_dof_handler, - darcy_dofs_per_block, - darcy_block_component); + const std::vector darcy_dofs_per_block = + DoFTools::count_dofs_per_fe_block(darcy_dof_handler, + darcy_block_component); const unsigned int n_u = darcy_dofs_per_block[0], n_p = darcy_dofs_per_block[1], n_s = saturation_dof_handler.n_dofs(); diff --git a/examples/step-44/step-44.cc b/examples/step-44/step-44.cc index 570365d58b..31eeefcfdf 100644 --- a/examples/step-44/step-44.cc +++ b/examples/step-44/step-44.cc @@ -1509,9 +1509,9 @@ namespace Step44 dof_handler.distribute_dofs(fe); DoFRenumbering::Cuthill_McKee(dof_handler); DoFRenumbering::component_wise(dof_handler, block_component); - DoFTools::count_dofs_per_block(dof_handler, - dofs_per_block, - block_component); + + dofs_per_block = + DoFTools::count_dofs_per_fe_block(dof_handler, block_component); std::cout << "Triangulation:" << "\n\t Number of active cells: " diff --git a/examples/step-45/step-45.cc b/examples/step-45/step-45.cc index 87bb4bc24e..2227da05d9 100644 --- a/examples/step-45/step-45.cc +++ b/examples/step-45/step-45.cc @@ -364,10 +364,8 @@ namespace Step45 block_component[dim] = 1; DoFRenumbering::component_wise(dof_handler, block_component); - std::vector dofs_per_block(2); - DoFTools::count_dofs_per_block(dof_handler, - dofs_per_block, - block_component); + const std::vector dofs_per_block = + DoFTools::count_dofs_per_fe_block(dof_handler, block_component); const unsigned int n_u = dofs_per_block[0], n_p = dofs_per_block[1]; { diff --git a/examples/step-46/doc/intro.dox b/examples/step-46/doc/intro.dox index b77ed76f19..cd2b14e28f 100644 --- a/examples/step-46/doc/intro.dox +++ b/examples/step-46/doc/intro.dox @@ -262,7 +262,7 @@ mapping the problem on to the hp framework makes sense: the same (here, 2*dim+1). This makes all sorts of things possible since a uniform description allows for code re-use. For example, counting degrees of freedom per vector - component (DoFTools::count_dofs_per_component), sorting degrees of + component (DoFTools::count_dofs_per_fe_component), sorting degrees of freedom by component (DoFRenumbering::component_wise), subsequent partitioning of matrices and vectors into blocks and many other functions work as they always did without the need to add special diff --git a/examples/step-55/step-55.cc b/examples/step-55/step-55.cc index c984e78397..4d6362626d 100644 --- a/examples/step-55/step-55.cc +++ b/examples/step-55/step-55.cc @@ -362,12 +362,11 @@ namespace Step55 stokes_sub_blocks[dim] = 1; DoFRenumbering::component_wise(dof_handler, stokes_sub_blocks); - std::vector dofs_per_block(2); - DoFTools::count_dofs_per_block(dof_handler, - dofs_per_block, - stokes_sub_blocks); + const std::vector dofs_per_block = + DoFTools::count_dofs_per_fe_block(dof_handler, stokes_sub_blocks); - const unsigned int n_u = dofs_per_block[0], n_p = dofs_per_block[1]; + const unsigned int n_u = dofs_per_block[0]; + const unsigned int n_p = dofs_per_block[1]; pcout << " Number of degrees of freedom: " << dof_handler.n_dofs() << " (" << n_u << '+' << n_p << ')' << std::endl; diff --git a/examples/step-56/step-56.cc b/examples/step-56/step-56.cc index 3073d1419c..19a9b3ab99 100644 --- a/examples/step-56/step-56.cc +++ b/examples/step-56/step-56.cc @@ -553,11 +553,10 @@ namespace Step56 } } - std::vector dofs_per_block(2); - DoFTools::count_dofs_per_block(dof_handler, - dofs_per_block, - block_component); - const unsigned int n_u = dofs_per_block[0], n_p = dofs_per_block[1]; + const std::vector dofs_per_block = + DoFTools::count_dofs_per_fe_block(dof_handler, block_component); + const unsigned int n_u = dofs_per_block[0]; + const unsigned int n_p = dofs_per_block[1]; { constraints.clear(); diff --git a/examples/step-57/step-57.cc b/examples/step-57/step-57.cc index d46b2e1a85..a8b8911cb4 100644 --- a/examples/step-57/step-57.cc +++ b/examples/step-57/step-57.cc @@ -290,10 +290,8 @@ namespace Step57 block_component[dim] = 1; DoFRenumbering::component_wise(dof_handler, block_component); - dofs_per_block.resize(2); - DoFTools::count_dofs_per_block(dof_handler, - dofs_per_block, - block_component); + dofs_per_block = + DoFTools::count_dofs_per_fe_block(dof_handler, block_component); unsigned int dof_u = dofs_per_block[0]; unsigned int dof_p = dofs_per_block[1]; -- 2.39.5