AdaptStationary.cc 2.14 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
//
// Software License for AMDiS
//
// Copyright (c) 2010 Dresden University of Technology 
// All rights reserved.
// Authors: Simon Vey, Thomas Witkowski et al.
//
// This file is part of AMDiS
//
// See also license.opensource.txt in the distribution.


13
#include "AdaptStationary.h"
14
#include "Initfile.h"
15
16
17
18
#include "Estimator.h"
#include "ProblemIterationInterface.h"
#include <math.h>

19
20
21
22
23
#if HAVE_PARALLEL_DOMAIN_AMDIS
#include "parallel/MeshDistributor.h"
#include <petsc.h>
#endif

24
25
namespace AMDiS {

Thomas Witkowski's avatar
Thomas Witkowski committed
26
  AdaptStationary::AdaptStationary(std::string name,
27
				   ProblemIterationInterface *prob,
Thomas Witkowski's avatar
Thomas Witkowski committed
28
				   AdaptInfo *info) 
29
30
    : AdaptBase(name, prob, info)
  {
31
32
    FUNCNAME("AdaptStationary::AdaptStationary()");

33
34
    MSG("You make use of the obsolete constructor AdaptStationary::AdaptStationary(...)!\n");
    MSG("Please use the constructor that uses references instead of pointers!\n");
35
36
37
38

    initialize();
  }

Thomas Witkowski's avatar
Thomas Witkowski committed
39

40
41
42
43
44
  AdaptStationary::AdaptStationary(std::string name,
				   ProblemIterationInterface& prob,
				   AdaptInfo& info) 
    : AdaptBase(name, &prob, &info)
  {
45
46
47
    initialize();
  }

Thomas Witkowski's avatar
Thomas Witkowski committed
48

49
50
51
52
  int AdaptStationary::adapt()
  {
    FUNCNAME("AdaptStationary::adapt()");

53
54
55
56
#if HAVE_PARALLEL_DOMAIN_AMDIS
    MeshDistributor::globalMeshDistributor->initParallelization(); 
#endif

57
    // initial iteration
Thomas Witkowski's avatar
* Bla    
Thomas Witkowski committed
58
    if (adaptInfo->getSpaceIteration() == -1) {
Thomas Witkowski's avatar
Thomas Witkowski committed
59
60
61
      problemIteration->beginIteration(adaptInfo);
      problemIteration->oneIteration(adaptInfo, NO_ADAPTION);
      problemIteration->endIteration(adaptInfo);
Thomas Witkowski's avatar
* Bla    
Thomas Witkowski committed
62
      adaptInfo->incSpaceIteration();
63
    }
64
    
65
    // adaption loop
Thomas Witkowski's avatar
* Bla    
Thomas Witkowski committed
66
67
68
    while (!adaptInfo->spaceToleranceReached() && 
	   (adaptInfo->getSpaceIteration() < adaptInfo->getMaxSpaceIteration() || 
	    adaptInfo->getMaxSpaceIteration() < 0) ) {
69

Thomas Witkowski's avatar
Thomas Witkowski committed
70
71
72
      problemIteration->beginIteration(adaptInfo);
      Flag adapted = problemIteration->oneIteration(adaptInfo, FULL_ITERATION);
      problemIteration->endIteration(adaptInfo);
73
74
75
76
      
      if (!adapted) 
	break;
      
Thomas Witkowski's avatar
* Bla    
Thomas Witkowski committed
77
      adaptInfo->incSpaceIteration();
78
    }
79
80
81
82

    return 0;
  }

Thomas Witkowski's avatar
Thomas Witkowski committed
83

84
85
86
87
  void AdaptStationary::initialize()
  {
    FUNCNAME("AdaptStationary::initialize()");
  
88
    Parameters::get(name + "->info", info);
89
90
91
  }

}