Dune Core Modules (2.3.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// $Id$
4#ifndef DUNE_AMGCONSTRUCTION_HH
5#define DUNE_AMGCONSTRUCTION_HH
6
11#include <dune/istl/solvercategory.hh>
12#include "pinfo.hh"
13
14namespace Dune
15{
16 namespace Amg
17 {
18
37 template<typename T>
39 {
40 public:
45 typedef const void* Arguments;
46
53 static inline T* construct(Arguments& args)
54 {
55 return new T();
56 }
57
62 static inline void deconstruct(T* t)
63 {
64 delete t;
65 }
66
67 };
68
69 template<class T, class A>
70 class ConstructionTraits<BlockVector<T,A> >
71 {
72 public:
73 typedef const int Arguments;
74 static inline BlockVector<T,A>* construct(Arguments& n)
75 {
76 return new BlockVector<T,A>(n);
77 }
78
79 static inline void deconstruct(BlockVector<T,A>* t)
80 {
81 delete t;
82 }
83 };
84
85 template<class M, class C>
86 struct OverlappingSchwarzOperatorArgs
87 {
88 OverlappingSchwarzOperatorArgs(M& matrix, C& comm)
89 : matrix_(&matrix), comm_(&comm)
90 {}
91
92 M* matrix_;
93 C* comm_;
94 };
95
96 template<class M, class C>
97 struct NonoverlappingOperatorArgs
98 {
99 NonoverlappingOperatorArgs(M& matrix, C& comm)
100 : matrix_(&matrix), comm_(&comm)
101 {}
102
103 M* matrix_;
104 C* comm_;
105 };
106
107#if HAVE_MPI
108 struct OwnerOverlapCopyCommunicationArgs
109 {
110 OwnerOverlapCopyCommunicationArgs(MPI_Comm comm, SolverCategory::Category cat)
111 : comm_(comm), cat_(cat)
112 {}
113
114 MPI_Comm comm_;
116 };
117#endif
118
119 struct SequentialCommunicationArgs
120 {
121 SequentialCommunicationArgs(CollectiveCommunication<void*> comm, int cat)
122 : comm_(comm)
123 {
125 }
126
127 CollectiveCommunication<void*> comm_;
128 };
129
130 } // end Amg namspace
131
132 // foward declaration
133 template<class M, class X, class Y, class C>
134 class OverlappingSchwarzOperator;
135
136 template<class M, class X, class Y, class C>
137 class NonoverlappingSchwarzOperator;
138
139 namespace Amg
140 {
141 template<class M, class X, class Y, class C>
142 class ConstructionTraits<OverlappingSchwarzOperator<M,X,Y,C> >
143 {
144 public:
145 typedef OverlappingSchwarzOperatorArgs<M,C> Arguments;
146
147 static inline OverlappingSchwarzOperator<M,X,Y,C>* construct(const Arguments& args)
148 {
149 return new OverlappingSchwarzOperator<M,X,Y,C>(*args.matrix_, *args.comm_);
150 }
151
152 static inline void deconstruct(OverlappingSchwarzOperator<M,X,Y,C>* t)
153 {
154 delete t;
155 }
156 };
157
158 template<class M, class X, class Y, class C>
159 class ConstructionTraits<NonoverlappingSchwarzOperator<M,X,Y,C> >
160 {
161 public:
162 typedef NonoverlappingOperatorArgs<M,C> Arguments;
163
164 static inline NonoverlappingSchwarzOperator<M,X,Y,C>* construct(const Arguments& args)
165 {
166 return new NonoverlappingSchwarzOperator<M,X,Y,C>(*args.matrix_, *args.comm_);
167 }
168
169 static inline void deconstruct(NonoverlappingSchwarzOperator<M,X,Y,C>* t)
170 {
171 delete t;
172 }
173 };
174
175 template<class M, class X, class Y>
176 struct MatrixAdapterArgs
177 {
178 MatrixAdapterArgs(M& matrix, const SequentialInformation&)
179 : matrix_(&matrix)
180 {}
181
182 M* matrix_;
183 };
184
185 template<class M, class X, class Y>
186 class ConstructionTraits<MatrixAdapter<M,X,Y> >
187 {
188 public:
189 typedef const MatrixAdapterArgs<M,X,Y> Arguments;
190
191 static inline MatrixAdapter<M,X,Y>* construct(Arguments& args)
192 {
193 return new MatrixAdapter<M,X,Y>(*args.matrix_);
194 }
195
196 static inline void deconstruct(MatrixAdapter<M,X,Y>* m)
197 {
198 delete m;
199 }
200 };
201
202 template<>
203 class ConstructionTraits<SequentialInformation>
204 {
205 public:
206 typedef const SequentialCommunicationArgs Arguments;
207 static inline SequentialInformation* construct(Arguments& args)
208 {
209 return new SequentialInformation(args.comm_);
210 }
211
212 static inline void deconstruct(SequentialInformation* si)
213 {
214 delete si;
215 }
216 };
217
218
219#if HAVE_MPI
220
221 template<class T1, class T2>
222 class ConstructionTraits<OwnerOverlapCopyCommunication<T1,T2> >
223 {
224 public:
225 typedef const OwnerOverlapCopyCommunicationArgs Arguments;
226
227 static inline OwnerOverlapCopyCommunication<T1,T2>* construct(Arguments& args)
228 {
229 return new OwnerOverlapCopyCommunication<T1,T2>(args.comm_, args.cat_);
230 }
231
232 static inline void deconstruct(OwnerOverlapCopyCommunication<T1,T2>* com)
233 {
234 delete com;
235 }
236 };
237
238#endif
239
241 } // namespace Amg
242} // namespace Dune
243#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:39
A vector of blocks with memory management.
Definition: bvector.hh:254
const void * Arguments
A type holding all the arguments needed to call the constructor.
Definition: construction.hh:45
static T * construct(Arguments &args)
Construct an object with the specified arguments.
Definition: construction.hh:53
static void deconstruct(T *t)
Destroys an object.
Definition: construction.hh:62
Dune namespace.
Definition: alignment.hh:14
Define general, extensible interface for operators. The available implementation wraps a matrix.
Classes providing communication interfaces for overlapping Schwarz methods.
Category
Definition: solvercategory.hh:20
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 (Jul 15, 22:36, 2024)