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

Start to change pointer usage to reference usage in AMDiS interface.

parent 709a214e
...@@ -20,16 +20,41 @@ namespace AMDiS { ...@@ -20,16 +20,41 @@ namespace AMDiS {
{ {
FUNCNAME("AdaptInstationary::AdaptInstationary()"); FUNCNAME("AdaptInstationary::AdaptInstationary()");
// MSG("You make use of the obsolete constructor AdaptInstationary::AdaptInstationary(...)!\n");
// MSG("Please use the constructor that uses references instead of pointers!\n");
initConstructor(problemStat, info, initialInfo, initialTimestamp);
}
AdaptInstationary::AdaptInstationary(std::string name,
ProblemIterationInterface &problemStat,
AdaptInfo &info,
ProblemTimeInterface &problemInstat,
AdaptInfo &initialInfo,
time_t initialTimestamp)
: AdaptBase(name, &problemStat, &info, &problemInstat, &initialInfo),
breakWhenStable(0),
dbgMode(false)
{
FUNCNAME("AdaptInstationary::AdaptInstationary()");
initConstructor(&problemStat, &info, &initialInfo, initialTimestamp);
}
void AdaptInstationary::initConstructor(ProblemIterationInterface *problemStat,
AdaptInfo *info,
AdaptInfo *initialInfo,
time_t initialTimestamp)
{
initialize(name); initialize(name);
fixedTimestep_ = (info->getMinTimestep() == info->getMaxTimestep()); fixedTimestep_ = (info->getMinTimestep() == info->getMaxTimestep());
if (initialTimestamp == 0) { if (initialTimestamp == 0)
initialTimestamp_ = time(NULL); initialTimestamp_ = time(NULL);
} else { else
initialTimestamp_ = initialTimestamp; initialTimestamp_ = initialTimestamp;
}
// 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);
......
...@@ -43,7 +43,7 @@ namespace AMDiS { ...@@ -43,7 +43,7 @@ namespace AMDiS {
public: public:
/** \brief /** \brief
* Creates a AdaptInstationary object with the given name for the time * Creates a AdaptInstationary object with the given name for the time
* dependent problem problemInstat. * dependent problem problemInstat. TODO: Make obsolete!
*/ */
AdaptInstationary(std::string name, AdaptInstationary(std::string name,
ProblemIterationInterface *problemStat, ProblemIterationInterface *problemStat,
...@@ -52,6 +52,28 @@ namespace AMDiS { ...@@ -52,6 +52,28 @@ namespace AMDiS {
AdaptInfo *initialInfo, AdaptInfo *initialInfo,
time_t initialTimestamp = 0); time_t initialTimestamp = 0);
/** \brief
* Creates a AdaptInstationary object with the given name for the time
* dependent problem problemInstat.
*/
AdaptInstationary(std::string name,
ProblemIterationInterface &problemStat,
AdaptInfo &info,
ProblemTimeInterface &problemInstat,
AdaptInfo &initialInfo,
time_t initialTimestamp = 0);
/** \brief
* This funciton is used only to avoid double code in both constructors. If the
* obsolte constructure, which uses pointers instead of references, will be
* removed, remove also this function.
* TODO: Remove if obsolete constructor will be removed.
*/
void initConstructor(ProblemIterationInterface *problemStat,
AdaptInfo *info,
AdaptInfo *initialInfo,
time_t initialTimestamp);
/// Destructor /// Destructor
virtual ~AdaptInstationary(); virtual ~AdaptInstationary();
......
...@@ -11,6 +11,19 @@ namespace AMDiS { ...@@ -11,6 +11,19 @@ namespace AMDiS {
ProblemIterationInterface *prob, ProblemIterationInterface *prob,
AdaptInfo *info) AdaptInfo *info)
: AdaptBase(name, prob, info) : AdaptBase(name, prob, info)
{
FUNCNAME("AdaptStationary::AdaptStationary()");
// MSG("You make use of the obsolete constructor AdaptStationary::AdaptStationary(...)!\n");
// MSG("Please use the constructor that uses references instead of pointers!\n");
initialize();
}
AdaptStationary::AdaptStationary(std::string name,
ProblemIterationInterface& prob,
AdaptInfo& info)
: AdaptBase(name, &prob, &info)
{ {
initialize(); initialize();
} }
......
...@@ -45,11 +45,16 @@ namespace AMDiS { ...@@ -45,11 +45,16 @@ namespace AMDiS {
class AdaptStationary : public AdaptBase class AdaptStationary : public AdaptBase
{ {
public: public:
/// Creates a AdaptStationary object with given name. /// Creates a AdaptStationary object with given name. TODO: Make obsolete!
AdaptStationary(std::string name, AdaptStationary(std::string name,
ProblemIterationInterface *prob, ProblemIterationInterface *prob,
AdaptInfo *info); AdaptInfo *info);
/// Creates a AdaptStationary object with given name.
AdaptStationary(std::string name,
ProblemIterationInterface &prob,
AdaptInfo &info);
/// Destructor /// Destructor
virtual ~AdaptStationary() {} virtual ~AdaptStationary() {}
......
...@@ -50,6 +50,20 @@ namespace AMDiS { ...@@ -50,6 +50,20 @@ namespace AMDiS {
oldSolution(NULL) oldSolution(NULL)
{} {}
ProblemInstatScal::ProblemInstatScal(std::string name_,
ProblemScal& prob)
: ProblemInstat(name_, NULL),
problemStat(&prob),
oldSolution(NULL)
{}
ProblemInstatScal::ProblemInstatScal(std::string name_,
ProblemScal& prob,
ProblemStatBase& initialProb)
: ProblemInstat(name_, &initialProb),
problemStat(&prob),
oldSolution(NULL)
{}
ProblemInstatScal::~ProblemInstatScal() ProblemInstatScal::~ProblemInstatScal()
{ {
......
...@@ -119,6 +119,10 @@ namespace AMDiS { ...@@ -119,6 +119,10 @@ namespace AMDiS {
ProblemScal *prob, ProblemScal *prob,
ProblemStatBase *initialProb = NULL); ProblemStatBase *initialProb = NULL);
ProblemInstatScal(std::string name, ProblemScal& prob);
ProblemInstatScal(std::string name, ProblemScal& prob, ProblemStatBase& initialProb);
/// Destructor. /// Destructor.
virtual ~ProblemInstatScal(); virtual ~ProblemInstatScal();
......
...@@ -58,6 +58,11 @@ namespace AMDiS { ...@@ -58,6 +58,11 @@ namespace AMDiS {
fileWriters[i]->writeFiles(adaptInfo, force); fileWriters[i]->writeFiles(adaptInfo, force);
} }
void ProblemScal::writeFiles(AdaptInfo &adaptInfo, bool force)
{
writeFiles(&adaptInfo, force);
}
void ProblemScal::interpolInitialSolution(AbstractFunction<double, WorldVector<double> > *fct) void ProblemScal::interpolInitialSolution(AbstractFunction<double, WorldVector<double> > *fct)
{ {
solution->interpol(fct); solution->interpol(fct);
......
...@@ -157,9 +157,12 @@ namespace AMDiS { ...@@ -157,9 +157,12 @@ namespace AMDiS {
return this; return this;
} }
/// Writes output files. /// Writes output files. TODO: Make obsolete.
void writeFiles(AdaptInfo *adaptInfo, bool force); void writeFiles(AdaptInfo *adaptInfo, bool force);
/// Writes output files.
void writeFiles(AdaptInfo &adaptInfo, bool force);
/// Interpolates fct to \ref solution. /// Interpolates fct to \ref solution.
void interpolInitialSolution(AbstractFunction<double, WorldVector<double> > *fct); void interpolInitialSolution(AbstractFunction<double, WorldVector<double> > *fct);
......
...@@ -842,6 +842,11 @@ namespace AMDiS { ...@@ -842,6 +842,11 @@ namespace AMDiS {
#endif #endif
} }
void ProblemVec::writeFiles(AdaptInfo &adaptInfo, bool force)
{
writeFiles(&adaptInfo, force);
}
void ProblemVec::interpolInitialSolution(std::vector<AbstractFunction<double, WorldVector<double> >*> *fct) void ProblemVec::interpolInitialSolution(std::vector<AbstractFunction<double, WorldVector<double> >*> *fct)
{ {
FUNCNAME("ProblemVec::interpolInitialSolution()"); FUNCNAME("ProblemVec::interpolInitialSolution()");
......
...@@ -202,9 +202,12 @@ namespace AMDiS { ...@@ -202,9 +202,12 @@ namespace AMDiS {
return this; return this;
} }
/// Writes output files. /// Writes output files. TODO: Make obsolete.
void writeFiles(AdaptInfo *adaptInfo, bool force); void writeFiles(AdaptInfo *adaptInfo, bool force);
/// Writes output files.
void writeFiles(AdaptInfo &adaptInfo, bool force);
/// Interpolates fct to \ref solution. /// Interpolates fct to \ref solution.
void interpolInitialSolution(std::vector<AbstractFunction<double, WorldVector<double> >*> *fct); void interpolInitialSolution(std::vector<AbstractFunction<double, WorldVector<double> >*> *fct);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment