Commit 21470979 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

New time strategy.

parent 19107682
......@@ -30,10 +30,10 @@
# the same distribution terms that you use for the rest of that program.
# A sed program that does not truncate output.
SED="/usr/bin/sed"
SED="/bin/sed"
# Sed that helps us avoid accidentally triggering echo(1) options like -n.
Xsed="/usr/bin/sed -e 1s/^X//"
Xsed="/bin/sed -e 1s/^X//"
# The HP-UX ksh and POSIX shell print the target directory to stdout
# if CDPATH is set.
......@@ -44,7 +44,7 @@ available_tags=" CXX F77"
# ### BEGIN LIBTOOL CONFIG
# Libtool was configured on host deimos104:
# Libtool was configured on host NWRW15:
# Shell to use when invoking shell scripts.
SHELL="/bin/sh"
......@@ -66,12 +66,12 @@ fast_install=yes
# The host system.
host_alias=
host=x86_64-unknown-linux-gnu
host=i686-pc-linux-gnu
host_os=linux-gnu
# The build system.
build_alias=
build=x86_64-unknown-linux-gnu
build=i686-pc-linux-gnu
build_os=linux-gnu
# An echo program that does not interpret backslashes.
......@@ -97,7 +97,7 @@ with_gcc=yes
EGREP="grep -E"
# The linker used to build libraries.
LD="/usr/x86_64-suse-linux/bin/ld -m elf_x86_64"
LD="/usr/bin/ld"
# Whether we need hard or soft links.
LN_S="ln -s"
......@@ -325,10 +325,10 @@ variables_saved_for_relink="PATH LD_LIBRARY_PATH LD_RUN_PATH GCC_EXEC_PREFIX COM
link_all_deplibs=unknown
# Compile-time system search path for libraries
sys_lib_search_path_spec=" /usr/lib64/gcc/x86_64-suse-linux/4.1.2/ /usr/lib/gcc/x86_64-suse-linux/4.1.2/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib/x86_64-suse-linux/4.1.2/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib/../lib64/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../x86_64-suse-linux/4.1.2/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/ /lib/x86_64-suse-linux/4.1.2/ /lib/../lib64/ /usr/lib/x86_64-suse-linux/4.1.2/ /usr/lib/../lib64/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../ /lib/ /usr/lib/"
sys_lib_search_path_spec=" /u/witkowski/local/lib/i386-redhat-linux/4.1.2/ /u/witkowski/local/lib/ /usr/lib/gcc/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/lib/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/lib/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../ /lib/i386-redhat-linux/4.1.2/ /lib/ /usr/lib/i386-redhat-linux/4.1.2/ /usr/lib/"
# Run-time system search path for libraries
sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/X11R6/lib64/Xaw3d /usr/X11R6/lib64 /usr/X11R6/lib/Xaw3d /usr/X11R6/lib /usr/x86_64-suse-linux/lib /usr/local/lib64 /usr/local/lib /opt/kde3/lib64 /opt/kde3/lib /opt/gnome/lib64 /opt/gnome/lib /lib64 /lib /usr/lib64 /usr/lib /opt/cluster/intel/cce/9.1.042/lib /opt/cluster/intel/fce/9.1.036/lib /opt/cluster/Pathscale3.0/lib/2.9.99 /opt/cluster/Pathscale3.0/lib/2.9.99/32 /work/licsoft/compilers/pgi/linux86-64/6.2/lib /work/licsoft/compilers/pgi/linux86-64/6.2/libso "
sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/octave-2.9.9 /usr/lib/qt-3.3/lib /usr/lib/qt4/lib "
# Fix the shell variable $srcfile for the compiler.
fix_srcfile_path=""
......@@ -6760,7 +6760,7 @@ build_old_libs=`case $build_libtool_libs in yes) $echo no;; *) $echo yes;; esac`
# End:
# ### BEGIN LIBTOOL TAG CONFIG: CXX
# Libtool was configured on host deimos104:
# Libtool was configured on host NWRW15:
# Shell to use when invoking shell scripts.
SHELL="/bin/sh"
......@@ -6782,12 +6782,12 @@ fast_install=yes
# The host system.
host_alias=
host=x86_64-unknown-linux-gnu
host=i686-pc-linux-gnu
host_os=linux-gnu
# The build system.
build_alias=
build=x86_64-unknown-linux-gnu
build=i686-pc-linux-gnu
build_os=linux-gnu
# An echo program that does not interpret backslashes.
......@@ -6813,7 +6813,7 @@ with_gcc=yes
EGREP="grep -E"
# The linker used to build libraries.
LD="/usr/x86_64-suse-linux/bin/ld -m elf_x86_64"
LD="/usr/bin/ld"
# Whether we need hard or soft links.
LN_S="ln -s"
......@@ -6942,11 +6942,11 @@ striplib="strip --strip-unneeded"
# Dependencies to place before the objects being linked to create a
# shared library.
predep_objects="/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/crti.o /usr/lib64/gcc/x86_64-suse-linux/4.1.2/crtbeginS.o"
predep_objects="/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crti.o /usr/lib/gcc/i386-redhat-linux/4.1.2/crtbeginS.o"
# Dependencies to place after the objects being linked to create a
# shared library.
postdep_objects="/usr/lib64/gcc/x86_64-suse-linux/4.1.2/crtendS.o /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/crtn.o"
postdep_objects="/usr/lib/gcc/i386-redhat-linux/4.1.2/crtendS.o /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crtn.o"
# Dependencies to place before the objects being linked to create a
# shared library.
......@@ -6958,7 +6958,7 @@ postdeps="-lstdc++ -lm -lgcc_s -lc -lgcc_s"
# The library search path used internally by the compiler when linking
# a shared library.
compiler_lib_search_path="-L/usr/lib64/gcc/x86_64-suse-linux/4.1.2 -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib -L/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../.."
compiler_lib_search_path="-L/u/witkowski/local/lib -L/usr/lib/gcc/i386-redhat-linux/4.1.2 -L/usr/lib/gcc/i386-redhat-linux/4.1.2 -L/usr/lib/gcc/i386-redhat-linux/4.1.2/../../.."
# Method to check whether dependent libraries are shared objects.
deplibs_check_method="pass_all"
......@@ -7038,10 +7038,10 @@ variables_saved_for_relink="PATH LD_LIBRARY_PATH LD_RUN_PATH GCC_EXEC_PREFIX COM
link_all_deplibs=unknown
# Compile-time system search path for libraries
sys_lib_search_path_spec=" /usr/lib64/gcc/x86_64-suse-linux/4.1.2/ /usr/lib/gcc/x86_64-suse-linux/4.1.2/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib/x86_64-suse-linux/4.1.2/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib/../lib64/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../x86_64-suse-linux/4.1.2/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/ /lib/x86_64-suse-linux/4.1.2/ /lib/../lib64/ /usr/lib/x86_64-suse-linux/4.1.2/ /usr/lib/../lib64/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib/ /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../ /lib/ /usr/lib/"
sys_lib_search_path_spec=" /u/witkowski/local/lib/i386-redhat-linux/4.1.2/ /u/witkowski/local/lib/ /usr/lib/gcc/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/lib/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/lib/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../ /lib/i386-redhat-linux/4.1.2/ /lib/ /usr/lib/i386-redhat-linux/4.1.2/ /usr/lib/"
# Run-time system search path for libraries
sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/X11R6/lib64/Xaw3d /usr/X11R6/lib64 /usr/X11R6/lib/Xaw3d /usr/X11R6/lib /usr/x86_64-suse-linux/lib /usr/local/lib64 /usr/local/lib /opt/kde3/lib64 /opt/kde3/lib /opt/gnome/lib64 /opt/gnome/lib /lib64 /lib /usr/lib64 /usr/lib /opt/cluster/intel/cce/9.1.042/lib /opt/cluster/intel/fce/9.1.036/lib /opt/cluster/Pathscale3.0/lib/2.9.99 /opt/cluster/Pathscale3.0/lib/2.9.99/32 /work/licsoft/compilers/pgi/linux86-64/6.2/lib /work/licsoft/compilers/pgi/linux86-64/6.2/libso "
sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/octave-2.9.9 /usr/lib/qt-3.3/lib /usr/lib/qt4/lib "
# Fix the shell variable $srcfile for the compiler.
fix_srcfile_path=""
......@@ -7065,7 +7065,7 @@ include_expsyms=""
# ### BEGIN LIBTOOL TAG CONFIG: F77
# Libtool was configured on host deimos104:
# Libtool was configured on host NWRW15:
# Shell to use when invoking shell scripts.
SHELL="/bin/sh"
......@@ -7087,12 +7087,12 @@ fast_install=yes
# The host system.
host_alias=
host=x86_64-unknown-linux-gnu
host=i686-pc-linux-gnu
host_os=linux-gnu
# The build system.
build_alias=
build=x86_64-unknown-linux-gnu
build=i686-pc-linux-gnu
build_os=linux-gnu
# An echo program that does not interpret backslashes.
......@@ -7112,13 +7112,13 @@ LTCFLAGS="-g -O2"
CC="g77"
# Is the compiler the GNU C compiler?
with_gcc=
with_gcc=yes
# An ERE matcher.
EGREP="grep -E"
# The linker used to build libraries.
LD="/usr/x86_64-suse-linux/bin/ld -m elf_x86_64"
LD="/usr/bin/ld"
# Whether we need hard or soft links.
LN_S="ln -s"
......@@ -7346,10 +7346,10 @@ variables_saved_for_relink="PATH LD_LIBRARY_PATH LD_RUN_PATH GCC_EXEC_PREFIX COM
link_all_deplibs=unknown
# Compile-time system search path for libraries
sys_lib_search_path_spec=" /usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/ /usr/lib/gcc/x86_64-suse-linux/3.3.5/ /usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/../../../../x86_64-suse-linux/lib/x86_64-suse-linux/3.3.5/ /usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/../../../../x86_64-suse-linux/lib/ /usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/../../../x86_64-suse-linux/3.3.5/ /usr/lib64/gcc-lib/x86_64-suse-linux/3.3.5/../../../ /lib/x86_64-suse-linux/3.3.5/ /lib/ /usr/lib/x86_64-suse-linux/3.3.5/ /usr/lib/"
sys_lib_search_path_spec=" /u/witkowski/local/lib/i386-redhat-linux/3.4.6/ /u/witkowski/local/lib/ /usr/lib/gcc/i386-redhat-linux/3.4.6/ /usr/lib/gcc/i386-redhat-linux/3.4.6/ /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../i386-redhat-linux/lib/i386-redhat-linux/3.4.6/ /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../i386-redhat-linux/lib/ /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../i386-redhat-linux/3.4.6/ /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../ /lib/i386-redhat-linux/3.4.6/ /lib/ /usr/lib/i386-redhat-linux/3.4.6/ /usr/lib/"
# Run-time system search path for libraries
sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/X11R6/lib64/Xaw3d /usr/X11R6/lib64 /usr/X11R6/lib/Xaw3d /usr/X11R6/lib /usr/x86_64-suse-linux/lib /usr/local/lib64 /usr/local/lib /opt/kde3/lib64 /opt/kde3/lib /opt/gnome/lib64 /opt/gnome/lib /lib64 /lib /usr/lib64 /usr/lib /opt/cluster/intel/cce/9.1.042/lib /opt/cluster/intel/fce/9.1.036/lib /opt/cluster/Pathscale3.0/lib/2.9.99 /opt/cluster/Pathscale3.0/lib/2.9.99/32 /work/licsoft/compilers/pgi/linux86-64/6.2/lib /work/licsoft/compilers/pgi/linux86-64/6.2/libso "
sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/octave-2.9.9 /usr/lib/qt-3.3/lib /usr/lib/qt4/lib "
# Fix the shell variable $srcfile for the compiler.
fix_srcfile_path=""
......
......@@ -2,6 +2,6 @@
namespace AMDiS {
int AdaptBase::info_ = 10;
int AdaptBase::info = 10;
}
......@@ -33,15 +33,15 @@ namespace AMDiS {
public:
/// Constructor
AdaptBase(std::string sname,
ProblemIterationInterface *problemIteration,
ProblemIterationInterface *problemIteration_,
AdaptInfo *adapt,
ProblemTimeInterface *problemTime = NULL,
AdaptInfo *initialAdaptInfo = NULL)
ProblemTimeInterface *problemTime_ = NULL,
AdaptInfo *initialAdaptInfo_ = NULL)
: name(sname),
problemIteration_(problemIteration),
problemIteration(problemIteration_),
adaptInfo(adapt),
problemTime_(problemTime),
initialAdaptInfo_(initialAdaptInfo)
problemTime(problemTime_),
initialAdaptInfo(initialAdaptInfo_)
{}
/// Destructor
......@@ -62,13 +62,13 @@ namespace AMDiS {
/// Returns \ref problemIteration_
inline ProblemIterationInterface *getProblemIteration()
{
return problemIteration_;
return problemIteration;
}
///
inline void setProblemIteration(ProblemIterationInterface *pii)
{
problemIteration_ = pii;
problemIteration = pii;
}
/// Returns \ref adaptInfo
......@@ -80,19 +80,19 @@ namespace AMDiS {
/// Returns \ref problemTime_
inline ProblemTimeInterface *getProblemTime()
{
return problemTime_;
return problemTime;
}
///
inline void setProblemTime(ProblemTimeInterface *pti)
{
problemTime_ = pti;
problemTime = pti;
}
/// Returns \ref initialAdaptInfo_
inline AdaptInfo *getInitialAdaptInfo()
{
return initialAdaptInfo_;
return initialAdaptInfo;
}
protected:
......@@ -100,22 +100,22 @@ namespace AMDiS {
std::string name;
/// Problem iteration interface
ProblemIterationInterface *problemIteration_;
ProblemIterationInterface *problemIteration;
/// Main adapt info
AdaptInfo *adaptInfo;
/// problem time interface
ProblemTimeInterface *problemTime_;
ProblemTimeInterface *problemTime;
/** \brief
* Adapt info for initial adapt. Will be given to
* problemTime_->solveInitialProblem().
*/
AdaptInfo *initialAdaptInfo_;
AdaptInfo *initialAdaptInfo;
/// Info level
static int info_;
static int info;
};
}
......
......@@ -26,6 +26,7 @@ namespace AMDiS {
initConstructor(problemStat, info, initialInfo, initialTimestamp);
}
AdaptInstationary::AdaptInstationary(std::string name,
ProblemIterationInterface &problemStat,
AdaptInfo &info,
......@@ -41,6 +42,7 @@ namespace AMDiS {
initConstructor(&problemStat, &info, &initialInfo, initialTimestamp);
}
void AdaptInstationary::initConstructor(ProblemIterationInterface *problemStat,
AdaptInfo *info,
AdaptInfo *initialInfo,
......@@ -48,12 +50,12 @@ namespace AMDiS {
{
initialize(name);
fixedTimestep_ = (info->getMinTimestep() == info->getMaxTimestep());
fixedTimestep = (info->getMinTimestep() == info->getMaxTimestep());
if (initialTimestamp == 0)
initialTimestamp_ = time(NULL);
initialTimestamp = time(NULL);
else
initialTimestamp_ = initialTimestamp;
initialTimestamp = initialTimestamp;
// Check if the problem should be deserialized because of the -rs parameter.
std::string serializationFilename = "";
......@@ -62,9 +64,9 @@ namespace AMDiS {
if (serializationFilename.compare("")) {
// The value of the -rs argument is ignored, because we want to use the
// serialization file mentioned in the used init file.
MSG("Deserialization from file: %s\n", queueSerializationFilename_.c_str());
MSG("Deserialization from file: %s\n", queueSerializationFilename.c_str());
std::ifstream in(queueSerializationFilename_.c_str());
std::ifstream in(queueSerializationFilename.c_str());
deserialize(in);
in.close();
......@@ -94,58 +96,61 @@ namespace AMDiS {
}
}
AdaptInstationary::~AdaptInstationary()
{
}
void AdaptInstationary::explicitTimeStrategy()
{
FUNCNAME("AdaptInstationary::explicitTimeStrategy()");
// estimate before first adaption
if (adaptInfo->getTime() <= adaptInfo->getStartTime())
problemIteration_->oneIteration(adaptInfo, ESTIMATE);
problemIteration->oneIteration(adaptInfo, ESTIMATE);
// increment time
adaptInfo->setTime(adaptInfo->getTime() + adaptInfo->getTimestep());
problemTime_->setTime(adaptInfo);
problemTime->setTime(adaptInfo);
INFO(info_,6)("time = %e, timestep = %e\n",
INFO(info,6)("time = %e, timestep = %e\n",
adaptInfo->getTime(), adaptInfo->getTimestep());
adaptInfo->setSpaceIteration(0);
// do the iteration
problemIteration_->beginIteration(adaptInfo);
problemIteration_->oneIteration(adaptInfo, FULL_ITERATION);
problemIteration_->endIteration(adaptInfo);
problemIteration->beginIteration(adaptInfo);
problemIteration->oneIteration(adaptInfo, FULL_ITERATION);
problemIteration->endIteration(adaptInfo);
adaptInfo->setLastProcessedTimestep(adaptInfo->getTimestep());
}
void AdaptInstationary::implicitTimeStrategy()
{
FUNCNAME("AdaptInstationary::implicitTimeStrategy()");
do {
adaptInfo->setTime(adaptInfo->getTime() + adaptInfo->getTimestep());
problemTime_->setTime(adaptInfo);
problemTime->setTime(adaptInfo);
INFO(info_,6)("time = %e, try timestep = %e\n",
adaptInfo->getTime(), adaptInfo->getTimestep());
INFO(info,6)("time = %e, try timestep = %e\n",
adaptInfo->getTime(), adaptInfo->getTimestep());
problemIteration_->oneIteration(adaptInfo, NO_ADAPTION);
problemIteration->oneIteration(adaptInfo, NO_ADAPTION);
adaptInfo->incTimestepIteration();
if (!fixedTimestep_ &&
if (!fixedTimestep &&
!adaptInfo->timeToleranceReached() &&
adaptInfo->getTimestepIteration() <= adaptInfo->getMaxTimestepIteration() &&
!(adaptInfo->getTimestep() <= adaptInfo->getMinTimestep())) {
adaptInfo->setTime(adaptInfo->getTime() - adaptInfo->getTimestep());
adaptInfo->setTimestep(adaptInfo->getTimestep() * time_delta_1);
adaptInfo->setTimestep(adaptInfo->getTimestep() * timeDelta1);
continue;
}
......@@ -159,28 +164,28 @@ namespace AMDiS {
/* === Space iterations === */
do {
problemIteration_->beginIteration(adaptInfo);
problemIteration->beginIteration(adaptInfo);
if (problemIteration_->oneIteration(adaptInfo, FULL_ITERATION)) {
if (!fixedTimestep_ &&
if (problemIteration->oneIteration(adaptInfo, FULL_ITERATION)) {
if (!fixedTimestep &&
!adaptInfo->timeToleranceReached() &&
!(adaptInfo->getTimestep() <= adaptInfo->getMinTimestep())) {
adaptInfo->setTime(adaptInfo->getTime() - adaptInfo->getTimestep());
adaptInfo->setTimestep(adaptInfo->getTimestep() * time_delta_1);
problemIteration_->endIteration(adaptInfo);
adaptInfo->setTimestep(adaptInfo->getTimestep() * timeDelta2);
problemIteration->endIteration(adaptInfo);
adaptInfo->incSpaceIteration();
break;
}
}
adaptInfo->incSpaceIteration();
problemIteration_->endIteration(adaptInfo);
problemIteration->endIteration(adaptInfo);
} while (!adaptInfo->spaceToleranceReached() &&
adaptInfo->getSpaceIteration() <= adaptInfo->getMaxSpaceIteration());
} else {
problemIteration_->endIteration(adaptInfo);
problemIteration->endIteration(adaptInfo);
}
......@@ -193,8 +198,8 @@ namespace AMDiS {
// After successful iteration/timestep the timestep will be changed according
// adaption rules for next timestep.
// First, check for increase of timestep
if (!fixedTimestep_ && adaptInfo->timeErrorLow()) {
adaptInfo->setTimestep(adaptInfo->getTimestep() * time_delta_2);
if (!fixedTimestep && adaptInfo->timeErrorLow()) {
adaptInfo->setTimestep(adaptInfo->getTimestep() * timeDelta2);
if (dbgMode) {
// print information about timestep increase
}
......@@ -202,20 +207,51 @@ namespace AMDiS {
if (dbgMode) {
std::cout << "=== ADAPT INFO DEBUG MODE ===\n";
std::cout << " Do not increase timestep: \n";
if (fixedTimestep_)
if (fixedTimestep)
std::cout << " fixedTimestep = true\n";
if (!adaptInfo->timeErrorLow())
adaptInfo->printTimeErrorLowInfo();
}
}
// Second, check for decrease of timestep
if (!fixedTimestep_ &&
if (!fixedTimestep &&
!adaptInfo->timeToleranceReached() &&
!(adaptInfo->getTimestep() <= adaptInfo->getMinTimestep())) {
adaptInfo->setTimestep(adaptInfo->getTimestep() * time_delta_1);
}
!(adaptInfo->getTimestep() <= adaptInfo->getMinTimestep()))
adaptInfo->setTimestep(adaptInfo->getTimestep() * timeDelta1);
}
void AdaptInstationary::simpleAdaptiveTimeStrategy()
{
FUNCNAME("AdaptInstationary::explicitTimeStrategy()");
// estimate before first adaption
if (adaptInfo->getTime() <= adaptInfo->getStartTime())
problemIteration->oneIteration(adaptInfo, ESTIMATE);
adaptInfo->setTime(adaptInfo->getTime() + adaptInfo->getTimestep());
problemTime->setTime(adaptInfo);
INFO(info,6)("time = %e, timestep = %e\n",
adaptInfo->getTime(), adaptInfo->getTimestep());
problemIteration->oneIteration(adaptInfo, FULL_ITERATION);
adaptInfo->setLastProcessedTimestep(adaptInfo->getTimestep());
// First, check for increase of timestep
if (!fixedTimestep && adaptInfo->timeErrorLow())
adaptInfo->setTimestep(adaptInfo->getTimestep() * timeDelta2);
// Second, check for decrease of timestep
if (!fixedTimestep &&
!adaptInfo->timeToleranceReached() &&
!(adaptInfo->getTimestep() <= adaptInfo->getMinTimestep()))
adaptInfo->setTimestep(adaptInfo->getTimestep() * timeDelta1);
}
void AdaptInstationary::oneTimestep()
{
FUNCNAME("AdaptInstationary::oneTimestep()");
......@@ -229,14 +265,17 @@ namespace AMDiS {
case 1:
implicitTimeStrategy();
break;
case 2:
simpleAdaptiveTimeStrategy();
break;
default:
MSG("unknown strategy = %d; use explicit strategy\n", strategy);
explicitTimeStrategy();
ERROR_EXIT("Unknown strategy = %d!\n", strategy);
}
adaptInfo->incTimestepNumber();
}
int AdaptInstationary::adapt()
{
FUNCNAME("AdaptInstationary::adapt()");
......@@ -252,22 +291,22 @@ namespace AMDiS {
if (adaptInfo->getTimestepNumber() == 0) {
adaptInfo->setTime(adaptInfo->getStartTime());
initialAdaptInfo_->setStartTime(adaptInfo->getStartTime());
initialAdaptInfo_->setTime(adaptInfo->getStartTime());
initialAdaptInfo->setStartTime(adaptInfo->getStartTime());
initialAdaptInfo->setTime(adaptInfo->getStartTime());
problemTime_->setTime(adaptInfo);
problemTime->setTime(adaptInfo);
// initial adaption
problemTime_->solveInitialProblem(initialAdaptInfo_);
problemTime_->transferInitialSolution(adaptInfo);
problemTime->solveInitialProblem(initialAdaptInfo);
problemTime->transferInitialSolution(adaptInfo);
}
while (!adaptInfo->reachedEndTime()) {
iterationTimestamp_ = time(NULL);
iterationTimestamp = time(NULL);
problemTime_->initTimestep(adaptInfo);
problemTime->initTimestep(adaptInfo);
oneTimestep();
problemTime_->closeTimestep(adaptInfo);
problemTime->closeTimestep(adaptInfo);
if (breakWhenStable && (adaptInfo->getSolverIterations() == 0)) {
break;
......@@ -285,53 +324,54 @@ namespace AMDiS {
return errorCode;
}
void AdaptInstationary::initialize(std::string aName)
{
FUNCNAME("AdaptInstationary::initialize()");
strategy = 0;
time_delta_1 = 0.7071;
time_delta_2 = 1.4142;
queueRuntime_ = -1;
queueSerializationFilename_ = "__serialized_problem.ser";
timeDelta1 = 0.7071;
timeDelta2 = 1.4142;
queueRuntime = -1;
queueSerializationFilename = "__serialized_problem.ser";
GET_PARAMETER(0, aName + "->strategy", "%d", &strategy);
GET_PARAMETER(0, aName + "->time delta 1", "%f", &time_delta_1);
GET_PARAMETER(0, aName + "->time delta 2", "%f", &time_delta_2);
GET_PARAMETER(0, aName + "->info", "%d", &info_);
GET_PARAMETER(0, aName + "->time delta 1", "%f", &timeDelta1);
GET_PARAMETER(0, aName + "->time delta 2", "%f", &timeDelta2);
GET_PARAMETER(0, aName + "->info", "%d", &info);
GET_PARAMETER(0, aName + "->break when stable", "%d", &breakWhenStable);
GET_PARAMETER(0, aName + "->queue->runtime", "%d", &queueRuntime_);
GET_PARAMETER(0, aName + "->queue->runtime", "%d", &queueRuntime);
GET_PARAMETER(0, aName + "->queue->serialization filename",
&queueSerializationFilename_);
&queueSerializationFilename);
}
void AdaptInstationary::serialize(std::ostream &out)
{
FUNCNAME("AdaptInstationary::serialize()");
problemIteration_->serialize(out);
problemIteration->serialize(out);
adaptInfo->serialize(out);
if (problemTime_) {
problemTime_->serialize(out);
}
if (problemTime)
problemTime->serialize(out);
}
void AdaptInstationary::deserialize(std::istream &in)
{
FUNCNAME("AdaptInstationary::deserialize()");
problemIteration_->deserialize(in);
problemIteration->deserialize(in);
adaptInfo->deserialize(in);
if (problemTime_) {
problemTime_->deserialize(in);
}
if (problemTime)
problemTime->deserialize(in);
}
bool AdaptInstationary::checkQueueRuntime()
{
// If there is no time limited runtime queue, there is also nothing to check.
if (queueRuntime_ == -1) {
if (queueRuntime == -1) {
return false;
}
......@@ -339,24 +379,23 @@ namespace AMDiS {
time_t currentTimestamp = time(NULL);
// Update list with the last iteration runtimes.
lastIterationsDuration_.push(currentTimestamp - iterationTimestamp_);
lastIterationsDuration.push(currentTimestamp - iterationTimestamp);
// The list should not contain more than 5 elements. If so, delete the oldest one.
if (lastIterationsDuration_.size() > 5) {
lastIterationsDuration_.pop();
}
if (lastIterationsDuration.size() > 5)
lastIterationsDuration.pop();
// Calculate the avarage of the last iterations.
std::queue<int> tmpQueue = lastIterationsDuration_;
std::queue<int> tmpQueue = lastIterationsDuration;
int avrgLastIterations = 0;