AdaptStationary.cc 1.33 KB
Newer Older
1 2 3 4 5 6 7 8 9
#include "AdaptStationary.h"
#include "Parameters.h"
#include "Estimator.h"
#include "TecPlotWriter.h"
#include "ProblemIterationInterface.h"
#include <math.h>

namespace AMDiS {

Thomas Witkowski's avatar
Thomas Witkowski committed
10
  AdaptStationary::AdaptStationary(std::string name,
11
				   ProblemIterationInterface *prob,
Thomas Witkowski's avatar
Thomas Witkowski committed
12
				   AdaptInfo *info) 
13 14 15 16 17 18 19 20 21 22
    : AdaptBase(name, prob, info)
  {
    initialize();
  }

  int AdaptStationary::adapt()
  {
    FUNCNAME("AdaptStationary::adapt()");

    // initial iteration
Thomas Witkowski's avatar
* Bla  
Thomas Witkowski committed
23 24 25 26 27
    if (adaptInfo->getSpaceIteration() == -1) {
      problemIteration_->beginIteration(adaptInfo);
      problemIteration_->oneIteration(adaptInfo, NO_ADAPTION);
      problemIteration_->endIteration(adaptInfo);
      adaptInfo->incSpaceIteration();
28 29 30
    }

    // adaption loop
Thomas Witkowski's avatar
* Bla  
Thomas Witkowski committed
31 32 33
    while (!adaptInfo->spaceToleranceReached() && 
	   (adaptInfo->getSpaceIteration() < adaptInfo->getMaxSpaceIteration() || 
	    adaptInfo->getMaxSpaceIteration() < 0) ) {
34

Thomas Witkowski's avatar
* Bla  
Thomas Witkowski committed
35 36 37
      problemIteration_->beginIteration(adaptInfo);
      Flag adapted = problemIteration_->oneIteration(adaptInfo, FULL_ITERATION);
      problemIteration_->endIteration(adaptInfo);
38 39 40 41
      
      if (!adapted) 
	break;
      
Thomas Witkowski's avatar
* Bla  
Thomas Witkowski committed
42
      adaptInfo->incSpaceIteration();
43
    }
44 45 46 47 48 49 50 51

    return 0;
  }

  void AdaptStationary::initialize()
  {
    FUNCNAME("AdaptStationary::initialize()");
  
Thomas Witkowski's avatar
Thomas Witkowski committed
52
    GET_PARAMETER(0, name + "->info", "%d", &info_);
53 54 55
  }

}