ProblemInstat.inc.hpp 1.39 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
#include "ProblemInstat.hpp"

#include "AdaptInfo.hpp"

namespace AMDiS
{  
  template <class Traits>
  void ProblemInstat<Traits>::transferInitialSolution(AdaptInfo& adaptInfo)
  {
    AMDIS_TEST_EXIT(adaptInfo.getTime() == adaptInfo.getStartTime(),
      "after initial solution: time != start time");
    problemStat.writeFiles(adaptInfo, true);
  }


  template <class Traits>
  void ProblemInstat<Traits>::closeTimestep(AdaptInfo& adaptInfo)
  {
    bool force = (adaptInfo.getTime() >= adaptInfo.getEndTime());
    problemStat.writeFiles(adaptInfo, force);
  }
  

  template <class Traits>
  void ProblemInstat<Traits>::initialize(Flag initFlag)
  {
    AMDIS_FUNCNAME("ProblemInstat::initialize()");

    // === create vector for old solution ===
    if (initFlag.isSet(INIT_UH_OLD))
        createUhOld();
  }


  template <class Traits>
  void ProblemInstat<Traits>::createUhOld()
  {
38
    if (oldSolution) {
39 40
      AMDIS_WARNING("oldSolution already created\n");
    }
41
    else {
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
      const int size = problemStat.getNumComponents();
      
      // create oldSolution
      std::vector<std::string> componentNames(size, name + "_uOld");
      oldSolution = std::make_shared<SystemVectorType>(*problemStat.getFeSpaces(), componentNames);
    }
  }


  template <class Traits>
  void ProblemInstat<Traits>::initTimestep(AdaptInfo&)
  {
    if (oldSolution)
      oldSolution->copy(*problemStat.getSolution());
  }

}