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
f88922d9
Commit
f88922d9
authored
Apr 16, 2020
by
Praetorius, Simon
Browse files
higher order vtk reader
parent
fb381494
Changes
29
Hide whitespace changes
Inline
Side-by-side
doc/triangles_2d_order3.vtu
0 → 100644
View file @
f88922d9
<VTKFile type="UnstructuredGrid" version="1.0" byte_order="LittleEndian" header_type="UInt64">
<UnstructuredGrid>
<Piece NumberOfPoints="49" NumberOfCells="8">
<PointData>
<DataArray type="Float32" Name="DistanceToCenter" format="ascii" RangeMin="0" RangeMax="1.4142135381698608">
1.4142135381698608 1 1.4142135381698608 1 0 1
1.4142135381698608 1 1.4142135381698608 1.201850414276123 1.054092526435852 1.201850414276123
0.9428090453147888 0.7453559637069702 0.6666666269302368 1.054092526435852 0.7453559637069702 0.471404492855072
0.3333333134651184 0.6666666269302368 0.3333333134651184 1.054092526435852 1.201850414276123 0.745356023311615
0.942808985710144 1.201850414276123 0.4714045226573944 0.7453559637069702 1.054092526435852 0.3333333730697632
0.6666666269302368 1.054092526435852 0.745356023311615 0.4714045226573944 0.3333333730697632 1.201850414276123
0.942808985710144 0.7453559637069702 0.6666666269302368 1.201850414276123 1.054092526435852 0.4714045822620392
0.7453559637069702 1.054092526435852 0.7453559637069702 0.942808985710144 1.201850414276123 1.054092526435852
1.201850414276123
</DataArray>
<DataArray type="Float32" Name="Polynomial" format="ascii" RangeMin="1" RangeMax="49">
1 4 15 4 10 26
15 26 49 1 1 1
1 1 4 1 1 1
4 4 4 5 8 5
8 16 6 10 18 11
15 5 5 6 11 8
8 10 15 16 18 14
19 29 19 25 36 29
36
</DataArray>
</PointData>
<CellData>
</CellData>
<Points>
<DataArray type="Float32" Name="Points" NumberOfComponents="3" format="ascii" RangeMin="0" RangeMax="2.8284271247461903">
0 0 0 1 0 0
2 0 0 0 1 0
1 1 0 2 1 0
0 2 0 1 2 0
2 2 0 0.3333333432674408 0 0
0.6666666865348816 0 0 0 0.3333333432674408 0
0.3333333432674408 0.3333333432674408 0 0.6666666865348816 0.3333333432674408 0
1 0.3333333432674408 0 0 0.6666666865348816 0
0.3333333432674408 0.6666666865348816 0 0.6666666865348816 0.6666666865348816 0
1 0.6666666865348816 0 0.3333333432674408 1 0
0.6666666865348816 1 0 1.3333333730697632 0 0
1.6666666269302368 0 0 1.3333333730697632 0.3333333432674408 0
1.6666666269302368 0.3333333432674408 0 2 0.3333333432674408 0
1.3333333730697632 0.6666666865348816 0 1.6666666269302368 0.6666666865348816 0
2 0.6666666865348816 0 1.3333333730697632 1 0
1.6666666269302368 1 0 0 1.3333333730697632 0
0.3333333432674408 1.3333333730697632 0 0.6666666865348816 1.3333333730697632 0
1 1.3333333730697632 0 0 1.6666666269302368 0
0.3333333432674408 1.6666666269302368 0 0.6666666865348816 1.6666666269302368 0
1 1.6666666269302368 0 0.3333333432674408 2 0
0.6666666865348816 2 0 1.3333333730697632 1.3333333730697632 0
1.6666666269302368 1.3333333730697632 0 2 1.3333333730697632 0
1.3333333730697632 1.6666666269302368 0 1.6666666269302368 1.6666666269302368 0
2 1.6666666269302368 0 1.3333333730697632 2 0
1.6666666269302368 2 0
<InformationKey name="L2_NORM_FINITE_RANGE" location="vtkDataArray" length="2">
<Value index="0">
0
</Value>
<Value index="1">
2.8284271247
</Value>
</InformationKey>
<InformationKey name="L2_NORM_RANGE" location="vtkDataArray" length="2">
<Value index="0">
0
</Value>
<Value index="1">
2.8284271247
</Value>
</InformationKey>
</DataArray>
</Points>
<Cells>
<DataArray type="Int64" Name="connectivity" format="ascii" RangeMin="0" RangeMax="48">
0 1 3 9 10 13
16 15 11 12 4 3
1 20 19 16 13 14
18 17 1 2 4 21
22 24 26 18 14 23
5 4 2 30 29 26
24 25 28 27 3 4
6 19 20 33 36 35
31 32 7 6 4 40
39 36 33 34 38 37
4 5 7 29 30 42
44 38 34 41 8 7
5 48 47 44 42 43
46 45
</DataArray>
<DataArray type="Int64" Name="offsets" format="ascii" RangeMin="10" RangeMax="80">
10 20 30 40 50 60
70 80
</DataArray>
<DataArray type="UInt8" Name="types" format="ascii" RangeMin="69" RangeMax="69">
69 69 69 69 69 69
69 69
</DataArray>
</Cells>
</Piece>
</UnstructuredGrid>
</VTKFile>
doc/triangles_3d_order3.vtu
0 → 100644
View file @
f88922d9
<VTKFile type="UnstructuredGrid" version="1.0" byte_order="LittleEndian" header_type="UInt64">
<UnstructuredGrid>
<Piece NumberOfPoints="49" NumberOfCells="8">
<PointData Vectors="Result">
<DataArray type="Float32" Name="DistanceToCenter" format="ascii" RangeMin="0" RangeMax="1.4142135381698608">
1.4142135381698608 1 1.4142135381698608 1 0 1
1.4142135381698608 1 1.4142135381698608 1.201850414276123 1.054092526435852 1.201850414276123
0.9428090453147888 0.7453559637069702 0.6666666269302368 1.054092526435852 0.7453559637069702 0.471404492855072
0.3333333134651184 0.6666666269302368 0.3333333134651184 1.054092526435852 1.201850414276123 0.745356023311615
0.942808985710144 1.201850414276123 0.4714045226573944 0.7453559637069702 1.054092526435852 0.3333333730697632
0.6666666269302368 1.054092526435852 0.745356023311615 0.4714045226573944 0.3333333730697632 1.201850414276123
0.942808985710144 0.7453559637069702 0.6666666269302368 1.201850414276123 1.054092526435852 0.4714045822620392
0.7453559637069702 1.054092526435852 0.7453559637069702 0.942808985710144 1.201850414276123 1.054092526435852
1.201850414276123
</DataArray>
<DataArray type="Float32" Name="Polynomial" format="ascii" RangeMin="1" RangeMax="49">
1 4 15 4 10 26
15 26 49 1 1 1
1 1 4 1 1 1
4 4 4 5 8 5
8 16 6 10 18 11
15 5 5 6 11 8
8 10 15 16 18 14
19 29 19 25 36 29
36
</DataArray>
<DataArray type="Float64" Name="Result" NumberOfComponents="3" format="ascii" RangeMin="0.08895213036368632" RangeMax="1.9954079615554763">
0 0 1 0 0 1.8414709848078965
0 0 1.9092974268256817 0 0 0.5403023058681398
0 0 1.3817732906760363 0 0 1.4495997326938215
0 0 -0.4161468365471424 0 0 0.4253241482607541
0 0 0.4931505902785393 0 0 1.3271947061834561
0 0 1.618369818683914 0 0 0.9449569430643503
0 0 1.2721516492478064 0 0 1.5633267617482642
0 0 1.7864279278722468 0 0 0.7858872484910437
0 0 1.1130819546744999 0 0 1.4042570671749577
0 0 1.6273582332989402 0 0 0.8674970120515959
0 0 1.1586721245520537 0 0 1.9719379107108135
0 0 1.9954079615554763 0 0 1.9168948537751636
0 0 1.9403649046198266 0 0 1.854254369890032
0 0 1.757825159201857 0 0 1.78129521004652
0 0 1.6951846753167255 0 0 1.5122402165789532
0 0 1.535710267423616 0 0 0.23523753468164693
0 0 0.562432240865103 0 0 0.8536073533655608
0 0 1.0767085194895434 0 0 -0.09572350846041702
0 0 0.23147119772303906 0 0 0.522646310223497
0 0 0.7457474763474795 0 0 -0.08895213036368632
0 0 0.20222298213677153 0 0 1.2071754453924604
0 0 1.2306454962371232 0 0 1.1445349615073286
0 0 0.8762144022503964 0 0 0.8996844530950593
0 0 0.8135739183652647 0 0 0.5557910741636709
0 0 0.5792611250083339
<InformationKey name="L2_NORM_RANGE" location="vtkDataArray" length="2">
<Value index="0">
0.088952130364
</Value>
<Value index="1">
1.9954079616
</Value>
</InformationKey>
<InformationKey name="L2_NORM_FINITE_RANGE" location="vtkDataArray" length="2">
<Value index="0">
0.088952130364
</Value>
<Value index="1">
1.9954079616
</Value>
</InformationKey>
</DataArray>
</PointData>
<CellData>
</CellData>
<Points>
<DataArray type="Float32" Name="Points" NumberOfComponents="3" format="ascii" RangeMin="1" RangeMax="2.871096916901671">
0 0 1 1 0 1.8414709568023682
2 0 1.9092974662780762 0 1 0.5403022766113281
1 1 1.3817732334136963 2 1 1.4495997428894043
0 2 -0.416146844625473 1 2 0.42532414197921753
2 2 0.49315059185028076 0.3333333432674408 0 1.3271946907043457
0.6666666865348816 0 1.6183698177337646 0 0.3333333432674408 0.9449569582939148
0.3333333432674408 0.3333333432674408 1.2721517086029053 0.6666666865348816 0.3333333432674408 1.5633267164230347
1 0.3333333432674408 1.7864279747009277 0 0.6666666865348816 0.7858872413635254
0.3333333432674408 0.6666666865348816 1.113081932067871 0.6666666865348816 0.6666666865348816 1.40425705909729
1 0.6666666865348816 1.6273581981658936 0.3333333432674408 1 0.8674970269203186
0.6666666865348816 1 1.1586720943450928 1.3333333730697632 0 1.971937894821167
1.6666666269302368 0 1.9954079389572144 1.3333333730697632 0.3333333432674408 1.9168949127197266
1.6666666269302368 0.3333333432674408 1.940364956855774 2 0.3333333432674408 1.8542543649673462
1.3333333730697632 0.6666666865348816 1.7578251361846924 1.6666666269302368 0.6666666865348816 1.7812951803207397
2 0.6666666865348816 1.6951847076416016 1.3333333730697632 1 1.5122401714324951
1.6666666269302368 1 1.5357102155685425 0 1.3333333730697632 0.23523753881454468
0.3333333432674408 1.3333333730697632 0.5624322295188904 0.6666666865348816 1.3333333730697632 0.8536073565483093
1 1.3333333730697632 1.0767085552215576 0 1.6666666269302368 -0.09572350978851318
0.3333333432674408 1.6666666269302368 0.2314711958169937 0.6666666865348816 1.6666666269302368 0.5226463079452515
1 1.6666666269302368 0.745747447013855 0.3333333432674408 2 -0.08895213156938553
0.6666666865348816 2 0.20222298800945282 1.3333333730697632 1.3333333730697632 1.2071754932403564
1.6666666269302368 1.3333333730697632 1.2306455373764038 2 1.3333333730697632 1.144534945487976
1.3333333730697632 1.6666666269302368 0.8762143850326538 1.6666666269302368 1.6666666269302368 0.8996844291687012
2 1.6666666269302368 0.8135738968849182 1.3333333730697632 2 0.5557910799980164
1.6666666269302368 2 0.5792611241340637
<InformationKey name="L2_NORM_FINITE_RANGE" location="vtkDataArray" length="2">
<Value index="0">
1
</Value>
<Value index="1">
2.8710969169
</Value>
</InformationKey>
<InformationKey name="L2_NORM_RANGE" location="vtkDataArray" length="2">
<Value index="0">
1
</Value>
<Value index="1">
2.8710969169
</Value>
</InformationKey>
</DataArray>
</Points>
<Cells>
<DataArray type="Int64" Name="connectivity" format="ascii" RangeMin="0" RangeMax="48">
0 1 3 9 10 13 16 15 11 12
4 3 1 20 19 16 13 14 18 17
1 2 4 21 22 24 26 18 14 23
5 4 2 30 29 26 24 25 28 27
3 4 6 19 20 33 36 35 31 32
7 6 4 40 39 36 33 34 38 37
4 5 7 29 30 42 44 38 34 41
8 7 5 48 47 44 42 43 46 45
</DataArray>
<DataArray type="Int64" Name="offsets" format="ascii" RangeMin="10" RangeMax="80">
10 20 30 40 50 60
70 80
</DataArray>
<DataArray type="UInt8" Name="types" format="ascii" RangeMin="69" RangeMax="69">
69 69 69 69 69 69
69 69
</DataArray>
</Cells>
</Piece>
</UnstructuredGrid>
</VTKFile>
dune.module
View file @
f88922d9
...
...
@@ -8,4 +8,4 @@ Version: 0.2
Maintainer
:
simon
.
praetorius
@
tu
-
dresden
.
de
#depending on
Depends
:
dune
-
common
(
>=
2.6
)
dune
-
geometry
(
>=
2.6
)
dune
-
grid
dune
-
uggrid
Suggests
:
dune
-
functions
dune
-
spgrid
dune
-
polygongrid
dune
-
alugrid
Suggests
:
dune
-
functions
dune
-
spgrid
dune
-
polygongrid
dune
-
alugrid
dune
-
foamgrid
dune/vtk/datacollectors/CMakeLists.txt
View file @
f88922d9
...
...
@@ -8,3 +8,5 @@ install(FILES
unstructureddatacollector.hh
yaspdatacollector.hh
DESTINATION
${
CMAKE_INSTALL_INCLUDEDIR
}
/dune/vtkwriter/datacollectors
)
add_subdirectory
(
test
)
\ No newline at end of file
dune/vtk/datacollectors/lagrangedatacollector.hh
0 → 100644
View file @
f88922d9
#pragma once
#include
<cassert>
#include
<map>
#include
<vector>
#include
<dune/geometry/referenceelements.hh>
#include
<dune/grid/common/partitionset.hh>
#include
<dune/vtk/forward.hh>
#include
<dune/vtk/vtktypes.hh>
#include
<dune/vtk/utility/lagrangepoints.hh>
#include
"unstructureddatacollector.hh"
namespace
Dune
{
/// Implementation of \ref DataCollector for lagrange cells
template
<
class
GridView
,
int
ORDER
=
-
1
>
class
LagrangeDataCollector
:
public
UnstructuredDataCollectorInterface
<
GridView
,
LagrangeDataCollector
<
GridView
,
ORDER
>
,
Partitions
::
All
>
{
using
Self
=
LagrangeDataCollector
;
using
Super
=
UnstructuredDataCollectorInterface
<
GridView
,
Self
,
Partitions
::
All
>
;
public:
static_assert
(
ORDER
!=
0
,
"Order 0 not supported"
);
using
Super
::
dim
;
using
Super
::
partition
;
// NOTE: lagrange data-collector currently implemented for the All partition only
public:
LagrangeDataCollector
(
GridView
const
&
gridView
,
int
order
=
(
ORDER
<
0
?
2
:
ORDER
))
:
Super
(
gridView
)
,
order_
(
order
)
{
assert
(
order
>
0
&&
"Order 0 not supported"
);
assert
(
ORDER
<
0
||
order
==
ORDER
);
}
/// Construct the point sets
void
updateImpl
()
{
auto
const
&
indexSet
=
gridView_
.
indexSet
();
pointSets_
.
clear
();
for
(
auto
gt
:
indexSet
.
types
(
0
))
pointSets_
.
emplace
(
gt
,
order_
);
for
(
auto
&
pointSet
:
pointSets_
)
pointSet
.
second
.
build
(
pointSet
.
first
);
numPoints_
=
indexSet
.
size
(
dim
);
for
(
auto
const
&
pointSet
:
pointSets_
)
{
auto
gt
=
pointSet
.
first
;
auto
refElem
=
referenceElement
<
double
,
dim
>
(
gt
);
numPoints_
+=
(
pointSet
.
second
.
size
()
-
refElem
.
size
(
dim
))
*
indexSet
.
size
(
gt
);
}
}
/// Return number of lagrange nodes
std
::
uint64_t
numPointsImpl
()
const
{
return
numPoints_
;
}
/// Return a vector of point coordinates.
/**
* The vector of point coordinates is composed of vertex coordinates first and second
* edge center coordinates.
**/
template
<
class
T
>
std
::
vector
<
T
>
pointsImpl
()
const
{
std
::
vector
<
T
>
data
(
this
->
numPoints
()
*
3
);
auto
const
&
indexSet
=
gridView_
.
indexSet
();
std
::
size_t
shift
=
indexSet
.
size
(
dim
);
for
(
auto
const
&
element
:
elements
(
gridView_
,
partition
))
{
auto
geometry
=
element
.
geometry
();
auto
refElem
=
referenceElement
<
T
,
dim
>
(
element
.
type
());
auto
const
&
pointSet
=
pointSets_
.
at
(
element
.
type
());
unsigned
int
vertexDOFs
=
refElem
.
size
(
dim
);
unsigned
int
innerDOFs
=
pointSet
.
size
()
-
vertexDOFs
;
for
(
std
::
size_t
i
=
0
;
i
<
pointSet
.
size
();
++
i
)
{
auto
const
&
p
=
pointSet
[
i
];
if
(
i
<
vertexDOFs
)
assert
(
p
.
localKey
().
codim
()
==
dim
);
auto
const
&
localKey
=
p
.
localKey
();
std
::
size_t
idx
=
3
*
(
localKey
.
codim
()
==
dim
?
indexSet
.
subIndex
(
element
,
localKey
.
subEntity
(),
dim
)
:
innerDOFs
*
indexSet
.
index
(
element
)
+
(
i
-
vertexDOFs
)
+
shift
);
auto
v
=
geometry
.
global
(
p
.
point
());
for
(
std
::
size_t
j
=
0
;
j
<
v
.
size
();
++
j
)
data
[
idx
+
j
]
=
T
(
v
[
j
]);
for
(
std
::
size_t
j
=
v
.
size
();
j
<
3u
;
++
j
)
data
[
idx
+
j
]
=
T
(
0
);
}
}
return
data
;
}
/// Return number of grid cells
std
::
uint64_t
numCellsImpl
()
const
{
return
gridView_
.
size
(
0
);
}
/// \brief Return cell types, offsets, and connectivity. \see Cells
/**
* The cell connectivity is composed of cell vertices first and second cell edges,
* where the indices are grouped [vertex-indices..., (#vertices)+edge-indices...]
**/
Cells
cellsImpl
()
const
{
Cells
cells
;
cells
.
connectivity
.
reserve
(
this
->
numPoints
());
cells
.
offsets
.
reserve
(
this
->
numCells
());
cells
.
types
.
reserve
(
this
->
numCells
());
auto
const
&
indexSet
=
gridView_
.
indexSet
();
std
::
size_t
shift
=
indexSet
.
size
(
dim
);
std
::
int64_t
old_o
=
0
;
for
(
auto
const
&
element
:
elements
(
gridView_
,
partition
))
{
auto
refElem
=
referenceElement
<
double
,
dim
>
(
element
.
type
());
Vtk
::
CellType
cellType
(
element
.
type
(),
Vtk
::
LAGRANGE
);
auto
const
&
pointSet
=
pointSets_
.
at
(
element
.
type
());
unsigned
int
vertexDOFs
=
refElem
.
size
(
dim
);
unsigned
int
innerDOFs
=
pointSet
.
size
()
-
vertexDOFs
;
for
(
std
::
size_t
i
=
0
;
i
<
pointSet
.
size
();
++
i
)
{
auto
const
&
p
=
pointSet
[
i
];
auto
const
&
localKey
=
p
.
localKey
();
std
::
size_t
idx
=
(
localKey
.
codim
()
==
dim
?
indexSet
.
subIndex
(
element
,
localKey
.
subEntity
(),
dim
)
:
innerDOFs
*
indexSet
.
index
(
element
)
+
(
i
-
vertexDOFs
)
+
shift
);
cells
.
connectivity
.
push_back
(
idx
);
}
cells
.
offsets
.
push_back
(
old_o
+=
pointSet
.
size
());
cells
.
types
.
push_back
(
cellType
.
type
());
}
return
cells
;
}
/// Evaluate the `fct` at element vertices and edge centers in the same order as the point coords.
template
<
class
T
,
class
GlobalFunction
>
std
::
vector
<
T
>
pointDataImpl
(
GlobalFunction
const
&
fct
)
const
{
int
nComps
=
fct
.
ncomps
();
std
::
vector
<
T
>
data
(
this
->
numPoints
()
*
nComps
);
auto
const
&
indexSet
=
gridView_
.
indexSet
();
std
::
size_t
shift
=
indexSet
.
size
(
dim
);
auto
localFct
=
localFunction
(
fct
);
for
(
auto
const
&
element
:
elements
(
gridView_
,
partition
))
{
localFct
.
bind
(
element
);
auto
refElem
=
referenceElement
<
T
,
dim
>
(
element
.
type
());
auto
const
&
pointSet
=
pointSets_
.
at
(
element
.
type
());
unsigned
int
vertexDOFs
=
refElem
.
size
(
dim
);
unsigned
int
innerDOFs
=
pointSet
.
size
()
-
vertexDOFs
;
for
(
std
::
size_t
i
=
0
;
i
<
pointSet
.
size
();
++
i
)
{
auto
const
&
p
=
pointSet
[
i
];
auto
const
&
localKey
=
p
.
localKey
();
std
::
size_t
idx
=
nComps
*
(
localKey
.
codim
()
==
dim
?
indexSet
.
subIndex
(
element
,
localKey
.
subEntity
(),
dim
)
:
innerDOFs
*
indexSet
.
index
(
element
)
+
(
i
-
vertexDOFs
)
+
shift
);
for
(
int
comp
=
0
;
comp
<
nComps
;
++
comp
)
data
[
idx
+
comp
]
=
T
(
localFct
.
evaluate
(
comp
,
p
.
point
()));
}
localFct
.
unbind
();
}
return
data
;
}
protected:
using
Super
::
gridView_
;
unsigned
int
order_
;
std
::
uint64_t
numPoints_
=
0
;
using
PointSet
=
VtkLagrangePointSet
<
typename
GridView
::
ctype
,
GridView
::
dimension
>
;
std
::
map
<
GeometryType
,
PointSet
>
pointSets_
;
};
}
// end namespace Dune
dune/vtk/datacollectors/test/CMakeLists.txt
0 → 100644
View file @
f88922d9
dune_add_test
(
SOURCES test-lagrangedatacollector.cc
LINK_LIBRARIES dunevtk
)
\ No newline at end of file
dune/vtk/datacollectors/test/test-lagrangedatacollector.cc
0 → 100644
View file @
f88922d9
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifdef HAVE_CONFIG_H
#include
"config.h"
#endif
#include
<dune/common/hybridutilities.hh>
#include
<dune/common/rangeutilities.hh>
#include
<dune/common/test/testsuite.hh>
#include
<dune/grid/yaspgrid.hh>
#if HAVE_UG
#include
<dune/grid/uggrid.hh>
#endif
#include
<dune/vtk/datacollectors/continuousdatacollector.hh>
#include
<dune/vtk/datacollectors/lagrangedatacollector.hh>
/**
* This test compares LagrangeDataCollector<1> against the ContinuousDataCollector, thus
* just compares the linear order implementations
**/
template
<
class
DataCollector1
,
class
DataCollector2
>
void
testDataCollector
(
std
::
string
prefix
,
Dune
::
TestSuite
&
testSuite
,
DataCollector1
&
dataCollector1
,
DataCollector2
&
dataCollector2
)
{
using
std
::
sqrt
;
auto
tol
=
sqrt
(
std
::
numeric_limits
<
double
>::
epsilon
());
dataCollector1
.
update
();
dataCollector2
.
update
();
// check that number of points and cells are equal
testSuite
.
check
(
dataCollector1
.
numPoints
()
==
dataCollector2
.
numPoints
(),
prefix
+
"_numPoints"
);
testSuite
.
check
(
dataCollector1
.
numCells
()
==
dataCollector2
.
numCells
(),
prefix
+
"_numCells"
);
auto
points1
=
dataCollector1
.
template
points
<
double
>();
auto
points2
=
dataCollector2
.
template
points
<
double
>();
// check that point sizes are equal
testSuite
.
check
(
points1
.
size
()
==
points2
.
size
(),
prefix
+
"_points.size"
);
testSuite
.
check
(
points1
.
size
()
==
3
*
dataCollector1
.
numPoints
(),
prefix
+
"_points.size/3"
);
// check that point coordinates are equal
using
std
::
abs
;
for
(
std
::
size_t
i
=
0
;
i
<
points1
.
size
();
++
i
)
testSuite
.
check
(
abs
(
points1
[
i
]
-
points2
[
i
])
<
tol
,
prefix
+
"_points["
+
std
::
to_string
(
i
)
+
"]"
);
auto
cells1
=
dataCollector1
.
cells
();
auto
cells2
=
dataCollector2
.
cells
();
// check that cell sizes are equal
testSuite
.
check
(
cells1
.
types
.
size
()
==
cells2
.
types
.
size
(),
prefix
+
"_cells.types.size"
);
testSuite
.
check
(
cells1
.
offsets
.
size
()
==
cells2
.
offsets
.
size
(),
prefix
+
"_cells.offsets.size"
);
testSuite
.
check
(
cells1
.
connectivity
.
size
()
==
cells2
.
connectivity
.
size
(),
prefix
+
"_cells.connectivity.size"
);
// NOTE: cells.types do not need to be equal, e.g. LINEAR != LAGRANGE_LINEAR
// check that offsets are equal
for
(
std
::
size_t
i
=
0
;
i
<
cells1
.
offsets
.
size
();
++
i
)
testSuite
.
check
(
cells1
.
offsets
[
i
]
==
cells2
.
offsets
[
i
],
prefix
+
"_cells.offsets["
+
std
::
to_string
(
i
)
+
"]"
);
// check that connectivities are equal
for
(
std
::
size_t
i
=
0
;
i
<
cells1
.
connectivity
.
size
();
++
i
)
testSuite
.
check
(
cells1
.
connectivity
[
i
]
==
cells2
.
connectivity
[
i
],
prefix
+
"_cells.connectivity["
+
std
::
to_string
(
i
)
+
"]"
);
}
template
<
class
GridView
>
void
testGridView
(
std
::
string
prefix
,
Dune
::
TestSuite
&
testSuite
,
GridView
const
&
gridView
)
{
// 1. test linear order lagrange data-collector
{
Dune
::
ContinuousDataCollector
<
GridView
>
linearDataCollector
(
gridView
);
// data collector with template order
Dune
::
LagrangeDataCollector
<
GridView
,
1
>
lagrangeDataCollector1a
(
gridView
);
testDataCollector
(
prefix
+
"_linear_template"
,
testSuite
,
lagrangeDataCollector1a
,
linearDataCollector
);
// data collector with runtime order
Dune
::
LagrangeDataCollector
<
GridView
>
lagrangeDataCollector1b
(
gridView
,
1
);
testDataCollector
(
prefix
+
"_linear_runtime"
,
testSuite
,
lagrangeDataCollector1b
,
linearDataCollector
);
}
}
template
<
class
Grid
>
void
testGrid
(
std
::
string
prefix
,
Dune
::
TestSuite
&
testSuite
,
Grid
&
grid
)
{
grid
.
globalRefine
(
1
);
testGridView
(
prefix
+
"_level0"
,
testSuite
,
grid
.
levelGridView
(
0
));
testGridView
(
prefix
+
"_leaf"
,
testSuite
,
grid
.
leafGridView
());
}
int
main
(
int
argc
,
char
**
argv
)
{
using
namespace
Dune
;
MPIHelper
::
instance
(
argc
,
argv
);
TestSuite
testSuite
;
YaspGrid
<
1
>
yaspGrid1
({
1.0
},
{
1
});
YaspGrid
<
2
>
yaspGrid2
({
1.0
,
1.0
},
{
1
,
1
});
YaspGrid
<
3
>
yaspGrid3
({
1.0
,
1.0
,
1.0
},
{
1
,
1
,
1
});
testGrid
(
"yaspgrid_1d"
,
testSuite
,
yaspGrid1
);
testGrid
(
"yaspgrid_2d"
,
testSuite
,
yaspGrid2
);
testGrid
(
"yaspgrid_3d"
,
testSuite
,
yaspGrid3
);
#if HAVE_UG
auto
ugGrid2
=
StructuredGridFactory
<
UGGrid
<
2
>>::
createSimplexGrid
({
0.0
,
0.0
},
{
1.0
,
1.0
},
{
1u
,
1u
});
auto
ugGrid3
=
StructuredGridFactory
<
UGGrid
<
3
>>::
createSimplexGrid
({
0.0
,
0.0
,
0.0
},
{
1.0
,
1.0
,
1.0
},
{
1u
,
1u
,
1u
});
testGrid
(
"uggrid_2d"
,
testSuite
,
*
ugGrid2
);
testGrid
(
"uggrid_3d"
,
testSuite
,
*
ugGrid3
);
#endif
return
testSuite
.
exit
();
}
dune/vtk/forward.hh
View file @
f88922d9
...
...
@@ -65,6 +65,9 @@ namespace Dune
template
<
class
Grid
>
struct
SerialGridCreator
;
template
<
class
Grid
>
class
LagrangeGridCreator
;
// @} gridcreators
...
...
dune/vtk/gridcreatorinterface.hh
View file @
f88922d9
...
...
@@ -17,15 +17,17 @@ namespace Dune
/**
* Construct a grid from data read from VTK files.
*
* \tparam GridView Model of Dune::GridView
* \tparam Derived Implementation of a concrete GridCreator.
* \tparam GridType Model of Dune::Grid
* \tparam GlobalCoordType Type of the global coordinates.
* \tparam DerivedType Implementation of a concrete GridCreator.
**/
template
<
class
G
,
class
Derived
>
template
<
class
G
ridType
,
class
Derived
Type
>
class
GridCreatorInterface
{
public: