[dune-functions] [Dune-functions-commit] [Commit] dune-functions - c7b3989: Resize must now be done manually before interpolate()

Carsten Gräser graeser at mi.fu-berlin.de
Mon Sep 14 15:50:10 CEST 2015


Hi Oliver,

Am 14.09.2015 um 15:19 schrieb Oliver Sander:
> Hi all,
>> commit c7b398972459ed3caf3af893d4954d46a755f9e6
>> Author: Carsten Gräser <graeser at mi.fu-berlin.de>
>> Date:   Mon Sep 14 15:14:30 2015 +0200
>>
>>     Resize must now be done manually before interpolate()
> [snip]
>>  
>>    // Interpolating the indicator function of the boundary will
>>    // mark all boundary dofs.
>> +  Dune::Functions::HierarchicVectorBackend::resize(dirichletNodes, feBasis);
>>    interpolate(feBasis, std::make_tuple(), dirichletNodes,
>>        [&bbox](Coordinate x){
>>          bool isBoundary = false;
> is this really necessary?  I'd rather avoid having to expose the user to this VectorBackend thingy.
> In particular in an example like poisson-pq2, where the basis is real simple and scalar.
there are two parts to this question:

a)Should we expect the user to resize manually?
we could simply call this in the interpolate method. But the result of
calling this will be rather complicated to describe for a nested vector,
especially because we only write into a subset of components in general
and it's hard to give proper defaults. For me it's much cleaner to say,
that the user has to resize on its own.

For this simple example you could also simply do

  dirichletNodes.resize(feBasis.size());

Making it easier to the eye. But this expects knowledge
about the implementation details of the basis and interpolate.

b)Should we expose the backend stuff?
The basis itself does only provide indices and does not tell,
how to map them to a specific container implementation. But
each time you want to interpolate, or construct a grid function
from coefficients and basis, you need to pass mutiindices and
size information to the containers nested operator[] and resize().
Even for the simple p1 example you cannot pass the multi-index
directly but have to explain the appended [0]. This is exactly
what the backend encapsulates.

Maybe a cleaner solution would be, to provide some kind of vector
adaptor providing operator()(MultiIndex) and a hierachic resize.
Then we would write

  SomeVector v;
  auto&& v_coeff = basisCoefficients(v, basis);
  v_coeff.resize();
  interpolate(v_coeff, treePath, f);

This would also allow to exchange the now hard wired backend
more easily.

Best,
Carsten








-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <https://lists.dune-project.org/pipermail/dune-functions/attachments/20150914/e5d3aea0/attachment.sig>


More information about the dune-functions mailing list