Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dorie
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
31
Issues
31
List
Boards
Labels
Service Desk
Milestones
Merge Requests
9
Merge Requests
9
Operations
Operations
Incidents
Environments
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
dorie
dorie
Commits
fff5b51a
Commit
fff5b51a
authored
Sep 04, 2018
by
Lukas Riedel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve unit test of SimulationBase to check for calls to write_data
parent
c482c97d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
dune/dorie/test/base_simulation.cc
dune/dorie/test/base_simulation.cc
+15
-6
No files found.
dune/dorie/test/base_simulation.cc
View file @
fff5b51a
...
...
@@ -2,6 +2,8 @@
#include "config.h"
#endif
#include <cassert>
#include <dune/dorie/interface/simulation_base.hh>
#include <dune/common/parallel/mpihelper.hh>
...
...
@@ -15,11 +17,13 @@ class DummyModel : public Dune::Dorie::SimulationBase
{
public:
DummyModel
()
:
Dune
::
Dorie
::
SimulationBase
(
Dune
::
Dorie
::
OutputPolicy
::
EndOfStep
)
:
Dune
::
Dorie
::
SimulationBase
(
Dune
::
Dorie
::
OutputPolicy
::
None
,
Dune
::
Dorie
::
AdaptivityPolicy
::
None
)
,
_dt
(
.1
)
,
_current_time
(
begin_time
())
,
_end_time
(
1.0
)
,
_grid_was_adapted
(
false
)
,
_data_was_written
(
false
)
{}
double
begin_time
()
const
override
{
return
0.
;
}
...
...
@@ -31,7 +35,7 @@ public:
/// Do nothing.
void
mark_grid
()
override
{};
///
Grid was adapted!
///
Adapt the grid in our minds.
void
adapt_grid
()
override
{
_grid_was_adapted
=
true
;
...
...
@@ -40,6 +44,7 @@ public:
void
write_data
()
const
override
{
std
::
cout
<<
"current time: "
<<
_current_time
<<
std
::
endl
;
_data_was_written
=
true
;
}
private:
...
...
@@ -49,34 +54,38 @@ private:
public:
double
_end_time
;
bool
_grid_was_adapted
;
mutable
bool
_data_was_written
;
};
int
main
(
int
argc
,
char
**
argv
)
{
Dune
::
MPIHelper
::
instance
(
argc
,
argv
);
bool
passed
=
true
;
try
{
DummyModel
model
;
// run the model without adaptivity
model
.
run
();
assert
(
not
model
.
_grid_was_adapted
);
assert
(
not
model
.
_data_was_written
);
assert
(
Dune
::
FloatCmp
::
ge
(
model
.
current_time
(),
model
.
end_time
()));
// now set adaptivity
model
.
set_policy
(
Dune
::
Dorie
::
AdaptivityPolicy
::
WaterFlux
);
model
.
set_policy
(
Dune
::
Dorie
::
OutputPolicy
::
EndOfStep
);
model
.
_end_time
+=
1.0
;
model
.
run
();
assert
(
model
.
_grid_was_adapted
);
assert
(
model
.
_data_was_written
);
assert
(
Dune
::
FloatCmp
::
ge
(
model
.
current_time
(),
model
.
end_time
()));
}
catch
(
Dune
::
Exception
&
e
)
{
std
::
cout
<<
e
.
what
()
<<
std
::
endl
;
passed
&=
false
;
return
1
;
}
catch
(...)
{
std
::
cerr
<<
"Exception occurred!"
<<
std
::
endl
;
passed
&=
false
;
return
1
;
}
return
!
passed
;
return
0
;
}
Write
Preview
Markdown
is supported
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