Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dumux-repositories
dumux
Commits
1612f45e
Commit
1612f45e
authored
Apr 27, 2018
by
Dennis Gläser
Browse files
[io][vtk] avoid deprecation warnings for Dune::IsIndexable
parent
96379636
Changes
3
Hide whitespace changes
Inline
Side-by-side
dumux/common/typetraits/typetraits.hh
View file @
1612f45e
...
...
@@ -26,6 +26,8 @@
#include
<type_traits>
#include
<dune/common/version.hh>
namespace
Dumux
{
/*!
...
...
@@ -34,5 +36,17 @@ namespace Dumux
*/
template
<
typename
T
>
struct
AlwaysFalse
:
public
std
::
false_type
{};
/*! \brief We define our own is_indexable type in order
* to avoid several version checks throughout dumux.
* This should be deleted when the deprecation phase is over.
*/
template
<
typename
T
,
typename
I
=
std
::
size_t
>
using
IsIndexable
=
#if DUNE_VERSION_NEWER(DUNE_COMMON,2,7)
typename
Dune
::
IsIndexable
<
T
,
I
>
;
#else
typename
Dune
::
is_indexable
<
T
,
I
>
;
#endif
}
#endif
dumux/io/vtkfunction.hh
View file @
1612f45e
...
...
@@ -30,6 +30,8 @@
#include
<dune/grid/io/file/vtk/common.hh>
#include
<dune/grid/io/file/vtk/function.hh>
#include
<dumux/common/typetraits/typetraits.hh>
namespace
Dumux
{
namespace
Vtk
{
...
...
@@ -56,7 +58,7 @@ public:
//! evaluate
virtual
double
evaluate
(
int
mycomp
,
const
Element
&
e
,
const
Dune
::
FieldVector
<
ctype
,
dim
>&
)
const
{
return
accessChooser_
(
mycomp
,
mapper_
.
index
(
e
),
Dune
::
is_i
ndexable
<
decltype
(
field_
[
0
])
>
());
}
{
return
accessChooser_
(
mycomp
,
mapper_
.
index
(
e
),
IsI
ndexable
<
decltype
(
field_
[
0
])
>
());
}
//! Constructor
VectorP0VTKFunction
(
const
GridView
&
gridView
,
const
Mapper
&
mapper
,
const
F
&
field
,
const
std
::
string
&
name
,
int
nComps
)
...
...
@@ -70,20 +72,16 @@ private:
//! access for vectorial fields
double
accessChooser_
(
int
mycomp
,
int
i
,
std
::
true_type
)
const
{
static
constexpr
auto
isIndexable
=
Dune
::
is_indexable
<
decltype
(
field_
[
0
][
0
])
>
();
return
vectorFieldAccess_
<
isIndexable
>
(
mycomp
,
i
);
}
{
return
vectorFieldAccess_
(
mycomp
,
i
,
IsIndexable
<
decltype
(
field_
[
0
][
0
])
>
());
}
//! access for scalar fields
double
accessChooser_
(
int
mycomp
,
int
i
,
std
::
false_type
)
const
{
return
field_
[
i
];
}
//! access to permissive vectorial fields
template
<
bool
is
,
std
::
enable_if_t
<!
is
,
int
>
=
0
>
double
vectorFieldAccess_
(
int
mycomp
,
int
i
)
const
{
return
field_
[
i
][
mycomp
];
}
double
vectorFieldAccess_
(
int
mycomp
,
int
i
,
std
::
false_type
)
const
{
return
field_
[
i
][
mycomp
];
}
//! if the field is indexable more than two times, throw error
template
<
bool
is
,
std
::
enable_if_t
<
is
,
int
>
=
0
>
double
vectorFieldAccess_
(
int
mycomp
,
int
i
)
const
{
DUNE_THROW
(
Dune
::
InvalidStateException
,
"Invalid field type"
);
}
double
vectorFieldAccess_
(
int
mycomp
,
int
i
,
std
::
true_type
)
const
{
DUNE_THROW
(
Dune
::
InvalidStateException
,
"Invalid field type"
);
}
const
F
&
field_
;
const
std
::
string
name_
;
...
...
@@ -120,7 +118,7 @@ public:
std
::
vector
<
Dune
::
FieldVector
<
ctype
,
1
>>
cornerValues
(
nVertices
);
for
(
unsigned
i
=
0
;
i
<
nVertices
;
++
i
)
cornerValues
[
i
]
=
accessChooser_
(
mycomp
,
mapper_
.
subIndex
(
e
,
i
,
dim
),
Dune
::
is_i
ndexable
<
decltype
(
field_
[
0
])
>
());
cornerValues
[
i
]
=
accessChooser_
(
mycomp
,
mapper_
.
subIndex
(
e
,
i
,
dim
),
IsI
ndexable
<
decltype
(
field_
[
0
])
>
());
// (Ab)use the MultiLinearGeometry class to do multi-linear interpolation between scalars
const
Dune
::
MultiLinearGeometry
<
ctype
,
dim
,
1
>
interpolation
(
e
.
type
(),
std
::
move
(
cornerValues
));
...
...
@@ -138,7 +136,7 @@ private:
//! access for vectorial fields
double
accessChooser_
(
int
mycomp
,
int
i
,
std
::
true_type
)
const
{
return
vectorFieldAccess_
(
mycomp
,
i
,
Dune
::
is_i
ndexable
<
decltype
(
field_
[
0
][
0
])
>
());
}
{
return
vectorFieldAccess_
(
mycomp
,
i
,
IsI
ndexable
<
decltype
(
field_
[
0
][
0
])
>
());
}
//! access for scalar fields
double
accessChooser_
(
int
mycomp
,
int
i
,
std
::
false_type
)
const
{
return
field_
[
i
];
}
...
...
@@ -184,7 +182,7 @@ public:
std
::
vector
<
Dune
::
FieldVector
<
ctype
,
1
>>
cornerValues
(
nVertices
);
for
(
unsigned
i
=
0
;
i
<
nVertices
;
++
i
)
cornerValues
[
i
]
=
accessChooser_
(
mycomp
,
mapper_
.
index
(
e
),
i
,
Dune
::
is_i
ndexable
<
decltype
(
field_
[
0
])
>
());
cornerValues
[
i
]
=
accessChooser_
(
mycomp
,
mapper_
.
index
(
e
),
i
,
IsI
ndexable
<
decltype
(
field_
[
0
])
>
());
// (Ab)use the MultiLinearGeometry class to do multi-linear interpolation between scalars
const
Dune
::
MultiLinearGeometry
<
ctype
,
dim
,
1
>
interpolation
(
e
.
type
(),
std
::
move
(
cornerValues
));
...
...
@@ -202,7 +200,7 @@ private:
//! access to the field
double
accessChooser_
(
int
mycomp
,
int
eIdx
,
int
cornerIdx
,
std
::
true_type
)
const
{
return
fieldAccess_
(
mycomp
,
eIdx
,
cornerIdx
,
Dune
::
is_i
ndexable
<
decltype
(
field_
[
0
][
0
])
>
());
}
{
return
fieldAccess_
(
mycomp
,
eIdx
,
cornerIdx
,
IsI
ndexable
<
decltype
(
field_
[
0
][
0
])
>
());
}
//! fields have to be indexable at least twice
double
accessChooser_
(
int
mycomp
,
int
eIdx
,
int
cornerIdx
,
std
::
false_type
)
const
...
...
dumux/io/vtkoutputmodule.hh
View file @
1612f45e
...
...
@@ -42,6 +42,7 @@
#include
<dumux/common/properties.hh>
#include
<dumux/common/parameters.hh>
#include
<dumux/common/typetraits/typetraits.hh>
#include
<dumux/discretization/methods.hh>
#include
"vtkfunction.hh"
...
...
@@ -571,11 +572,11 @@ private:
}
//! Deduces the number of components of the value type of a vector of values
template
<
class
Vector
,
typename
std
::
enable_if_t
<
Dune
::
is_i
ndexable
<
decltype
(
std
::
declval
<
Vector
>()[
0
])
>::
value
,
int
>
=
0
>
template
<
class
Vector
,
typename
std
::
enable_if_t
<
IsI
ndexable
<
decltype
(
std
::
declval
<
Vector
>()[
0
])
>::
value
,
int
>
=
0
>
std
::
size_t
getNumberOfComponents_
(
const
Vector
&
v
)
{
return
v
[
0
].
size
();
}
//! Deduces the number of components of the value type of a vector of values
template
<
class
Vector
,
typename
std
::
enable_if_t
<!
Dune
::
is_i
ndexable
<
decltype
(
std
::
declval
<
Vector
>()[
0
])
>::
value
,
int
>
=
0
>
template
<
class
Vector
,
typename
std
::
enable_if_t
<!
IsI
ndexable
<
decltype
(
std
::
declval
<
Vector
>()[
0
])
>::
value
,
int
>
=
0
>
std
::
size_t
getNumberOfComponents_
(
const
Vector
&
v
)
{
return
1
;
}
//! return the number of dofs
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment