[dune-pdelab] Convergence tests: Mapping Data between different grids / grid levels

Gregor Corbin corbin at mathematik.uni-kl.de
Wed Aug 1 12:40:39 CEST 2018


Dear all,

I am currently trying to implement a convergence test for my solver.

Starting from a very coarse grid, I compute the same problem on a number
of refined grids. Then I would like to use a
Dune::PDELab::DifferenceAdapter to compute differences between the
DiscreteGridFunctions for the solutions .

The problem is, that this difference adapter only works for
GridFunctions that have the same grid. So is there some way to map a
function (dof vector + gfs) to another grid view? The other grid view is
currently just a different LevelGridView for the same grid.

My approach so far is to use a GridAdaptor. The Idea is to use
backupData on the coarse GFS and then restoreData on the fineGFS. This
seems to work for a serial program but fails for parallel execution.
Does anyone have an Idea, where this goes wrong(code extract below)?

Is there maybe a different method?

Thanks,

Gregor 


          for (int s = 0; s <= sim; ++s)
          {
            using U   = typename Program::U::Rho;  //  this is just a
convenience type that bundles a GridFunctionSpace together with a
coefficient vector and the resulting discrete grid function. It hase
methods to return the GFS the dof vector and the DGF ( gfs(), vec() and
fun() )
            using GFS = typename U::GFS;    // grid function space
            using DGF = typename U::DGF;   // discrete grid function
            using X   = typename U::X;          // dof vector
           
            // get coarse solution on level s  and solution on finest
grid level sim
            U& Ucoarse = prog[s]->solution().rho();
            U& Ufine      = prog[sim]->solution().rho();
           
            typedef Dune::PDELab::L2Projection<GFS,X> Projection;
            Projection coarseProj(Ucoarse.gfs(),2);           
            Projection fineProj(Ufine.gfs(),2);

            Dune::PDELab::GridAdaptor<Grid,GFS,X,Projection>
grid_adaptor(Ucoarse.gfs());

            // save u in coarse space
            typename
Dune::PDELab::GridAdaptor<Grid,GFS,X,Projection>::MapType transferMap1;
           
grid_adaptor.backupData(grid,Ucoarse.gfs(),coarseProj,Ucoarse.vec(),transferMap1);

            // reset u in fine space
            U Umapped(Ufine.gfs());
           
grid_adaptor.replayData(grid,Ufine.gfs(),fineProj,Umapped.vec(),transferMap1);
           
            // compute L2 norm of the difference
            Dune::PDELab::DifferenceAdapter<DGF,DGF>
diff(Ufine.fun(),Umapped.fun());
            auto l2diff = l2norm(diff,2);           
            l2diff_global(sim,s) =  comm.sum(l2diff);
          }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <https://lists.dune-project.org/pipermail/dune-pdelab/attachments/20180801/c521e95d/attachment.sig>


More information about the dune-pdelab mailing list