dune-istl  2.7.0
construction.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_AMGCONSTRUCTION_HH
4 #define DUNE_AMGCONSTRUCTION_HH
5 
6 #include <dune/common/unused.hh>
7 #include <dune/istl/bvector.hh>
8 #include <dune/istl/operators.hh>
11 #include "pinfo.hh"
12 
13 namespace Dune
14 {
15  namespace Amg
16  {
17 
36  template<typename T>
37  class ConstructionTraits
38  {
39  public:
44  typedef const void* Arguments;
45 
52  static inline std::shared_ptr<T> construct(Arguments& args)
53  {
54  return std::make_shared<T>();
55  }
56  };
57 
58  template<class T, class A>
60  {
61  public:
62  typedef const int Arguments;
63  static inline std::shared_ptr<BlockVector<T,A>> construct(Arguments& n)
64  {
65  return std::make_shared<BlockVector<T,A>>(n);
66  }
67  };
68 
69  template<class M, class C>
71  {
72  ParallelOperatorArgs(std::shared_ptr<M> matrix, const C& comm)
73  : matrix_(matrix), comm_(comm)
74  {}
75 
76  std::shared_ptr<M> matrix_;
77  const C& comm_;
78  };
79 
80 #if HAVE_MPI
81  struct OwnerOverlapCopyCommunicationArgs
82  {
83  OwnerOverlapCopyCommunicationArgs(MPI_Comm comm, SolverCategory::Category cat)
84  : comm_(comm), cat_(cat)
85  {}
86 
87  MPI_Comm comm_;
89  };
90 #endif
91 
93  {
94  SequentialCommunicationArgs(CollectiveCommunication<void*> comm, int cat)
95  : comm_(comm)
96  {
97  DUNE_UNUSED_PARAMETER(cat);
98  }
99 
100  CollectiveCommunication<void*> comm_;
101  };
102 
103  } // end Amg namspace
104 
105  // forward declaration
106  template<class M, class X, class Y, class C>
108 
109  template<class M, class X, class Y, class C>
111 
112  namespace Amg
113  {
114  template<class M, class X, class Y, class C>
116  {
117  public:
119 
120  static inline std::shared_ptr<OverlappingSchwarzOperator<M,X,Y,C>> construct(const Arguments& args)
121  {
122  return std::make_shared<OverlappingSchwarzOperator<M,X,Y,C>>
123  (args.matrix_, args.comm_);
124  }
125  };
126 
127  template<class M, class X, class Y, class C>
129  {
130  public:
132 
133  static inline std::shared_ptr<NonoverlappingSchwarzOperator<M,X,Y,C>> construct(const Arguments& args)
134  {
135  return std::make_shared<NonoverlappingSchwarzOperator<M,X,Y,C>>
136  (args.matrix_, args.comm_);
137  }
138  };
139 
140  template<class M, class X, class Y>
142  {
143  MatrixAdapterArgs(std::shared_ptr<M> matrix, const SequentialInformation)
144  : matrix_(matrix)
145  {}
146 
147  std::shared_ptr<M> matrix_;
148  };
149 
150  template<class M, class X, class Y>
152  {
153  public:
155 
156  static inline std::shared_ptr<MatrixAdapter<M,X,Y>> construct(Arguments& args)
157  {
158  return std::make_shared<MatrixAdapter<M,X,Y>>(args.matrix_);
159  }
160  };
161 
162  template<>
164  {
165  public:
167  static inline std::shared_ptr<SequentialInformation> construct(Arguments& args)
168  {
169  return std::make_shared<SequentialInformation>(args.comm_);
170  }
171  };
172 
173 
174 #if HAVE_MPI
175 
176  template<class T1, class T2>
177  class ConstructionTraits<OwnerOverlapCopyCommunication<T1,T2> >
178  {
179  public:
180  typedef const OwnerOverlapCopyCommunicationArgs Arguments;
181 
182  static inline std::shared_ptr<OwnerOverlapCopyCommunication<T1,T2>> construct(Arguments& args)
183  {
184  return std::make_shared<OwnerOverlapCopyCommunication<T1,T2>>(args.comm_, args.cat_);
185  }
186  };
187 
188 #endif
189 
191  } // namespace Amg
192 } // namespace Dune
193 #endif
Dune::Amg::ParallelOperatorArgs::comm_
const C & comm_
Definition: construction.hh:77
pinfo.hh
Dune::Amg::ConstructionTraits::construct
static std::shared_ptr< T > construct(Arguments &args)
Construct an object with the specified arguments.
Definition: construction.hh:52
Dune::Amg::MatrixAdapterArgs
Definition: construction.hh:141
Dune::Amg::SequentialCommunicationArgs
Definition: construction.hh:92
Dune::Amg::ConstructionTraits
Traits class for generically constructing non default constructable types.
Definition: novlpschwarz.hh:251
Dune::Amg::ConstructionTraits< OverlappingSchwarzOperator< M, X, Y, C > >::Arguments
ParallelOperatorArgs< M, C > Arguments
Definition: construction.hh:118
Dune::Amg::ParallelOperatorArgs::ParallelOperatorArgs
ParallelOperatorArgs(std::shared_ptr< M > matrix, const C &comm)
Definition: construction.hh:72
Dune::Amg::ConstructionTraits< SequentialInformation >::Arguments
const typedef SequentialCommunicationArgs Arguments
Definition: construction.hh:166
Dune::Amg::ConstructionTraits< MatrixAdapter< M, X, Y > >::construct
static std::shared_ptr< MatrixAdapter< M, X, Y > > construct(Arguments &args)
Definition: construction.hh:156
Dune::Amg::MatrixAdapterArgs::matrix_
std::shared_ptr< M > matrix_
Definition: construction.hh:147
Dune::Amg::ConstructionTraits< OverlappingSchwarzOperator< M, X, Y, C > >::construct
static std::shared_ptr< OverlappingSchwarzOperator< M, X, Y, C > > construct(const Arguments &args)
Definition: construction.hh:120
Dune::Amg::ParallelOperatorArgs::matrix_
std::shared_ptr< M > matrix_
Definition: construction.hh:76
Dune::Amg::ParallelOperatorArgs
Definition: construction.hh:70
Dune::Amg::MatrixAdapterArgs::MatrixAdapterArgs
MatrixAdapterArgs(std::shared_ptr< M > matrix, const SequentialInformation)
Definition: construction.hh:143
Dune::Amg::ConstructionTraits::Arguments
const typedef void * Arguments
A type holding all the arguments needed to call the constructor.
Definition: construction.hh:44
Dune::Amg::SequentialCommunicationArgs::SequentialCommunicationArgs
SequentialCommunicationArgs(CollectiveCommunication< void * > comm, int cat)
Definition: construction.hh:94
Dune::Amg::ConstructionTraits< NonoverlappingSchwarzOperator< M, X, Y, C > >::Arguments
ParallelOperatorArgs< M, C > Arguments
Definition: construction.hh:131
Dune::MatrixAdapter
Adapter to turn a matrix into a linear operator.
Definition: operators.hh:134
Dune::OverlappingSchwarzOperator
An overlapping Schwarz operator.
Definition: construction.hh:107
Dune
Definition: allocator.hh:7
Dune::Amg::ConstructionTraits< SequentialInformation >::construct
static std::shared_ptr< SequentialInformation > construct(Arguments &args)
Definition: construction.hh:167
Dune::NonoverlappingSchwarzOperator
A nonoverlapping operator with communication object.
Definition: novlpschwarz.hh:59
Dune::Amg::SequentialInformation
Definition: pinfo.hh:25
solvercategory.hh
Dune::Amg::ConstructionTraits< MatrixAdapter< M, X, Y > >::Arguments
const typedef MatrixAdapterArgs< M, X, Y > Arguments
Definition: construction.hh:154
owneroverlapcopy.hh
Classes providing communication interfaces for overlapping Schwarz methods.
Dune::Amg::SequentialCommunicationArgs::comm_
CollectiveCommunication< void * > comm_
Definition: construction.hh:100
Dune::BlockVector
A vector of blocks with memory management.
Definition: bvector.hh:402
Dune::SolverCategory::Category
Category
Definition: solvercategory.hh:21
Dune::Amg::ConstructionTraits< BlockVector< T, A > >::Arguments
const typedef int Arguments
Definition: construction.hh:62
bvector.hh
This file implements a vector space as a tensor product of a given vector space. The number of compon...
Dune::Amg::ConstructionTraits< NonoverlappingSchwarzOperator< M, X, Y, C > >::construct
static std::shared_ptr< NonoverlappingSchwarzOperator< M, X, Y, C > > construct(const Arguments &args)
Definition: construction.hh:133
Dune::Amg::ConstructionTraits< BlockVector< T, A > >::construct
static std::shared_ptr< BlockVector< T, A > > construct(Arguments &n)
Definition: construction.hh:63
operators.hh
Define general, extensible interface for operators. The available implementation wraps a matrix.