AMDiS.cc 1.68 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
//
// 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 "AMDiS.h"
#include <string>
#ifdef HAVE_ZOLTAN
#include <zoltan_cpp.h>
#endif

namespace AMDiS {

  using namespace std;

23
24
25
26
#if defined(HAVE_PARALLEL_DOMAIN_AMDIS) && defined(HAVE_PARALLEL_MTL4)
  mtl::par::environment* mtl_environment=NULL;
#endif

Thomas Witkowski's avatar
Thomas Witkowski committed
27
  void init(int argc, char **argv, std::string initFileName)
28
29
30
31
  {
    FUNCNAME("AMDiS::init()");

#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
32
33
34
#ifdef HAVE_PARALLEL_MTL4
    mtl_environment = new mtl::par::environment(argc, argv);
#else
35
36
    PetscInitialize(&argc, &argv, NULL, NULL);
    mpi::startRand();
37
#endif
38
39
40
41
42
43

#ifdef HAVE_ZOLTAN
    float zoltanVersion = 0.0;
    Zoltan_Initialize(argc, argv, &zoltanVersion);
#endif
#endif
Praetorius, Simon's avatar
Praetorius, Simon committed
44
45
46
47
    
    Parameters::clearData();
    Parameters::readArgv(argc, argv);
    
Thomas Witkowski's avatar
Thomas Witkowski committed
48
49
50
51
52
53
    if (initFileName == "") {
      TEST_EXIT(argc >= 2)("No init file!\n");
      Parameters::init(string(argv[1]));
    } else {
      Parameters::init(initFileName);
    }
54
55
56
57
58

    Parameters::readArgv(argc, argv);
  }


59
60
61
62
63
64
65
66
67
68
69
70
  void init(std::string initFileName)
  {
    FUNCNAME("AMDiS::init()");

#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
    ERROR_EXIT("Does not work in parallel!\n");
#endif

    Parameters::init(initFileName);
  }


71
72
73
74
75
76
  void finalize()
  {
    FUNCNAME("AMDiS::finalize()");

#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
    MeshDistributor::globalMeshDistributor->exitParallelization();
77
#ifdef HAVE_PARALLEL_MTL4
Thomas Witkowski's avatar
Thomas Witkowski committed
78
    if (mtl_environment)
79
80
      delete mtl_environment;
#else
81
    PetscFinalize();
82
#endif
83
84
85
86
#endif
  }

}