Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Mpp
MLUQ
Commits
15c3ce52
Commit
15c3ce52
authored
Mar 24, 2020
by
niklas.baumgarten
Browse files
worked on multilevel plotter
parent
523fa928
Changes
3
Hide whitespace changes
Inline
Side-by-side
mlmc/src/utils/MultilevelPlotter.cpp
View file @
15c3ce52
#include
"MultilevelPlotter.hpp"
//MultilevelPlotter *MultilevelPlotter::instance = nullptr;
\ No newline at end of file
MultilevelPlotter
*
MultilevelPlotter
::
instance
=
nullptr
;
\ No newline at end of file
mlmc/src/utils/MultilevelPlotter.hpp
View file @
15c3ce52
...
...
@@ -2,18 +2,13 @@
#define MULTILEVELPLOTTER_HPP
#include
"Plot.h"
#include
"plot/VtuPlot.h"
class
MultilevelPlotter
{
map
<
int
,
Plot
*>
mapPlots
;
private:
static
MultilevelPlotter
*
instance
;
void
initializeMap
(
const
vector
<
int
>
&
levels
,
const
Meshes
&
meshes
)
{
for
(
auto
&
l
:
levels
)
{
mapPlots
[
l
]
=
new
Plot
(
meshes
[
l
],
meshes
.
dim
());
}
}
public:
explicit
MultilevelPlotter
(
const
Meshes
&
meshes
)
{
vector
<
int
>
levels
;
for
(
int
l
=
meshes
.
pLevel
();
l
<=
meshes
.
Level
();
l
++
)
...
...
@@ -21,24 +16,36 @@ public:
initializeMap
(
levels
,
meshes
);
}
MultilevelPlotter
(
int
startLevel
,
int
endLevel
,
const
Meshes
&
meshes
)
{
vector
<
int
>
levels
;
for
(
int
l
=
startLevel
;
l
<=
endLevel
;
l
++
)
levels
.
push_back
(
l
);
initializeMap
(
levels
,
meshes
);
void
initializeMap
(
const
vector
<
int
>
&
levels
,
const
Meshes
&
meshes
)
{
for
(
auto
&
l
:
levels
)
{
PlotMap
[
l
]
=
make_unique
<
SerialVtuPlot
>
(
meshes
[
l
]);
}
}
explicit
MultilevelPlotter
(
const
vector
<
int
>
&
levels
,
const
Meshes
&
meshes
)
{
initializeMap
(
levels
,
meshes
);
public:
map
<
int
,
unique_ptr
<
SerialVtuPlot
>>
PlotMap
;
static
MultilevelPlotter
*
GetInstance
(
const
Meshes
&
meshes
)
{
if
(
!
instance
)
instance
=
new
MultilevelPlotter
(
meshes
);
return
instance
;
}
Plot
*
GetPlot
(
int
l
)
{
return
mapPlots
[
l
];
void
PlotVector
(
const
string
&
name
,
const
Vector
&
data
,
int
dim
,
int
l
,
const
string
&
dataType
)
{
if
(
dataType
==
"PointData"
)
{
PlotMap
[
l
]
->
AddPointData
(
name
,
data
,
dim
);
PlotMap
[
l
]
->
PlotFile
(
name
);
}
if
(
dataType
==
"CellData"
)
{
PlotMap
[
l
]
->
AddCellData
(
name
,
data
,
dim
);
PlotMap
[
l
]
->
PlotFile
(
name
);
}
}
~
MultilevelPlotter
()
{
for
(
auto
&
plot
:
mapPlots
)
delete
plot
.
second
;
PlotMap
.
clear
();
}
};
...
...
tests/TestMultilevelPlotter.cpp
0 → 100644
View file @
15c3ce52
#include
"gtest/gtest.h"
#include
"utils/MultilevelPlotter.hpp"
#include
<memory>
#include
"m++.h"
using
namespace
::
testing
;
class
TestMultilevelPlotter
:
public
::
Test
{
protected:
MultilevelPlotter
*
plotter
;
Meshes
*
meshes
;
MatrixGraphs
*
cellMatrixGraphs
;
MatrixGraphs
*
vertexMatrixGraphs
;
void
SetUp
()
override
{
meshes
=
new
Meshes
(
"UnitSquare"
,
0
,
4
);
cellMatrixGraphs
=
new
MatrixGraphs
(
*
meshes
,
dof
(
"cell"
,
1
));
vertexMatrixGraphs
=
new
MatrixGraphs
(
*
meshes
,
dof
(
"vertex"
,
1
));
plotter
=
MultilevelPlotter
::
GetInstance
(
*
meshes
);
}
};
TEST_F
(
TestMultilevelPlotter
,
TestSingelton
)
{
MultilevelPlotter
*
secondInstance
;
secondInstance
=
MultilevelPlotter
::
GetInstance
(
*
meshes
);
ASSERT_EQ
(
plotter
,
secondInstance
);
}
TEST_F
(
TestMultilevelPlotter
,
TestVertexData
)
{
for
(
int
l
=
meshes
->
pLevel
();
l
<=
meshes
->
Level
();
l
++
)
{
Vector
pointData
((
*
vertexMatrixGraphs
)[
l
]);
Vector
cellData
((
*
cellMatrixGraphs
)[
l
]);
string
name
=
"testVec"
+
to_string
(
l
);
plotter
->
PlotVector
(
name
,
pointData
,
1
,
l
,
"PointData"
);
// plotter->PlotVector(name, cellData, 1, l, "CellData");
if
(
PPM
->
master
())
ASSERT_TRUE
(
FileExists
(
"data/vtk/"
+
name
+
".vtu"
));
}
}
int
main
(
int
argc
,
char
**
argv
)
{
InitGoogleTest
(
&
argc
,
argv
);
Config
::
setSearchPath
(
"../../tests/"
);
Config
::
setConfigFileName
(
"m++.conf"
);
DPO
dpo
(
&
argc
,
argv
);
TestEventListeners
&
listeners
=
UnitTest
::
GetInstance
()
->
listeners
();
if
(
!
PPM
->
master
())
{
delete
listeners
.
Release
(
listeners
.
default_result_printer
());
}
return
RUN_ALL_TESTS
();
}
\ No newline at end of file
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