| 1 |
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
| 2 |
// vi: set et ts=4 sw=2 sts=2: |
| 3 |
// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root |
| 4 |
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception |
| 5 |
#ifndef DUNE_DGLOCALCOEFFICIENTS_HH |
| 6 |
#define DUNE_DGLOCALCOEFFICIENTS_HH |
| 7 |
|
| 8 |
#include <cassert> |
| 9 |
#include <vector> |
| 10 |
|
| 11 |
#include <dune/localfunctions/common/localkey.hh> |
| 12 |
|
| 13 |
namespace Dune |
| 14 |
{ |
| 15 |
|
| 16 |
// DGLocalCoefficients |
| 17 |
// ------------------- |
| 18 |
|
| 19 |
/** |
| 20 |
* @brief A class providing local coefficients for dg spaces |
| 21 |
**/ |
| 22 |
class DGLocalCoefficients |
| 23 |
{ |
| 24 |
typedef DGLocalCoefficients This; |
| 25 |
|
| 26 |
public: |
| 27 |
//! construct local keys for n basis functions |
| 28 |
DGLocalCoefficients ( const unsigned int n ) |
| 29 |
: localKey_( n ) |
| 30 |
{ |
| 31 |
for( unsigned i = 0; i < n; ++i ) |
| 32 |
localKey_[ i ] = LocalKey( 0, 0, i ); |
| 33 |
} |
| 34 |
|
| 35 |
const LocalKey &localKey ( const unsigned int i ) const |
| 36 |
{ |
| 37 |
assert( i < size() ); |
| 38 |
return localKey_[ i ]; |
| 39 |
} |
| 40 |
|
| 41 |
unsigned int size () const |
| 42 |
{ |
| 43 |
return localKey_.size(); |
| 44 |
} |
| 45 |
|
| 46 |
private: |
| 47 |
std::vector< LocalKey > localKey_; |
| 48 |
}; |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
// DGLocalCoefficientsFactory |
| 53 |
// -------------------------- |
| 54 |
/** |
| 55 |
* @brief A factory class for the dg local coefficients. |
| 56 |
**/ |
| 57 |
template< class BasisFactory > |
| 58 |
struct DGLocalCoefficientsFactory |
| 59 |
{ |
| 60 |
static const unsigned int dimension = BasisFactory::dimension; |
| 61 |
typedef typename BasisFactory::Key Key; |
| 62 |
typedef const DGLocalCoefficients Object; |
| 63 |
|
| 64 |
template< GeometryType::Id geometryId > |
| 65 |
static Object *create ( const Key &key ) |
| 66 |
{ |
| 67 |
const typename BasisFactory::Object *basis |
| 68 |
= BasisFactory::template create< geometryId >( key ); |
| 69 |
Object *coefficients = new Object( basis->size() ); |
| 70 |
BasisFactory::release( basis ); |
| 71 |
return coefficients; |
| 72 |
} |
| 73 |
static void release( Object *object ) { delete object; } |
| 74 |
}; |
| 75 |
|
| 76 |
} |
| 77 |
|
| 78 |
#endif // #ifndef DUNE_DGLOCALCOEFFICIENTS_HH |