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
Aland, Sebastian
amdis
Commits
960408e0
Commit
960408e0
authored
Jun 14, 2010
by
Backofen, Rainer
Browse files
fixed bug in runtime calculation, initialTimestamp was not set correctly
parent
8daad3cb
Changes
2
Hide whitespace changes
Inline
Side-by-side
AMDiS/src/AdaptInstationary.cc
View file @
960408e0
...
@@ -13,7 +13,7 @@ namespace AMDiS {
...
@@ -13,7 +13,7 @@ namespace AMDiS {
AdaptInfo
*
info
,
AdaptInfo
*
info
,
ProblemTimeInterface
*
problemInstat
,
ProblemTimeInterface
*
problemInstat
,
AdaptInfo
*
initialInfo
,
AdaptInfo
*
initialInfo
,
time_t
initialTimestamp
)
time_t
initialTimestamp
Set
)
:
AdaptBase
(
name
,
problemStat
,
info
,
problemInstat
,
initialInfo
),
:
AdaptBase
(
name
,
problemStat
,
info
,
problemInstat
,
initialInfo
),
breakWhenStable
(
0
),
breakWhenStable
(
0
),
dbgMode
(
false
)
dbgMode
(
false
)
...
@@ -23,8 +23,9 @@ namespace AMDiS {
...
@@ -23,8 +23,9 @@ namespace AMDiS {
// MSG("You make use of the obsolete constructor AdaptInstationary::AdaptInstationary(...)!\n");
// MSG("You make use of the obsolete constructor AdaptInstationary::AdaptInstationary(...)!\n");
// MSG("Please use the constructor that uses references instead of pointers!\n");
// MSG("Please use the constructor that uses references instead of pointers!\n");
initConstructor
(
problemStat
,
info
,
initialInfo
,
initialTimestamp
);
initConstructor
(
problemStat
,
info
,
initialInfo
,
initialTimestampSet
);
}
}
AdaptInstationary
::
AdaptInstationary
(
std
::
string
name
,
AdaptInstationary
::
AdaptInstationary
(
std
::
string
name
,
...
@@ -32,31 +33,32 @@ namespace AMDiS {
...
@@ -32,31 +33,32 @@ namespace AMDiS {
AdaptInfo
&
info
,
AdaptInfo
&
info
,
ProblemTimeInterface
&
problemInstat
,
ProblemTimeInterface
&
problemInstat
,
AdaptInfo
&
initialInfo
,
AdaptInfo
&
initialInfo
,
time_t
initialTimestamp
)
time_t
initialTimestamp
Set
)
:
AdaptBase
(
name
,
&
problemStat
,
&
info
,
&
problemInstat
,
&
initialInfo
),
:
AdaptBase
(
name
,
&
problemStat
,
&
info
,
&
problemInstat
,
&
initialInfo
),
breakWhenStable
(
0
),
breakWhenStable
(
0
),
dbgMode
(
false
)
dbgMode
(
false
)
{
{
FUNCNAME
(
"AdaptInstationary::AdaptInstationary()"
);
FUNCNAME
(
"AdaptInstationary::AdaptInstationary()"
);
initConstructor
(
&
problemStat
,
&
info
,
&
initialInfo
,
initialTimestamp
);
initConstructor
(
&
problemStat
,
&
info
,
&
initialInfo
,
initialTimestampSet
);
}
}
void
AdaptInstationary
::
initConstructor
(
ProblemIterationInterface
*
problemStat
,
void
AdaptInstationary
::
initConstructor
(
ProblemIterationInterface
*
problemStat
,
AdaptInfo
*
info
,
AdaptInfo
*
info
,
AdaptInfo
*
initialInfo
,
AdaptInfo
*
initialInfo
,
time_t
initialTimestamp
)
time_t
initialTimestamp
Set
)
{
{
initialize
(
name
);
initialize
(
name
);
fixedTimestep
=
(
info
->
getMinTimestep
()
==
info
->
getMaxTimestep
());
fixedTimestep
=
(
info
->
getMinTimestep
()
==
info
->
getMaxTimestep
());
if
(
initialTimestamp
==
0
)
if
(
initialTimestamp
Set
==
0
)
initialTimestamp
=
time
(
NULL
);
initialTimestamp
=
time
(
NULL
);
else
else
initialTimestamp
=
initialTimestamp
;
initialTimestamp
=
initialTimestamp
Set
;
// Check if the problem should be deserialized because of the -rs parameter.
// Check if the problem should be deserialized because of the -rs parameter.
std
::
string
serializationFilename
=
""
;
std
::
string
serializationFilename
=
""
;
GET_PARAMETER
(
0
,
"argv->rs"
,
&
serializationFilename
);
GET_PARAMETER
(
0
,
"argv->rs"
,
&
serializationFilename
);
...
@@ -279,7 +281,6 @@ namespace AMDiS {
...
@@ -279,7 +281,6 @@ namespace AMDiS {
int
AdaptInstationary
::
adapt
()
int
AdaptInstationary
::
adapt
()
{
{
FUNCNAME
(
"AdaptInstationary::adapt()"
);
FUNCNAME
(
"AdaptInstationary::adapt()"
);
int
errorCode
=
0
;
int
errorCode
=
0
;
TEST_EXIT
(
adaptInfo
->
getTimestep
()
>=
adaptInfo
->
getMinTimestep
())
TEST_EXIT
(
adaptInfo
->
getTimestep
()
>=
adaptInfo
->
getMinTimestep
())
...
@@ -308,10 +309,12 @@ namespace AMDiS {
...
@@ -308,10 +309,12 @@ namespace AMDiS {
oneTimestep
();
oneTimestep
();
problemTime
->
closeTimestep
(
adaptInfo
);
problemTime
->
closeTimestep
(
adaptInfo
);
if
(
breakWhenStable
&&
(
adaptInfo
->
getSolverIterations
()
==
0
))
{
if
(
breakWhenStable
&&
(
adaptInfo
->
getSolverIterations
()
==
0
))
break
;
break
;
}
/*
if (adaptInfo->forceBreak)
break;
*/
// Check if there is a runtime limitation. If there is a runtime limitation
// Check if there is a runtime limitation. If there is a runtime limitation
// and there is no more time for a next adaption loop, than return the error
// and there is no more time for a next adaption loop, than return the error
// code for rescheduling the problem and break the adaption loop.
// code for rescheduling the problem and break the adaption loop.
...
@@ -374,7 +377,6 @@ namespace AMDiS {
...
@@ -374,7 +377,6 @@ namespace AMDiS {
if
(
queueRuntime
==
-
1
)
{
if
(
queueRuntime
==
-
1
)
{
return
false
;
return
false
;
}
}
// Get the current time.
// Get the current time.
time_t
currentTimestamp
=
time
(
NULL
);
time_t
currentTimestamp
=
time
(
NULL
);
...
@@ -388,11 +390,11 @@ namespace AMDiS {
...
@@ -388,11 +390,11 @@ namespace AMDiS {
std
::
queue
<
int
>
tmpQueue
=
lastIterationsDuration
;
std
::
queue
<
int
>
tmpQueue
=
lastIterationsDuration
;
int
avrgLastIterations
=
0
;
int
avrgLastIterations
=
0
;
while
(
!
tmpQueue
.
empty
())
{
while
(
!
tmpQueue
.
empty
())
{
avrgLastIterations
+=
tmpQueue
.
front
();
avrgLastIterations
+=
tmpQueue
.
front
();
tmpQueue
.
pop
();
tmpQueue
.
pop
();
}
}
avrgLastIterations
/=
lastIterationsDuration
.
size
();
avrgLastIterations
/=
lastIterationsDuration
.
size
();
// Check if there is enough time for a further iteration.
// Check if there is enough time for a further iteration.
if
(
initialTimestamp
+
queueRuntime
-
currentTimestamp
<
avrgLastIterations
*
2
)
{
if
(
initialTimestamp
+
queueRuntime
-
currentTimestamp
<
avrgLastIterations
*
2
)
{
std
::
ofstream
out
(
queueSerializationFilename
.
c_str
());
std
::
ofstream
out
(
queueSerializationFilename
.
c_str
());
...
...
AMDiS/src/AdaptInstationary.h
View file @
960408e0
...
@@ -50,7 +50,7 @@ namespace AMDiS {
...
@@ -50,7 +50,7 @@ namespace AMDiS {
AdaptInfo
*
info
,
AdaptInfo
*
info
,
ProblemTimeInterface
*
problemInstat
,
ProblemTimeInterface
*
problemInstat
,
AdaptInfo
*
initialInfo
,
AdaptInfo
*
initialInfo
,
time_t
initialTimestamp
=
0
);
time_t
initialTimestamp
Set
=
0
);
/** \brief
/** \brief
* Creates a AdaptInstationary object with the given name for the time
* Creates a AdaptInstationary object with the given name for the time
...
@@ -61,7 +61,7 @@ namespace AMDiS {
...
@@ -61,7 +61,7 @@ namespace AMDiS {
AdaptInfo
&
info
,
AdaptInfo
&
info
,
ProblemTimeInterface
&
problemInstat
,
ProblemTimeInterface
&
problemInstat
,
AdaptInfo
&
initialInfo
,
AdaptInfo
&
initialInfo
,
time_t
initialTimestamp
=
0
);
time_t
initialTimestamp
Set
=
0
);
/** \brief
/** \brief
* This funciton is used only to avoid double code in both constructors. If the
* This funciton is used only to avoid double code in both constructors. If the
...
@@ -72,7 +72,7 @@ namespace AMDiS {
...
@@ -72,7 +72,7 @@ namespace AMDiS {
void
initConstructor
(
ProblemIterationInterface
*
problemStat
,
void
initConstructor
(
ProblemIterationInterface
*
problemStat
,
AdaptInfo
*
info
,
AdaptInfo
*
info
,
AdaptInfo
*
initialInfo
,
AdaptInfo
*
initialInfo
,
time_t
initialTimestamp
);
time_t
initialTimestamp
Set
);
/// Destructor
/// Destructor
virtual
~
AdaptInstationary
();
virtual
~
AdaptInstationary
();
...
@@ -88,7 +88,6 @@ namespace AMDiS {
...
@@ -88,7 +88,6 @@ namespace AMDiS {
{
{
return
strategy
;
return
strategy
;
}
}
/// Implementation of AdaptBase::adapt()
/// Implementation of AdaptBase::adapt()
virtual
int
adapt
();
virtual
int
adapt
();
...
@@ -152,7 +151,6 @@ namespace AMDiS {
...
@@ -152,7 +151,6 @@ namespace AMDiS {
* of solver iterations to solve the problem is zero, the adaption loop will stop.
* of solver iterations to solve the problem is zero, the adaption loop will stop.
*/
*/
int
breakWhenStable
;
int
breakWhenStable
;
///
///
bool
fixedTimestep
;
bool
fixedTimestep
;
...
...
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