dune-istl  2.6-git
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 T* construct(Arguments& args)
53  {
54  return new T();
55  }
56 
61  static inline void deconstruct(T* t)
62  {
63  delete t;
64  }
65 
66  };
67 
68  template<class T, class A>
70  {
71  public:
72  typedef const int Arguments;
74  {
75  return new BlockVector<T,A>(n);
76  }
77 
78  static inline void deconstruct(BlockVector<T,A>* t)
79  {
80  delete t;
81  }
82  };
83 
84  template<class M, class C>
86  {
87  OverlappingSchwarzOperatorArgs(M& matrix, C& comm)
88  : matrix_(&matrix), comm_(&comm)
89  {}
90 
91  M* matrix_;
92  C* comm_;
93  };
94 
95  template<class M, class C>
97  {
98  NonoverlappingOperatorArgs(M& matrix, C& comm)
99  : matrix_(&matrix), comm_(&comm)
100  {}
101 
103  C* comm_;
104  };
105 
106 #if HAVE_MPI
107  struct OwnerOverlapCopyCommunicationArgs
108  {
109  OwnerOverlapCopyCommunicationArgs(MPI_Comm comm, SolverCategory::Category cat)
110  : comm_(comm), cat_(cat)
111  {}
112 
113  MPI_Comm comm_;
115  };
116 #endif
117 
119  {
120  SequentialCommunicationArgs(CollectiveCommunication<void*> comm, int cat)
121  : comm_(comm)
122  {
123  DUNE_UNUSED_PARAMETER(cat);
124  }
125 
126  CollectiveCommunication<void*> comm_;
127  };
128 
129  } // end Amg namspace
130 
131  // forward declaration
132  template<class M, class X, class Y, class C>
134 
135  template<class M, class X, class Y, class C>
137 
138  namespace Amg
139  {
140  template<class M, class X, class Y, class C>
142  {
143  public:
145 
147  {
148  return new OverlappingSchwarzOperator<M,X,Y,C>(*args.matrix_, *args.comm_);
149  }
150 
152  {
153  delete t;
154  }
155  };
156 
157  template<class M, class X, class Y, class C>
159  {
160  public:
162 
164  {
165  return new NonoverlappingSchwarzOperator<M,X,Y,C>(*args.matrix_, *args.comm_);
166  }
167 
169  {
170  delete t;
171  }
172  };
173 
174  template<class M, class X, class Y>
176  {
178  : matrix_(&matrix)
179  {}
180 
182  };
183 
184  template<class M, class X, class Y>
186  {
187  public:
189 
191  {
192  return new MatrixAdapter<M,X,Y>(*args.matrix_);
193  }
194 
195  static inline void deconstruct(MatrixAdapter<M,X,Y>* m)
196  {
197  delete m;
198  }
199  };
200 
201  template<>
203  {
204  public:
207  {
208  return new SequentialInformation(args.comm_);
209  }
210 
211  static inline void deconstruct(SequentialInformation* si)
212  {
213  delete si;
214  }
215  };
216 
217 
218 #if HAVE_MPI
219 
220  template<class T1, class T2>
221  class ConstructionTraits<OwnerOverlapCopyCommunication<T1,T2> >
222  {
223  public:
224  typedef const OwnerOverlapCopyCommunicationArgs Arguments;
225 
226  static inline OwnerOverlapCopyCommunication<T1,T2>* construct(Arguments& args)
227  {
228  return new OwnerOverlapCopyCommunication<T1,T2>(args.comm_, args.cat_);
229  }
230 
231  static inline void deconstruct(OwnerOverlapCopyCommunication<T1,T2>* com)
232  {
233  delete com;
234  }
235  };
236 
237 #endif
238 
240  } // namespace Amg
241 } // namespace Dune
242 #endif
Dune::Amg::ConstructionTraits< NonoverlappingSchwarzOperator< M, X, Y, C > >::Arguments
NonoverlappingOperatorArgs< M, C > Arguments
Definition: construction.hh:161
Dune::SolverCategory::Category
Category
Definition: solvercategory.hh:21
Dune::Amg::ConstructionTraits< OverlappingSchwarzOperator< M, X, Y, C > >::construct
static OverlappingSchwarzOperator< M, X, Y, C > * construct(const Arguments &args)
Definition: construction.hh:146
Dune::MatrixAdapter
Adapter to turn a matrix into a linear operator.
Definition: operators.hh:133
Dune::Amg::NonoverlappingOperatorArgs::NonoverlappingOperatorArgs
NonoverlappingOperatorArgs(M &matrix, C &comm)
Definition: construction.hh:98
Dune::Amg::ConstructionTraits< NonoverlappingSchwarzOperator< M, X, Y, C > >::construct
static NonoverlappingSchwarzOperator< M, X, Y, C > * construct(const Arguments &args)
Definition: construction.hh:163
Dune::Amg::SequentialCommunicationArgs
Definition: construction.hh:118
Dune::Amg::NonoverlappingOperatorArgs::comm_
C * comm_
Definition: construction.hh:103
pinfo.hh
solvercategory.hh
Dune::Amg::OverlappingSchwarzOperatorArgs::comm_
C * comm_
Definition: construction.hh:92
Dune::Amg::SequentialInformation
Definition: pinfo.hh:25
Dune::Amg::OverlappingSchwarzOperatorArgs::matrix_
M * matrix_
Definition: construction.hh:91
Dune::Amg::ConstructionTraits
Traits class for generically constructing non default constructable types.
Definition: novlpschwarz.hh:247
Dune::Amg::NonoverlappingOperatorArgs
Definition: construction.hh:96
Dune::Amg::ConstructionTraits< MatrixAdapter< M, X, Y > >::deconstruct
static void deconstruct(MatrixAdapter< M, X, Y > *m)
Definition: construction.hh:195
Dune::Amg::ConstructionTraits< OverlappingSchwarzOperator< M, X, Y, C > >::deconstruct
static void deconstruct(OverlappingSchwarzOperator< M, X, Y, C > *t)
Definition: construction.hh:151
Dune::Amg::ConstructionTraits< SequentialInformation >::Arguments
const typedef SequentialCommunicationArgs Arguments
Definition: construction.hh:205
Dune::Amg::NonoverlappingOperatorArgs::matrix_
M * matrix_
Definition: construction.hh:102
Dune::Amg::MatrixAdapterArgs::matrix_
M * matrix_
Definition: construction.hh:181
Dune::NonoverlappingSchwarzOperator
A nonoverlapping operator with communication object.
Definition: novlpschwarz.hh:59
operators.hh
Define general, extensible interface for operators. The available implementation wraps a matrix.
Dune::Amg::ConstructionTraits< BlockVector< T, A > >::construct
static BlockVector< T, A > * construct(Arguments &n)
Definition: construction.hh:73
Dune::Amg::OverlappingSchwarzOperatorArgs
Definition: construction.hh:85
Dune::Amg::ConstructionTraits< MatrixAdapter< M, X, Y > >::Arguments
const typedef MatrixAdapterArgs< M, X, Y > Arguments
Definition: construction.hh:188
Dune::Amg::ConstructionTraits< BlockVector< T, A > >::deconstruct
static void deconstruct(BlockVector< T, A > *t)
Definition: construction.hh:78
Dune::Amg::ConstructionTraits< MatrixAdapter< M, X, Y > >::construct
static MatrixAdapter< M, X, Y > * construct(Arguments &args)
Definition: construction.hh:190
Dune::Amg::ConstructionTraits< SequentialInformation >::deconstruct
static void deconstruct(SequentialInformation *si)
Definition: construction.hh:211
Dune::Amg::ConstructionTraits< NonoverlappingSchwarzOperator< M, X, Y, C > >::deconstruct
static void deconstruct(NonoverlappingSchwarzOperator< M, X, Y, C > *t)
Definition: construction.hh:168
Dune::Amg::ConstructionTraits::Arguments
const typedef void * Arguments
A type holding all the arguments needed to call the constructor.
Definition: construction.hh:44
owneroverlapcopy.hh
Classes providing communication interfaces for overlapping Schwarz methods.
Dune::Amg::ConstructionTraits< BlockVector< T, A > >::Arguments
const typedef int Arguments
Definition: construction.hh:72
Dune::Amg::SequentialCommunicationArgs::comm_
CollectiveCommunication< void * > comm_
Definition: construction.hh:126
Dune::Amg::ConstructionTraits::deconstruct
static void deconstruct(T *t)
Destroys an object.
Definition: construction.hh:61
Dune
Definition: allocator.hh:7
Dune::Amg::ConstructionTraits< SequentialInformation >::construct
static SequentialInformation * construct(Arguments &args)
Definition: construction.hh:206
Dune::Amg::ConstructionTraits< OverlappingSchwarzOperator< M, X, Y, C > >::Arguments
OverlappingSchwarzOperatorArgs< M, C > Arguments
Definition: construction.hh:144
Dune::Amg::OverlappingSchwarzOperatorArgs::OverlappingSchwarzOperatorArgs
OverlappingSchwarzOperatorArgs(M &matrix, C &comm)
Definition: construction.hh:87
Dune::Amg::SequentialCommunicationArgs::SequentialCommunicationArgs
SequentialCommunicationArgs(CollectiveCommunication< void * > comm, int cat)
Definition: construction.hh:120
bvector.hh
This file implements a vector space as a tensor product of a given vector space. The number of compon...
Dune::Amg::MatrixAdapterArgs
Definition: construction.hh:175
Dune::OverlappingSchwarzOperator
An overlapping schwarz operator.
Definition: construction.hh:133
Dune::Amg::ConstructionTraits::construct
static T * construct(Arguments &args)
Construct an object with the specified arguments.
Definition: construction.hh:52
Dune::BlockVector
A vector of blocks with memory management.
Definition: bvector.hh:316
Dune::Amg::MatrixAdapterArgs::MatrixAdapterArgs
MatrixAdapterArgs(M &matrix, const SequentialInformation &)
Definition: construction.hh:177