Commit 1886c364 authored by Fabian's avatar Fabian
Browse files

Cleaned up bug fix. However, Example 3 now does not work anymore...

parent 2696c6a9
......@@ -12,20 +12,17 @@
// System includes ------------------------------------------------------------------
#include <vector>
// Eigen includes -------------------------------------------------------------------
#include <Eigen/Dense>
// eth includes ---------------------------------------------------------------------
// ETH includes ---------------------------------------------------------------------
#include <eth_base/ETH_ASSERT.hpp>
#include <eth_base/ref_el_types.hpp>
#include <grid_utils/grid_view_factory.hpp>
// Own includes ---------------------------------------------------------------------
#include "utils/static_iterate.hpp"
#include "fe/fe_enumerators.hpp"
#include "ex_data_set.hpp"
#include "num_dof_data_set.hpp"
#include "num_dof_data_set_factories.hpp"
namespace betl2 {
namespace fe {
......@@ -101,30 +98,17 @@ namespace betl2 {
//! Type of eth::grid::IndexSet
typedef eth::grid::IndexSet<gridTraits_t , typename viewTraits_t::indexSet_t>
indexSet_t;
// typedef std::array<std::vector<unsigned>, gridTraits_t::dimMesh+2> set_t;
typedef NumDofDataSet<unsigned, gridViewFactory_t, eth::base::RefElType::QUAD,
eth::base::RefElType::TRIA,
eth::base::RefElType::SEGMENT,
eth::base::RefElType::POINT > set_t;
//! Type of container for multiplicities.
typedef typename NumDofDataSetFactory< gridTraits_t::dimMesh,
gridViewFactory_t >::dofSet_t set_t;
/*! Constructor
*
* @param gridViewFactory A grid view factory.
*/
FEBasis(gridViewFactory_t gridViewFactory) :
multiplicities_( std::move(gridViewFactory) )
{
// Resize (and set to zero) multiplicities for all entities in this mesh
// typedef betl2::utils::static_iterate< gridTraits_t::dimMesh,
// ResizeMultiplcities_,
// const decltype( gridView_ )&,
// set_t&> static_iterate;
// static_iterate()( gridView_, multiplicities_);
//std::get<3>(multiplicities_).resize(indexSet_->size(eth::base::RefElType::QUAD));
}
FEBasis(gridViewFactory_t gridViewFactory)
: multiplicities_( std::move(gridViewFactory) ) {}
//! @attention needed for interpolation (set to Lagrange)
constexpr static betl2::fe::FEBasisType feBasisType( ) {
......@@ -140,11 +124,7 @@ eth::base::RefElType::POINT > set_t;
template< int CODIM >
void setMult(const eth::grid::Entity<gridTraits_t, CODIM>& ent,
const size_type mult) {
// if( ent.refElType() == eth::base::RefElType::QUAD)
// multiplicities_[3].at(gridView_.indexSet().index(ent)) = mult;
// else
// multiplicities_[CODIM].at(gridView_.indexSet().index(ent)) = mult;
multiplicities_.setData(ent, mult);
multiplicities_.setData(ent, mult);
}
......@@ -155,11 +135,7 @@ multiplicities_.setData(ent, mult);
*/
template< int CODIM >
size_type multiplicity(const eth::grid::Entity<gridTraits_t, CODIM>& ent) const {
// if( ent.refElType() == eth::base::RefElType::QUAD)
// return multiplicities_[3].at(gridView_.indexSet().index(ent));
// else
// return multiplicities_[CODIM].at(gridView_.indexSet().index(ent));
return multiplicities_.data(ent);
return multiplicities_.data(ent);
}
/*! @return total number of degrees of freedom for an element.
......@@ -189,25 +165,12 @@ return multiplicities_.data(ent);
// -------------------------------------------------------------------------
/*------------------------- BEGIN DOXYGEN HIDING -------------------------*/
//! @cond
/*
// Helper struct for resizing all entities in mesh
// Helper struct for retrieving the degrees of freedom of all entities
// given a codimension
template< int CODIM >
struct ResizeMultiplcities_
struct GetDofs_
{
template< typename GRID_VIEW, typename DATA_SET_T>
void operator()( const GRID_VIEW& gridView,
DATA_SET_T& data) const
{
std::get<CODIM>(data).resize(gridView.size(CODIM));
}
}; // end struct ResizeMultiplicities_
*/
// Helper struct for retrieving the degrees of freedom of all entities
// given a codimension
template< int CODIM >
struct GetDofs_
{
template< typename ELEMENT_T>
void operator()( const FEBasis& febasis, const ELEMENT_T& elem,
size_type& dofs) const
......@@ -219,6 +182,7 @@ return multiplicities_.data(ent);
dofs += febasis.multiplicity( *(elem.template subEntity<CODIM+1>(i)) );
}
}; // end struct GetDofs_
//! @endcond
/*-------------------------- END DOXYGEN HIDING --------------------------*/
// -------------------------------------------------------------------------
......
......@@ -3,59 +3,26 @@
// </preamble>
//------------------------------------------------------------------------------
//! @file ex_dof_data_set_factories.hpp
//! @file num_dof_data_set.hpp
//! @author Fabian Hillebrand
//! @date 2017
#ifndef BETL2_FE_EX_DOF_DATA_SET_FACTORIES_HPP_T
#define BETL2_FE_EX_DOF_DATA_SET_FACTORIES_HPP_T
#ifndef BETL2_FE_EX_NUM_DOF_DATA_SET_HPP
#define BETL2_FE_EX_NUM_DOF_DATA_SET_HPP
// eth includes ----------------------------------------------------------------
// 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{
// Forward declaration
template< typename DATA_TYPE, class GRID_VIEW_FACTORY_T,
enum eth::base::RefElType... REFS >
class NumDofDataSet;
namespace detail {
template< typename DATA_TYPE, class GRID_VIEW_FACTORY_T,
enum eth::base::RefElType... REFS >
struct NumDofDataSetTraits;
//! @brief Provides some types for \ref NumDofDataSet
/*
template< typename DATA_TYPE, class GRID, eth::grid::GridViewTypes GV_T,
enum eth::base::RefElType... REFS >
struct NumDofDataSetTraits< DATA_TYPE,
eth::grids::utils::GridViewFactory<GRID,GV_T>,
REFS... >
{
//! View traits of GridViewFactory
typedef typename eth::grid::utils::GridViewFactory<GRID,GV_T>::viewTraits_t
viewTraits_t;
};
*/
} // end namespace detail
/*! WANT: Storage for all reference types (REFS...)' multiplicity
* MEANS: NumDofDataSet will be build like:
......@@ -75,14 +42,11 @@ namespace betl2 {
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;
typedef typename gridViewFactory_t::viewTraits_t viewTraits_t;
//! Type of grid traits
typedef typename viewTraits_t::gridTraits_t gridTraits_t;
//! Type of index set
typedef eth::grid::IndexSet<gridTraits_t, typename viewTraits_t::indexSet_t>
indexSet_t;
//! List of reference types
......@@ -91,6 +55,9 @@ namespace betl2 {
template<int CODIM>
using entity_t = eth::grid::Entity<gridTraits_t, CODIM>;
//----------------------------------------------------------------------
//----------------------------------------------------------------------
public:
//! Constructor
......@@ -100,11 +67,11 @@ namespace betl2 {
indexSet_( &gridView_.indexSet() )
{
// Resizing StorageHelpers (done via indexSet_)
std::cout << "Resizing StorageHelpers...\n";
resizeStorageHelper<REFS...>();
std::cout << "Done resizing StorageHelpers.\n";
}
//----------------------------------------------------------------------
/*! @return the number of degrees of freedom associated with an entity.
*
* @param ent Entity.
......@@ -120,22 +87,6 @@ std::cout << "Done resizing StorageHelpers.\n";
} // end mult()
/*! @return the total number of degrees of freedom associated with an element.
*
* @param elem Element.
*/
const dataType_t& sumData(const entity_t<0>& elem) const
{
// TODO
static constexpr int dim = gridTraits_t::dimMesh;
return eth::base::ReferenceElements::applyUniversal<
DataFunctor,
typename refElList_t::template onlyDim_t<dim>,
const NumDofDataSet&,
const entity_t<0>& >( elem.refElType(), *this, elem );
} // end numDofs()
/*! @brief Sets the number of degree of freedom for an entity.
*
* @param ent Entity.
......@@ -153,6 +104,9 @@ std::cout << "Done resizing StorageHelpers.\n";
} // end setMult()
//----------------------------------------------------------------------
//----------------------------------------------------------------------
private:
// Structs that fulfil the interface of applyUniversal
......@@ -250,7 +204,6 @@ std::cout << "Done resizing StorageHelpers.\n";
void resize( const indexSet_t* indexSet )
{
indexSet_ = indexSet;
std::cout << "Resizing data for " << RET << " to " << indexSet_->size(RET) << '\n';
data_.resize( indexSet_->size(RET) );
}
......@@ -365,210 +318,9 @@ std::cout << "Resizing data for " << RET << " to " << indexSet_->size(RET) << '\
}; // end class NumDofDataSet
//------------------------------------------------------------------------
//------------------------------------------------------------------------
//------------------------------------------------------------------------
/*! @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
} // end namespace belt2
#endif // BETL2_FE_EX_DOF_DATA_SET_FACTORIES_HPP
#endif // BETL2_FE_EX_NUM_DOF_DATA_SET_HPP
//------------------------------------------------------------------------------
// <preamble>
// </preamble>
//------------------------------------------------------------------------------
//! @file num_dof_data_set_factories.hpp
//! @author Fabian Hillebrand
//! @date 2017
#ifndef BETL2_FE_EX_NUM_DOF_DATA_SET_FACTORIES_HPP
#define BETL2_FE_EX_NUM_DOF_DATA_SET_FACTORIES_HPP
// ETH includes ----------------------------------------------------------------
#include <eth_base/ref_el_types.hpp>
// Own includes ----------------------------------------------------------------
#include "num_dof_data_set.hpp"
namespace betl2 {
namespace fe {
namespace ex {
/*! @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 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 GRID_VIEW_FACTORY_T >
class NumDofDataSetFactory< 2, GRID_VIEW_FACTORY_T >
{
private:
typedef unsigned value_t;
// typedef for storing pointers to data
template< eth::base::RefElType... REFS >
using vNumDofDataSet = NumDofDataSet< value_t, GRID_VIEW_FACTORY_T, REFS... >;
public:
//! Type of a data set for elements with pointers to degrees of freedom.
typedef vNumDofDataSet< eth::base::RefElType::POINT,
eth::base::RefElType::SEGMENT,
eth::base::RefElType::TRIA,
eth::base::RefElType::QUAD > dofSet_t;
}; // end struct NumDofDataSetFactory< 2 >
/*------------------------ BEGIN DOXYGEN HIDING ------------------------*/
// @cond
//------------------------------------------------------------------------
template< typename GRID_VIEW_FACTORY_T >
class NumDofDataSetFactory< 1, GRID_VIEW_FACTORY_T >
{
private:
typedef unsigned value_t;
// typedef for storing pointers to data
template< eth::base::RefElType... REFS >
using vNumDofDataSet = NumDofDataSet< value_t, GRID_VIEW_FACTORY_T, REFS... >;
public:
//! Type of a data set for elements with pointers to degrees of freedom.
typedef vNumDofDataSet< eth::base::RefElType::POINT,
eth::base::RefElType::SEGMENT > dofSet_t;
}; // end struct NumDofDataSetFactory< 1 >
//------------------------------------------------------------------------
template< typename GRID_VIEW_FACTORY_T >
class NumDofDataSetFactory< 3, GRID_VIEW_FACTORY_T >
{
private:
typedef unsigned value_t;
// typedef for storing pointers to data
template< eth::base::RefElType... REFS >
using vNumDofDataSet = NumDofDataSet< value_t, GRID_VIEW_FACTORY_T, REFS... >;
public:
//! Type of a data set for elements with pointers to degrees of freedom.
typedef vNumDofDataSet< eth::base::RefElType::POINT,
eth::base::RefElType::SEGMENT,
eth::base::RefElType::TRIA,
eth::base::RefElType::QUAD,
eth::base::RefElType::TETRA,
eth::base::RefElType::HEXA,
eth::base::RefElType::PRISM,
eth::base::RefElType::PYRAMID > dofSet_t;
}; // end struct NumDofDataSetFactory< 3 >
// @endcond
/*------------------------- END DOXYGEN HIDING -------------------------*/
} // end namespace ex
} // end namespace fe
} // end namespace betl2
#endif // BETL2_FE_EX_NUM_DOF_DATA_SET_FACTORIES_HPP
......@@ -34,7 +34,7 @@ for i in range( len(sys.argv)-1 ):
mplot.semilogx(l[:,0], l[:,1], '--o'+col[i], label=name)
mplot.semilogx(l[:,0], l[:,2], '--*'+col[i])
mplot.ylim([0.8, 2.2])
mplot.ylim([0.8, 3])
mplot.legend(loc='upper left')
mplot.grid(True)
mplot.savefig("performance"+filename[0]+".pdf")
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