From 4ec447e17e50f6ba7eaeea96050b4d2dd78d93c1 Mon Sep 17 00:00:00 2001 From: guido Date: Thu, 17 Apr 2003 09:24:09 +0000 Subject: [PATCH] returned vectors replaced by return arguments I git-svn-id: https://svn.dealii.org/trunk@7406 0785d39b-7218-0410-832d-ea1e28bc413d --- .../include/numerics/dof_renumbering.h | 15 ++-- .../deal.II/source/dofs/dof_renumbering.cc | 75 +++++++++++-------- 2 files changed, 51 insertions(+), 39 deletions(-) diff --git a/deal.II/deal.II/include/numerics/dof_renumbering.h b/deal.II/deal.II/include/numerics/dof_renumbering.h index bbc8d57e6f..344bdaae36 100644 --- a/deal.II/deal.II/include/numerics/dof_renumbering.h +++ b/deal.II/deal.II/include/numerics/dof_renumbering.h @@ -325,8 +325,9 @@ class DoFRenumbering * vector. */ template - static std::vector - compute_component_wise (DoFHandler &dof_handler, + static void + compute_component_wise (std::vector& new_index, + const DoFHandler& dof_handler, const std::vector &component_order = std::vector()); /** @@ -378,8 +379,9 @@ class DoFRenumbering * vector. */ template - static std::vector - compute_cell_wise_dg (DoFHandler &dof_handler, + static void + compute_cell_wise_dg (std::vector&, + const DoFHandler &dof_handler, const std::vector::cell_iterator> &cell_order); /** @@ -438,8 +440,9 @@ class DoFRenumbering * vector. */ template - static std::vector - compute_downstream_dg (DoFHandler &dof_handler, + static void + compute_downstream_dg (std::vector&, + const DoFHandler &dof_handler, const Point &direction); /** diff --git a/deal.II/deal.II/source/dofs/dof_renumbering.cc b/deal.II/deal.II/source/dofs/dof_renumbering.cc index e4c79fdce6..cd2393970e 100644 --- a/deal.II/deal.II/source/dofs/dof_renumbering.cc +++ b/deal.II/deal.II/source/dofs/dof_renumbering.cc @@ -451,8 +451,10 @@ void DoFRenumbering::component_wise (DoFHandler &dof_handler, const std::vector &component_order_arg) { - std::vector renumbering - =compute_component_wise(dof_handler, component_order_arg); + std::vector renumbering (dof_handler.n_dofs(), + DoFHandler::invalid_dof_index); + + compute_component_wise(renumbering, dof_handler, component_order_arg); if (renumbering.size()!=0) dof_handler.renumber_dofs (renumbering); @@ -461,22 +463,23 @@ DoFRenumbering::component_wise (DoFHandler &dof_handler, template -std::vector -DoFRenumbering::compute_component_wise (DoFHandler &dof_handler, +void +DoFRenumbering::compute_component_wise (std::vector& new_indices, + const DoFHandler& dof_handler, const std::vector &component_order_arg) { const unsigned int dofs_per_cell = dof_handler.get_fe().dofs_per_cell; const FiniteElement &fe = dof_handler.get_fe(); - std::vector new_indices (dof_handler.n_dofs(), - DoFHandler::invalid_dof_index); + Assert (new_indices.size() == dof_handler.n_dofs(), + ExcDimensionMismatch(new_indices.size(), dof_handler.n_dofs())); // do nothing if the FE has only // one component if (fe.n_components() == 1) { new_indices.resize(0); - return new_indices; + return; } std::vector component_order (component_order_arg); @@ -610,8 +613,6 @@ DoFRenumbering::compute_component_wise (DoFHandler &dof_han Assert (next_free_index == dof_handler.n_dofs(), ExcInternalError()); - - return new_indices; } @@ -823,8 +824,8 @@ DoFRenumbering::cell_wise_dg ( DoFHandler& dof, const typename std::vector::cell_iterator>& cells) { - std::vector renumbering - =compute_cell_wise_dg(dof, cells); + std::vector renumbering(dof.n_dofs()); + compute_cell_wise_dg(renumbering, dof, cells); dof.renumber_dofs(renumbering); } @@ -832,9 +833,10 @@ DoFRenumbering::cell_wise_dg ( template -std::vector +void DoFRenumbering::compute_cell_wise_dg ( - DoFHandler& dof, + std::vector& new_indices, + const DoFHandler& dof, const typename std::vector::cell_iterator>& cells) { Assert(cells.size() == dof.get_tria().n_active_cells(), @@ -856,7 +858,13 @@ DoFRenumbering::compute_cell_wise_dg ( unsigned int n_global_dofs = dof.n_dofs(); unsigned int n_cell_dofs = dof.get_fe().n_dofs_per_cell(); - std::vector new_order(n_global_dofs); + // Actually, we compute the inverse of the reordering vector, called reverse here. + // Later, irs inverse is computed into new_indices, which is the return argument. + + Assert(new_indices.size() == n_global_dofs, + ExcDimensionMismatch(new_indices.size(), n_global_dofs)); + std::vector reverse(new_indices.size()); + std::vector cell_dofs(n_cell_dofs); unsigned int global_index = 0; @@ -875,17 +883,13 @@ DoFRenumbering::compute_cell_wise_dg ( for (unsigned int i=0;i reverse(new_order.size()); - - for (unsigned int i=0;i& dof, const Point& direction) { - std::vector renumbering - =compute_downstream_dg(dof, direction); + std::vector renumbering(dof.n_dofs()); + compute_downstream_dg(renumbering, dof, direction); dof.renumber_dofs(renumbering); } @@ -989,9 +993,11 @@ DoFRenumbering::downstream_dg (DoFHandler& dof, template -std::vector -DoFRenumbering::compute_downstream_dg (DoFHandler& dof, - const Point& direction) +void +DoFRenumbering::compute_downstream_dg ( + std::vector& renumbering, + const DoFHandler& dof, + const Point& direction) { std::vector::cell_iterator> ordered_cells(dof.get_tria().n_active_cells()); @@ -1003,7 +1009,7 @@ DoFRenumbering::compute_downstream_dg (DoFHandler& dof, copy (begin, end, ordered_cells.begin()); sort (ordered_cells.begin(), ordered_cells.end(), comparator); - return compute_cell_wise_dg(dof, ordered_cells); + compute_cell_wise_dg(renumbering, dof, ordered_cells); } @@ -1079,9 +1085,10 @@ void DoFRenumbering::component_wise const std::vector&); template -std::vector +void DoFRenumbering::compute_component_wise -(DoFHandler&, +(std::vector&, + const DoFHandler&, const std::vector&); template @@ -1098,9 +1105,10 @@ DoFRenumbering::cell_wise_dg const std::vector::cell_iterator>&); template -std::vector +void DoFRenumbering::compute_cell_wise_dg -(DoFHandler&, +(std::vector&, + const DoFHandler&, const std::vector::cell_iterator>&); template @@ -1110,9 +1118,10 @@ DoFRenumbering::downstream_dg const Point&); template -std::vector +void DoFRenumbering::compute_downstream_dg -(DoFHandler&, +(std::vector&, + const DoFHandler&, const Point&); template -- 2.39.5