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
e2aefebc
Commit
e2aefebc
authored
May 03, 2019
by
Praetorius, Simon
Browse files
replace try-catch with grid capability check
parent
fb26f4c1
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/amdis/ProblemStat.inc.hpp
View file @
e2aefebc
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
#include
<dune/common/hybridutilities.hh>
#include
<dune/common/hybridutilities.hh>
#include
<dune/common/timer.hh>
#include
<dune/common/timer.hh>
#include
<dune/grid/common/capabilities.hh>
#include
<dune/typetree/childextraction.hh>
#include
<dune/typetree/childextraction.hh>
#include
<amdis/AdaptInfo.hpp>
#include
<amdis/AdaptInfo.hpp>
...
@@ -489,23 +490,26 @@ template <class Traits>
...
@@ -489,23 +490,26 @@ template <class Traits>
void
ProblemStat
<
Traits
>::
void
ProblemStat
<
Traits
>::
backup
(
std
::
string
const
&
filename
)
const
backup
(
std
::
string
const
&
filename
)
const
{
{
try
{
if
(
Dune
::
Capabilities
::
hasBackupRestoreFacilities
<
Grid
>::
v
)
Dune
::
BackupRestoreFacility
<
Grid
>::
backup
(
*
grid_
,
filename
);
Dune
::
BackupRestoreFacility
<
Grid
>::
backup
(
*
grid_
,
filename
);
}
catch
(
Dune
::
NotImplemented
const
&
)
{
else
{
warning
(
"Falling back to backup of gridview."
);
warning
(
"Falling back to backup of gridview."
);
BackupRestoreByGridFactory
<
Grid
>::
backup
(
gridView
(),
filename
);
BackupRestoreByGridFactory
<
Grid
>::
backup
(
gridView
(),
filename
);
}
}
}
}
template
<
class
Traits
>
template
<
class
Traits
>
void
ProblemStat
<
Traits
>::
void
ProblemStat
<
Traits
>::
backup
(
AdaptInfo
&
adaptInfo
)
backup
(
AdaptInfo
&
adaptInfo
)
{
{
auto
param
=
Parameters
::
get
<
std
::
string
>
(
name_
+
"->backup->grid"
);
auto
param
=
Parameters
::
get
<
std
::
string
>
(
name_
+
"->backup->grid"
);
std
::
string
grid_filename
=
param
?
*
param
:
name_
+
"_"
+
std
::
to_string
(
adaptInfo
.
timestepNumber
())
+
".grid"
;
std
::
string
grid_filename
=
param
?
*
param
:
name_
+
"_"
+
std
::
to_string
(
adaptInfo
.
timestepNumber
())
+
".grid"
;
auto
param2
=
Parameters
::
get
<
std
::
string
>
(
name_
+
"->backup->solution"
);
auto
param2
=
Parameters
::
get
<
std
::
string
>
(
name_
+
"->backup->solution"
);
std
::
string
solution_filename
=
param2
?
*
param2
:
name_
+
"_"
+
std
::
to_string
(
adaptInfo
.
timestepNumber
())
+
".solution"
;
std
::
string
solution_filename
=
param2
?
*
param2
:
name_
+
"_"
+
std
::
to_string
(
adaptInfo
.
timestepNumber
())
+
".solution"
;
backup
(
grid_filename
);
backup
(
grid_filename
);
solution_
->
backup
(
solution_filename
);
solution_
->
backup
(
solution_filename
);
...
@@ -519,14 +523,14 @@ restore(std::string const& filename)
...
@@ -519,14 +523,14 @@ restore(std::string const& filename)
{
{
// restore grid from file
// restore grid from file
std
::
unique_ptr
<
Grid
>
grid
;
std
::
unique_ptr
<
Grid
>
grid
;
try
{
if
(
Dune
::
Capabilities
::
hasBackupRestoreFacilities
<
Grid
>::
v
)
grid
.
reset
(
Dune
::
BackupRestoreFacility
<
Grid
>::
restore
(
filename
));
grid
.
reset
(
Dune
::
BackupRestoreFacility
<
Grid
>::
restore
(
filename
));
}
catch
(
Dune
::
NotImplemented
const
&
)
{
else
grid
.
reset
(
BackupRestoreByGridFactory
<
Grid
>::
restore
(
filename
));
grid
.
reset
(
BackupRestoreByGridFactory
<
Grid
>::
restore
(
filename
));
}
return
std
::
move
(
grid
);
return
std
::
move
(
grid
);
}
}
template
<
class
Traits
>
template
<
class
Traits
>
void
ProblemStat
<
Traits
>::
void
ProblemStat
<
Traits
>::
restore
(
Flag
initFlag
)
restore
(
Flag
initFlag
)
...
...
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