[Dune] [Dune-Commit] dune-grid r7578 - trunk/dune/grid/genericgeometry
Andreas Dedner
dedner at mathematik.uni-freiburg.de
Tue Mar 29 17:10:05 CEST 2011
Hi Christian,
The problem is with multi precision types, In
localfunctions/utility/field.hh we overload std::abs
for the ampf field type and that overloaded function is needed in
matrixhelper.hh.
Now we basically have no idea what the problem is - is has to do with
the order of inclusion of matrixhelper.hh and field.hh.
If we include field.hh in matrixhelper.hh directly everything works. But
this is not an option since fileld.hh is in localfunctions.
If matrixhelper.hh is included before field.hh the compiler says that he
cannot find std::abs for the ampf field:
testgenericfem.cc:77:31: instantiated from here
/home/maths/masjal/DUNE/dune-grid/dune/grid/genericgeometry/matrixhelper.hh:444:32:
error: no matching function for call to ‘abs(const
Dune::GenericGeometry::MatrixHelper<Dune::GenericGeometry::DuneCoordTraits<amp::ampf<64u>
> >::FieldType&)’
compilation terminated due to -Wfatal-errors.
This was be seen by adding
GRIDTYPE=YASPGRID
GRIDDIM=2
before including config.h in testgenericfem
Perhaps you have an idea?
Best
Andreas
On 29/03/11 15:34, Christian Engwer wrote:
> Hi Martin,
>
> I don't quite undestand, what happend here. How is the new
> construction different from the previous one? Can you enlight me?
>
> Thanks
> Christian
>
> On Tue, Mar 29, 2011 at 04:06:59PM +0200, mnolte at dune-project.org wrote:
>> Author: mnolte
>> Date: 2011-03-29 16:06:59 +0200 (Tue, 29 Mar 2011)
>> New Revision: 7578
>>
>> Modified:
>> trunk/dune/grid/genericgeometry/matrixhelper.hh
>> Log:
>> fix a problem with method overloading
>>
>>
>> Modified: trunk/dune/grid/genericgeometry/matrixhelper.hh
>> ===================================================================
>> --- trunk/dune/grid/genericgeometry/matrixhelper.hh 2011-03-21 23:22:41 UTC (rev 7577)
>> +++ trunk/dune/grid/genericgeometry/matrixhelper.hh 2011-03-29 14:06:59 UTC (rev 7578)
>> @@ -1,6 +1,8 @@
>> #ifndef DUNE_GENERICGEOMETRY_MATRIXHELPER_HH
>> #define DUNE_GENERICGEOMETRY_MATRIXHELPER_HH
>>
>> +#include<cmath>
>> +
>> #include<dune/common/fvector.hh>
>> #include<dune/common/fmatrix.hh>
>> #include<dune/common/static_assert.hh>
>> @@ -11,11 +13,31 @@
>> namespace GenericGeometry
>> {
>>
>> + // FieldHelper
>> + // -----------
>> +
>> + template< class Field>
>> + struct FieldHelper
>> + {
>> + static Field abs ( const Field&x ) { return std::abs( x ); }
>> + };
>> +
>> +
>> +
>> + // MatrixHelper
>> + // ------------
>> +
>> template< class Traits>
>> struct MatrixHelper
>> {
>> - typedef typename Traits :: ctype FieldType;
>> + typedef typename Traits::ctype FieldType;
>>
>> + static FieldType abs ( const FieldType&x )
>> + {
>> + //return std::abs( x );
>> + return FieldHelper< FieldType>::abs( x );
>> + }
>> +
>> template< int m, int n>
>> static void
>> Ax ( const typename Traits :: template Matrix< m, n> :: type&A,
>> @@ -373,7 +395,7 @@
>> if( (n == 2)&& (m == 2) )
>> {
>> // Special implementation for 2x2 matrices: faster and more stable
>> - return std::abs( A[ 0 ][ 0 ]*A[ 1 ][ 1 ] - A[ 1 ][ 0 ]*A[ 0 ][ 1 ] );
>> + return abs( A[ 0 ][ 0 ]*A[ 1 ][ 1 ] - A[ 1 ][ 0 ]*A[ 0 ][ 1 ] );
>> }
>> else if( (n == 3)&& (m == 3) )
>> {
>> @@ -381,7 +403,7 @@
>> const FieldType v0 = A[ 0 ][ 1 ] * A[ 1 ][ 2 ] - A[ 1 ][ 1 ] * A[ 0 ][ 2 ];
>> const FieldType v1 = A[ 0 ][ 2 ] * A[ 1 ][ 0 ] - A[ 1 ][ 2 ] * A[ 0 ][ 0 ];
>> const FieldType v2 = A[ 0 ][ 0 ] * A[ 1 ][ 1 ] - A[ 1 ][ 0 ] * A[ 0 ][ 1 ];
>> - return std::abs( v0 * A[ 2 ][ 0 ] + v1 * A[ 2 ][ 1 ] + v2 * A[ 2 ][ 2 ] );
>> + return abs( v0 * A[ 2 ][ 0 ] + v1 * A[ 2 ][ 1 ] + v2 * A[ 2 ][ 2 ] );
>> }
>> else if( n>= m )
>> {
>> @@ -438,7 +460,7 @@
>> ret[ 1 ][ 1 ] = A[ 0 ][ 0 ] * detInv;
>> ret[ 1 ][ 0 ] = -A[ 1 ][ 0 ] * detInv;
>> ret[ 0 ][ 1 ] = -A[ 0 ][ 1 ] * detInv;
>> - return std::abs( det );
>> + return abs( det );
>> }
>> else
>> {
>> @@ -464,8 +486,8 @@
>> }
>> };
>>
>> - }
>> + } // namespace GenericGeometry
>>
>> -}
>> +} // namespace Dune
>>
>> #endif // #ifndef DUNE_GENERICGEOMETRY_MATRIXHELPER_HH
>>
>>
>> _______________________________________________
>> Dune-Commit mailing list
>> Dune-Commit at dune-project.org
>> http://lists.dune-project.org/mailman/listinfo/dune-commit
>>
> _______________________________________________
> Dune mailing list
> Dune at dune-project.org
> http://lists.dune-project.org/mailman/listinfo/dune
More information about the Dune
mailing list