ProblemNonLin.h 2.95 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
// ============================================================================
// ==                                                                        ==
// == 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"
#include "MatrixVector.h"

32
33
34
35
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
#include "parallel/PetscProblemStat.h"
#endif

36
37
38
39
40
41
42
43
44
45
46
47
48
49
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()),
50
	nonLinSolver(NULL)
51
    {
52
53
      u0.resize(nComponents);
      u0.set(NULL);
54
55
    }

56
57
    /// Sets \ref u0 and interpolates it to \ref solution.
    inline void setU0(AbstractFunction<double, WorldVector<double> > *u0Fct, 
58
59
60
		      int index) 
    {
      FUNCNAME("ProblemNonLinVec::setU0()");
61
62
63

      TEST_EXIT(index < nComponents)("Invalid index!\n");
      u0[index] = u0Fct;
64
65
66
      solution->getDOFVector(index)->interpol(u0Fct);
    }

67
68
69
    /// Destructor
    virtual ~ProblemNonLin() 
    {}
70

71
    /// Initialization of the problem.
72
73
74
75
    virtual void initialize(Flag initFlag,
			    ProblemStat *adoptProblem = NULL,
			    Flag adoptFlag = INIT_NOTHING);

76
    /// Used in \ref initialize().
77
78
79
    virtual void createNonLinSolver();

    /** \brief
80
81
     * Overrides ProblemStat::solve(). Uses the non linear solver 
     * \ref nonLinSolver.
82
     */
83
    virtual void solve(AdaptInfo *adaptInfo, bool fixedMatrix = false);
84

85
    /// Overrides ProblemStat::buildAfterCoarsen(). 
86
87
88
89
    virtual void buildAfterCoarsen(AdaptInfo *adaptInfo, Flag,
				   bool assembleMatrix = true,
				   bool assembleVector = true);

90
    /// Returns \ref nonLinSolver.
91
92
    inline NonLinSolver *getNonLinSolver() 
    {
93
      return nonLinSolver;
94
95
    }

96
97
    /// Sets \ref nonLinSolver.
    inline void setNonLinSolver(NonLinSolver *s) 
98
    {
99
      nonLinSolver = s;
100
101
102
    }

  protected:
103
104
    /// Initial guess for the solution.
    Vector<AbstractFunction<double, WorldVector<double> >*> u0;
105

106
107
    /// Non linear solver object. Used in \ref solve().
    NonLinSolver *nonLinSolver;
108
109
110
111
112
113
  };

}

#endif