Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
iwr
dune-vtk
Commits
9a772702
Commit
9a772702
authored
Apr 04, 2021
by
Praetorius, Simon
Browse files
Extract some concepts from Vtk::Function
parent
a139f141
Changes
2
Hide whitespace changes
Inline
Side-by-side
dune/vtk/function.hh
View file @
9a772702
...
...
@@ -9,6 +9,7 @@
#include
<dune/vtk/localfunction.hh>
#include
<dune/vtk/types.hh>
#include
<dune/vtk/utility/arguments.hh>
#include
<dune/vtk/utility/concepts.hh>
namespace
Dune
{
...
...
@@ -28,16 +29,6 @@ namespace Dune
using
Element
=
typename
GridView
::
template
Codim
<
0
>
::
Entity
;
using
LocalDomain
=
typename
Element
::
Geometry
::
LocalCoordinate
;
template
<
class
GF
>
using
IsGridFunction
=
decltype
(
localFunction
(
std
::
declval
<
GF
>
()));
template
<
class
LocalFunction
,
class
LF
=
std
::
decay_t
<
LocalFunction
>
>
using
IsLocalFunction
=
decltype
((
std
::
declval
<
LF
&>
().
bind
(
std
::
declval
<
Element
>
()),
std
::
declval
<
LF
&>
().
unbind
(),
std
::
declval
<
LF
>
()(
std
::
declval
<
LocalDomain
>
()),
0
));
template
<
class
F
,
class
D
>
using
Range
=
std
::
decay_t
<
std
::
result_of_t
<
F
(
D
)
>>
;
...
...
@@ -67,15 +58,15 @@ namespace Dune
* \param localFct A local-function, providing a `bind(Element)` and an `operator()(LocalDomain)`
* \param name The name to use as identification in the VTK file
* \param components A vector of component indices to extract from the range type
* \param category The \ref Vtk::RangeTypes category for the range. [Vtk::RangeTypes::
AUTO
]
* \param dataType The \ref Vtk::DataTypes used in the output. [Vtk::DataTypes::FLOAT
32
]
* \param category The \ref Vtk::RangeTypes category for the range. [Vtk::RangeTypes::
UNSPECIFIED
]
* \param dataType The \ref Vtk::DataTypes used in the output. [Vtk::DataTypes::FLOAT
64
]
*
* The arguments `category` and `dataType` can be passed in any order.
*
* NOTE: Stores the localFunction by value.
**/
template
<
class
LF
,
class
...
Args
,
class
=
IsLocalFunction
<
LF
>
>
IsLocalFunction
<
LF
,
Element
>
=
true
>
Function
(
LF
&&
localFct
,
std
::
string
name
,
std
::
vector
<
int
>
components
,
Args
&&
...
args
)
:
localFct_
(
std
::
forward
<
LF
>
(
localFct
))
,
name_
(
std
::
move
(
name
))
...
...
@@ -97,7 +88,7 @@ namespace Dune
* NOTE: Stores the localFunction by value.
**/
template
<
class
LF
,
class
...
Args
,
class
=
IsLocalFunction
<
LF
>
>
IsLocalFunction
<
LF
,
Element
>
=
true
>
Function
(
LF
&&
localFct
,
std
::
string
name
,
int
ncomps
,
Args
&&
...
args
)
:
Function
(
std
::
forward
<
LF
>
(
localFct
),
std
::
move
(
name
),
allComponents
(
ncomps
),
std
::
forward
<
Args
>
(
args
)...)
...
...
@@ -110,7 +101,7 @@ namespace Dune
* static size information could be extracted.
**/
template
<
class
LF
,
class
...
Args
,
class
=
IsLocalFunction
<
LF
>
,
IsLocalFunction
<
LF
,
Element
>
=
true
,
class
R
=
Range
<
LF
,
LocalDomain
>
>
Function
(
LF
&&
localFct
,
std
::
string
name
,
Args
&&
...
args
)
:
Function
(
std
::
forward
<
LF
>
(
localFct
),
std
::
move
(
name
),
sizeOf
<
R
>
(),
...
...
@@ -138,7 +129,7 @@ namespace Dune
*/
template
<
class
GF
,
class
...
Args
,
disableCopyMove
<
Function
,
GF
>
=
0
,
class
=
IsGridFunction
<
GF
>
>
IsGridFunction
<
GF
>
=
true
>
Function
(
GF
&&
fct
,
std
::
string
name
,
Args
&&
...
args
)
:
Function
(
localFunction
(
std
::
forward
<
GF
>
(
fct
)),
std
::
move
(
name
),
std
::
forward
<
Args
>
(
args
)...)
{}
...
...
@@ -149,10 +140,10 @@ namespace Dune
:
Function
(
std
::
forward
<
F
>
(
fct
),
info
.
name
(),
info
.
size
(),
info
.
rangeType
(),
info
.
dataType
())
{}
/// (
6
) Automatically extract name and num components from GridFunction if available
/// (
7
) Automatically extract name and num components from GridFunction if available
template
<
class
F
,
class
...
Args
,
disableCopyMove
<
Function
,
F
>
=
0
,
class
=
decltype
(
localFunction
(
std
::
declval
<
F
>
()))
,
IsGridFunction
<
F
>
=
true
,
class
=
decltype
(
std
::
declval
<
F
>
().
name
()),
class
=
decltype
(
std
::
declval
<
F
>
().
numComponents
()),
class
=
decltype
(
std
::
declval
<
F
>
().
dataType
())
>
...
...
@@ -161,8 +152,7 @@ namespace Dune
Vtk
::
RangeTypes
::
UNSPECIFIED
,
fct
.
dataType
())
{}
/// (7) Construct from legacy VTKFunction
/// (8) Construct from legacy VTKFunction
/**
* \param fct The Dune::VTKFunction to wrap
**/
...
...
@@ -175,7 +165,7 @@ namespace Dune
setRangeType
(
rangeTypeOf
(
fct
->
ncomps
()));
}
/// (
8
) Default constructor. After construction, the function is an an invalid state.
/// (
9
) Default constructor. After construction, the function is an an invalid state.
Function
()
=
default
;
/// Create a LocalFunction
...
...
dune/vtk/utility/concepts.hh
View file @
9a772702
...
...
@@ -26,5 +26,17 @@ namespace Dune
CheckTypes
<
typename
GV
::
Grid
,
typename
GV
::
IndexSet
>
{},
true
));
template
<
class
GridFunction
,
class
GF
=
std
::
decay_t
<
GridFunction
>
>
using
IsGridFunction
=
decltype
((
localFunction
(
std
::
declval
<
GF
const
&>
()),
true
));
template
<
class
LocalFunction
,
class
LocalContext
,
class
LF
=
std
::
decay_t
<
LocalFunction
>
>
using
IsLocalFunction
=
decltype
((
std
::
declval
<
LF
&>
().
bind
(
std
::
declval
<
LocalContext
>
()),
std
::
declval
<
LF
&>
().
unbind
(),
std
::
declval
<
LF
>
()(
std
::
declval
<
typename
LocalContext
::
Geometry
::
LocalCoordinate
>
()),
true
));
}
// end namespace Vtk
}
// end namespace Dune
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