Communication.hpp 1.13 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#pragma once

#include <memory>
#include <type_traits>

#include <dune/common/unused.hh>
#include <dune/common/typeutilities.hh>

#include <amdis/Output.hpp>

namespace AMDiS
{
  /// Dummy implementation for sequential communication
  class SequentialCommunication
  {
  public:
    using Impl = SequentialCommunication;

19
20
    template <class T>
    SequentialCommunication(T&&) {}
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

    Impl const& get() const
    {
      return *this;
    }

    template <class Basis>
    void update(Basis const&) { /* do nothing */ }
  };


  template <class C>
  struct DefaultCommunicationCreator
  {
    using Communication = C;

    template <class Basis>
38
    static Communication create(Basis const& basis)
39
    {
40
      return {Environment::comm()};
41
42
43
44
45
46
47
48
49
50
51
    }
  };


  /// Implementation of a creator pattern for Communication types
  template <class C>
  struct CommunicationCreator
  {
    using Communication = C;

    template <class Basis>
52
    static Communication create(Basis const& basis, std::string const& prefix = "")
53
54
55
56
57
58
59
    {
      DUNE_UNUSED_PARAMETER(prefix);
      return DefaultCommunicationCreator<C>::create(basis);
    }
  };

} // end namespace AMDiS