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 "backend/timer.h"
11#ifdef MPI_VERSION
13#endif
14
15namespace dg
16{
17
20
28template<class Geometry, class Matrix, class Container>
30{
31 using geometry_type = Geometry;
33 using container_type = Container; // MultiMatrix<Matrix, Container>
34 using value_type = typename Geometry::value_type;
36 NestedGrids(): m_stages(0), m_grids(0), m_inter(0), m_project(0){}
45 template<class ...ContainerParams>
46 NestedGrids( const Geometry& grid, const unsigned stages, ContainerParams&& ...ps):
47 m_stages(stages),
48 m_grids( stages),
49 m_x( stages)
50 {
51 if(stages < 1 )
52 throw Error( Message(_ping_)<<" There must be minimum 1 stage in nested Grids construction! You gave " << stages);
53 m_grids[0].reset( grid);
54 //m_grids[0].get().display();
55
56 for(unsigned u=1; u<stages; u++)
57 {
58 m_grids[u] = m_grids[u-1]; // deep copy
59 m_grids[u]->multiplyCellNumbers(0.5, 0.5);
60 //m_grids[u]->display();
61 }
62
63 m_inter.resize( stages-1);
64 m_project.resize( stages-1);
65 for(unsigned u=0; u<stages-1; u++)
66 {
67 // Projecting from one grid to the next is the same as
68 // projecting from the original grid to the coarse grids
69 m_project[u].construct( dg::create::fast_projection(*m_grids[u], 1,
70 2, 2), std::forward<ContainerParams>(ps)...);
71 m_inter[u].construct( dg::create::fast_interpolation(*m_grids[u+1],
72 1, 2, 2), std::forward<ContainerParams>(ps)...);
73 }
74 for( unsigned u=0; u<m_stages; u++)
76 *m_grids[u]), std::forward<ContainerParams>(ps)...);
77 m_w = m_r = m_b = m_x;
78
79 }
80
82 template<class ...Params>
83 void construct( Params&& ...ps)
84 {
85 //construct and swap
86 *this = NestedGrids( std::forward<Params>( ps)...);
87 }
94 template<class ContainerType0>
95 void project( const ContainerType0& src, std::vector<ContainerType0>& out) const
96 {
97 dg::blas1::copy( src, out[0]);
98 for( unsigned u=0; u<m_stages-1; u++)
99 dg::blas2::gemv( m_project[u], out[u], out[u+1]);
100 }
101
107 template<class ContainerType0>
108 std::vector<ContainerType0> project( const ContainerType0& src) const
109 {
110 //use the fact that m_x has the correct sizes from the constructor
111 std::vector<Container> out( m_x);
112 project( src, out);
113 return out;
114
115 }
118 const Container& copyable() const {return m_x[0];}
119
121 unsigned stages()const{return m_stages;}
123 unsigned num_stages()const{return m_stages;}
124
127 const Geometry& grid( unsigned stage) const {
128 return *(m_grids[stage]);
129 }
130
133 const MultiMatrix<Matrix, Container>& interpolation( unsigned stage) const
134 {
135 return m_inter[stage];
136 }
139 const MultiMatrix<Matrix, Container>& projection( unsigned stage) const
140 {
141 return m_project[stage];
142 }
143 Container& x(unsigned stage){ return m_x[stage];}
144 const Container& x(unsigned stage) const{ return m_x[stage];}
145 Container& r(unsigned stage){ return m_r[stage];}
146 const Container& r(unsigned stage) const{ return m_r[stage];}
147 Container& b(unsigned stage){ return m_b[stage];}
148 const Container& b(unsigned stage) const{ return m_b[stage];}
149 Container& w(unsigned stage){ return m_w[stage];}
150 const Container& w(unsigned stage) const{ return m_w[stage];}
151
152 private:
153 unsigned m_stages;
154 std::vector< dg::ClonePtr< Geometry> > m_grids;
155 std::vector< MultiMatrix<Matrix, Container> > m_inter;
156 std::vector< MultiMatrix<Matrix, Container> > m_project;
157 std::vector< Container> m_x, m_r, m_b, m_w;
158};
159
197template<class MatrixType0, class ContainerType0, class ContainerType1, class MatrixType1, class NestedGrids>
199 std::vector<MatrixType0>& ops, ContainerType0& x, const ContainerType1& b,
200 std::vector<MatrixType1>& inverse_ops, NestedGrids& nested_grids)
201{
202 NestedGrids& nested = nested_grids;
203 // compute residual r = b - A x
204 dg::apply(ops[0], x, nested.r(0));
205 dg::blas1::axpby(1., b, -1., nested.r(0));
206 // project residual down to coarse grid
207 dg::blas1::copy( x, nested.x(0));
208 for( unsigned u=0; u<nested.stages()-1; u++)
209 {
210 dg::blas2::gemv( nested.projection(u), nested.r(u), nested.r(u+1));
211 dg::blas2::gemv( nested.projection(u), nested.x(u), nested.x(u+1));
212 // compute FAS right hand side
213 dg::blas2::symv( ops[u+1], nested.x(u+1), nested.b(u+1));
214 dg::blas1::axpby( 1., nested.b(u+1), 1., nested.r(u+1), nested.b(u+1));
215 dg::blas1::copy( nested.x(u+1), nested.w(u+1)); // remember x0
216 }
217
218 //now solve residual equations
219 for( unsigned u=nested.stages()-1; u>0; u--)
220 {
221 try{
222 dg::apply( inverse_ops[u], nested.b(u), nested.x(u));
223 }catch( dg::Error& err){
224 err.append_line( dg::Message(_ping_)<<"ERROR on stage "<<u<<" of nested iterations");
225 throw;
226 }
227 // delta
228 dg::blas1::axpby( 1., nested.x(u), -1., nested.w(u), nested.x(u) );
229 // update x
230 dg::blas2::symv( 1., nested.interpolation(u-1), nested.x(u), 1.,
231 nested.x(u-1));
232 }
233 //update initial guess
234 dg::blas1::copy( nested.x(0), x);
235 try{
236 dg::apply(inverse_ops[0], b, x);
237 }catch( dg::Error& err){
238 err.append_line( dg::Message(_ping_)<<"ERROR on stage 0 of nested iterations");
239 throw;
240 }
241}
242
276template<class NestedGrids, class MatrixType0, class MatrixType1, class MatrixType2>
278 std::vector<MatrixType0>& ops,
279 std::vector<MatrixType1>& inverse_ops_down, //stages -1
280 std::vector<MatrixType2>& inverse_ops_up, //stages
281 NestedGrids& nested_grids, unsigned gamma, unsigned p)
282{
283 NestedGrids& nested = nested_grids;
284 // 1 multigrid cycle beginning on grid p
285 // p < m_stages-1
286 // x[p] READ-write, initial guess on input, solution on output
287 // x[p+1] write only, solution on next stage on output
288 // w[p] untouched, copy of initial guess on current stage
289 // w[p+1] write only, contains delta solution on next stage on output
290 // b[p] READ only, right hand side on current stage
291 // b[p+1] write only new right hand side on next stage
292 // r[p] write only residuum at current stage
293 // r[p+1] write only, residuum on next stage
294
295 // 1. Pre-Smooth times
296 try{
297 dg::apply( inverse_ops_down[p], nested.b(p), nested.x(p));
298 }catch( dg::Error& err){
299 err.append_line( dg::Message(_ping_)<<"ERROR on pre-smoothing stage "<<p<<" of multigrid cycle");
300 throw;
301 }
302 // 2. Residuum
303 dg::apply( ops[p], nested.x(p), nested.r(p));
304 dg::blas1::axpby( 1., nested.b(p), -1., nested.r(p));
305 // 3. Coarsen
306 dg::blas2::symv( nested.projection(p), nested.r(p), nested.r(p+1));
307 dg::blas2::symv( nested.projection(p), nested.x(p), nested.x(p+1));
308 dg::blas2::symv( ops[p+1], nested.x(p+1), nested.b(p+1));
309 dg::blas1::axpby( 1., nested.r(p+1), 1., nested.b(p+1));
310 // 4. Solve or recursive call to get x[p+1] with initial guess 0
311 dg::blas1::copy( nested.x(p+1), nested.w(p+1));
312 if( p+1 == nested.stages()-1)
313 {
314 try{
315 dg::apply( inverse_ops_up[p+1], nested.b(p+1), nested.x(p+1));
316 }catch( dg::Error& err){
317 err.append_line( dg::Message(_ping_)<<"ERROR on stage "<<p+1<<" of multigrid cycle");
318 throw;
319 }
320 }
321 else
322 {
323 //update x[p+1] gamma times
324 for( unsigned u=0; u<gamma; u++)
325 {
326 multigrid_cycle( ops, inverse_ops_down, inverse_ops_up,
327 nested, gamma, p+1);
328 }
329 }
330
331 // 5. Correct
332 dg::blas1::axpby( 1., nested.x(p+1), -1., nested.w(p+1));
333 dg::blas2::symv( 1., nested.interpolation(p), nested.w(p+1), 1., nested.x(p));
334 // 6. Post-Smooth nu2 times
335 try{
336 dg::apply(inverse_ops_up[p], nested.b(p), nested.x(p));
337 }catch( dg::Error& err){
338 err.append_line( dg::Message(_ping_)<<"ERROR on post-smoothing stage "<<p<<" of multigrid cycle");
339 throw;
340 }
341}
342
365template<class MatrixType0, class MatrixType1, class MatrixType2, class NestedGrids, class ContainerType0, class ContainerType1>
367 std::vector<MatrixType0>& ops, ContainerType0& x, const ContainerType1& b,
368 std::vector<MatrixType1>& inverse_ops_down, //stages -1
369 std::vector<MatrixType2>& inverse_ops_up, //stages
370 NestedGrids& nested_grids, unsigned gamma, unsigned mu)
371{
372 NestedGrids& nested = nested_grids;
373 // Like nested iterations, just uses multigrid-cycles instead of solves
374 // compute residual r = b - A x
375 dg::apply(ops[0], x, nested.r(0));
376 dg::blas1::axpby(1., b, -1., nested.r(0));
377 // project residual down to coarse grid
378 dg::blas1::copy( x, nested.x(0));
379 for( unsigned u=0; u<nested.stages()-1; u++)
380 {
381 dg::blas2::gemv( nested.projection(u), nested.r(u), nested.r(u+1));
382 dg::blas2::gemv( nested.projection(u), nested.x(u), nested.x(u+1));
383 // compute FAS right hand side
384 dg::blas2::symv( ops[u+1], nested.x(u+1), nested.b(u+1));
385 dg::blas1::axpby( 1., nested.b(u+1), 1., nested.r(u+1), nested.b(u+1));
386 dg::blas1::copy( nested.x(u+1), nested.w(u+1)); // remember x0
387 }
388
389 //begin on coarsest level and cycle through to highest
390 unsigned s = nested.stages()-1;
391 try{
392 dg::apply( inverse_ops_up[s], nested.b(s), nested.x(s));
393 }catch( dg::Error& err){
394 err.append_line( dg::Message(_ping_)<<"ERROR on stage "<<s<<" of full multigrid");
395 throw;
396 }
397 dg::blas1::axpby( 1., nested.x(s), -1., nested.w(s), nested.x(s) );
398 dg::blas2::symv( 1., nested.interpolation(s-1), nested.x(s), 1.,
399 nested.x(s-1));
400
401 for( int p=nested.stages()-2; p>=1; p--)
402 {
403 for( unsigned u=0; u<mu; u++)
404 multigrid_cycle( ops, inverse_ops_down, inverse_ops_up, nested, gamma, p);
405 dg::blas1::axpby( 1., nested.x(p), -1., nested.w(p), nested.x(p) );
406 dg::blas2::symv( 1., nested.interpolation(p-1), nested.x(p), 1.,
407 nested.x(p-1));
408 }
409 dg::blas1::copy( b, nested.b(0));
410 for( unsigned u=0; u<mu; u++)
411 multigrid_cycle( ops, inverse_ops_down, inverse_ops_up, nested, gamma, 0);
412 dg::blas1::copy( nested.x(0), x);
413}
414
439template<class NestedGrids, class MatrixType0, class MatrixType1, class MatrixType2,
440 class ContainerType0, class ContainerType1, class ContainerType2>
442 std::vector<MatrixType0>& ops,
443 ContainerType0& x, const ContainerType1& b,
444 std::vector<MatrixType1>& inverse_ops_down, //stages -1
445 std::vector<MatrixType2>& inverse_ops_up, //stages
446 NestedGrids& nested_grids,
447 const ContainerType2& weights, double eps, unsigned gamma)
448{
449 //FULL MULTIGRID
450 //full approximation scheme
451 double nrmb = sqrt( blas2::dot( weights, b));
452
453 try{
454 full_multigrid( ops, x, b, inverse_ops_down, inverse_ops_up, nested_grids, gamma, 1);
455 }catch( dg::Error& err){
456 err.append_line( dg::Message(_ping_)<<"ERROR in fmg_solve");
457 throw;
458 }
459
460 dg::apply( ops[0], x, nested_grids.r(0));
461 dg::blas1::axpby( 1., b, -1., nested_grids.r(0));
462 double error = sqrt( blas2::dot(weights,nested_grids.r(0)) );
463
464 while ( error > eps*(nrmb + 1))
465 {
466 //MULTIGRID CYCLES
467 //multigrid_cycle( ops, inverse_ops_down, inverse_ops_up, nested_grids, gamma, 0);
468 //FMG cycles
469 try{
470 full_multigrid( ops, x, b, inverse_ops_down, inverse_ops_up, nested_grids, gamma, 1);
471 }catch( dg::Error& err){
472 err.append_line( dg::Message(_ping_)<<"ERROR in fmg_solve");
473 throw;
474 }
475
476 blas2::symv( ops[0], x, nested_grids.r(0));
477 dg::blas1::axpby( 1., b, -1., nested_grids.r(0));
478 error = sqrt( blas2::dot(weights,nested_grids.r(0)) );
479 //DG_RANK0 std::cout<< "# Relative Residual error is "<<error/(nrmb+1)<<"\n";
480 }
481}
482
483
484
507template< class Geometry, class Matrix, class Container, ComplexMode complex_mode = dg::complex_hermitian>
509{
510 using geometry_type = Geometry;
513 using value_type = typename Geometry::value_type; // Type of eps needs to be real
515 MultigridCG2d() = default;
524 template<class ...ContainerParams>
525 MultigridCG2d( const Geometry& grid, const unsigned stages,
526 ContainerParams&& ... ps):
527 m_nested( grid, stages, std::forward<ContainerParams>(ps)...),
528 m_pcg( stages), m_stages(stages)
529 {
530 for (unsigned u = 0; u < stages; u++)
531 m_pcg[u].construct(m_nested.x(u), m_nested.grid(u).size());
532 }
533
540 template<class ...Params>
541 void construct( Params&& ...ps)
542 {
543 //construct and swap
544 *this = MultigridCG2d( std::forward<Params>( ps)...);
545 }
546
548 template<class ContainerType0>
549 void project( const ContainerType0& src, std::vector<ContainerType0>& out) const
550 {
551 m_nested.project( src, out);
552 }
553
555 template<class ContainerType0>
556 std::vector<ContainerType0> project( const ContainerType0& src) const
557 {
558 return m_nested.project( src);
559 }
561 unsigned stages()const{return m_nested.stages();}
563 unsigned num_stages()const{return m_nested.num_stages();}
564
567 const Geometry& grid( unsigned stage) const {
568 return m_nested.grid(stage);
569 }
570
571
574 unsigned max_iter() const{return m_pcg[0].get_max();}
583 void set_max_iter(unsigned new_max){ m_pcg[0].set_max(new_max);}
591 void set_benchmark( bool benchmark, std::string message = "Nested Iterations"){
592 m_benchmark = benchmark;
593 m_message = message;
594 }
595
598 const Container& copyable() const {return m_nested.copyable();}
625 template<class MatrixType, class ContainerType0, class ContainerType1>
626 std::vector<unsigned> solve( std::vector<MatrixType>& ops, ContainerType0& x, const ContainerType1& b, value_type eps)
627 {
628 std::vector<value_type> v_eps( m_stages, eps);
629 for( unsigned u=m_stages-1; u>0; u--)
630 v_eps[u] = eps;
631 return solve( ops, x, b, v_eps);
632 }
634 template<class MatrixType, class ContainerType0, class ContainerType1>
635 std::vector<unsigned> solve( std::vector<MatrixType>& ops, ContainerType0& x, const ContainerType1& b, std::vector<value_type> eps)
636 {
637#ifdef MPI_VERSION
638 int rank;
639 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
640#endif //MPI
641 std::vector<unsigned> number(m_stages);
642 std::vector<std::function<void( const ContainerType1&, ContainerType0&)> >
643 multi_inv_pol(m_stages);
644 for(unsigned u=0; u<m_stages; u++)
645 {
646 multi_inv_pol[u] = [&, u, &pcg = m_pcg[u], &pol = ops[u]](
647 const auto& y, auto& x)
648 {
649 dg::Timer t;
650 t.tic();
651 if ( u == 0)
652 number[u] = pcg.solve( pol, x, y, pol.precond(),
653 pol.weights(), eps[u], 1, 1);
654 else
655 number[u] = pcg.solve( pol, x, y, pol.precond(),
656 pol.weights(), eps[u], 1, 10);
657 t.toc();
658 if( m_benchmark)
659 DG_RANK0 std::cout << "# `"<<m_message<<"` stage: " << u << ", iter: " << number[u] << ", took "<<t.diff()<<"s\n";
660 };
661 }
662 nested_iterations( ops, x, b, multi_inv_pol, m_nested);
663
664 return number;
665 }
666
667 private:
669 std::vector< PCG<Container, complex_mode> > m_pcg;
670 unsigned m_stages;
671 bool m_benchmark = true;
672 std::string m_message = "Nested Iterations";
673
674};
676
677}//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, Ts ...)
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:345
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:496
void symv(MatrixType &&M, const ContainerType1 &x, ContainerType2 &y)
Definition blas2.h:331
@ forward
forward derivative (cell to the right and current cell)
Definition enums.h:98
@ y
y direction
@ x
x direction
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:277
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:441
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:366
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:198
Interpolation matrix creation functions.
dg::DVec Container
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...
Ell Sparse Block Matrix format.
Definition sparseblockmat.h:46
Struct that applies given matrices one after the other.
Definition fast_interpolation.h:37
Solve.
Definition multigrid.h:509
typename Geometry::value_type value_type
Definition multigrid.h:513
void set_max_iter(unsigned new_max)
Set the maximum number of iterations allowed at stage 0.
Definition multigrid.h:583
void project(const ContainerType0 &src, std::vector< ContainerType0 > &out) const
Project vector to all involved grids.
Definition multigrid.h:549
std::vector< unsigned > solve(std::vector< MatrixType > &ops, ContainerType0 &x, const ContainerType1 &b, std::vector< value_type > eps)
Nested iterations.
Definition multigrid.h:635
unsigned max_iter() const
Definition multigrid.h:574
Container container_type
Definition multigrid.h:512
unsigned num_stages() const
Definition multigrid.h:563
std::vector< ContainerType0 > project(const ContainerType0 &src) const
Project vector to all involved grids (allocate memory version)
Definition multigrid.h:556
void construct(Params &&...ps)
Perfect forward parameters to one of the constructors.
Definition multigrid.h:541
Geometry geometry_type
Definition multigrid.h:510
MultigridCG2d()=default
Allocate nothing, Call construct method before usage.
const Geometry & grid(unsigned stage) const
return the grid at given stage
Definition multigrid.h:567
const Container & copyable() const
Return an object of same size as the object used for construction on the finest grid.
Definition multigrid.h:598
std::vector< unsigned > solve(std::vector< MatrixType > &ops, ContainerType0 &x, const ContainerType1 &b, value_type eps)
Nested iterations.
Definition multigrid.h:626
unsigned stages() const
Definition multigrid.h:561
MultigridCG2d(const Geometry &grid, const unsigned stages, ContainerParams &&... ps)
Construct the grids and the interpolation/projection operators.
Definition multigrid.h:525
void set_benchmark(bool benchmark, std::string message="Nested Iterations")
Set or unset performance timings during iterations.
Definition multigrid.h:591
Hold nested grids and provide dg fast interpolation and projection matrices.
Definition multigrid.h:30
const Container & w(unsigned stage) const
Definition multigrid.h:150
const Container & copyable() const
Return an object of same size as the object used for construction on the finest grid.
Definition multigrid.h:118
typename Geometry::value_type value_type
Definition multigrid.h:34
Container & b(unsigned stage)
Definition multigrid.h:147
const Container & b(unsigned stage) const
Definition multigrid.h:148
const MultiMatrix< Matrix, Container > & interpolation(unsigned stage) const
return the interpolation matrix at given stage
Definition multigrid.h:133
Container container_type
Definition multigrid.h:33
void project(const ContainerType0 &src, std::vector< ContainerType0 > &out) const
Project vector to all involved grids.
Definition multigrid.h:95
const MultiMatrix< Matrix, Container > & projection(unsigned stage) const
return the projection matrix at given stage
Definition multigrid.h:139
void construct(Params &&...ps)
Perfect forward parameters to one of the constructors.
Definition multigrid.h:83
std::vector< ContainerType0 > project(const ContainerType0 &src) const
Project vector to all involved grids (allocate memory version)
Definition multigrid.h:108
NestedGrids()
Allocate nothing, Call construct method before usage.
Definition multigrid.h:36
Container & r(unsigned stage)
Definition multigrid.h:145
const Container & x(unsigned stage) const
Definition multigrid.h:144
unsigned stages() const
Definition multigrid.h:121
Geometry geometry_type
Definition multigrid.h:31
const Container & r(unsigned stage) const
Definition multigrid.h:146
Container & w(unsigned stage)
Definition multigrid.h:149
const Geometry & grid(unsigned stage) const
return the grid at given stage
Definition multigrid.h:127
unsigned num_stages() const
Definition multigrid.h:123
NestedGrids(const Geometry &grid, const unsigned stages, ContainerParams &&...ps)
Construct the grids and the interpolation/projection operators.
Definition multigrid.h:46
Container & x(unsigned stage)
Definition multigrid.h:143
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.
double pol(double x, double y)
double mu(double s, unsigned i, unsigned n)
#define DG_RANK0
Definition typedefs.h:152