Commit 3f7d485c authored by Fabian's avatar Fabian
Browse files

Starting with fixing bug (the replacement container will probably look very...

Starting with fixing bug (the replacement container will probably look very much like DataSet but provide different functions and drop the top layer of storage)
parent 0a2a795c
//------------------------------------------------------------------------------
// <preamble>
// </preamble>
//------------------------------------------------------------------------------
//! @file ex_dof_data_set_factories.hpp
//! @author Fabian Hillebrand
//! @date 2017
#ifndef BETL2_FE_EX_DOF_DATA_SET_FACTORIES_HPP
#define BETL2_FE_EX_DOF_DATA_SET_FACTORIES_HPP
// eth includes ----------------------------------------------------------------
#include <eth_base/ref_el_types.hpp>
#include <eth_base/numeric_types.hpp>
#include <grid_utils/i_grid_data_set.hpp>
#include <grid_utils/grid_data_set.hpp>
#include "ex_data_set.hpp"
//------------------------------------------------------------------------------
// forward declaration
namespace betl2 { namespace fe { class Dof; } }
//------------------------------------------------------------------------------
namespace betl2 {
namespace fe {
namespace ex{
/*! WANT: Storage for all reference types (REFS...)' multiplicity
* MEANS: NumDofDataSet will be build like:
* NumDofDatSet<unsigned,GVF_T, POINT, SEGMENT, TRIA, ...>
*
* UNLIKE DATASET WHICH IS BUILD LIKE
* DataSet<dof, GVT_T, POINT >
* or
* DataSet<dof*, GVT_T, TRIA, QUAD>
*/
template< typename DATA_TYPE, class GRID_VIEW_FACTORY_T,
enum eth::base::RefElType REFS... >
class NumDofDataSet
{
public:
//! Type of data type (usually unsigned int or int)
typedef DATA_TYPE dataType_t;
//! Type of grid view factory
typedef GRID_VIEW_FACTORY_T gridViewFactory_t;
//! Type of traits
typedef detail::NumDofDataSetTraits<dataType_t,gridViewFactory_t,REFS...>
traits_t;
//! Type of view traits
typedef typename traits_t::viewTraits_t viewTraits_t;
//! Type of grid traits
typedef typename viewTrais_t::gridTraits_t gridTraits_t;
typedef eth::grid::IndexSet<gridTraits_t, typename viewTraits::indexSet_t>
indexSet_t;
//! List of reference types
typedef typename eth::base::RefElList<REFS...> refElList_t;
//! Type of an entity
template<int CODIM>
using entity_t = eth::grid::Entity<gridTraits_t, CODIM>;
public:
//! Constructor
NumDofDataSet(gridViewFactory_t gridViewFactory)
: gridviewFactory_( std::move(gridViewFactory) ),
gridView_( std::move(gridViewFactory_.getView()) ),
indexSet_( &gridView_.indexSet() )
{
resizeStorageHelper<REFS...>();
}
/*! @return the number of degrees of freedom associated with an entity.
*
* @param ent Entity.
*/
template<int CODIM>
dataType_t mult(const entity_t<CODIM>& ent) const
{
static constexpr int dim = gridTraits_t::dimMesh-CODIM;
return eth::base::ReferenceElements::applyUniversal< /*TODO*/,
typename refElList_t::template onlyDim_t<dim>,
NumDofDataSet&,
const entity_t<CODIM>& >( ent.refElType(), *this, ent);
} // end mult()
/*! @return the total number of degrees of freedom associated with an element.
*
* @param elem Element.
*/
dataType_t numDofs(const entity_t<0>& elem) const
{
static constexpr int dim = gridTraits_t::dimMesh-CODIM;
return eth::base::ReferenceElements::applyUniversal< /*TODO*/,
typename refElList_t::template onlyDim_t<dim>,
NumDofDataSet&,
const entity_t<CODIM>& >( elem.refElType(), *this, ent);
} // end numDofs()
/*! @brief Sets the number of degree of freedom for an entity.
*
* @param ent Entity.
*/
template<int CODIM>
void setMult(const entity_t<CODIM>& ent)
{
static constexpr int dim = gridTraits_t::dimMesh-CODIM;
return eth::base::ReferenceElements::applyUniversal< /*TODO*/,
typename refElList_t::template onlyDim_t<dim>,
NumDofDataSet&,
const entity_t<CODIM>& >( ent.refElType(), *this, ent);
} // end setMult()
private:
// TODO Structs for member functions
// TODO Class for storage
private:
// TODO
//! De facto storage of multiplicities
std::tuple< StorageHelper<REFS>... > multiplicities_;
//! Grid view factory
const gridViewFactory_t gridViewFactory_;
//! Grid view from gridViewFactory_
eth::grid::GridView<viewTraits_t> gridView_;
//! Pointer to index set of gridView_
const indexSet_t* indexSet_;
};
//------------------------------------------------------------------------
//------------------------------------------------------------------------
//------------------------------------------------------------------------
/*! @brief Provides data structures for the finite element space.
*
* This class is implemented as specialisations as is based on
* \ref DataSet. These mostly specialisations are hidden for readability
* in the documentation. Their functionality is described for the case
* DIM = 2 and is analogue for DIM = 1 and DIM = 3.
*
* @tparam DIM Dimension of mesh.
* @tparam FE_BASIS_T Type of finite element basis.
* @tparam GRID_VIEW_FACTORY_T Type of grid view factory.
*
* @sa \ref DataSet
*/
template< int DIM, typename FE_BASIS_T, typename GRID_VIEW_FACTORY_T >
class NumDofDataSetFactory;
//------------------------------------------------------------------------
/*! @brief Layout of \ref NumDofDataSetFactory
*
* This is the specialised implemenation of \ref NumDofDataSetFactory
* for the 2 dimensional case. It is listed here for an overview
* of the provided functions and types. The other dimensions are
* analogue.
*
* @sa \ref NumDofDataSetFactory
*/
template< typename FE_BASIS_T,
typename GRID_VIEW_FACTORY_T >
class NumDofDataSetFactory< 2, FE_BASIS_T, GRID_VIEW_FACTORY_T >
{
private:
typedef Dof value_t;
typedef Dof* pointer_t;
// define data sets for storing sub-entities
template< eth::base::RefElType... REFS >
using vDofDataSet = DataSet< value_t, GRID_VIEW_FACTORY_T, REFS... >;
// typedef for storing pointers to data
template< eth::base::RefElType... REFS >
using pDofDataSet = DataSet< pointer_t, GRID_VIEW_FACTORY_T, REFS... >;
typedef vDofDataSet< eth::base::RefElType::POINT > point_container_t;
typedef vDofDataSet< eth::base::RefElType::SEGMENT > segment_container_t;
typedef vDofDataSet< eth::base::RefElType::TRIA,
eth::base::RefElType::QUAD > face_container_t;
public:
//! Type of a data set for elements with pointers to degrees of freedom.
typedef pDofDataSet< eth::base::RefElType::TRIA,
eth::base::RefElType::QUAD > dofDataSet_t;
//! Type of a data set for all entities with degrees of freedom.
typedef std::tuple< face_container_t*,
segment_container_t*,
point_container_t* > dofTuple_t;
//! @brief Creates the tuple containing degrees of freedom for entites.
static void Create( const GRID_VIEW_FACTORY_T& grid_view_factory,
dofTuple_t& t )
{
std::get<0>( t ) = new face_container_t (grid_view_factory);
std::get<1>( t ) = new segment_container_t(grid_view_factory);
std::get<2>( t ) = new point_container_t (grid_view_factory);
}
//! @brief Frees the degrees of freedom on entities from tuple.
static void Free( dofTuple_t& t )
{
if( std::get<0>( t ) != nullptr ) delete std::get<0>( t );
if( std::get<1>( t ) != nullptr ) delete std::get<1>( t );
if( std::get<2>( t ) != nullptr ) delete std::get<2>( t );
}
}; // end struct NumDofDataSetFactory< 2 >
/*------------------------ BEGIN DOXYGEN HIDING ------------------------*/
// @cond
//------------------------------------------------------------------------
template< typename FE_BASIS_T,
typename GRID_VIEW_FACTORY_T >
class NumDofDataSetFactory< 1, FE_BASIS_T, GRID_VIEW_FACTORY_T >
{
private:
typedef Dof value_t;
typedef Dof* pointer_t;
// define data sets for storing sub-entities
template< eth::base::RefElType... REFS >
using vDofDataSet = DataSet< value_t, GRID_VIEW_FACTORY_T, REFS... >;
// typedef for storing pointers to data
template< eth::base::RefElType... REFS >
using pDofDataSet = DataSet< pointer_t, GRID_VIEW_FACTORY_T, REFS... >;
// define data sets for storing sub-entities
typedef vDofDataSet< eth::base::RefElType::POINT
> point_container_t;
typedef vDofDataSet< eth::base::RefElType::SEGMENT
> segment_container_t;
public:
// the data set in which the (accessible) dofs are finally stored
typedef pDofDataSet< eth::base::RefElType::SEGMENT > dofDataSet_t;
// collect all sub-entities in a tuple-like structure
typedef std::tuple< segment_container_t*,
point_container_t* > dofTuple_t;
// create the tuple containing dofs for sub-entities
static void Create( const GRID_VIEW_FACTORY_T& grid_view_factory,
dofTuple_t& t )
{
std::get<0>( t ) = new segment_container_t(grid_view_factory);
std::get<1>( t ) = new point_container_t (grid_view_factory);
}
// free dofs on sub-entities
static void Free( dofTuple_t& t )
{
if( std::get<0>( t ) != nullptr ) delete std::get<0>( t );
if( std::get<1>( t ) != nullptr ) delete std::get<1>( t );
}
}; // end struct NumDofDataSetFactory< 1 >
//------------------------------------------------------------------------
template< typename FE_BASIS_T,
typename GRID_VIEW_FACTORY_T >
class NumDofDataSetFactory< 3, FE_BASIS_T, GRID_VIEW_FACTORY_T >
{
private:
typedef Dof value_t;
typedef Dof* pointer_t;
// define data sets for storing sub-entities
template< eth::base::RefElType... REFS >
using vDofDataSet = DataSet< value_t, GRID_VIEW_FACTORY_T, REFS... >;
// typedef for storing pointers to data
template< eth::base::RefElType... REFS >
using pDofDataSet = DataSet< pointer_t, GRID_VIEW_FACTORY_T, REFS... >;
typedef vDofDataSet< eth::base::RefElType::POINT > point_container_t;
typedef vDofDataSet< eth::base::RefElType::SEGMENT > segment_container_t;
typedef vDofDataSet< eth::base::RefElType::TRIA,
eth::base::RefElType::QUAD > face_container_t;
typedef vDofDataSet< eth::base::RefElType::TETRA,
eth::base::RefElType::HEXA,
eth::base::RefElType::PRISM,
eth::base::RefElType::PYRAMID
> element_container_t;
public:
// the data set in which the (accessible) dofs are finally stored
typedef pDofDataSet< eth::base::RefElType::TETRA,
eth::base::RefElType::HEXA,
eth::base::RefElType::PRISM,
eth::base::RefElType::PYRAMID
> dofDataSet_t;
// collect all sub-entities in a tuple-like structure
typedef std::tuple< element_container_t*,
face_container_t*,
segment_container_t*,
point_container_t* > dofTuple_t;
static void Create( const GRID_VIEW_FACTORY_T& grid_view_factory,
dofTuple_t& t )
{
std::get<0>( t ) = new element_container_t(grid_view_factory);
std::get<1>( t ) = new face_container_t (grid_view_factory);
std::get<2>( t ) = new segment_container_t(grid_view_factory);
std::get<3>( t ) = new point_container_t (grid_view_factory);
}
static void Free( dofTuple_t& t )
{
delete std::get<0>( t );
delete std::get<1>( t );
delete std::get<2>( t );
delete std::get<3>( t );
}
}; // end struct NumDofDataSetFactory< 3 >
// @endcond
/*------------------------- END DOXYGEN HIDING -------------------------*/
} // end namespace ex
} // end namespace fe
} // end namespace betl2
#endif // BETL2_FE_EX_DOF_DATA_SET_FACTORIES_HPP
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment