From ff976b97e725302f02d8be2ba4840a13a86bfec8 Mon Sep 17 00:00:00 2001 From: Felix Schindler <felix.schindler@wwu.de> Date: Sun, 18 Jan 2015 11:46:39 +0100 Subject: [PATCH] [spaces.fv.default] moved out of playground, refs #15 --- dune/gdt/playground/spaces/fv/default.hh | 148 +--------------------- dune/gdt/spaces/fv/default.hh | 150 +++++++++++++++++++++++ 2 files changed, 152 insertions(+), 146 deletions(-) create mode 100644 dune/gdt/spaces/fv/default.hh diff --git a/dune/gdt/playground/spaces/fv/default.hh b/dune/gdt/playground/spaces/fv/default.hh index 0679f1916..56f24eb00 100644 --- a/dune/gdt/playground/spaces/fv/default.hh +++ b/dune/gdt/playground/spaces/fv/default.hh @@ -3,149 +3,5 @@ // Copyright holders: Felix Schindler // License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -#ifndef DUNE_GDT_PLAYGROUND_SPACES_FV_DEFAULT_HH -#define DUNE_GDT_PLAYGROUND_SPACES_FV_DEFAULT_HH - -#include <dune/common/deprecated.hh> - -#include <dune/stuff/common/type_utils.hh> - -#include <dune/gdt/spaces/parallel.hh> - -#include <dune/gdt/basefunctionset/default/fv.hh> -#include <dune/gdt/mapper/default/fv.hh> -#include "../../../spaces/interface.hh" - -namespace Dune { -namespace GDT { -namespace Spaces { -namespace FV { - - -// forward, to be used in the traits and to allow for specialization -template <class GridViewImp, class RangeFieldImp, int rangeDim, int rangeDimCols = 1> -class Default -{ - static_assert(Dune::AlwaysFalse<GridViewImp>::value, "Untested for these dimensions!"); -}; - - -/** - * \brief Traits class for Spaces::CG::FemBased. - */ -template <class GridViewImp, class RangeFieldImp, int rangeDim, int rangeDimCols> -class DefaultTraits -{ -public: - typedef Default<GridViewImp, RangeFieldImp, rangeDim, rangeDimCols> derived_type; - static const int polOrder = 0; - typedef GridViewImp GridViewType; - typedef typename GridViewType::IndexSet BackendType; - typedef typename GridViewType::template Codim<0>::Entity EntityType; - typedef RangeFieldImp RangeFieldType; - typedef Mapper::FiniteVolume<GridViewType, rangeDim, rangeDimCols> MapperType; - typedef BaseFunctionSet::FiniteVolume<typename GridViewType::template Codim<0>::Entity, typename GridViewType::ctype, - GridViewType::dimension, RangeFieldType, rangeDim, - rangeDimCols> BaseFunctionSetType; - static const Stuff::Grid::ChoosePartView part_view_type = Stuff::Grid::ChoosePartView::view; - static const bool needs_grid_view = true; - typedef CommunicationChooser<GridViewType> CommunicationChooserType; - typedef typename CommunicationChooserType::Type CommunicatorType; -}; // class DefaultTraits - - -template <class GridViewImp, class RangeFieldImp, int rangeDim> -class Default<GridViewImp, RangeFieldImp, rangeDim, 1> - : public SpaceInterface<DefaultTraits<GridViewImp, RangeFieldImp, rangeDim, 1>, GridViewImp::dimension, rangeDim, 1> -{ - typedef Default<GridViewImp, RangeFieldImp, rangeDim, 1> ThisType; - typedef SpaceInterface<DefaultTraits<GridViewImp, RangeFieldImp, rangeDim, 1>, GridViewImp::dimension, rangeDim, 1> - BaseType; - -public: - typedef DefaultTraits<GridViewImp, RangeFieldImp, rangeDim, 1> Traits; - - static const int polOrder = Traits::polOrder; - static const unsigned int dimDomain = BaseType::dimDomain; - static const unsigned int dimRange = BaseType::dimRange; - static const unsigned int dimRangeCols = BaseType::dimRangeCols; - - typedef typename Traits::GridViewType GridViewType; - typedef typename Traits::RangeFieldType RangeFieldType; - typedef typename Traits::BackendType BackendType; - typedef typename Traits::MapperType MapperType; - typedef typename Traits::EntityType EntityType; - typedef typename Traits::BaseFunctionSetType BaseFunctionSetType; - typedef typename Traits::CommunicationChooserType CommunicationChooserType; - typedef typename Traits::CommunicatorType CommunicatorType; - - typedef Dune::Stuff::LA::SparsityPatternDefault PatternType; - typedef typename GridViewType::ctype DomainFieldType; - - Default(GridViewType gv) - : grid_view_(gv) - , mapper_(grid_view_) - , communicator_(CommunicationChooserType::create(grid_view_)) - { - } - - Default(const ThisType& other) - : grid_view_(other.grid_view_) - , mapper_(other.mapper_) - , communicator_(CommunicationChooserType::create(grid_view_)) - { - } - - Default(ThisType&& source) = default; - - ThisType& operator=(const ThisType& other) = delete; - - ThisType& operator=(ThisType&& source) = delete; - - const GridViewType& grid_view() const - { - return grid_view_; - } - - const BackendType& backend() const - { - return grid_view_.indexSet(); - } - - const MapperType& mapper() const - { - return mapper_; - } - - BaseFunctionSetType base_function_set(const EntityType& entity) const - { - return BaseFunctionSetType(entity); - } - - using BaseType::compute_pattern; - - template <class G, class S, int d, int r, int rC> - PatternType compute_pattern(const GridView<G>& local_grid_view, const SpaceInterface<S, d, r, rC>& ansatz_space) const - { - return BaseType::compute_face_and_volume_pattern(local_grid_view, ansatz_space); - } - - CommunicatorType& communicator() const - { - // no need to prepare the communicator, since we are not pdelab based - return *communicator_; - } - -private: - const GridViewType grid_view_; - const MapperType mapper_; - const std::unique_ptr<CommunicatorType> communicator_; -}; // class Default< ..., 1, 1 > - - -} // namespace FV -} // namespace Spaces -} // namespace GDT -} // namespace Dune - -#endif // DUNE_GDT_PLAYGROUND_SPACES_FV_DEFAULT_HH +#warning This header is deprecated, include dune/gdt/spaces/fv/default.hh instead (17.01.2015)! +#include <dune/gdt/spaces/fv/default.hh> diff --git a/dune/gdt/spaces/fv/default.hh b/dune/gdt/spaces/fv/default.hh new file mode 100644 index 000000000..8a984226d --- /dev/null +++ b/dune/gdt/spaces/fv/default.hh @@ -0,0 +1,150 @@ +// This file is part of the dune-gdt project: +// http://users.dune-project.org/projects/dune-gdt +// Copyright holders: Felix Schindler +// License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) + +#ifndef DUNE_GDT_SPACES_FV_DEFAULT_HH +#define DUNE_GDT_SPACES_FV_DEFAULT_HH + +#include <dune/common/deprecated.hh> + +#include <dune/stuff/common/type_utils.hh> + +#include <dune/gdt/basefunctionset/default/fv.hh> +#include <dune/gdt/mapper/default/fv.hh> +#include <dune/gdt/spaces/interface.hh> +#include <dune/gdt/spaces/parallel.hh> + +namespace Dune { +namespace GDT { +namespace Spaces { +namespace FV { + + +// forward, to be used in the traits and to allow for specialization +template <class GridViewImp, class RangeFieldImp, int rangeDim, int rangeDimCols = 1> +class Default +{ + static_assert(Dune::AlwaysFalse<GridViewImp>::value, "Untested for these dimensions!"); +}; + + +/** + * \brief Traits class for Spaces::CG::FemBased. + */ +template <class GridViewImp, class RangeFieldImp, int rangeDim, int rangeDimCols> +class DefaultTraits +{ +public: + typedef Default<GridViewImp, RangeFieldImp, rangeDim, rangeDimCols> derived_type; + static const int polOrder = 0; + typedef GridViewImp GridViewType; + typedef typename GridViewType::IndexSet BackendType; + typedef typename GridViewType::template Codim<0>::Entity EntityType; + typedef RangeFieldImp RangeFieldType; + typedef Mapper::FiniteVolume<GridViewType, rangeDim, rangeDimCols> MapperType; + typedef BaseFunctionSet::FiniteVolume<typename GridViewType::template Codim<0>::Entity, typename GridViewType::ctype, + GridViewType::dimension, RangeFieldType, rangeDim, + rangeDimCols> BaseFunctionSetType; + static const Stuff::Grid::ChoosePartView part_view_type = Stuff::Grid::ChoosePartView::view; + static const bool needs_grid_view = true; + typedef CommunicationChooser<GridViewType> CommunicationChooserType; + typedef typename CommunicationChooserType::Type CommunicatorType; +}; // class DefaultTraits + + +template <class GridViewImp, class RangeFieldImp, int rangeDim> +class Default<GridViewImp, RangeFieldImp, rangeDim, 1> + : public SpaceInterface<DefaultTraits<GridViewImp, RangeFieldImp, rangeDim, 1>, GridViewImp::dimension, rangeDim, 1> +{ + typedef Default<GridViewImp, RangeFieldImp, rangeDim, 1> ThisType; + typedef SpaceInterface<DefaultTraits<GridViewImp, RangeFieldImp, rangeDim, 1>, GridViewImp::dimension, rangeDim, 1> + BaseType; + +public: + typedef DefaultTraits<GridViewImp, RangeFieldImp, rangeDim, 1> Traits; + + static const int polOrder = Traits::polOrder; + static const unsigned int dimDomain = BaseType::dimDomain; + static const unsigned int dimRange = BaseType::dimRange; + static const unsigned int dimRangeCols = BaseType::dimRangeCols; + + typedef typename Traits::GridViewType GridViewType; + typedef typename Traits::RangeFieldType RangeFieldType; + typedef typename Traits::BackendType BackendType; + typedef typename Traits::MapperType MapperType; + typedef typename Traits::EntityType EntityType; + typedef typename Traits::BaseFunctionSetType BaseFunctionSetType; + typedef typename Traits::CommunicationChooserType CommunicationChooserType; + typedef typename Traits::CommunicatorType CommunicatorType; + + typedef Dune::Stuff::LA::SparsityPatternDefault PatternType; + typedef typename GridViewType::ctype DomainFieldType; + + Default(GridViewType gv) + : grid_view_(gv) + , mapper_(grid_view_) + , communicator_(CommunicationChooserType::create(grid_view_)) + { + } + + Default(const ThisType& other) + : grid_view_(other.grid_view_) + , mapper_(other.mapper_) + , communicator_(CommunicationChooserType::create(grid_view_)) + { + } + + Default(ThisType&& source) = default; + + ThisType& operator=(const ThisType& other) = delete; + + ThisType& operator=(ThisType&& source) = delete; + + const GridViewType& grid_view() const + { + return grid_view_; + } + + const BackendType& backend() const + { + return grid_view_.indexSet(); + } + + const MapperType& mapper() const + { + return mapper_; + } + + BaseFunctionSetType base_function_set(const EntityType& entity) const + { + return BaseFunctionSetType(entity); + } + + using BaseType::compute_pattern; + + template <class G, class S, int d, int r, int rC> + PatternType compute_pattern(const GridView<G>& local_grid_view, const SpaceInterface<S, d, r, rC>& ansatz_space) const + { + return BaseType::compute_face_and_volume_pattern(local_grid_view, ansatz_space); + } + + CommunicatorType& communicator() const + { + // no need to prepare the communicator, since we are not pdelab based + return *communicator_; + } + +private: + const GridViewType grid_view_; + const MapperType mapper_; + const std::unique_ptr<CommunicatorType> communicator_; +}; // class Default< ..., 1, 1 > + + +} // namespace FV +} // namespace Spaces +} // namespace GDT +} // namespace Dune + +#endif // DUNE_GDT_SPACES_FV_DEFAULT_HH -- GitLab