ProblemNonLin.h 2.93 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
// ============================================================================
// ==                                                                        ==
// == 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's avatar
Thomas Witkowski committed
30
#include <vector>
31

32
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
Naumann, Andreas's avatar
Naumann, Andreas committed
33
34
35
#ifdef HAVE_PARALLEL_MTL4
#include "parallel/Mtl4Solver.h"
#else
36
37
#include "parallel/PetscProblemStat.h"
#endif
Naumann, Andreas's avatar
Naumann, Andreas committed
38
#endif
39

Thomas Witkowski's avatar
Thomas Witkowski committed
40
41
using namespace std;

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()),
56
	nonLinSolver(NULL)
57
    {
58
      u0.resize(nComponents);
Thomas Witkowski's avatar
Thomas Witkowski committed
59
60
      for (int i = 0; i < nComponents; i++)
	u0[i] = NULL;
61
62
    }

63
64
    /// Sets \ref u0 and interpolates it to \ref solution.
    inline void setU0(AbstractFunction<double, WorldVector<double> > *u0Fct, 
65
66
67
		      int index) 
    {
      FUNCNAME("ProblemNonLinVec::setU0()");
68
69
70

      TEST_EXIT(index < nComponents)("Invalid index!\n");
      u0[index] = u0Fct;
71
72
73
      solution->getDOFVector(index)->interpol(u0Fct);
    }

74
75
76
    /// Destructor
    virtual ~ProblemNonLin() 
    {}
77

78
    /// Initialization of the problem.
79
    virtual void initialize(Flag initFlag,
80
			    ProblemStatSeq *adoptProblem = NULL,
81
82
			    Flag adoptFlag = INIT_NOTHING);

83
    /// Used in \ref initialize().
84
85
86
    virtual void createNonLinSolver();

    /** \brief
87
88
     * Overrides ProblemStat::solve(). Uses the non linear solver 
     * \ref nonLinSolver.
89
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
90
91
92
    void solve(AdaptInfo *adaptInfo,
	       bool createMatrixData = true,
	       bool storeMatrixData = false);
93

94
    /// Returns \ref nonLinSolver.
95
96
    inline NonLinSolver *getNonLinSolver() 
    {
97
      return nonLinSolver;
98
99
    }

100
101
    /// Sets \ref nonLinSolver.
    inline void setNonLinSolver(NonLinSolver *s) 
102
    {
103
      nonLinSolver = s;
104
105
106
    }

  protected:
107
    /// Initial guess for the solution.
Thomas Witkowski's avatar
Thomas Witkowski committed
108
    vector<AbstractFunction<double, WorldVector<double> >*> u0;
109

110
111
    /// Non linear solver object. Used in \ref solve().
    NonLinSolver *nonLinSolver;
112
113
114
115
116
117
  };

}

#endif