diff --git a/extensions/base_problems/BaseProblem.h b/extensions/base_problems/BaseProblem.h index cff8f289d93a58ab96e4ccbcd150db3718d1390e..9438671e92e860acbda991aa772db1d99346999e 100644 --- a/extensions/base_problems/BaseProblem.h +++ b/extensions/base_problems/BaseProblem.h @@ -18,48 +18,52 @@ class BaseProblem : public ProblemIterationInterface, public ProblemInstatBase { public: - + BaseProblem(const std::string &name_); ~BaseProblem() { delete prob; } - + /// Initialisation of the problem. - virtual void initialize(Flag initFlag, - ProblemStat *adoptProblem = NULL, - Flag adoptFlag = INIT_NOTHING); - + void initialize(Flag initFlag, + ProblemStat *adoptProblem = NULL, + Flag adoptFlag = INIT_NOTHING); + /// Initialisation of DOFVectors and AbstractFunctions, /// is called in \ref initTimeInteface after feSpace and mesh are initialized virtual void initData() {}; - + /// calls \ref initData, \ref fillOperators and \ref fillBoundaryConditions in this ordering virtual void initTimeInterface() - { FUNCNAME("BaseProblem::initTimeInterface()"); + { + FUNCNAME("BaseProblem::initTimeInterface()"); initData(); fillOperators(); fillBoundaryConditions(); - }; - + } + /// read solution DOFVectors from .arh, .dat or .vtu files virtual Flag initDataFromFile(AdaptInfo *adaptInfo); - + /// calls \ref initDataFromFile virtual void solveInitialProblem(AdaptInfo *adaptInfo) - { FUNCNAME("BaseProblem::solveInitialProblem()"); + { + FUNCNAME("BaseProblem::solveInitialProblem()"); Flag initFlag = initDataFromFile(adaptInfo); - }; + } /// calls \ref writeFiles virtual void transferInitialSolution(AdaptInfo *adaptInfo) - { FUNCNAME("BaseProblem::transferInitialSolution()"); + { + FUNCNAME("BaseProblem::transferInitialSolution()"); oldMeshChangeIdx = getMesh()->getChangeIndex(); writeFiles(adaptInfo, false); - }; + } /// This method is called before \ref beginIteration, \ref oneIteration and \ref endIteration. - virtual void initTimestep(AdaptInfo *adaptInfo) {}; + virtual void initTimestep(AdaptInfo *adaptInfo) + {} /// calls \ref writeFiles virtual void closeTimestep(AdaptInfo *adaptInfo); @@ -70,9 +74,10 @@ public: /// Calls writeFiles of the problem virtual void writeFiles(AdaptInfo *adaptInfo, bool force) - { FUNCNAME("BaseProblem::writeFiles()"); + { + FUNCNAME("BaseProblem::writeFiles()"); prob->writeFiles(adaptInfo, force); - }; + } // getting methods @@ -98,25 +103,28 @@ public: std::string getName() { return name; - }; + } int getNumProblems() { return 1; - }; + } int getNumComponents() { return prob->getNumComponents(); - }; + } - ProblemType *getProblem(int number= 0) + ProblemType *getProblem(int number = 0) { - if (number<0 || number >= getNumProblems()) + if (number < 0 || number >= getNumProblems()) throw(std::runtime_error("problem with given number does not exist")); + if (number == 0) return prob; - }; + + return NULL; + } ProblemType *getProblem(std::string name) { @@ -124,7 +132,7 @@ public: return prob; else throw(std::runtime_error("problem with given name '" + name + "' does not exist")); - }; + } // setting methods @@ -138,14 +146,19 @@ public: nTimesteps= nTimesteps_; } - void serialize(std::ostream&) {}; - void deserialize(std::istream&) {}; + void serialize(std::ostream&) + {} + + void deserialize(std::istream&) + {} /// method where operators are added to the problem - virtual void fillOperators() {}; + virtual void fillOperators() + {} /// method where boundary conditions are added to the problem - virtual void fillBoundaryConditions() {}; + virtual void fillBoundaryConditions() + {} /// classical backward-euler time-discretization void addTimeOperator(ProblemStat *prob, int i, int j); diff --git a/extensions/base_problems/BaseProblem.hh b/extensions/base_problems/BaseProblem.hh index 3bb934650c4c77c84a269f42165c89fa324e0d88..213c821404980e5aa54311ed0326192bc5e02279 100644 --- a/extensions/base_problems/BaseProblem.hh +++ b/extensions/base_problems/BaseProblem.hh @@ -1,51 +1,52 @@ using namespace AMDiS; template<typename ProblemType> -BaseProblem<ProblemType>::BaseProblem(const std::string &name_) : - ProblemInstatBase(name_,NULL), - prob(NULL), - secureIteration(false), - oldMeshChangeIdx(0), - nTimesteps(-1), - dim(1), - dow(1), - oldTimestep(0.0) +BaseProblem<ProblemType>::BaseProblem(const std::string &name_) + : ProblemInstatBase(name_,NULL), + prob(NULL), + secureIteration(false), + oldMeshChangeIdx(0), + nTimesteps(-1), + dim(1), + dow(1), + oldTimestep(0.0) { // create basic problems prob = new ProblemType(name + "->space"); dow = Global::getGeo(WORLD); - + Initfile::get(name + "->secure iteration", secureIteration); }; template<typename ProblemType> void BaseProblem<ProblemType>::initialize(Flag initFlag, - ProblemStat *adoptProblem, - Flag adoptFlag) + ProblemStat *adoptProblem, + Flag adoptFlag) { FUNCNAME("BaseProblem::initialize()"); - + prob->initialize(initFlag, adoptProblem, adoptFlag); dim = getMesh()->getDim(); -}; +} template<typename ProblemType> Flag BaseProblem<ProblemType>::initDataFromFile(AdaptInfo *adaptInfo) -{ FUNCNAME("BaseProblem::initDataFromFile()"); - +{ + FUNCNAME("BaseProblem::initDataFromFile()"); + Flag initFlag; bool readDataFromFile = false, readArhFiles = false, readDatFiles = false; Initfile::get(name + "->read data from file", readDataFromFile, 2); if (!readDataFromFile) return initFlag; - + std::string readFormat = "arh"; Initfile::get(name + "->read format", readFormat, 2); if (readFormat != "arh" && readFormat != "dat" && readFormat != "vtu") { WARNING("You can not read data from formats other than .arh, .dat or .vtu! The .arh-format is selected.\n"); } - + // read data and mesh from arh-files/dat-files MSG("read data from file...\n"); if (readFormat == "arh") {