ProblemNonLin.h 2.93 KB
 Thomas Witkowski committed Jun 26, 2011 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 // ============================================================================ // == == // == AMDiS - Adaptive multidimensional simulations == // == == // == http://www.amdis-fem.org == // == == // ============================================================================ // // 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. /** \file ProblemNonLin.h */ #ifndef AMDIS_PROBLEMNONLIN_H_ #define AMDIS_PROBLEMNONLIN_H_ #include "ProblemStat.h" #include "NonLinSolver.h" #include "DOFVector.h" #include "SystemVector.h"  Thomas Witkowski committed Apr 03, 2012 30 #include  Thomas Witkowski committed Jun 26, 2011 31   Thomas Witkowski committed Jun 27, 2011 32 #ifdef HAVE_PARALLEL_DOMAIN_AMDIS  Naumann, Andreas committed Aug 13, 2011 33 34 35 #ifdef HAVE_PARALLEL_MTL4 #include "parallel/Mtl4Solver.h" #else  Thomas Witkowski committed Jun 27, 2011 36 37 #include "parallel/PetscProblemStat.h" #endif  Naumann, Andreas committed Aug 13, 2011 38 #endif  Thomas Witkowski committed Jun 27, 2011 39   Thomas Witkowski committed Apr 03, 2012 40 41 using namespace std;  Thomas Witkowski committed Jun 26, 2011 42 43 44 45 46 47 48 49 50 51 52 53 54 55 namespace AMDiS { /** * \ingroup Problem * * \brief * Standard implementation for a vector valued non linear problem. */ class ProblemNonLin : public ProblemStat { public: /// Constructs a ProblemNonLin with given name. ProblemNonLin(const std::string& name_) : ProblemStat(name_.c_str()),  Thomas Witkowski committed Jun 27, 2011 56  nonLinSolver(NULL)  Thomas Witkowski committed Jun 26, 2011 57  {  Thomas Witkowski committed Jun 27, 2011 58  u0.resize(nComponents);  Thomas Witkowski committed Apr 03, 2012 59 60  for (int i = 0; i < nComponents; i++) u0[i] = NULL;  Thomas Witkowski committed Jun 26, 2011 61 62  }  Thomas Witkowski committed Jun 27, 2011 63 64  /// Sets \ref u0 and interpolates it to \ref solution. inline void setU0(AbstractFunction > *u0Fct,  Thomas Witkowski committed Jun 26, 2011 65 66 67  int index) { FUNCNAME("ProblemNonLinVec::setU0()");  Thomas Witkowski committed Jun 27, 2011 68 69 70  TEST_EXIT(index < nComponents)("Invalid index!\n"); u0[index] = u0Fct;  Thomas Witkowski committed Jun 26, 2011 71 72 73  solution->getDOFVector(index)->interpol(u0Fct); }  Thomas Witkowski committed Jun 27, 2011 74 75 76  /// Destructor virtual ~ProblemNonLin() {}  Thomas Witkowski committed Jun 26, 2011 77   Thomas Witkowski committed Jun 27, 2011 78  /// Initialization of the problem.  Thomas Witkowski committed Jun 26, 2011 79  virtual void initialize(Flag initFlag,  80  ProblemStatSeq *adoptProblem = NULL,  Thomas Witkowski committed Jun 26, 2011 81 82  Flag adoptFlag = INIT_NOTHING);  Thomas Witkowski committed Jun 27, 2011 83  /// Used in \ref initialize().  Thomas Witkowski committed Jun 26, 2011 84 85 86  virtual void createNonLinSolver(); /** \brief  Thomas Witkowski committed Jun 27, 2011 87 88  * Overrides ProblemStat::solve(). Uses the non linear solver * \ref nonLinSolver.  Thomas Witkowski committed Jun 26, 2011 89  */  Thomas Witkowski committed Apr 03, 2012 90 91 92  void solve(AdaptInfo *adaptInfo, bool createMatrixData = true, bool storeMatrixData = false);  Thomas Witkowski committed Jun 26, 2011 93   Thomas Witkowski committed Jun 27, 2011 94  /// Returns \ref nonLinSolver.  Thomas Witkowski committed Jun 26, 2011 95 96  inline NonLinSolver *getNonLinSolver() {  Thomas Witkowski committed Jun 27, 2011 97  return nonLinSolver;  Thomas Witkowski committed Jun 26, 2011 98 99  }  Thomas Witkowski committed Jun 27, 2011 100 101  /// Sets \ref nonLinSolver. inline void setNonLinSolver(NonLinSolver *s)  Thomas Witkowski committed Jun 26, 2011 102  {  Thomas Witkowski committed Jun 27, 2011 103  nonLinSolver = s;  Thomas Witkowski committed Jun 26, 2011 104 105 106  } protected:  Thomas Witkowski committed Jun 27, 2011 107  /// Initial guess for the solution.  Thomas Witkowski committed Apr 03, 2012 108  vector >*> u0;  Thomas Witkowski committed Jun 26, 2011 109   Thomas Witkowski committed Jun 27, 2011 110 111  /// Non linear solver object. Used in \ref solve(). NonLinSolver *nonLinSolver;  Thomas Witkowski committed Jun 26, 2011 112 113 114 115 116 117  }; } #endif