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
5ada89c6
Commit
5ada89c6
authored
Sep 01, 2018
by
Praetorius, Simon
Browse files
examples cleaned up
parent
7a7c7a21
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/datacollector.cc
View file @
5ada89c6
...
...
@@ -38,7 +38,7 @@ void write_dc (std::string prefix, GridView const& gridView, Fct1 const& fct1, F
vtkWriter
.
addPointData
(
fct2
,
"q1"
);
vtkWriter
.
addCellData
(
fct2
,
"q0"
);
vtkWriter
.
write
(
prefix
+
"_"
+
std
::
to_string
(
GridView
::
dimension
)
+
"d_ascii.vtu"
);
vtkWriter
.
write
(
prefix
+
"_"
+
std
::
to_string
(
GridView
::
dimension
world
)
+
"d_ascii.vtu"
);
}
template
<
class
GridView
>
...
...
@@ -47,10 +47,10 @@ void write (std::string prefix, GridView const& gridView)
using
namespace
BasisFactory
;
auto
basis
=
makeBasis
(
gridView
,
lagrange
<
1
>
());
FieldVector
<
double
,
GridView
::
dimension
>
c
;
if
(
GridView
::
dimension
>
0
)
c
[
0
]
=
11.0
;
if
(
GridView
::
dimension
>
1
)
c
[
1
]
=
7.0
;
if
(
GridView
::
dimension
>
2
)
c
[
2
]
=
3.0
;
FieldVector
<
double
,
GridView
::
dimension
world
>
c
;
if
(
GridView
::
dimension
world
>
0
)
c
[
0
]
=
11.0
;
if
(
GridView
::
dimension
world
>
1
)
c
[
1
]
=
7.0
;
if
(
GridView
::
dimension
world
>
2
)
c
[
2
]
=
3.0
;
std
::
vector
<
double
>
vec
(
basis
.
dimension
());
interpolate
(
basis
,
vec
,
[
&
c
](
auto
const
&
x
)
{
return
c
.
dot
(
x
);
});
...
...
@@ -77,8 +77,8 @@ int main(int argc, char** argv)
{
using
GridType
=
YaspGrid
<
dim
.
value
>
;
FieldVector
<
double
,
dim
.
value
>
upperRight
;
upperRight
=
1.0
;
auto
numElements
=
filledArray
<
dim
.
value
,
int
>
(
4
);
GridType
grid
(
upperRight
,
numElements
);
auto
numElements
=
filledArray
<
dim
.
value
,
int
>
(
8
);
GridType
grid
(
upperRight
,
numElements
,
0
,
0
);
write
(
"yasp"
,
grid
.
leafGridView
());
});
}
src/geometrygrid.cc
View file @
5ada89c6
...
...
@@ -46,10 +46,10 @@ private:
template
<
class
GridView
>
void
write
(
std
::
string
prefix
,
GridView
const
&
gridView
)
{
FieldVector
<
double
,
GridView
::
dimension
>
c
;
if
(
GridView
::
dimension
>
0
)
c
[
0
]
=
11.0
;
if
(
GridView
::
dimension
>
1
)
c
[
1
]
=
7.0
;
if
(
GridView
::
dimension
>
2
)
c
[
2
]
=
3.0
;
FieldVector
<
double
,
GridView
::
dimension
world
>
c
;
if
(
GridView
::
dimension
world
>
0
)
c
[
0
]
=
11.0
;
if
(
GridView
::
dimension
world
>
1
)
c
[
1
]
=
7.0
;
if
(
GridView
::
dimension
world
>
2
)
c
[
2
]
=
3.0
;
auto
p1Analytic
=
makeAnalyticGridViewFunction
([
&
c
](
auto
const
&
x
)
{
return
c
.
dot
(
x
);
},
gridView
);
...
...
@@ -66,7 +66,7 @@ int main (int argc, char** argv)
using
HostGrid
=
YaspGrid
<
2
>
;
FieldVector
<
double
,
2
>
bbox
=
{
2.0
*
M_PI
,
2.0
*
M_PI
};
std
::
array
<
int
,
2
>
num
=
{
4
,
12
};
HostGrid
hostGrid
{
bbox
,
num
};
//, std::bitset<2>{"11"}};
HostGrid
hostGrid
{
bbox
,
num
,
0
,
0
};
//, std::bitset<2>{"11"}};
// grid build up of mapped coordinates
double
R
=
1.0
,
r
=
0.25
;
...
...
src/legacyvtkwriter.cc
View file @
5ada89c6
...
...
@@ -28,7 +28,7 @@ int main(int argc, char** argv)
using
GridType
=
YaspGrid
<
dim
>
;
FieldVector
<
double
,
dim
>
upperRight
;
upperRight
=
1.0
;
auto
numElements
=
filledArray
<
dim
,
int
>
(
8
);
GridType
grid
(
upperRight
,
numElements
);
GridType
grid
(
upperRight
,
numElements
,
0
,
0
);
using
GridView
=
typename
GridType
::
LeafGridView
;
GridView
gridView
=
grid
.
leafGridView
();
...
...
src/pvdwriter.cc
View file @
5ada89c6
...
...
@@ -30,10 +30,10 @@ void write (std::string prefix, GridView const& gridView)
using
namespace
BasisFactory
;
auto
basis
=
makeBasis
(
gridView
,
lagrange
<
1
>
());
FieldVector
<
double
,
GridView
::
dimension
>
c
;
if
(
GridView
::
dimension
>
0
)
c
[
0
]
=
11.0
;
if
(
GridView
::
dimension
>
1
)
c
[
1
]
=
7.0
;
if
(
GridView
::
dimension
>
2
)
c
[
2
]
=
3.0
;
FieldVector
<
double
,
GridView
::
dimension
world
>
c
;
if
(
GridView
::
dimension
world
>
0
)
c
[
0
]
=
11.0
;
if
(
GridView
::
dimension
world
>
1
)
c
[
1
]
=
7.0
;
if
(
GridView
::
dimension
world
>
2
)
c
[
2
]
=
3.0
;
// write analytic function
auto
p1Analytic
=
makeAnalyticGridViewFunction
([
&
c
](
auto
const
&
x
)
{
return
c
.
dot
(
x
);
},
gridView
);
...
...
@@ -44,7 +44,7 @@ void write (std::string prefix, GridView const& gridView)
pvdWriter
.
addPointData
(
p1Analytic
,
"p1"
);
pvdWriter
.
addCellData
(
p1Analytic
,
"p0"
);
for
(
double
t
=
0.0
;
t
<
10.0
;
t
+=
1.0
)
{
pvdWriter
.
write
(
t
,
prefix
+
"_"
+
std
::
to_string
(
GridView
::
dimension
)
+
"d_ascii.vtu"
);
pvdWriter
.
write
(
t
,
prefix
+
"_"
+
std
::
to_string
(
GridView
::
dimension
world
)
+
"d_ascii.vtu"
);
}
}
...
...
@@ -58,7 +58,7 @@ int main (int argc, char** argv)
// Test PvdWriter for YaspGrid
using
GridType
=
YaspGrid
<
2
>
;
FieldVector
<
double
,
2
>
upperRight
;
upperRight
=
1.0
;
auto
numElements
=
filledArray
<
2
,
int
>
(
4
);
GridType
grid
(
upperRight
,
numElements
);
auto
numElements
=
filledArray
<
2
,
int
>
(
8
);
GridType
grid
(
upperRight
,
numElements
,
0
,
0
);
write
(
"yasp"
,
grid
.
leafGridView
());
}
\ No newline at end of file
src/structuredgridwriter.cc
View file @
5ada89c6
...
...
@@ -36,10 +36,10 @@ using int_ = std::integral_constant<int,dim>;
template
<
class
GridView
>
void
write
(
std
::
string
prefix
,
GridView
const
&
gridView
)
{
FieldVector
<
double
,
GridView
::
dimension
>
c
;
if
(
GridView
::
dimension
>
0
)
c
[
0
]
=
11.0
;
if
(
GridView
::
dimension
>
1
)
c
[
1
]
=
7.0
;
if
(
GridView
::
dimension
>
2
)
c
[
2
]
=
3.0
;
FieldVector
<
double
,
GridView
::
dimension
world
>
c
;
if
(
GridView
::
dimension
world
>
0
)
c
[
0
]
=
11.0
;
if
(
GridView
::
dimension
world
>
1
)
c
[
1
]
=
7.0
;
if
(
GridView
::
dimension
world
>
2
)
c
[
2
]
=
3.0
;
auto
fct2
=
makeAnalyticGridViewFunction
([
&
c
](
auto
const
&
x
)
->
float
{
return
c
.
dot
(
x
);
},
gridView
);
...
...
@@ -77,7 +77,7 @@ void write_yaspgrid(std::integral_constant<int,dim>)
{
using
GridType
=
YaspGrid
<
dim
>
;
FieldVector
<
double
,
dim
>
upperRight
;
upperRight
=
1.0
;
auto
numElements
=
filledArray
<
dim
,
int
>
(
12
);
auto
numElements
=
filledArray
<
dim
,
int
>
(
8
);
GridType
grid
(
upperRight
,
numElements
,
0
,
0
);
grid
.
globalRefine
(
1
);
...
...
@@ -90,7 +90,7 @@ void write_spgrid(std::integral_constant<int,dim>)
#if HAVE_DUNE_SPGRID
using
GridType
=
SPGrid
<
double
,
dim
,
SPIsotropicRefinement
>
;
FieldVector
<
double
,
dim
>
upperRight
;
upperRight
=
1.0
;
auto
numElements
=
filledArray
<
dim
,
int
>
(
12
);
auto
numElements
=
filledArray
<
dim
,
int
>
(
8
);
GridType
grid
(
SPDomain
<
double
,
dim
>::
unitCube
(),
numElements
);
// grid.globalRefine(1);
...
...
src/timeserieswriter.cc
View file @
5ada89c6
...
...
@@ -24,14 +24,14 @@ using namespace Dune::Functions;
template
<
class
GridView
>
void
write
(
std
::
string
prefix
,
GridView
const
&
gridView
)
{
FieldVector
<
double
,
GridView
::
dimension
>
c
{
11.0
,
7.0
,
3.0
};
FieldVector
<
double
,
GridView
::
dimension
world
>
c
{
11.0
,
7.0
,
3.0
};
auto
p1Analytic
=
makeAnalyticGridViewFunction
([
&
c
](
auto
const
&
x
)
->
float
{
return
c
.
dot
(
x
);
},
gridView
);
using
Writer
=
VtkUnstructuredGridWriter
<
GridView
>
;
VtkTimeseriesWriter
<
Writer
>
seriesWriter
(
gridView
,
Vtk
::
BINARY
,
Vtk
::
FLOAT32
);
seriesWriter
.
addPointData
(
p1Analytic
,
"q1"
);
seriesWriter
.
addCellData
(
p1Analytic
,
"q0"
);
std
::
string
filename
=
prefix
+
"_"
+
std
::
to_string
(
GridView
::
dimension
)
+
"d_binary32.vtu"
;
std
::
string
filename
=
prefix
+
"_"
+
std
::
to_string
(
GridView
::
dimension
world
)
+
"d_binary32.vtu"
;
for
(
double
t
=
0.0
;
t
<
5
;
t
+=
0.5
)
{
seriesWriter
.
writeTimestep
(
t
,
filename
);
}
...
...
@@ -50,6 +50,6 @@ int main (int argc, char** argv)
using
GridType
=
YaspGrid
<
3
>
;
FieldVector
<
double
,
3
>
upperRight
;
upperRight
=
1.0
;
auto
numElements
=
filledArray
<
3
,
int
>
(
8
);
GridType
grid
(
upperRight
,
numElements
);
GridType
grid
(
upperRight
,
numElements
,
0
,
0
);
write
(
"yasp"
,
grid
.
leafGridView
());
}
\ No newline at end of file
src/vtkreader.cc
View file @
5ada89c6
...
...
@@ -31,7 +31,7 @@ int main(int argc, char** argv)
{
FieldVector
<
double
,
dim
>
lowerLeft
;
lowerLeft
=
0.0
;
FieldVector
<
double
,
dim
>
upperRight
;
upperRight
=
1.0
;
auto
numElements
=
filledArray
<
dim
,
unsigned
int
>
(
4
);
auto
numElements
=
filledArray
<
dim
,
unsigned
int
>
(
8
);
auto
gridPtr
=
StructuredGridFactory
<
GridType
>::
createSimplexGrid
(
lowerLeft
,
upperRight
,
numElements
);
auto
&
grid
=
*
gridPtr
;
...
...
src/vtkwriter.cc
View file @
5ada89c6
...
...
@@ -40,11 +40,12 @@ void write (std::string prefix, GridView const& gridView)
using
namespace
BasisFactory
;
auto
basis
=
makeBasis
(
gridView
,
lagrange
<
1
>
());
FieldVector
<
double
,
GridView
::
dimension
>
c
;
if
(
GridView
::
dimension
>
0
)
c
[
0
]
=
11.0
;
if
(
GridView
::
dimension
>
1
)
c
[
1
]
=
7.0
;
if
(
GridView
::
dimension
>
2
)
c
[
2
]
=
3.0
;
FieldVector
<
double
,
GridView
::
dimension
world
>
c
;
if
(
GridView
::
dimension
world
>
0
)
c
[
0
]
=
11.0
;
if
(
GridView
::
dimension
world
>
1
)
c
[
1
]
=
7.0
;
if
(
GridView
::
dimension
world
>
2
)
c
[
2
]
=
3.0
;
assert
(
basis
.
dimension
()
>
0
);
std
::
vector
<
double
>
vec
(
basis
.
dimension
());
interpolate
(
basis
,
vec
,
[
&
c
](
auto
const
&
x
)
{
return
c
.
dot
(
x
);
});
...
...
@@ -60,7 +61,7 @@ void write (std::string prefix, GridView const& gridView)
vtkWriter
.
addCellData
(
p1Interpol
,
"p0"
);
vtkWriter
.
addPointData
(
p1Analytic
,
"q1"
);
vtkWriter
.
addCellData
(
p1Analytic
,
"q0"
);
vtkWriter
.
write
(
prefix
+
"_"
+
std
::
to_string
(
GridView
::
dimension
)
+
"d_"
+
std
::
get
<
0
>
(
test_case
)
+
".vtu"
);
vtkWriter
.
write
(
prefix
+
"_"
+
std
::
to_string
(
GridView
::
dimension
world
)
+
"d_"
+
std
::
get
<
0
>
(
test_case
)
+
".vtu"
);
}
}
...
...
@@ -79,7 +80,7 @@ int main (int argc, char** argv)
{
FieldVector
<
double
,
dim
.
value
>
lowerLeft
;
lowerLeft
=
0.0
;
FieldVector
<
double
,
dim
.
value
>
upperRight
;
upperRight
=
1.0
;
auto
numElements
=
filledArray
<
dim
.
value
,
unsigned
int
>
(
4
);
auto
numElements
=
filledArray
<
dim
.
value
,
unsigned
int
>
(
8
);
auto
gridPtr
=
StructuredGridFactory
<
GridType
>::
createSimplexGrid
(
lowerLeft
,
upperRight
,
numElements
);
write
(
"ug"
,
gridPtr
->
leafGridView
());
...
...
@@ -92,8 +93,8 @@ int main (int argc, char** argv)
{
using
GridType
=
YaspGrid
<
dim
.
value
>
;
FieldVector
<
double
,
dim
.
value
>
upperRight
;
upperRight
=
1.0
;
auto
numElements
=
filledArray
<
dim
.
value
,
int
>
(
4
);
GridType
grid
(
upperRight
,
numElements
);
auto
numElements
=
filledArray
<
dim
.
value
,
int
>
(
8
);
GridType
grid
(
upperRight
,
numElements
,
0
,
0
);
write
(
"yasp"
,
grid
.
leafGridView
());
});
}
\ No newline at end of file
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