Liebe Gitlab-Nutzerin, lieber Gitlab-Nutzer,
es ist nun möglich sich mittels des ZIH-Logins/LDAP an unserem Dienst anzumelden. Die Konten der externen Nutzer:innen sind über den Reiter "Standard" erreichbar.
Die Administratoren


Dear Gitlab user,
it is now possible to log in to our service using the ZIH login/LDAP. The accounts of external users can be accessed via the "Standard" tab.
The administrators

ProblemInstat.cc 5.76 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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
#include "ProblemInstat.h"
#include "FileWriter.h"
#include "AdaptStationary.h"
#include "AdaptInstationary.h"
#include "Estimator.h"
#include "ProblemScal.h"
#include "StandardProblemIteration.h"

namespace AMDiS {

  // === ProblemInstat =================================

  ProblemInstat::~ProblemInstat()
  {
  }

  void ProblemInstat::initialize(Flag initFlag,
				 ProblemInstat *adoptProblem/* = NULL*/,
				 Flag adoptFlag /* = INIT_NOTHING*/) 
  {
    FUNCNAME("ProblemInstat::initialize()");
  }

  void ProblemInstat::solveInitialProblem(AdaptInfo *adaptInfo)
  {
    AdaptStationary initialAdapt((name + "->initial->adapt").c_str(),
				 NEW StandardProblemIteration(initialProblem),
				 adaptInfo);

    initialAdapt.adapt();
  }

  void ProblemInstatScal::transferInitialSolution(AdaptInfo *adaptInfo)
  {
    TEST_EXIT(adaptInfo->getTime() == 
	      adaptInfo->getStartTime())
      ("after initial solution: time != start time\n");
    problemStat->writeFiles(adaptInfo, true);
  }

  void ProblemInstatVec::transferInitialSolution(AdaptInfo *adaptInfo)
  {
    TEST_EXIT(adaptInfo->getTime() == 
	      adaptInfo->getStartTime())
      ("after initial solution: time != start time\n");
    problemStat->writeFiles(adaptInfo, true);
  }


  ProblemInstatScal::ProblemInstatScal(char* name_, 
				       ProblemScal *prob,
				       ProblemStatBase *initialProb)
    : ProblemInstat(name_, initialProb), 
      problemStat(prob),oldSolution(NULL)
55
  {};
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97


  ProblemInstatScal::~ProblemInstatScal()
  {
    DELETE oldSolution;
  }

  void ProblemInstatScal::initialize(Flag initFlag,
				     ProblemInstat *adoptProblem/* = NULL*/,
				     Flag adoptFlag /* = INIT_NOTHING*/) 
  {
    FUNCNAME("ProblemInstat::initialize()");
  
    ProblemInstat::initialize(initFlag, adoptProblem, adoptFlag);

    // === create vector for old solution ===
    if (oldSolution) {
      WARNING("oldSolution already created\n");
    } else {
      if (initFlag.isSet(INIT_UH_OLD)) {
	createUhOld();
      } 
      if (adoptProblem && adoptFlag.isSet(INIT_UH_OLD)) {
	ProblemInstatScal* _adoptProblem = dynamic_cast<ProblemInstatScal*>(adoptProblem);
	TEST_EXIT(_adoptProblem)("can't adopt oldSolution from problem which is not instationary and scalar");
	TEST_EXIT(!oldSolution)("oldSolution already created");
	oldSolution = _adoptProblem->getOldSolution();
      }
    }

    if (!oldSolution) 
      WARNING("no oldSolution created\n");
  }

  void ProblemInstatScal::createUhOld() {
    if (oldSolution) {
      WARNING("oldSolution already created\n");
    } else {
      // create oldSolution
      oldSolution = NEW DOFVector<double>(problemStat->getFESpace(), name + "->uOld");
      oldSolution->refineInterpol(true);
      oldSolution->setCoarsenOperation(COARSE_INTERPOL);
Thomas Witkowski's avatar
Thomas Witkowski committed
98
      if (problemStat->getEstimator()) {
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
	dynamic_cast<Estimator*>(problemStat->getEstimator())
	  ->addUhOldToSystem(0, oldSolution);
      }
    }
  }


