AdaptStationary.cc 2.18 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
#include "est/Estimator.h"
16
17
18
#include "ProblemIterationInterface.h"
#include <math.h>

19
20
#if HAVE_PARALLEL_DOMAIN_AMDIS
#include "parallel/MeshDistributor.h"
Naumann, Andreas's avatar
Naumann, Andreas committed
21
#ifndef HAVE_PARALLEL_MTL4
22
23
#include <petsc.h>
#endif
Naumann, Andreas's avatar
Naumann, Andreas committed
24
#endif
25

26
27
namespace AMDiS {

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

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

    initialize();
  }

Thomas Witkowski's avatar
Thomas Witkowski committed
41

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

Thomas Witkowski's avatar
Thomas Witkowski committed
50

51
52
53
54
  int AdaptStationary::adapt()
  {
    FUNCNAME("AdaptStationary::adapt()");

55
56
57
58
#if HAVE_PARALLEL_DOMAIN_AMDIS
    MeshDistributor::globalMeshDistributor->initParallelization(); 
#endif

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

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

    return 0;
  }

Thomas Witkowski's avatar
Thomas Witkowski committed
85

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

}