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
amdis
amdis-core
Commits
5d07110f
Commit
5d07110f
authored
Dec 26, 2019
by
Praetorius, Simon
Browse files
writers for general gridfunction
parent
81bcc9de
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/amdis/io/DuneVtkWriter.hpp
View file @
5d07110f
...
...
@@ -15,20 +15,24 @@
namespace
AMDiS
{
/// Adapter for the dune-vtk writer
template
<
class
GB
,
class
VT
,
class
TP
>
/**
* \tparam GV GridView describing the grid to write
* \tparam GF GridFunction defined on that GridView
**/
template
<
class
GV
,
class
GF
>
class
DuneVtkWriter
:
public
FileWriterBase
{
using
GridView
=
typename
GB
::
GridView
;
using
GridView
=
GV
;
using
Writer
=
Dune
::
VtkWriter
<
GridView
>
;
using
SeqWriter
=
Dune
::
PvdWriter
<
Writer
>
;
using
Function
=
DiscreteFunction
<
GB
,
VT
,
TP
,
true
>
;
using
Grid
Function
=
GF
;
public:
/// Constructor.
DuneVtkWriter
(
std
::
string
const
&
name
,
Function
const
&
discreteFct
)
DuneVtkWriter
(
std
::
string
const
&
name
,
GridView
const
&
gridView
,
Grid
Function
const
&
gridFunction
)
:
FileWriterBase
(
name
)
,
discreteFct_
(
discreteFct
)
,
gridFunction_
(
gridFunction
)
{
int
m
=
0
,
p
=
0
;
Parameters
::
get
(
name
+
"->animation"
,
animation_
);
...
...
@@ -45,11 +49,11 @@ namespace AMDiS
Dune
::
Vtk
::
FLOAT64
;
if
(
animation_
)
{
vtkSeqWriter_
=
std
::
make_shared
<
SeqWriter
>
(
gridView
()
,
mode
,
precision
);
vtkSeqWriter_
->
addPointData
(
discreteFct
_
,
this
->
name
());
vtkSeqWriter_
=
std
::
make_shared
<
SeqWriter
>
(
gridView
,
mode
,
precision
);
vtkSeqWriter_
->
addPointData
(
gridFunction
_
,
this
->
name
());
}
else
{
vtkWriter_
=
std
::
make_shared
<
Writer
>
(
gridView
()
,
mode
,
precision
);
vtkWriter_
->
addPointData
(
discreteFct
_
,
this
->
name
());
vtkWriter_
=
std
::
make_shared
<
Writer
>
(
gridView
,
mode
,
precision
);
vtkWriter_
->
addPointData
(
gridFunction
_
,
this
->
name
());
}
}
...
...
@@ -69,14 +73,7 @@ namespace AMDiS
}
private:
/// The Gridview this writer lives on. Given by the discrete function.
GridView
const
&
gridView
()
const
{
return
discreteFct_
.
basis
()
->
gridView
();
}
private:
Function
discreteFct_
;
GridFunction
gridFunction_
;
std
::
shared_ptr
<
Writer
>
vtkWriter_
;
std
::
shared_ptr
<
SeqWriter
>
vtkSeqWriter_
;
...
...
@@ -85,6 +82,14 @@ namespace AMDiS
bool
animation_
=
false
;
};
/// Generator function for \ref DuneVtkWriter
template
<
class
GridView
,
class
GridFunction
>
DuneVtkWriter
<
GridView
,
GridFunction
>
makeDuneVtkWriter
(
std
::
string
const
&
name
,
GridView
const
&
gridView
,
GridFunction
const
&
gridFunction
)
{
return
{
name
,
gridView
,
gridFunction
};
}
}
// end namespace AMDiS
#endif // HAVE_DUNE_VTK
src/amdis/io/FileWriterCreator.hpp
View file @
5d07110f
...
...
@@ -51,31 +51,32 @@ namespace AMDiS
}
private:
template
<
class
GB
,
class
VT
,
class
TP
,
class
ValCat
>
template
<
class
Data
,
class
ValCat
>
std
::
unique_ptr
<
FileWriterInterface
>
create_impl
(
std
::
string
type
,
std
::
string
prefix
,
D
iscreteFunction
<
GB
,
VT
,
TP
,
true
>
const
&
data
,
ValCat
)
const
create_impl
(
std
::
string
type
,
std
::
string
prefix
,
D
ata
const
&
data
,
ValCat
)
const
{
GridView
const
&
gridView
=
systemVector_
->
basis
()
->
gridView
();
// ParaView VTK format, writer from dune-grid
if
(
type
==
"vtk"
)
{
return
std
::
make_unique
<
VTKWriter
<
G
B
,
VT
,
TP
>>
(
prefix
,
data
);
return
std
::
make_unique
<
VTKWriter
<
G
ridView
,
Data
>>
(
prefix
,
gridView
,
data
);
}
#if HAVE_DUNE_VTK
// ParaView VTK format, writer from dune-vtk
else
if
(
type
==
"dune-vtk"
)
{
return
std
::
make_unique
<
DuneVtkWriter
<
G
B
,
VT
,
TP
>>
(
prefix
,
data
);
return
std
::
make_unique
<
DuneVtkWriter
<
G
ridView
,
Data
>>
(
prefix
,
gridView
,
data
);
}
#endif
// GMsh file format, writing just the grid and optionally boundary ids
else
if
(
type
==
"gmsh"
)
{
GridView
const
&
gridView
=
systemVector_
->
basis
()
->
gridView
();
if
(
!!
boundaryManager_
)
return
std
::
make_unique
<
GmshWriter
<
typename
GB
::
GridView
>>
(
prefix
,
gridView
,
return
std
::
make_unique
<
GmshWriter
<
GridView
>>
(
prefix
,
gridView
,
std
::
vector
<
int
>
{},
boundaryManager_
->
boundaryIds
());
else
return
std
::
make_unique
<
GmshWriter
<
typename
GB
::
GridView
>>
(
prefix
,
gridView
);
return
std
::
make_unique
<
GmshWriter
<
GridView
>>
(
prefix
,
gridView
);
}
// Backup writer, writing the grid and the solution vector
else
if
(
type
==
"backup"
)
...
...
@@ -90,9 +91,9 @@ namespace AMDiS
}
// The value-category is unknown, like a composite/hierarchic vector or any unknown type.
template
<
class
GB
,
class
VT
,
class
TP
>
template
<
class
Data
>
std
::
unique_ptr
<
FileWriterInterface
>
create_impl
(
std
::
string
type
,
std
::
string
prefix
,
D
iscreteFunction
<
GB
,
VT
,
TP
,
true
>
const
&
/*data*/
,
tag
::
unknown
)
const
create_impl
(
std
::
string
type
,
std
::
string
prefix
,
D
ata
const
&
/*data*/
,
tag
::
unknown
)
const
{
// Backup writer, writing the grid and the solution vector
if
(
type
==
"backup"
)
...
...
src/amdis/io/GmshWriter.hpp
View file @
5d07110f
...
...
@@ -15,6 +15,9 @@
namespace
AMDiS
{
/// The GmshWriter just writes the grid of a given gridView to a gmsh compatible .msh file
/**
* \tparam GV GridView describing the grid to write
**/
template
<
class
GV
>
class
GmshWriter
:
public
FileWriterBase
...
...
@@ -28,7 +31,6 @@ namespace AMDiS
std
::
vector
<
int
>
const
&
physicalEntities
=
std
::
vector
<
int
>
(),
std
::
vector
<
int
>
const
&
physicalBoundaries
=
std
::
vector
<
int
>
())
:
FileWriterBase
(
name
)
,
gridView_
(
gridView
)
,
physicalEntities_
(
physicalEntities
)
,
physicalBoundaries_
(
physicalBoundaries
)
{
...
...
@@ -40,7 +42,7 @@ namespace AMDiS
?
std
::
numeric_limits
<
float
>::
max_digits10
:
std
::
numeric_limits
<
double
>::
max_digits10
;
writer_
=
std
::
make_shared
<
Writer
>
(
gridView
_
,
precision
);
writer_
=
std
::
make_shared
<
Writer
>
(
gridView
,
precision
);
}
/// Implements \ref FileWriterBase::write
...
...
@@ -59,7 +61,6 @@ namespace AMDiS
}
private:
GridView
gridView_
;
std
::
vector
<
int
>
const
&
physicalEntities_
;
std
::
vector
<
int
>
const
&
physicalBoundaries_
;
...
...
src/amdis/io/VTKWriter.hpp
View file @
5d07110f
...
...
@@ -36,16 +36,20 @@ namespace AMDiS
/// Adapter for the dune-grid VTKWriter
template
<
class
GB
,
class
VT
,
class
TP
>
/**
* \tparam GV GridView describing the grid to write
* \tparam GF GridFunction defined on that GridView
**/
template
<
class
GV
,
class
GF
>
class
VTKWriter
:
public
FileWriterBase
{
using
GridView
=
typename
GB
::
GridView
;
using
GridView
=
GV
;
using
Writer
=
Dune
::
VTKWriter
<
GridView
>
;
using
SeqWriter
=
VTKSequenceWriter
<
GridView
>
;
using
Function
=
DiscreteFunction
<
GB
,
VT
,
TP
,
true
>
;
using
Range
=
typename
Function
::
Range
;
using
Grid
Function
=
GF
;
using
Range
=
typename
Grid
Function
::
Range
;
template
<
class
R
>
static
constexpr
Dune
::
VTK
::
FieldInfo
::
Type
VTKFieldType
()
{
...
...
@@ -59,9 +63,9 @@ namespace AMDiS
public:
/// Constructor.
VTKWriter
(
std
::
string
const
&
name
,
Function
const
&
discreteFct
)
VTKWriter
(
std
::
string
const
&
name
,
GridView
const
&
gridView
,
Grid
Function
const
&
gridFunction
)
:
FileWriterBase
(
name
)
,
discreteFct_
(
discreteFct
)
,
gridFunction_
(
gridFunction
)
{
int
m
=
0
;
Parameters
::
get
(
name
+
"->animation"
,
animation_
);
...
...
@@ -74,15 +78,15 @@ namespace AMDiS
auto
subSampling
=
Parameters
::
get
<
int
>
(
name
+
"->subsampling"
);
if
(
subSampling
)
{
using
SubsamplingWriter
=
Dune
::
SubsamplingVTKWriter
<
GridView
>
;
vtkWriter_
=
std
::
make_shared
<
SubsamplingWriter
>
(
gridView
()
,
subSampling
.
value
());
vtkWriter_
=
std
::
make_shared
<
SubsamplingWriter
>
(
gridView
,
subSampling
.
value
());
}
else
{
vtkWriter_
=
std
::
make_shared
<
Writer
>
(
gridView
()
);
vtkWriter_
=
std
::
make_shared
<
Writer
>
(
gridView
);
}
if
(
animation_
)
vtkSeqWriter_
=
std
::
make_shared
<
SeqWriter
>
(
vtkWriter_
);
vtkWriter_
->
addVertexData
(
discreteFct
_
,
vtkWriter_
->
addVertexData
(
gridFunction
_
,
Dune
::
VTK
::
FieldInfo
(
name_
,
VTKFieldType
<
Range
>
(),
VTKFieldSize
<
Range
>
()));
}
...
...
@@ -99,14 +103,7 @@ namespace AMDiS
}
private:
/// The Gridview this writer lives on. Given by the discrete function.
GridView
const
&
gridView
()
const
{
return
discreteFct_
.
basis
()
->
gridView
();
}
private:
Function
discreteFct_
;
GridFunction
gridFunction_
;
std
::
shared_ptr
<
Writer
>
vtkWriter_
;
std
::
shared_ptr
<
SeqWriter
>
vtkSeqWriter_
;
...
...
@@ -117,4 +114,12 @@ namespace AMDiS
Dune
::
VTK
::
OutputType
mode_
=
Dune
::
VTK
::
ascii
;
};
/// Generator function for \ref VTKWriter
template
<
class
GridView
,
class
GridFunction
>
VTKWriter
<
GridView
,
GridFunction
>
makeVTKWriter
(
std
::
string
const
&
name
,
GridView
const
&
gridView
,
GridFunction
const
&
gridFunction
)
{
return
{
name
,
gridView
,
gridFunction
};
}
}
// end namespace AMDiS
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