Discontinuous Galerkin Library
#include "dg/algorithm.h"
Loading...
Searching...
No Matches
multigrid.h
Go to the documentation of this file.
1#pragma once
2
4#include "backend/memory.h"
7#include "blas.h"
8#include "pcg.h"
9#include "chebyshev.h"
10#include "eve.h"
11#include "backend/timer.h"
12#ifdef MPI_VERSION
14#endif
15
16namespace dg
17{
18
21
27template<class Geometry, class Matrix, class Container>
29{
30 using geometry_type = Geometry;
31 using matrix_type = Matrix;
32 using container_type = Container;
35 NestedGrids(): m_stages(0), m_grids(0), m_inter(0), m_project(0){}
44 template<class ...ContainerParams>
45 NestedGrids( const Geometry& grid, const unsigned stages, ContainerParams&& ...ps):
46 m_stages(stages),
47 m_grids( stages),
48 m_x( stages)
49 {
50 if(stages < 1 )
51 throw Error( Message(_ping_)<<" There must be minimum 1 stage in nested Grids construction! You gave " << stages);
52 m_grids[0].reset( grid);
53 //m_grids[0].get().display();
54
55 for(unsigned u=1; u<stages; u++)
56 {
57 m_grids[u] = m_grids[u-1]; // deep copy
58 m_grids[u]->multiplyCellNumbers(0.5, 0.5);
59 //m_grids[u]->display();
60 }
61
62 m_inter.resize( stages-1);
63 m_project.resize( stages-1);
64 for(unsigned u=0; u<stages-1; u++)
65 {
66 // Projecting from one grid to the next is the same as
67 // projecting from the original grid to the coarse grids
68 m_project[u].construct( dg::create::fast_projection(*m_grids[u], 1,
69 2, 2), std::forward<ContainerParams>(ps)...);
70 m_inter[u].construct( dg::create::fast_interpolation(*m_grids[u+1],
71 1, 2, 2), std::forward<ContainerParams>(ps)...);
72 }
73 for( unsigned u=0; u<m_stages; u++)
75 *m_grids[u]), std::forward<ContainerParams>(ps)...);
76 m_w = m_r = m_b = m_x;
77
78 }
79
81 template<class ...Params>
82 void construct( Params&& ...ps)
83 {
84 //construct and swap
85 *this = NestedGrids( std::forward<Params>( ps)...);
86 }
93 template<class ContainerType0>
94 void project( const ContainerType0& src, std::vector<ContainerType0>& out) const
95 {
96 dg::blas1::copy( src, out[0]);
97 for( unsigned u=0; u<m_stages-1; u++)
98 dg::blas2::gemv( m_project[u], out[u], out[u+1]);
99 }
100
106 template<class ContainerType0>
107 std::vector<ContainerType0> project( const ContainerType0& src) const
108 {
109 //use the fact that m_x has the correct sizes from the constructor
110 std::vector<Container> out( m_x);
111 project( src, out);
112 return out;
113
114 }
117 const Container& copyable() const {return m_x[0];}
118
120 unsigned stages()const{return m_stages;}
122 unsigned num_stages()const{return m_stages;}
123
126 const Geometry& grid( unsigned stage) const {
127 return *(m_grids[stage]);
128 }
129
132 const MultiMatrix<Matrix, Container>& interpolation( unsigned stage) const
133 {
134 return m_inter[stage];
135 }
138 const MultiMatrix<Matrix, Container>& projection( unsigned stage) const
139 {
140 return m_project[stage];
141 }
142 Container& x(unsigned stage){ return m_x[stage];}
143 const Container& x(unsigned stage) const{ return m_x[stage];}
144 Container& r(unsigned stage){ return m_r[stage];}
145 const Container& r(unsigned stage) const{ return m_r[stage];}
146 Container& b(unsigned stage){ return m_b[stage];}
147 const Container& b(unsigned stage) const{ return m_b[stage];}
148 Container& w(unsigned stage){ return m_w[stage];}
149 const Container& w(unsigned stage) const{ return m_w[stage];}
150
151 private:
152 unsigned m_stages;
153 std::vector< dg::ClonePtr< Geometry> > m_grids;
154 std::vector< MultiMatrix<Matrix, Container> > m_inter;
155 std::vector< MultiMatrix<Matrix, Container> > m_project;
156 std::vector< Container> m_x, m_r, m_b, m_w;
157};
158
196template<class MatrixType0, class ContainerType0, class ContainerType1, class MatrixType1, class NestedGrids>
198 std::vector<MatrixType0>& ops, ContainerType0& x, const ContainerType1& b,
199 std::vector<MatrixType1>& inverse_ops, NestedGrids& nested_grids)
200{
201 NestedGrids& nested = nested_grids;
202 // compute residual r = b - A x
203 dg::apply(ops[0], x, nested.r(0));
204 dg::blas1::axpby(1., b, -1., nested.r(0));
205 // project residual down to coarse grid
206 dg::blas1::copy( x, nested.x(0));
207 for( unsigned u=0; u<nested.stages()-1; u++)
208 {
209 dg::blas2::gemv( nested.projection(u), nested.r(u), nested.r(u+1));
210 dg::blas2::gemv( nested.projection(u), nested.x(u), nested.x(u+1));
211 // compute FAS right hand side
212 dg::blas2::symv( ops[u+1], nested.x(u+1), nested.b(u+1));
213 dg::blas1::axpby( 1., nested.b(u+1), 1., nested.r(u+1), nested.b(u+1));
214 dg::blas1::copy( nested.x(u+1), nested.w(u+1)); // remember x0
215 }
216
217 //now solve residual equations
218 for( unsigned u=nested.stages()-1; u>0; u--)
219 {
220 try{
221 dg::apply( inverse_ops[u], nested.b(u), nested.x(u));
222 }catch( dg::Error& err){
223 err.append_line( dg::Message(_ping_)<<"ERROR on stage "<<u<<" of nested iterations");
224 throw;
225 }
226 // delta
227 dg::blas1::axpby( 1., nested.x(u), -1., nested.w(u), nested.x(u) );
228 // update x
229 dg::blas2::symv( 1., nested.interpolation(u-1), nested.x(u), 1.,
230 nested.x(u-1));
231 }
232 //update initial guess
233 dg::blas1::copy( nested.x(0), x);
234 try{
235 dg::apply(inverse_ops[0], b, x);
236 }catch( dg::Error& err){
237 err.append_line( dg::Message(_ping_)<<"ERROR on stage 0 of nested iterations");
238 throw;
239 }
240}
241
275template<class NestedGrids, class MatrixType0, class MatrixType1, class MatrixType2>
277 std::vector<MatrixType0>& ops,
278 std::vector<MatrixType1>& inverse_ops_down, //stages -1
279 std::vector<MatrixType2>& inverse_ops_up, //stages
280 NestedGrids& nested_grids, unsigned gamma, unsigned p)
281{
282 NestedGrids& nested = nested_grids;
283 // 1 multigrid cycle beginning on grid p
284 // p < m_stages-1
285 // x[p] READ-write, initial guess on input, solution on output
286 // x[p+1] write only, solution on next stage on output
287 // w[p] untouched, copy of initial guess on current stage
288 // w[p+1] write only, contains delta solution on next stage on output
289 // b[p] READ only, right hand side on current stage
290 // b[p+1] write only new right hand side on next stage
291 // r[p] write only residuum at current stage
292 // r[p+1] write only, residuum on next stage
293
294 // 1. Pre-Smooth times
295 try{
296 dg::apply( inverse_ops_down[p], nested.b(p), nested.x(p));
297 }catch( dg::Error& err){
298 err.append_line( dg::Message(_ping_)<<"ERROR on pre-smoothing stage "<<p<<" of multigrid cycle");
299 throw;
300 }
301 // 2. Residuum
302 dg::apply( ops[p], nested.x(p), nested.r(p));
303 dg::blas1::axpby( 1., nested.b(p), -1., nested.r(p));
304 // 3. Coarsen
305 dg::blas2::symv( nested.projection(p), nested.r(p), nested.r(p+1));
306 dg::blas2::symv( nested.projection(p), nested.x(p), nested.x(p+1));
307 dg::blas2::symv( ops[p+1], nested.x(p+1), nested.b(p+1));
308 dg::blas1::axpby( 1., nested.r(p+1), 1., nested.b(p+1));
309 // 4. Solve or recursive call to get x[p+1] with initial guess 0
310 dg::blas1::copy( nested.x(p+1), nested.w(p+1));
311 if( p+1 == nested.stages()-1)
312 {
313 try{
314 dg::apply( inverse_ops_up[p+1], nested.b(p+1), nested.x(p+1));
315 }catch( dg::Error& err){
316 err.append_line( dg::Message(_ping_)<<"ERROR on stage "<<p+1<<" of multigrid cycle");
317 throw;
318 }
319 }
320 else
321 {
322 //update x[p+1] gamma times
323 for( unsigned u=0; u<gamma; u++)
324 {
325 multigrid_cycle( ops, inverse_ops_down, inverse_ops_up,
326 nested, gamma, p+1);
327 }
328 }
329
330 // 5. Correct
331 dg::blas1::axpby( 1., nested.x(p+1), -1., nested.w(p+1));
332 dg::blas2::symv( 1., nested.interpolation(p), nested.w(p+1), 1., nested.x(p));
333 // 6. Post-Smooth nu2 times
334 try{
335 dg::apply(inverse_ops_up[p], nested.b(p), nested.x(p));
336 }catch( dg::Error& err){
337 err.append_line( dg::Message(_ping_)<<"ERROR on post-smoothing stage "<<p<<" of multigrid cycle");
338 throw;
339 }
340}
341
364template<class MatrixType0, class MatrixType1, class MatrixType2, class NestedGrids, class ContainerType0, class ContainerType1>
366 std::vector<MatrixType0>& ops, ContainerType0& x, const ContainerType1& b,
367 std::vector<MatrixType1>& inverse_ops_down, //stages -1
368 std::vector<MatrixType2>& inverse_ops_up, //stages
369 NestedGrids& nested_grids, unsigned gamma, unsigned mu)
370{
371 NestedGrids& nested = nested_grids;
372 // Like nested iterations, just uses multigrid-cycles instead of solves
373 // compute residual r = b - A x
374 dg::apply(ops[0], x, nested.r(0));
375 dg::blas1::axpby(1., b, -1., nested.r(0));
376 // project residual down to coarse grid
377 dg::blas1::copy( x, nested.x(0));
378 for( unsigned u=0; u<nested.stages()-1; u++)
379 {
380 dg::blas2::gemv( nested.projection(u), nested.r(u), nested.r(u+1));
381 dg::blas2::gemv( nested.projection(u), nested.x(u), nested.x(u+1));
382 // compute FAS right hand side
383 dg::blas2::symv( ops[u+1], nested.x(u+1), nested.b(u+1));
384 dg::blas1::axpby( 1., nested.b(u+1), 1., nested.r(u+1), nested.b(u+1));
385 dg::blas1::copy( nested.x(u+1), nested.w(u+1)); // remember x0
386 }
387
388 //begin on coarsest level and cycle through to highest
389 unsigned s = nested.stages()-1;
390 try{
391 dg::apply( inverse_ops_up[s], nested.b(s), nested.x(s));
392 }catch( dg::Error& err){
393 err.append_line( dg::Message(_ping_)<<"ERROR on stage "<<s<<" of full multigrid");
394 throw;
395 }
396 dg::blas1::axpby( 1., nested.x(s), -1., nested.w(s), nested.x(s) );
397 dg::blas2::symv( 1., nested.interpolation(s-1), nested.x(s), 1.,
398 nested.x(s-1));
399
400 for( int p=nested.stages()-2; p>=1; p--)
401 {
402 for( unsigned u=0; u<mu; u++)
403 multigrid_cycle( ops, inverse_ops_down, inverse_ops_up, nested, gamma, p);
404 dg::blas1::axpby( 1., nested.x(p), -1., nested.w(p), nested.x(p) );
405 dg::blas2::symv( 1., nested.interpolation(p-1), nested.x(p), 1.,
406 nested.x(p-1));
407 }
408 dg::blas1::copy( b, nested.b(0));
409 for( unsigned u=0; u<mu; u++)
410 multigrid_cycle( ops, inverse_ops_down, inverse_ops_up, nested, gamma, 0);
411 dg::blas1::copy( nested.x(0), x);
412}
413
438template<class NestedGrids, class MatrixType0, class MatrixType1, class MatrixType2,
439 class ContainerType0, class ContainerType1, class ContainerType2>
441 std::vector<MatrixType0>& ops,
442 ContainerType0& x, const ContainerType1& b,
443 std::vector<MatrixType1>& inverse_ops_down, //stages -1
444 std::vector<MatrixType2>& inverse_ops_up, //stages
445 NestedGrids& nested_grids,
446 const ContainerType2& weights, double eps, unsigned gamma)
447{
448 //FULL MULTIGRID
449 //full approximation scheme
450 double nrmb = sqrt( blas2::dot( weights, b));
451
452 try{
453 full_multigrid( ops, x, b, inverse_ops_down, inverse_ops_up, nested_grids, gamma, 1);
454 }catch( dg::Error& err){
455 err.append_line( dg::Message(_ping_)<<"ERROR in fmg_solve");
456 throw;
457 }
458
459 dg::apply( ops[0], x, nested_grids.r(0));
460 dg::blas1::axpby( 1., b, -1., nested_grids.r(0));
461 double error = sqrt( blas2::dot(weights,nested_grids.r(0)) );
462
463 while ( error > eps*(nrmb + 1))
464 {
465 //MULTIGRID CYCLES
466 //multigrid_cycle( ops, inverse_ops_down, inverse_ops_up, nested_grids, gamma, 0);
467 //FMG cycles
468 try{
469 full_multigrid( ops, x, b, inverse_ops_down, inverse_ops_up, nested_grids, gamma, 1);
470 }catch( dg::Error& err){
471 err.append_line( dg::Message(_ping_)<<"ERROR in fmg_solve");
472 throw;
473 }
474
475 blas2::symv( ops[0], x, nested_grids.r(0));
476 dg::blas1::axpby( 1., b, -1., nested_grids.r(0));
477 error = sqrt( blas2::dot(weights,nested_grids.r(0)) );
478 //DG_RANK0 std::cout<< "# Relative Residual error is "<<error/(nrmb+1)<<"\n";
479 }
480}
481
482
483
499template< class Geometry, class Matrix, class Container>
501{
502 using geometry_type = Geometry;
503 using matrix_type = Matrix;
504 using container_type = Container;
507 MultigridCG2d() = default;
516 template<class ...ContainerParams>
517 MultigridCG2d( const Geometry& grid, const unsigned stages,
518 ContainerParams&& ... ps):
519 m_nested( grid, stages, std::forward<ContainerParams>(ps)...),
520 m_pcg( stages), m_stages(stages)
521 {
522 for (unsigned u = 0; u < stages; u++)
523 m_pcg[u].construct(m_nested.x(u), m_nested.grid(u).size());
524 }
525
532 template<class ...Params>
533 void construct( Params&& ...ps)
534 {
535 //construct and swap
536 *this = MultigridCG2d( std::forward<Params>( ps)...);
537 }
538
540 template<class ContainerType0>
541 void project( const ContainerType0& src, std::vector<ContainerType0>& out) const
542 {
543 m_nested.project( src, out);
544 }
545
547 template<class ContainerType0>
548 std::vector<ContainerType0> project( const ContainerType0& src) const
549 {
550 return m_nested.project( src);
551 }
553 unsigned stages()const{return m_nested.stages();}
555 unsigned num_stages()const{return m_nested.num_stages();}
556
559 const Geometry& grid( unsigned stage) const {
560 return m_nested.grid(stage);
561 }
562
563
566 unsigned max_iter() const{return m_pcg[0].get_max();}
575 void set_max_iter(unsigned new_max){ m_pcg[0].set_max(new_max);}
583 void set_benchmark( bool benchmark, std::string message = "Nested Iterations"){
584 m_benchmark = benchmark;
585 m_message = message;
586 }
587
590 const Container& copyable() const {return m_nested.copyable();}
617 template<class MatrixType, class ContainerType0, class ContainerType1>
618 std::vector<unsigned> solve( std::vector<MatrixType>& ops, ContainerType0& x, const ContainerType1& b, value_type eps)
619 {
620 std::vector<value_type> v_eps( m_stages, eps);
621 for( unsigned u=m_stages-1; u>0; u--)
622 v_eps[u] = eps;
623 return solve( ops, x, b, v_eps);
624 }
626 template<class MatrixType, class ContainerType0, class ContainerType1>
627 std::vector<unsigned> solve( std::vector<MatrixType>& ops, ContainerType0& x, const ContainerType1& b, std::vector<value_type> eps)
628 {
629#ifdef MPI_VERSION
630 int rank;
631 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
632#endif //MPI
633 std::vector<unsigned> number(m_stages);
634 std::vector<std::function<void( const ContainerType1&, ContainerType0&)> >
635 multi_inv_pol(m_stages);
636 for(unsigned u=0; u<m_stages; u++)
637 {
638 multi_inv_pol[u] = [&, u, &pcg = m_pcg[u], &pol = ops[u]](
639 const auto& y, auto& x)
640 {
641 dg::Timer t;
642 t.tic();
643 if ( u == 0)
644 number[u] = pcg.solve( pol, x, y, pol.precond(),
645 pol.weights(), eps[u], 1, 1);
646 else
647 number[u] = pcg.solve( pol, x, y, pol.precond(),
648 pol.weights(), eps[u], 1, 10);
649 t.toc();
650 if( m_benchmark)
651 DG_RANK0 std::cout << "# `"<<m_message<<"` stage: " << u << ", iter: " << number[u] << ", took "<<t.diff()<<"s\n";
652 };
653 }
654 nested_iterations( ops, x, b, multi_inv_pol, m_nested);
655
656 return number;
657 }
658
659 private:
661 std::vector< PCG<Container> > m_pcg;
662 unsigned m_stages;
663 bool m_benchmark = true;
664 std::string m_message = "Nested Iterations";
665
666};
668
669}//namespace dg
class intended for the use in throw statements
Definition exceptions.h:83
void append_line(const Message &message)
Appends a newline and a message verbatim to the what string.
Definition exceptions.h:108
small class holding a stringstream
Definition exceptions.h:29
Error classes or the dg library.
#define _ping_
Definition exceptions.h:12
A matrix type for fast interpolations/projections.
DG_DEVICE T zero(T x, Ts ...xs)
This enum can be used in dg::evaluate.
Definition functions.h:19
void copy(const ContainerTypeIn &source, ContainerTypeOut &target)
Definition blas1.h:243
void axpby(value_type alpha, const ContainerType1 &x, value_type1 beta, ContainerType &y)
Definition blas1.h:306
ContainerType construct(const from_ContainerType &from, Params &&... ps)
Generic way to construct an object of ContainerType given a from_ContainerType object and optional ad...
Definition blas1.h:792
void gemv(get_value_type< ContainerType1 > alpha, MatrixType &&M, const ContainerType1 &x, get_value_type< ContainerType1 > beta, ContainerType2 &y)
Alias for blas2::symv ;.
Definition blas2.h:339
auto dot(const ContainerType1 &x, const MatrixType &m, const ContainerType2 &y)
; Binary reproducible general dot product
Definition blas2.h:94
void apply(get_value_type< ContainerType1 > alpha, MatrixType &&M, const ContainerType1 &x, get_value_type< ContainerType1 > beta, ContainerType2 &y)
Alias for dg::blas2::symv ;.
Definition blas2.h:490
void symv(MatrixType &&M, const ContainerType1 &x, ContainerType2 &y)
Definition blas2.h:325
@ forward
forward derivative (cell to the right and current cell)
Definition enums.h:98
@ y
y direction
@ x
x direction
typename TensorTraits< std::decay_t< Vector > >::value_type get_value_type
Definition tensor_traits.h:45
auto evaluate(Functor &&f, const Topology &g)
Evaluate a function on grid coordinates
Definition evaluation.h:74
EllSparseBlockMat< real_type, thrust::host_vector > fast_interpolation(unsigned coord, const aRealTopology< real_type, Nd > &t, unsigned multiplyn, unsigned multiplyNx)
Create interpolation matrix for integer multipliers.
Definition fast_interpolation.h:302
EllSparseBlockMat< real_type, thrust::host_vector > fast_projection(unsigned coord, const aRealTopology< real_type, Nd > &t, unsigned dividen, unsigned divideNx)
Create projecton matrix for integer dividers.
Definition fast_interpolation.h:314
void multigrid_cycle(std::vector< MatrixType0 > &ops, std::vector< MatrixType1 > &inverse_ops_down, std::vector< MatrixType2 > &inverse_ops_up, NestedGrids &nested_grids, unsigned gamma, unsigned p)
EXPERIMENTAL Full approximation multigrid cycle.
Definition multigrid.h:276
void fmg_solve(std::vector< MatrixType0 > &ops, ContainerType0 &x, const ContainerType1 &b, std::vector< MatrixType1 > &inverse_ops_down, std::vector< MatrixType2 > &inverse_ops_up, NestedGrids &nested_grids, const ContainerType2 &weights, double eps, unsigned gamma)
EXPERIMENTAL Full multigrid cycles.
Definition multigrid.h:440
void full_multigrid(std::vector< MatrixType0 > &ops, ContainerType0 &x, const ContainerType1 &b, std::vector< MatrixType1 > &inverse_ops_down, std::vector< MatrixType2 > &inverse_ops_up, NestedGrids &nested_grids, unsigned gamma, unsigned mu)
EXPERIMENTAL One Full multigrid cycle.
Definition multigrid.h:365
void nested_iterations(std::vector< MatrixType0 > &ops, ContainerType0 &x, const ContainerType1 &b, std::vector< MatrixType1 > &inverse_ops, NestedGrids &nested_grids)
Full approximation nested iterations.
Definition multigrid.h:197
Interpolation matrix creation functions.
Useful MPI typedefs and overloads of interpolation and projection.
This is the namespace for all functions and classes defined and used by the discontinuous Galerkin li...
Struct that applies given matrices one after the other.
Definition fast_interpolation.h:37
Solve.
Definition multigrid.h:501
std::vector< unsigned > solve(std::vector< MatrixType > &ops, ContainerType0 &x, const ContainerType1 &b, std::vector< value_type > eps)
Nested iterations.
Definition multigrid.h:627
get_value_type< Container > value_type
Definition multigrid.h:505
std::vector< unsigned > solve(std::vector< MatrixType > &ops, ContainerType0 &x, const ContainerType1 &b, value_type eps)
Nested iterations.
Definition multigrid.h:618
unsigned stages() const
Definition multigrid.h:553
const Container & copyable() const
Return an object of same size as the object used for construction on the finest grid.
Definition multigrid.h:590
void project(const ContainerType0 &src, std::vector< ContainerType0 > &out) const
Project vector to all involved grids.
Definition multigrid.h:541
void construct(Params &&...ps)
Perfect forward parameters to one of the constructors.
Definition multigrid.h:533
MultigridCG2d(const Geometry &grid, const unsigned stages, ContainerParams &&... ps)
Construct the grids and the interpolation/projection operators.
Definition multigrid.h:517
const Geometry & grid(unsigned stage) const
return the grid at given stage
Definition multigrid.h:559
Geometry geometry_type
Definition multigrid.h:502
void set_max_iter(unsigned new_max)
Set the maximum number of iterations allowed at stage 0.
Definition multigrid.h:575
MultigridCG2d()=default
Allocate nothing, Call construct method before usage.
unsigned max_iter() const
Definition multigrid.h:566
void set_benchmark(bool benchmark, std::string message="Nested Iterations")
Set or unset performance timings during iterations.
Definition multigrid.h:583
std::vector< ContainerType0 > project(const ContainerType0 &src) const
Project vector to all involved grids (allocate memory version)
Definition multigrid.h:548
unsigned num_stages() const
Definition multigrid.h:555
Container container_type
Definition multigrid.h:504
Matrix matrix_type
Definition multigrid.h:503
Hold nested grids and provide dg fast interpolation and projection matrices.
Definition multigrid.h:29
const Container & w(unsigned stage) const
Definition multigrid.h:149
const Container & copyable() const
Return an object of same size as the object used for construction on the finest grid.
Definition multigrid.h:117
Container & b(unsigned stage)
Definition multigrid.h:146
const Container & b(unsigned stage) const
Definition multigrid.h:147
const MultiMatrix< Matrix, Container > & interpolation(unsigned stage) const
return the interpolation matrix at given stage
Definition multigrid.h:132
Container container_type
Definition multigrid.h:32
void project(const ContainerType0 &src, std::vector< ContainerType0 > &out) const
Project vector to all involved grids.
Definition multigrid.h:94
const MultiMatrix< Matrix, Container > & projection(unsigned stage) const
return the projection matrix at given stage
Definition multigrid.h:138
void construct(Params &&...ps)
Perfect forward parameters to one of the constructors.
Definition multigrid.h:82
std::vector< ContainerType0 > project(const ContainerType0 &src) const
Project vector to all involved grids (allocate memory version)
Definition multigrid.h:107
NestedGrids()
Allocate nothing, Call construct method before usage.
Definition multigrid.h:35
Container & r(unsigned stage)
Definition multigrid.h:144
const Container & x(unsigned stage) const
Definition multigrid.h:143
unsigned stages() const
Definition multigrid.h:120
Geometry geometry_type
Definition multigrid.h:30
const Container & r(unsigned stage) const
Definition multigrid.h:145
Container & w(unsigned stage)
Definition multigrid.h:148
const Geometry & grid(unsigned stage) const
return the grid at given stage
Definition multigrid.h:126
unsigned num_stages() const
Definition multigrid.h:122
NestedGrids(const Geometry &grid, const unsigned stages, ContainerParams &&...ps)
Construct the grids and the interpolation/projection operators.
Definition multigrid.h:45
Container & x(unsigned stage)
Definition multigrid.h:142
get_value_type< Container > value_type
Definition multigrid.h:33
Matrix matrix_type
Definition multigrid.h:31
Simple tool for performance measuring.
Definition dg_doc.h:352
double diff() const
Return time in seconds elapsed between tic and toc.
void toc()
Stop timer.
void tic()
Start timer.
#define DG_RANK0
Definition typedefs.h:146