Skip to content
GitLab
Menu
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
12eebf7a
Commit
12eebf7a
authored
Aug 24, 2018
by
Praetorius, Simon
Browse files
restructuring of structureddatacollector
parent
45d5d9a8
Changes
6
Show whitespace changes
Inline
Side-by-side
dune/vtk/datacollectors/spdatacollector.hh
View file @
12eebf7a
...
...
@@ -97,6 +97,14 @@ private:
std
::
vector
<
std
::
size_t
>
indexMap_
;
};
#endif
namespace
Impl
{
template
<
class
GridView
,
class
ct
,
int
dim
,
template
<
int
>
class
Ref
,
class
Comm
>
struct
StructuredDataCollector
<
GridView
,
SPGrid
<
ct
,
dim
,
Ref
,
Comm
>>
{
using
type
=
SPDataCollector
<
GridView
>
;
};
}
#endif // HAVE_DUNE_SPGRID
}}
// end namespace Dune::experimental
dune/vtk/datacollectors/structureddatacollector.hh
View file @
12eebf7a
...
...
@@ -4,6 +4,19 @@
namespace
Dune
{
namespace
experimental
{
namespace
Impl
{
// Should be specialized for concrete structured grid
template
<
class
GridView
,
class
Grid
>
struct
StructuredDataCollector
;
}
template
<
class
GridView
>
using
StructuredDataCollector
=
typename
Impl
::
StructuredDataCollector
<
GridView
,
typename
GridView
::
Grid
>::
type
;
/// The Interface for structured data-collectors
template
<
class
GridView
,
class
Derived
>
class
StructuredDataCollectorInterface
:
public
DataCollectorInterface
<
GridView
,
Derived
>
...
...
dune/vtk/datacollectors/yaspdatacollector.hh
View file @
12eebf7a
...
...
@@ -121,4 +121,13 @@ private:
int
level_
;
};
namespace
Impl
{
template
<
class
GridView
,
int
dim
,
class
Coordinates
>
struct
StructuredDataCollector
<
GridView
,
YaspGrid
<
dim
,
Coordinates
>>
{
using
type
=
YaspDataCollector
<
GridView
>
;
};
}
}}
// end namespace Dune::experimental
dune/vtk/vtkimagedatawriter.hh
View file @
12eebf7a
...
...
@@ -14,7 +14,7 @@
namespace
Dune
{
namespace
experimental
{
/// File-Writer for VTK .vtu files
template
<
class
GridView
,
class
DataCollector
>
template
<
class
GridView
,
class
DataCollector
=
StructuredDataCollector
<
GridView
>
>
class
VtkImageDataWriter
:
public
VtkWriter
<
GridView
,
DataCollector
>
{
...
...
dune/vtk/vtkstructuredgridwriter.hh
View file @
12eebf7a
...
...
@@ -9,11 +9,12 @@
#include
"vtkfunction.hh"
#include
"vtktypes.hh"
#include
"vtkwriter.hh"
#include
"datacollectors/structureddatacollector.hh"
namespace
Dune
{
namespace
experimental
{
/// File-Writer for VTK .vtu files
template
<
class
GridView
,
class
DataCollector
>
template
<
class
GridView
,
class
DataCollector
=
StructuredDataCollector
<
GridView
>
>
class
VtkStructuredGridWriter
:
public
VtkWriter
<
GridView
,
DataCollector
>
{
...
...
src/structuredgridwriter.cc
View file @
12eebf7a
...
...
@@ -29,63 +29,26 @@ using namespace Dune;
using
namespace
Dune
::
experimental
;
using
namespace
Dune
::
Functions
;
namespace
Impl_
{
template
<
class
GridView
,
class
Grid
>
struct
StructuredDataCollector
;
#if HAVE_DUNE_SPGRID
template
<
class
GridView
,
class
ct
,
int
dim
,
template
<
int
>
class
Ref
,
class
Comm
>
struct
StructuredDataCollector
<
GridView
,
SPGrid
<
ct
,
dim
,
Ref
,
Comm
>>
{
using
type
=
SPDataCollector
<
GridView
>
;
};
#endif
template
<
class
GridView
,
int
dim
,
class
Coordinates
>
struct
StructuredDataCollector
<
GridView
,
YaspGrid
<
dim
,
Coordinates
>>
{
using
type
=
YaspDataCollector
<
GridView
>
;
};
}
template
<
class
GridView
>
using
StructuredDataCollector
=
typename
Impl_
::
StructuredDataCollector
<
GridView
,
typename
GridView
::
Grid
>::
type
;
template
<
int
dim
>
using
int_
=
std
::
integral_constant
<
int
,
dim
>
;
template
<
class
GridView
>
void
write
(
std
::
string
prefix
,
GridView
const
&
gridView
)
{
using
namespace
BasisFactory
;
auto
basis
=
makeBasis
(
gridView
,
lagrange
<
1
>
());
std
::
vector
<
double
>
p1function
(
basis
.
dimension
());
interpolate
(
basis
,
p1function
,
[](
auto
const
&
x
)
{
return
100
*
x
[
0
]
+
10
*
x
[
1
]
+
1
*
x
[
2
];
});
auto
fct1
=
makeDiscreteGlobalBasisFunction
<
double
>
(
basis
,
p1function
);
auto
fct2
=
makeAnalyticGridViewFunction
([](
auto
const
&
x
)
{
return
std
::
sin
(
10
*
x
[
0
])
*
std
::
cos
(
10
*
x
[
1
])
+
std
::
sin
(
10
*
x
[
2
]);
},
gridView
);
{
using
Writer
=
VtkStructuredGridWriter
<
GridView
,
StructuredDataCollector
<
GridView
>
>
;
using
Writer
=
VtkStructuredGridWriter
<
GridView
>
;
Writer
vtkWriter
(
gridView
);
vtkWriter
.
addPointData
(
fct1
,
"p1"
);
vtkWriter
.
addCellData
(
fct1
,
"p0"
);
vtkWriter
.
addPointData
(
fct2
,
"analytic"
);
vtkWriter
.
write
(
prefix
+
"sg_ascii_float32.vts"
,
Vtk
::
ASCII
);
}
{
using
Writer
=
VtkImageDataWriter
<
GridView
,
StructuredDataCollector
<
GridView
>
>
;
using
Writer
=
VtkImageDataWriter
<
GridView
>
;
Writer
vtkWriter
(
gridView
);
vtkWriter
.
addPointData
(
fct1
,
"p1"
);
vtkWriter
.
addCellData
(
fct1
,
"p0"
);
vtkWriter
.
addPointData
(
fct2
,
"analytic"
);
vtkWriter
.
write
(
prefix
+
"id_ascii_float32.vti"
,
Vtk
::
ASCII
);
}
...
...
@@ -98,6 +61,7 @@ void write_yaspgrid(std::integral_constant<int,dim>)
FieldVector
<
double
,
dim
>
upperRight
;
upperRight
=
1.0
;
auto
numElements
=
filledArray
<
dim
,
int
>
(
8
);
GridType
grid
(
upperRight
,
numElements
,
0
,
0
);
grid
.
globalRefine
(
1
);
write
(
"yasp_"
+
std
::
to_string
(
dim
)
+
"d_"
,
grid
.
leafGridView
());
}
...
...
@@ -110,6 +74,7 @@ void write_spgrid(std::integral_constant<int,dim>)
FieldVector
<
double
,
dim
>
upperRight
;
upperRight
=
1.0
;
auto
numElements
=
filledArray
<
dim
,
int
>
(
8
);
GridType
grid
(
SPDomain
<
double
,
dim
>::
unitCube
(),
numElements
);
grid
.
globalRefine
(
1
);
write
(
"sp_"
+
std
::
to_string
(
dim
)
+
"d_"
,
grid
.
leafGridView
());
#endif
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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