Skip to content
Snippets Groups Projects
Forked from iwr / amdis
2339 commits behind the upstream repository.
AdaptBase.h 3.48 KiB
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  TU Dresden                                                            ==
// ==                                                                        ==
// ==  Institut fr Wissenschaftliches Rechnen                               ==
// ==  Zellescher Weg 12-14                                                  ==
// ==  01069 Dresden                                                         ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  https://gforge.zih.tu-dresden.de/projects/amdis/                      ==
// ==                                                                        ==
// ============================================================================

/** \file AdaptBase.h */

#ifndef AMDIS_ADAPTBASE_H
#define AMDIS_ADAPTBASE_H

#include <string>
#include "AMDiS_fwd.h"

namespace AMDiS {

  /// Interface for adaption loops.
  class AdaptBase
  {
  public:
    /// Constructor
    AdaptBase(std::string sname,
	      ProblemIterationInterface *problemIteration,
	      AdaptInfo *adapt,
	      ProblemTimeInterface *problemTime = NULL,
	      AdaptInfo *initialAdaptInfo = NULL)
      : name(sname),
	problemIteration_(problemIteration),
	adaptInfo(adapt),
	problemTime_(problemTime),
	initialAdaptInfo_(initialAdaptInfo)
    {}

    /// Destructor
    virtual ~AdaptBase() {}

    /** \brief
     * Pure virtual method. Must be overloaded by sub classes to perform
     * a concrete adaption loop. 
     */
    virtual int adapt() = 0;

    /// Returns \ref name
    inline std::string getName() const 
    { 
      return name; 
    }

    /// Returns \ref problemIteration_
    inline ProblemIterationInterface *getProblemIteration() 
    {
      return problemIteration_;
    }

    ///
    inline void setProblemIteration(ProblemIterationInterface *pii) 
    {
      problemIteration_ = pii;
    }

    /// Returns \ref adaptInfo
    inline AdaptInfo *getAdaptInfo() 
    { 
      return adaptInfo; 
    }

    /// Returns \ref problemTime_
    inline ProblemTimeInterface *getProblemTime() 
    {
      return problemTime_;
    }

    ///
    inline void setProblemTime(ProblemTimeInterface *pti) 
    {
      problemTime_ = pti;
    }

    /// Returns \ref initialAdaptInfo_
    inline AdaptInfo *getInitialAdaptInfo() 
    { 
      return initialAdaptInfo_; 
    }

  protected:
    /// Name of the adaption loop
    std::string name;

    /// Problem iteration interface
    ProblemIterationInterface *problemIteration_;

    /// Main adapt info
    AdaptInfo *adaptInfo;

    /// problem time interface
    ProblemTimeInterface *problemTime_;

    /** \brief
     * Adapt info for initial adapt. Will be given to 
     * problemTime_->solveInitialProblem().
     */
    AdaptInfo *initialAdaptInfo_;

    /// Info level
    static int info_;
  };

}

#endif