[dune-functions] interface check for GridViewFunction

Carsten Gräser graeser at mi.fu-berlin.de
Sun Sep 20 21:51:18 CEST 2015


Hi Christian,

Am 20.09.2015 um 16:13 schrieb Christian Engwer:
> Hi Carsten,
> 
> thanks for putting this concept together. One downside of the current
> concepts approach (in contrast to interface tests) is that I don't get
> any information on what is missing/broken in the interface.
what do you mean by 'interface test'? Deriving from an interface class?
Of course you can still write tests against the interface.

> Is there an easy way to fix this? If not in general, then at least for
> debugging?
You can manually check the concept such that the substitution failure
that is triggered if your type does not match will result in a compiler
error. Then the error message indicates, which expression of the concept
failed. I.e., to check if vector<double> is a function of signature
double(int) you can do:

using F = std::vector<double>;
using Concept = Dune::Functions::Concept::Function<double(int)>;
using Check = decltype(Concept().require<F>(std::declval<F>()));

This will however not reveal if a base-concept is not satisfied.
But maybe one can add a convenience method that also checks the
parents in the concept hierarchy.

Best,
Carsten

> 
> Ciao
> Christian
> 
> On Sun, Sep 20, 2015 at 01:15:20AM +0200, Carsten Gräser wrote:
>> Am 20.09.2015 um 00:04 schrieb Carsten Gräser:
>>> Am 19.09.2015 um 23:40 schrieb Christian Engwer:
>>>> Dear all,
>>>>
>>>> I lost track... how do I test, whether my implementation fulfills the
>>>> GridViewFunction interface?
>>>
>>> There's no dedicated check for GridViewFunctions. But you can use the
>>> concept check for grid functions wrt to the GridViewEntitySet. Assume
>>> that you have given types Function/Range/GridView you can use
>>>
>>>  using Coordinate = GridView::Codim<0> ::Geometry::GlobalCoordinate;
>>>  using Signature = Range(Coordinate);
>>>  using EntitySet = Dune::Functions::GridViewEntitySet<GridView, 0>;
>>>  bool isGridViewFunction
>>>         = Dune::Functions::Concept::isGridFunction<Function, Signature, EntitySet>();
>>
>> Now you can do
>>
>>   using Coordinate = GridView::Codim<0> ::Geometry::GlobalCoordinate;
>>   using Signature = Range(Coordinate);
>>   bool isGridViewFunction
>>          = Dune::Functions::Concept::isGridViewFunction<Function,Signature, GridView>();
>>
>> I'm thinking if we should replace the parameter Signature in favor of Range
>> to make the check easier. Domain can be derived from the GridView/EntitySet
>> and the concept does anyway check if EntitySet::GlobalCoordinate is convertible
>> to Domain.
>>
>> This would mean to adjust uses of the concept in dune-functions.
>> Did anyone use the GridFunction concept definition outside of
>> dune-functions?
>>
>> Best,
>> Carsten
>>
>>
>>>
>>> Maybe I'll add this as a shortcut to functionconcepts.
>>>
>>> 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/20150920/dd5d3515/attachment.sig>


More information about the dune-functions mailing list