Dune Core Modules (unstable)

construction.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4// vi: set et ts=4 sw=2 sts=2:
5#ifndef DUNE_AMGCONSTRUCTION_HH
6#define DUNE_AMGCONSTRUCTION_HH
7
11#include <dune/istl/solvercategory.hh>
12#include "pinfo.hh"
13
14namespace Dune
15{
16 namespace Amg
17 {
18
37 template<typename T>
39 {
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>
59 struct ConstructionTraits<BlockVector<T,A> >
60 {
61 typedef const int Arguments;
62 static inline std::shared_ptr<BlockVector<T,A>> construct(Arguments& n)
63 {
64 return std::make_shared<BlockVector<T,A>>(n);
65 }
66 };
67
68 template<class M, class C>
69 struct ParallelOperatorArgs
70 {
71 ParallelOperatorArgs(std::shared_ptr<M> matrix, const C& comm)
72 : matrix_(matrix), comm_(comm)
73 {}
74
75 std::shared_ptr<M> matrix_;
76 const C& comm_;
77 };
78
79#if HAVE_MPI
80 struct OwnerOverlapCopyCommunicationArgs
81 {
82 OwnerOverlapCopyCommunicationArgs(MPI_Comm comm, SolverCategory::Category cat)
83 : comm_(comm), cat_(cat)
84 {}
85
86 MPI_Comm comm_;
88 };
89#endif
90
91 struct SequentialCommunicationArgs
92 {
93 SequentialCommunicationArgs(Communication<void*> comm, [[maybe_unused]] int cat)
94 : comm_(comm)
95 {}
96
97 Communication<void*> comm_;
98 };
99
100 } // end Amg namspace
101
102 // forward declaration
103 template<class M, class X, class Y, class C>
104 class OverlappingSchwarzOperator;
105
106 template<class M, class X, class Y, class C>
107 class NonoverlappingSchwarzOperator;
108
109 namespace Amg
110 {
111 template<class M, class X, class Y, class C>
112 struct ConstructionTraits<OverlappingSchwarzOperator<M,X,Y,C> >
113 {
114 typedef ParallelOperatorArgs<M,C> Arguments;
115
116 static inline std::shared_ptr<OverlappingSchwarzOperator<M,X,Y,C>> construct(const Arguments& args)
117 {
118 return std::make_shared<OverlappingSchwarzOperator<M,X,Y,C>>
119 (args.matrix_, args.comm_);
120 }
121 };
122
123 template<class M, class X, class Y, class C>
124 struct ConstructionTraits<NonoverlappingSchwarzOperator<M,X,Y,C> >
125 {
126 typedef ParallelOperatorArgs<M,C> Arguments;
127
128 static inline std::shared_ptr<NonoverlappingSchwarzOperator<M,X,Y,C>> construct(const Arguments& args)
129 {
130 return std::make_shared<NonoverlappingSchwarzOperator<M,X,Y,C>>
131 (args.matrix_, args.comm_);
132 }
133 };
134
135 template<class M, class X, class Y>
136 struct MatrixAdapterArgs
137 {
138 MatrixAdapterArgs(std::shared_ptr<M> matrix, const SequentialInformation)
139 : matrix_(matrix)
140 {}
141
142 std::shared_ptr<M> matrix_;
143 };
144
145 template<class M, class X, class Y>
146 struct ConstructionTraits<MatrixAdapter<M,X,Y> >
147 {
148 typedef const MatrixAdapterArgs<M,X,Y> Arguments;
149
150 static inline std::shared_ptr<MatrixAdapter<M,X,Y>> construct(Arguments& args)
151 {
152 return std::make_shared<MatrixAdapter<M,X,Y>>(args.matrix_);
153 }
154 };
155
156 template<>
157 struct ConstructionTraits<SequentialInformation>
158 {
159 typedef const SequentialCommunicationArgs Arguments;
160 static inline std::shared_ptr<SequentialInformation> construct(Arguments& args)
161 {
162 return std::make_shared<SequentialInformation>(args.comm_);
163 }
164 };
165
166
167#if HAVE_MPI
168
169 template<class T1, class T2>
170 struct ConstructionTraits<OwnerOverlapCopyCommunication<T1,T2> >
171 {
172 typedef const OwnerOverlapCopyCommunicationArgs Arguments;
173
174 static inline std::shared_ptr<OwnerOverlapCopyCommunication<T1,T2>> construct(Arguments& args)
175 {
176 return std::make_shared<OwnerOverlapCopyCommunication<T1,T2>>(args.comm_, args.cat_);
177 }
178 };
179
180#endif
181
183 } // namespace Amg
184} // namespace Dune
185#endif
This file implements a vector space as a tensor product of a given vector space. The number of compon...
A vector of blocks with memory management.
Definition: bvector.hh:392
const void * Arguments
A type holding all the arguments needed to call the constructor.
Definition: construction.hh:44
static std::shared_ptr< T > construct(Arguments &args)
Construct an object with the specified arguments.
Definition: construction.hh:52
Dune namespace.
Definition: alignedallocator.hh:13
Define general, extensible interface for operators. The available implementation wraps a matrix.
Classes providing communication interfaces for overlapping Schwarz methods.
Traits class for generically constructing non default constructable types.
Definition: construction.hh:39
Category
Definition: solvercategory.hh:23
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)