AdaptInfo.cc 4.77 KB
Newer Older
1 2 3 4 5 6 7
/******************************************************************************
 *
 * AMDiS - Adaptive multidimensional simulations
 *
 * Copyright (C) 2013 Dresden University of Technology. All Rights Reserved.
 * Web: https://fusionforge.zih.tu-dresden.de/projects/amdis
 *
8
 * Authors:
9 10 11 12 13 14 15 16 17
 * Simon Vey, Thomas Witkowski, Andreas Naumann, Simon Praetorius, et al.
 *
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 *
 * This file is part of AMDiS
 *
 * See also license.opensource.txt in the distribution.
18
 *
19
 ******************************************************************************/
20 21


22 23 24
#include "boost/lexical_cast.hpp"
#include "AdaptInfo.h"
#include "Serializer.h"
25 26 27

namespace AMDiS {

28 29
  using boost::lexical_cast;

30
  void AdaptInfo::setScalContents(int newSize)
31
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
32
    int oldSize = static_cast<int>(scalContents.size());
33

34
    if (newSize > oldSize) {
35 36
      scalContents.resize(newSize);

37
      for (int i = oldSize; i < newSize; i++)
38 39
	scalContents[i] =
	  new ScalContent(name + "[" + lexical_cast<std::string>(i) + "]");
40 41 42
    }
  }

Thomas Witkowski's avatar
Thomas Witkowski committed
43

44
  void AdaptInfo::serialize(std::ostream& out)
45
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
46
    out << name << "\n";
47

48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
    SerUtil::serialize(out, maxSpaceIteration);
    SerUtil::serialize(out, spaceIteration);
    SerUtil::serialize(out, timestepIteration);
    SerUtil::serialize(out, maxTimestepIteration);
    SerUtil::serialize(out, timeIteration);
    SerUtil::serialize(out, maxTimeIteration);
    SerUtil::serialize(out, time);
    SerUtil::serialize(out, startTime);
    SerUtil::serialize(out, endTime);
    SerUtil::serialize(out, timestep);
    SerUtil::serialize(out, minTimestep);
    SerUtil::serialize(out, maxTimestep);
    SerUtil::serialize(out, timestepNumber);
    SerUtil::serialize(out, nTimesteps);
    SerUtil::serialize(out, solverIterations);
    SerUtil::serialize(out, maxSolverIterations);
    SerUtil::serialize(out, solverTolerance);
    SerUtil::serialize(out, solverResidual);

Thomas Witkowski's avatar
Thomas Witkowski committed
67
    unsigned int size = scalContents.size();
68
    SerUtil::serialize(out, size);
Thomas Witkowski's avatar
Thomas Witkowski committed
69
    for (unsigned int i = 0; i < size; i++) {
70 71 72 73
      SerUtil::serialize(out, scalContents[i]->est_sum);
      SerUtil::serialize(out, scalContents[i]->est_t_sum);
      SerUtil::serialize(out, scalContents[i]->est_max);
      SerUtil::serialize(out, scalContents[i]->est_t_max);
74 75
      SerUtil::serialize(out, scalContents[i]->fac_max);
      SerUtil::serialize(out, scalContents[i]->fac_sum);
76
      SerUtil::serialize(out, scalContents[i]->spaceTolerance);
77
      SerUtil::serialize(out, scalContents[i]->timeTolerance);
78 79 80 81 82
      SerUtil::serialize(out, scalContents[i]->timeErrLow);
      SerUtil::serialize(out, scalContents[i]->coarsenAllowed);
      SerUtil::serialize(out, scalContents[i]->refinementAllowed);
      SerUtil::serialize(out, scalContents[i]->refineBisections);
      SerUtil::serialize(out, scalContents[i]->coarseBisections);
83 84 85
    }
  }

Thomas Witkowski's avatar
Thomas Witkowski committed
86

87
  void AdaptInfo::deserialize(std::istream& in)
88
  {
89
    in >> name;
90
    in.get();
91

92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
    SerUtil::deserialize(in, maxSpaceIteration);
    SerUtil::deserialize(in, spaceIteration);
    SerUtil::deserialize(in, timestepIteration);
    SerUtil::deserialize(in, maxTimestepIteration);
    SerUtil::deserialize(in, timeIteration);
    SerUtil::deserialize(in, maxTimeIteration);
    SerUtil::deserialize(in, time);
    SerUtil::deserialize(in, startTime);
    SerUtil::deserialize(in, endTime);
    SerUtil::deserialize(in, timestep);
    SerUtil::deserialize(in, minTimestep);
    SerUtil::deserialize(in, maxTimestep);
    SerUtil::deserialize(in, timestepNumber);
    SerUtil::deserialize(in, nTimesteps);
    SerUtil::deserialize(in, solverIterations);
    SerUtil::deserialize(in, maxSolverIterations);
    SerUtil::deserialize(in, solverTolerance);
    SerUtil::deserialize(in, solverResidual);
    int size = 0;
    SerUtil::deserialize(in, size);
112
    scalContents.resize(size);
113
    for (int i = 0; i < size; i++) {
114 115
      scalContents[i] =
	new ScalContent(name + "[" + lexical_cast<std::string>(i) + "]");
116

117
      SerUtil::deserialize(in, scalContents[i]->est_sum);
118 119 120
      SerUtil::deserialize(in, scalContents[i]->est_t_sum);
      SerUtil::deserialize(in, scalContents[i]->est_max);
      SerUtil::deserialize(in, scalContents[i]->est_t_max);
121 122
      SerUtil::deserialize(in, scalContents[i]->fac_max);
      SerUtil::deserialize(in, scalContents[i]->fac_sum);
123
      SerUtil::deserialize(in, scalContents[i]->spaceTolerance);
124
      SerUtil::deserialize(in, scalContents[i]->timeTolerance);
125 126 127 128 129
      SerUtil::deserialize(in, scalContents[i]->timeErrLow);
      SerUtil::deserialize(in, scalContents[i]->coarsenAllowed);
      SerUtil::deserialize(in, scalContents[i]->refinementAllowed);
      SerUtil::deserialize(in, scalContents[i]->refineBisections);
      SerUtil::deserialize(in, scalContents[i]->coarseBisections);
130
    }
131 132 133
  }

}