Dune Core Modules (2.4.1)

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
10#include <dune/istl/solvercategory.hh>
11#include "pinfo.hh"
12
13namespace Dune
14{
15 namespace Amg
16 {
17
36 template<typename T>
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>
69 class ConstructionTraits<BlockVector<T,A> >
70 {
71 public:
72 typedef const int Arguments;
73 static inline BlockVector<T,A>* construct(Arguments& n)
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>
85 struct OverlappingSchwarzOperatorArgs
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>
96 struct NonoverlappingOperatorArgs
97 {
98 NonoverlappingOperatorArgs(M& matrix, C& comm)
99 : matrix_(&matrix), comm_(&comm)
100 {}
101
102 M* matrix_;
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
118 struct SequentialCommunicationArgs
119 {
120 SequentialCommunicationArgs(CollectiveCommunication<void*> comm, int cat)
121 : comm_(comm)
122 {
124 }
125
126 CollectiveCommunication<void*> comm_;
127 };
128
129 } // end Amg namspace
130
131 // foward declaration
132 template<class M, class X, class Y, class C>
133 class OverlappingSchwarzOperator;
134
135 template<class M, class X, class Y, class C>
136 class NonoverlappingSchwarzOperator;
137
138 namespace Amg
139 {
140 template<class M, class X, class Y, class C>
141 class ConstructionTraits<OverlappingSchwarzOperator<M,X,Y,C> >
142 {
143 public:
144 typedef OverlappingSchwarzOperatorArgs<M,C> Arguments;
145
146 static inline OverlappingSchwarzOperator<M,X,Y,C>* construct(const Arguments& args)
147 {
148 return new OverlappingSchwarzOperator<M,X,Y,C>(*args.matrix_, *args.comm_);
149 }
150
151 static inline void deconstruct(OverlappingSchwarzOperator<M,X,Y,C>* t)
152 {
153 delete t;
154 }
155 };
156
157 template<class M, class X, class Y, class C>
158 class ConstructionTraits<NonoverlappingSchwarzOperator<M,X,Y,C> >
159 {
160 public:
161 typedef NonoverlappingOperatorArgs<M,C> Arguments;
162
163 static inline NonoverlappingSchwarzOperator<M,X,Y,C>* construct(const Arguments& args)
164 {
165 return new NonoverlappingSchwarzOperator<M,X,Y,C>(*args.matrix_, *args.comm_);
166 }
167
168 static inline void deconstruct(NonoverlappingSchwarzOperator<M,X,Y,C>* t)
169 {
170 delete t;
171 }
172 };
173
174 template<class M, class X, class Y>
175 struct MatrixAdapterArgs
176 {
177 MatrixAdapterArgs(M& matrix, const SequentialInformation&)
178 : matrix_(&matrix)
179 {}
180
181 M* matrix_;
182 };
183
184 template<class M, class X, class Y>
185 class ConstructionTraits<MatrixAdapter<M,X,Y> >
186 {
187 public:
188 typedef const MatrixAdapterArgs<M,X,Y> Arguments;
189
190 static inline MatrixAdapter<M,X,Y>* construct(Arguments& args)
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<>
202 class ConstructionTraits<SequentialInformation>
203 {
204 public:
205 typedef const SequentialCommunicationArgs Arguments;
206 static inline SequentialInformation* construct(Arguments& args)
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
This file implements a vector space as a tensor product of a given vector space. The number of compon...
Traits class for generically constructing non default constructable types.
Definition: construction.hh:38
A vector of blocks with memory management.
Definition: bvector.hh:253
const void * Arguments
A type holding all the arguments needed to call the constructor.
Definition: construction.hh:44
static T * construct(Arguments &args)
Construct an object with the specified arguments.
Definition: construction.hh:52
static void deconstruct(T *t)
Destroys an object.
Definition: construction.hh:61
Dune namespace.
Definition: alignment.hh:10
Define general, extensible interface for operators. The available implementation wraps a matrix.
Classes providing communication interfaces for overlapping Schwarz methods.
Category
Definition: solvercategory.hh:19
Definition of the DUNE_UNUSED macro for the case that config.h is not available.
#define DUNE_UNUSED_PARAMETER(parm)
A macro to mark intentional unused function parameters with.
Definition: unused.hh:18
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 13, 23:29, 2024)