ProblemNonLin.cc 1.91 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//
// 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.


#include "ProblemNonLin.h"
#include "NonLinSolver.h"
#include "CreatorMap.h"
#include "Traverse.h"
#include "AdaptInfo.h"

namespace AMDiS {

  void ProblemNonLin::initialize(Flag initFlag,
22
				 ProblemStatSeq *adoptProblem /*= NULL*/,
23
24
				 Flag adoptFlag /*= INIT_NOTHING*/) 
  {
25
    FUNCNAME("ProblemNonLin::initialize()");
26

27
    ProblemStat::initialize(initFlag, adoptProblem, adoptFlag);
28
29

    // === create nonlinear solver ===
30
31
    if (nonLinSolver) { 
      WARNING("Nonlinear solver already created!\n");
32
33
34
35
36
    } else {
      if (initFlag.isSet(INIT_NONLIN_SOLVER))
	createNonLinSolver();     

      if (adoptProblem && adoptFlag.isSet(INIT_NONLIN_SOLVER)) {
37
38
	TEST_EXIT(nonLinSolver == NULL)("Nonlinear solver already created!\n");
	nonLinSolver = dynamic_cast<ProblemNonLin*>(adoptProblem)->getNonLinSolver();
39
40
41
      }
    }

42
43
    if (nonLinSolver == NULL)
      WARNING("No nonlinear solver created!\n");
44
45
46
47
48
49
50
  }


  void ProblemNonLin::createNonLinSolver() 
  {
    // create non-linear solver
    std::string nonLinSolverType("no");
51
52
    std::string initFileStr(name + "->nonlin solver");
    Parameters::get(initFileStr, nonLinSolverType);
53
54

    NonLinSolverCreator *nonLinSolverCreator = 
55
      dynamic_cast<NonLinSolverCreator*>(CreatorMap<NonLinSolver>::getCreator(nonLinSolverType, initFileStr));
56
57
58

    nonLinSolverCreator->setLinearSolver(solver);
    nonLinSolverCreator->setName(name + "->nonlin solver");
59
    nonLinSolver = nonLinSolverCreator->create();
60
61
62
  }


Thomas Witkowski's avatar
Thomas Witkowski committed
63
  void ProblemNonLin::solve(AdaptInfo *adaptInfo, bool b0, bool b1) 
64
  {
65
66
    TEST_EXIT(nonLinSolver)("no non-linear solver!\n");

Thomas Witkowski's avatar
Thomas Witkowski committed
67
    MSG("HERE A\n");
68

Thomas Witkowski's avatar
Thomas Witkowski committed
69
    nonLinSolver->solve(solverMatrix, *solution, *rhs, adaptInfo, this);
70
71
72
  }

}