From 4c1bafe20c217fc6a248d6c31639c19810feeb5d Mon Sep 17 00:00:00 2001 From: wolf Date: Wed, 22 Oct 2003 22:49:41 +0000 Subject: [PATCH] Fix one bug in SolutionTransfer in which we first computed the size of the output vector and then resized it. git-svn-id: https://svn.dealii.org/trunk@8133 0785d39b-7218-0410-832d-ea1e28bc413d --- .../deal.II/include/numerics/solution_transfer.h | 6 ++++++ .../deal.II/source/numerics/solution_transfer.cc | 15 +++++++-------- deal.II/doc/news/c-4-0.html | 11 +++++++++++ .../bits/solution_transfer_1.output | 2 ++ .../bits/solution_transfer_1.output | 2 ++ .../bits/solution_transfer_1.output | 2 ++ 6 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 tests/results/i686-pc-linux-gnu+gcc2.95/bits/solution_transfer_1.output create mode 100644 tests/results/i686-pc-linux-gnu+gcc3.2/bits/solution_transfer_1.output create mode 100644 tests/results/sparc-sun-solaris2.7+gcc2.95/bits/solution_transfer_1.output diff --git a/deal.II/deal.II/include/numerics/solution_transfer.h b/deal.II/deal.II/include/numerics/solution_transfer.h index 762c3eb9ba..2d43a7c169 100644 --- a/deal.II/deal.II/include/numerics/solution_transfer.h +++ b/deal.II/deal.II/include/numerics/solution_transfer.h @@ -266,6 +266,12 @@ class SolutionTransfer * NOT allowed. Interpolating * several functions can be * performed in one step. + * + * If the number of output + * vectors is different from the + * number of input vectors, or if + * their sizes are not correct, + * then this is corrected. */ void interpolate (const std::vector >&all_in, std::vector > &all_out) const; diff --git a/deal.II/deal.II/source/numerics/solution_transfer.cc b/deal.II/deal.II/source/numerics/solution_transfer.cc index 0ee34b14fb..99b15d2f9a 100644 --- a/deal.II/deal.II/source/numerics/solution_transfer.cc +++ b/deal.II/deal.II/source/numerics/solution_transfer.cc @@ -287,13 +287,12 @@ interpolate (const std::vector > &all_in, ExcWrongVectorSize(all_in[i].size(), n_dofs_old)); - const unsigned int out_size=all_out.size(); - const unsigned int in_size=all_in.size(); + const unsigned int in_size = all_in.size(); - // resize the output vector - if (out_size != in_size) - all_out=std::vector >( - in_size, Vector(dof_handler->n_dofs())); + // resize the output vector if + // necessary + if (all_out.size() != in_size) + all_out.resize (in_size, Vector(dof_handler->n_dofs())); else for (unsigned int i=0; in_dofs()) @@ -336,7 +335,7 @@ interpolate (const std::vector > &all_in, // data vectors on this // cell and prolong it // to its children - for (unsigned int j=0; joperator[](i)); @@ -359,7 +358,7 @@ interpolate (const std::vector > &all_in, // distribute the // stored data to the // new vectors - for (unsigned int j=0; joperator[](j)(i); } diff --git a/deal.II/doc/news/c-4-0.html b/deal.II/doc/news/c-4-0.html index ef24f87578..bf5916b4be 100644 --- a/deal.II/doc/news/c-4-0.html +++ b/deal.II/doc/news/c-4-0.html @@ -256,6 +256,17 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK

deal.II

    +
  1. + Fixed: The SolutionTransfer::interpolate + function did not compute all output vectors if the number of + output vectors was different from the number of output + vectors. This was due to the fact that it stored the number of + output vectors before resizing that array. This is now fixed. +
    + (Brent Bailey, WB 2003/10/22) +

    +
  2. Fixed: The FEFaceValuesBase::boundary_form diff --git a/tests/results/i686-pc-linux-gnu+gcc2.95/bits/solution_transfer_1.output b/tests/results/i686-pc-linux-gnu+gcc2.95/bits/solution_transfer_1.output new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/results/i686-pc-linux-gnu+gcc2.95/bits/solution_transfer_1.output @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/results/i686-pc-linux-gnu+gcc3.2/bits/solution_transfer_1.output b/tests/results/i686-pc-linux-gnu+gcc3.2/bits/solution_transfer_1.output new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/results/i686-pc-linux-gnu+gcc3.2/bits/solution_transfer_1.output @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/results/sparc-sun-solaris2.7+gcc2.95/bits/solution_transfer_1.output b/tests/results/sparc-sun-solaris2.7+gcc2.95/bits/solution_transfer_1.output new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/results/sparc-sun-solaris2.7+gcc2.95/bits/solution_transfer_1.output @@ -0,0 +1,2 @@ + +DEAL::OK -- 2.39.5