/usr/include/dune/istl/paamg/construction.hh is in libdune-istl-dev 2.2.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | // $Id: construction.hh 1446 2011-01-24 11:55:06Z mblatt $
#ifndef DUNE_AMGCONSTRUCTION_HH
#define DUNE_AMGCONSTRUCTION_HH
#include<dune/istl/bvector.hh>
#include<dune/istl/operators.hh>
#include<dune/istl/owneroverlapcopy.hh>
#include<dune/istl/solvercategory.hh>
#include"pinfo.hh"
namespace Dune
{
namespace Amg
{
/**
* @addtogroup ISTL_PAAMG
*
* @{
*/
/** @file
* @author Markus Blatt
* @brief Helper classes for the construction of classes without
* empty constructor.
*/
/**
* @brief Traits class for generically constructing non default
* constructable types.
*
* Needed because BCRSMatrix and Vector do a deep copy which is
* too expensive.
*/
template<typename T>
class ConstructionTraits
{
public:
/**
* @brief A type holding all the arguments needed to call the
* constructor.
*/
typedef const void* Arguments;
/**
* @brief Construct an object with the specified arguments.
*
* In the default implementation the copy constructor is called.
* @param args The arguments for the construction.
*/
static inline T* construct(Arguments& args)
{
return new T();
}
/**
* @brief Destroys an object.
* @param t Pointer to the object to destroy.
*/
static inline void deconstruct(T* t)
{
delete t;
}
};
template<class T>
class ConstructionTraits<BlockVector<T> >
{
public:
typedef const int Arguments;
static inline BlockVector<T>* construct(Arguments& n)
{
return new BlockVector<T>(n);
}
static inline void deconstruct(BlockVector<T>* t)
{
delete t;
}
};
template<class M, class C>
struct OverlappingSchwarzOperatorArgs
{
OverlappingSchwarzOperatorArgs(M& matrix, C& comm)
: matrix_(&matrix), comm_(&comm)
{}
M* matrix_;
C* comm_;
};
template<class M, class C>
struct NonoverlappingOperatorArgs
{
NonoverlappingOperatorArgs(M& matrix, C& comm)
: matrix_(&matrix), comm_(&comm)
{}
M* matrix_;
C* comm_;
};
#if HAVE_MPI
struct OwnerOverlapCopyCommunicationArgs
{
OwnerOverlapCopyCommunicationArgs(MPI_Comm comm, SolverCategory::Category cat)
: comm_(comm), cat_(cat)
{}
MPI_Comm comm_;
SolverCategory::Category cat_;
};
#endif
struct SequentialCommunicationArgs
{
SequentialCommunicationArgs(CollectiveCommunication<void*> comm, int cat)
: comm_(comm)
{}
CollectiveCommunication<void*> comm_;
};
}// end Amg namspace
// foward declaration
template<class M, class X, class Y, class C>
class OverlappingSchwarzOperator;
template<class M, class X, class Y, class C>
class NonoverlappingSchwarzOperator;
namespace Amg
{
template<class M, class X, class Y, class C>
class ConstructionTraits<OverlappingSchwarzOperator<M,X,Y,C> >
{
public:
typedef OverlappingSchwarzOperatorArgs<M,C> Arguments;
static inline OverlappingSchwarzOperator<M,X,Y,C>* construct(const Arguments& args)
{
return new OverlappingSchwarzOperator<M,X,Y,C>(*args.matrix_, *args.comm_);
}
static inline void deconstruct(OverlappingSchwarzOperator<M,X,Y,C>* t)
{
delete t;
}
};
template<class M, class X, class Y, class C>
class ConstructionTraits<NonoverlappingSchwarzOperator<M,X,Y,C> >
{
public:
typedef NonoverlappingOperatorArgs<M,C> Arguments;
static inline NonoverlappingSchwarzOperator<M,X,Y,C>* construct(const Arguments& args)
{
return new NonoverlappingSchwarzOperator<M,X,Y,C>(*args.matrix_, *args.comm_);
}
static inline void deconstruct(NonoverlappingSchwarzOperator<M,X,Y,C>* t)
{
delete t;
}
};
template<class M, class X, class Y>
struct MatrixAdapterArgs
{
MatrixAdapterArgs(M& matrix, const SequentialInformation&)
: matrix_(&matrix)
{}
M* matrix_;
};
template<class M, class X, class Y>
class ConstructionTraits<MatrixAdapter<M,X,Y> >
{
public:
typedef const MatrixAdapterArgs<M,X,Y> Arguments;
static inline MatrixAdapter<M,X,Y>* construct(Arguments& args)
{
return new MatrixAdapter<M,X,Y>(*args.matrix_);
}
static inline void deconstruct(MatrixAdapter<M,X,Y>* m)
{
delete m;
}
};
template<>
class ConstructionTraits<SequentialInformation>
{
public:
typedef const SequentialCommunicationArgs Arguments;
static inline SequentialInformation* construct(Arguments& args)
{
return new SequentialInformation(args.comm_);
}
static inline void deconstruct(SequentialInformation* si)
{
delete si;
}
};
#if HAVE_MPI
template<class T1, class T2>
class ConstructionTraits<OwnerOverlapCopyCommunication<T1,T2> >
{
public:
typedef const OwnerOverlapCopyCommunicationArgs Arguments;
static inline OwnerOverlapCopyCommunication<T1,T2>* construct(Arguments& args)
{
return new OwnerOverlapCopyCommunication<T1,T2>(args.comm_, args.cat_);
}
static inline void deconstruct(OwnerOverlapCopyCommunication<T1,T2>* com)
{
delete com;
}
};
#endif
/** @} */
} // namespace Amg
} // namespace Dune
#endif
|