  void ProblemInstatScal::closeTimestep(AdaptInfo *adaptInfo) 
  {
    bool force = (adaptInfo->getTime() >= adaptInfo->getEndTime());
    problemStat->writeFiles(adaptInfo, force);
  }

  void ProblemInstatVec::closeTimestep(AdaptInfo *adaptInfo) 
  {
    bool force = (adaptInfo->getTime() >= adaptInfo->getEndTime());
    problemStat->writeFiles(adaptInfo, force);
  }

  ProblemInstatVec::ProblemInstatVec(char* name_, 
				     ProblemVec *prob,
				     ProblemStatBase *initialProb)
    : ProblemInstat(name_, initialProb), 
      problemStat(prob),oldSolution(NULL)
123
  {};
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138

  ProblemInstatVec::~ProblemInstatVec()
  {
    DELETE oldSolution;
  }

  void ProblemInstatVec::initialize(Flag initFlag,
				    ProblemInstat *adoptProblem/* = NULL*/,
				    Flag adoptFlag /* = INIT_NOTHING*/) 
  {
    FUNCNAME("ProblemInstatVec::initialize()");
  
    ProblemInstat::initialize(initFlag,adoptProblem,adoptFlag);

    // === create vector for old solution ===
Thomas Witkowski's avatar
Thomas Witkowski committed
139
    if (oldSolution) {
140 141
      WARNING("oldSolution already created\n");
    } else {
Thomas Witkowski's avatar
Thomas Witkowski committed
142
      if (initFlag.isSet(INIT_UH_OLD)) {
143 144
	createUhOld();
      } 
Thomas Witkowski's avatar
Thomas Witkowski committed
145 146
      if (adoptProblem && adoptFlag.isSet(INIT_UH_OLD)) {
	ProblemInstatVec* _adoptProblem = dynamic_cast<ProblemInstatVec*>(adoptProblem);
147 148 149 150 151 152 153 154 155 156 157
	TEST_EXIT(_adoptProblem)("can't adopt oldSolution from problem which is not instationary and vectorial");
	TEST_EXIT(!oldSolution)("oldSolution already created");
	oldSolution = _adoptProblem->getOldSolution();
      }
    }

    if(!oldSolution) WARNING("no oldSolution created\n");

  }

  void ProblemInstatVec::createUhOld() {
Thomas Witkowski's avatar
Thomas Witkowski committed
158 159 160
    if (oldSolution) {
      WARNING("oldSolution already created\n");
    } else {
161 162 163 164 165
      int size = problemStat->getNumComponents();
      // create oldSolution
      oldSolution = NEW SystemVector("old solution",
				     problemStat->getFESpaces(), 
				     size);
Thomas Witkowski's avatar
Thomas Witkowski committed
166
      for (int i = 0; i < size; i++) {
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
	oldSolution->setDOFVector(i, NEW DOFVector<double>(problemStat->getFESpace(i), 
							   name + "->uOld"));
	oldSolution->getDOFVector(i)->refineInterpol(true);
	oldSolution->getDOFVector(i)->setCoarsenOperation(COARSE_INTERPOL);
      
	if(problemStat->getEstimator(i)) {
	  problemStat->getEstimator(i)->addUhOldToSystem(i, oldSolution->getDOFVector(i));
	}
      }
    }
  }

  void ProblemInstatScal::initTimestep(AdaptInfo *adaptInfo) {
    oldSolution->copy(*(problemStat->getSolution())); 
  }

  void ProblemInstatVec::initTimestep(AdaptInfo *adaptInfo) {
    oldSolution->copy(*(problemStat->getSolution())); 
  }

Thomas Witkowski's avatar
Thomas Witkowski committed
187 188 189 190 191 192 193 194 195 196
  void ProblemInstatScal::startDelayedTimestepCalculation()
  {
    problemStat->writeDelayedFiles();
  }

  void ProblemInstatVec::startDelayedTimestepCalculation()
  {
    problemStat->writeDelayedFiles();
  }

Thomas Witkowski's avatar
Thomas Witkowski committed
197 198 199 200 201 202 203 204 205
  bool ProblemInstatScal::existsDelayedCalculation()
  {
    return problemStat->existsDelayedCalculation();
  }

  bool ProblemInstatVec::existsDelayedCalculation()
  {
    return problemStat->existsDelayedCalculation();
  }
206
}