transfer.restrict_and_add(1,u0,u1);
deallog << "u1\t" << (u1*u1+.5) << std::endl
<< "u0\t" << (u0*u0+.5) << std::endl;
+
+ // Fill a global vector by counting
+ // from one up
+ Vector<double> u;
+ u.reinit (mgdof.n_dofs());
+ for (unsigned int i=0;i<u.size();++i)
+ u(i) = i+1;
+
+ // See what part gets copied to mg
+ MGLevelObject<Vector<double> > v;
+ v.resize(2,2);
+ v[2].reinit(mgdof.n_dofs(2));
+
+ transfer.copy_to_mg(mgdof, v, u);
+ for (unsigned int i=0; i<v[2].size();++i)
+ deallog << ' ' << (int) v[2](i);
+ deallog << std::endl;
+
+ // Now do the opposite: fill a
+ // multigrid vector counting the
+ // dofs and see where the numbers go
+ u = 0.;
+ for (unsigned int i=0;i<v[2].size();++i)
+ v[2](i) = i+1;
+ transfer.copy_from_mg(mgdof, u, v);
+ for (unsigned int i=0; i<u.size();++i)
+ deallog << ' ' << (int) u(i);
+ deallog << std::endl;
}
if (factors.size()>0)
transfer.initialize(factors, mem);
- BlockVector<double> u2(mg_ndofs[2]);
- BlockVector<double> u1(mg_ndofs[1]);
- BlockVector<double> u0(mg_ndofs[0]);
+ MGLevelObject< BlockVector<double> > u(0, tr.n_levels()-1);
+
+ MGTools::reinit_vector_by_blocks(mgdof, u, selected, mg_ndofs);
// Prolongate a constant function
// twice
- u0 = 1;
- transfer.prolongate(1,u1,u0);
- transfer.prolongate(2,u2,u1);
+ u[0] = 1;
+ transfer.prolongate(1,u[1],u[0]);
+ transfer.prolongate(2,u[2],u[1]);
// These outputs are just the
// number of dofs on each level
deallog << "u0";
- for (unsigned int b=0;b<u0.n_blocks();++b)
- deallog << '\t' << (int) (u0.block(b)*u0.block(b)+.4);
+ for (unsigned int b=0;b<u[0].n_blocks();++b)
+ deallog << '\t' << (int) (u[0].block(b)*u[0].block(b)+.4);
deallog << std::endl << "u1";
- for (unsigned int b=0;b<u1.n_blocks();++b)
- deallog << '\t' << (int) (u1.block(b)*u1.block(b)+.4);
+ for (unsigned int b=0;b<u[1].n_blocks();++b)
+ deallog << '\t' << (int) (u[1].block(b)*u[1].block(b)+.4);
deallog << std::endl << "u2";
- for (unsigned int b=0;b<u2.n_blocks();++b)
- deallog << '\t' << (int) (u2.block(b)*u2.block(b)+.4);
+ for (unsigned int b=0;b<u[2].n_blocks();++b)
+ deallog << '\t' << (int) (u[2].block(b)*u[2].block(b)+.4);
deallog << std::endl;
- u1 = 0.;
- u0 = 0.;
- transfer.restrict_and_add(2,u1,u2);
- transfer.restrict_and_add(1,u0,u1);
+ u[1] = 0.;
+ u[0] = 0.;
+ transfer.restrict_and_add(2,u[1],u[2]);
+ transfer.restrict_and_add(1,u[0],u[1]);
// After adding the restrictions,
// things get bigger.
deallog << "u1";
- for (unsigned int b=0;b<u1.n_blocks();++b)
- deallog << '\t' << (int) (u1.block(b)*u1.block(b)+.5);
+ for (unsigned int b=0;b<u[1].n_blocks();++b)
+ deallog << '\t' << (int) (u[1].block(b)*u[1].block(b)+.5);
deallog << std::endl << "u0";
- for (unsigned int b=0;b<u0.n_blocks();++b)
- deallog << '\t' << (int) (u0.block(b)*u0.block(b)+.5);
+ for (unsigned int b=0;b<u[0].n_blocks();++b)
+ deallog << '\t' << (int) (u[0].block(b)*u[0].block(b)+.5);
deallog << std::endl;
// Check copy to mg and back
- BlockVector<double> u;
- u.reinit (ndofs);
- for (unsigned int i=0;i<u.size();++i)
- u(i) = i+1;
-
- std::vector<std::vector<unsigned int> > cached_sizes;
- MGLevelObject<BlockVector<double> > v;
- v.resize(0, tr.n_levels()-1);
- MGTools::reinit_vector_by_blocks(mgdof, v, selected, cached_sizes);
+ BlockVector<double> v;
+ v.reinit (ndofs);
+ for (unsigned int i=0;i<v.size();++i)
+ v(i) = i+1;
- transfer.copy_to_mg(mgdof, v, u);
- for (unsigned int i=0; i<v[2].size();++i)
- deallog << ' ' << (int) v[2](i);
+ u.resize(0, tr.n_levels()-1);
+ MGTools::reinit_vector_by_blocks(mgdof, u, selected, mg_ndofs);
+
+ transfer.copy_to_mg(mgdof, u, v);
+ for (unsigned int i=0; i<u[2].size();++i)
+ deallog << ' ' << (int) u[2](i);
deallog << std::endl;
// Now do the opposite: fill a
// multigrid vector counting the
// dofs and see where the numbers go
- u = 0.;
- for (unsigned int i=0;i<v[2].size();++i)
- v[2](i) = i+1;
- transfer.copy_from_mg_add(mgdof, u, v);
- for (unsigned int i=0; i<u.size();++i)
- deallog << ' ' << (int) u(i);
+ for (unsigned int i=0;i<u[2].size();++i)
+ u[2](i) = i+1;
+ v = 0.;
+ transfer.copy_from_mg(mgdof, v, u);
+ for (unsigned int i=0; i<v.size();++i)
+ deallog << ' ' << (int) v(i);
deallog << std::endl;
-
+ v.equ(-1., v);
+ transfer.copy_from_mg_add(mgdof, v, u);
+ deallog << "diff " << v.l2_norm() << std::endl;
}
DEAL::u0 2214 1024
DEAL:: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
DEAL:: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
+DEAL::diff 0
DEAL::Velocity
DEAL::FESystem<2>[FE_RaviartThomasNodal<2>(1)-FE_DGQ<2>(1)]
DEAL::selected 0
DEAL::Level 0 dofs: 12 4
DEAL::Level 1 dofs: 40 16
DEAL::Level 2 dofs: 144 64
-DEAL::u0 12 4
-DEAL::u1 40 0
-DEAL::u2 144 0
-DEAL::u1 572 0
-DEAL::u0 2214 0
+DEAL::u0 12
+DEAL::u1 40
+DEAL::u2 144
+DEAL::u1 572
+DEAL::u0 2214
DEAL:: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
DEAL:: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+DEAL::diff 0
DEAL::Pressure
DEAL::FESystem<2>[FE_RaviartThomasNodal<2>(1)-FE_DGQ<2>(1)]
DEAL::selected 1
DEAL::Level 0 dofs: 12 4
DEAL::Level 1 dofs: 40 16
DEAL::Level 2 dofs: 144 64
-DEAL::u0 12 4
-DEAL::u1 0 16
-DEAL::u2 0 64
-DEAL::u1 0 256
-DEAL::u0 0 1024
+DEAL::u0 4
+DEAL::u1 16
+DEAL::u2 64
+DEAL::u1 256
+DEAL::u0 1024
DEAL:: 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
DEAL:: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
+DEAL::diff 0
DEAL::FESystem<2>[FE_RaviartThomasNodal<2>(0)^2-FE_DGQ<2>(0)^2]
DEAL::selected 1 3
DEAL::Global dofs: 40 40 16 16
DEAL::Level 0 dofs: 4 4 1 1
DEAL::Level 1 dofs: 12 12 4 4
DEAL::Level 2 dofs: 40 40 16 16
-DEAL::u0 4 4 1 1
-DEAL::u1 0 12 0 4
-DEAL::u2 0 40 0 16
-DEAL::u1 0 136 0 64
-DEAL::u0 0 400 0 256
+DEAL::u0 4 1
+DEAL::u1 12 4
+DEAL::u2 40 16
+DEAL::u1 136 64
+DEAL::u0 400 256
DEAL:: 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
DEAL:: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
+DEAL::diff 0
// See what part gets copied to mg
MGLevelObject<Vector<double> > v;
- v.resize(2,2);
- v[2].reinit(mg_ndofs[2][selected]);
-
+ v.resize(0,tr.n_levels()-1);
+ MGTools::reinit_vector_by_blocks(mgdof, v, selected, mg_ndofs);
+
transfer.copy_to_mg(mgdof, v, u);
for (unsigned int i=0; i<v[2].size();++i)
deallog << ' ' << (int) v[2](i);
std::vector<std::vector<unsigned int> > cached_sizes;
MGLevelObject<BlockVector<double> > v;
- MGLevelObject<BlockVector<double> > w;
+ MGLevelObject<BlockVector<double> > wb;
+ MGLevelObject<Vector<double> > ws;
v.resize(0, tr.n_levels()-1);
- w.resize(0, tr.n_levels()-1);
+ wb.resize(0, tr.n_levels()-1);
+ ws.resize(0, tr.n_levels()-1);
MGTools::reinit_vector_by_blocks(mgdof, v, selected, cached_sizes);
- MGTools::reinit_vector_by_blocks(mgdof, w, selected, cached_sizes);
+ MGTools::reinit_vector_by_blocks(mgdof, wb, selected, cached_sizes);
+ MGTools::reinit_vector_by_blocks(mgdof, ws, 0, cached_sizes);
deallog << "copy to mg";
transfer.copy_to_mg(mgdof, v, u);
- transfer_block.copy_to_mg(mgdof, w, u);
-
+ transfer_block.copy_to_mg(mgdof, wb, u);
+ transfer_select.copy_to_mg(mgdof, ws, u);
+
for (unsigned int l=0; l<tr.n_levels();++l)
{
- w[l].add(-1., v[l]);
- deallog << ' ' << w[l].l2_norm();
+ wb[l].add(-1., v[l]);
+ ws[l].add(-1., v[l].block(0));
+ deallog << ' ' << wb[l].l2_norm();
+ deallog << ' ' << ws[l].l2_norm();
}
deallog << std::endl << "copy from mg ";
// Now do the opposite: fill a
for (unsigned int i=0;i<v[2].size();++i)
{
v[2](i) = i+1;
- w[2](i) = i+1;
+ wb[2](i) = i+1;
}
-
+ for (unsigned int i=0;i<ws[2].size();++i)
+ ws[2](i) = i+1;
BlockVector<double> uu;
uu.reinit(u);
transfer.copy_from_mg_add(mgdof, u, v);
transfer_block.copy_from_mg_add(mgdof, uu, v);
- u.print(std::cout, 0, false);
- uu.print(std::cout, 0, false);
u.add(-1., uu);
deallog << u.l2_norm() << std::endl;