Commit ec5abd62 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Implementing superentity initializer.

parent e77c8bf5
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
TODO: Mesh
 * vsechny traits zkusit presunout do jednotneho MeshTraits, tj. temer MeshConfigTraits ale pojmenovat jako MeshTraits
 * zrusit tnlDimesnionsTag
 * omezit tnlDimesnionsTag - asi to ale nepujde
   - ale pozor na konstrukce jako BaseType::superentityIdsArray< SuperDimensionTag >( DimensionsTag ); ( v tnlMesh.h)
 * prejmenovat Tagy v topologies na Topology zrejme
 * zrusit tnlStorageTraits

+4 −2
Original line number Diff line number Diff line
@@ -54,7 +54,8 @@ struct tnlMeshConfigBase
      /****
       *  Vertices and cells must always be stored
       */ 
		return ( dimensions == 0 || dimensions == cellDimensions );
      return true;
		//return ( dimensions == 0 || dimensions == cellDimensions );
	}
   
   /****
@@ -66,7 +67,8 @@ struct tnlMeshConfigBase
      /****
       *  Vertices must always be stored
       */
		return ( SubentityDimensions == 0 );
      return true;
		//return ( SubentityDimensions == 0 );
	}

	/****
+61 −9
Original line number Diff line number Diff line
@@ -22,6 +22,10 @@
#include <mesh/traits/tnlMeshTraits.h>
#include <mesh/traits/tnlMeshEntitiesTraits.h>
#include <mesh/traits/tnlStorageTraits.h>
#include <mesh/traits/tnlMeshConfigTraits.h>

template< typename MeshConfig >
class tnlMesh;

template< typename DimensionsTag,
          typename Device,
@@ -41,7 +45,8 @@ template< typename ConfigTag >
class tnlMeshStorageLayers
   : public tnlMeshStorageLayer< ConfigTag,
                                 typename tnlMeshTraits< ConfigTag >::DimensionsTag >
{};
{
};


template< typename ConfigTag,
@@ -49,10 +54,16 @@ template< typename ConfigTag,
class tnlMeshStorageLayer< ConfigTag,
                           DimensionsTag,
                           tnlStorageTraits< true > >
   : public tnlMeshStorageLayer< ConfigTag, typename DimensionsTag::Decrement >
   : public tnlMeshStorageLayer< ConfigTag, typename DimensionsTag::Decrement >,
     public tnlMeshSuperentityStorageLayers< ConfigTag, 
                                             typename tnlMeshConfigTraits< ConfigTag >::template EntityTraits< DimensionsTag >::Tag >
{
   public:

   typedef tnlMeshStorageLayer< ConfigTag,
                                typename DimensionsTag::Decrement >   BaseType;
   typedef tnlMeshSuperentityStorageLayers< ConfigTag, 
                                            typename tnlMeshConfigTraits< ConfigTag >::template EntityTraits< DimensionsTag >::Tag > SuperentityStorageBaseType;
   
   typedef tnlMeshEntitiesTraits< ConfigTag, DimensionsTag >         Tag;
   typedef typename Tag::ContainerType                                  ContainerType;
@@ -60,7 +71,6 @@ class tnlMeshStorageLayer< ConfigTag,
   typedef typename ContainerType::IndexType                            GlobalIndexType;
   typedef typename ContainerType::ElementType                          EntityType;

   protected:

   using BaseType::setNumberOfEntities;
   using BaseType::getNumberOfEntities;
@@ -167,6 +177,24 @@ class tnlMeshStorageLayer< ConfigTag,
      ContainerType entities;

      SharedContainerType sharedEntities;
   
   // TODO: this is only for the mesh initializer - fix it
   public:

      using BaseType::entitiesArray;
      
      typename tnlMeshConfigTraits< ConfigTag >::template EntityTraits< DimensionsTag >::ContainerType& entitiesArray( DimensionsTag )
      {
         return entities; 
      }
              
      using BaseType::superentityIdsArray;
	
      template< typename SuperDimensionsTag >
      typename tnlMeshConfigTraits< ConfigTag >::GlobalIdArrayType& superentityIdsArray( DimensionsTag )
      {
         return SuperentityStorageBaseType::superentityIdsArray( SuperDimensionsTag() );
      }
};

template< typename ConfigTag,
@@ -182,10 +210,19 @@ class tnlMeshStorageLayer< ConfigTag,
template< typename ConfigTag >
class tnlMeshStorageLayer< ConfigTag,
                           tnlDimensionsTag< 0 >,
                           tnlStorageTraits< true > >
                           tnlStorageTraits< true > > :
   public tnlMeshSuperentityStorageLayers< ConfigTag, 
                                           tnlMeshVertexTag >

{
   public:

   typedef tnlDimensionsTag< 0 >                        DimensionsTag;
   
   typedef tnlMeshSuperentityStorageLayers< ConfigTag, 
                                            tnlMeshVertexTag > SuperentityStorageBaseType;


   typedef tnlMeshEntitiesTraits< ConfigTag,
                                  DimensionsTag >       Tag;
   typedef typename Tag::ContainerType                     ContainerType;
@@ -194,7 +231,6 @@ class tnlMeshStorageLayer< ConfigTag,
   typedef typename ContainerType::ElementType             VertexType;
   typedef typename VertexType::PointType                  PointType;

   protected:

   tnlMeshStorageLayer()
   {
@@ -329,6 +365,22 @@ class tnlMeshStorageLayer< ConfigTag,
   ContainerType vertices;

   SharedContainerType sharedVertices;
   
   // TODO: this is only for the mesh initializer - fix it
   public:
      
      typename tnlMeshConfigTraits< ConfigTag >::template EntityTraits< DimensionsTag >::ContainerType& entitiesArray( DimensionsTag )
      {
         return vertices; 
      }

      
      template< typename SuperDimensionsTag >
      typename tnlMeshConfigTraits< ConfigTag >::GlobalIdArrayType& superentityIdsArray( DimensionsTag )
      {
         return SuperentityStorageBaseType::superentityIdsArray( SuperDimensionsTag() );
      }

};

/****
+107 −0
Original line number Diff line number Diff line
/***************************************************************************
                          tnlMeshSuperentityAccess.h  -  description
                             -------------------
    begin                : Aug 15, 2015
    copyright            : (C) 2015 by Tomas Oberhuber et al.
    email                : tomas.oberhuber@fjfi.cvut.cz
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef TNLSUPERENTITYACCESS_H
#define	TNLSUPERENTITYACCESS_H

#include <mesh/traits/tnlStorageTraits.h>
#include <mesh/traits/tnlMeshConfigTraits.h>


template< typename MeshConfig,
          typename MeshEntity,
          typename Dimensions,
          typename SuperentityStorage = 
             tnlStorageTraits< tnlMeshConfigTraits< MeshConfig >::template SuperentityTraits< MeshEntity, Dimensions>::storageEnabled > >
class tnlMeshSuperentityAccessLayer;


template< typename MeshConfig,
          typename MeshEntity >
class tnlMeshSuperentityAccess :
   public tnlMeshSuperentityAccessLayer< MeshConfig, 
                                         MeshEntity,
                                         tnlDimensionsTag< tnlMeshConfigTraits< MeshConfig >::meshDimensions > >
{
   public:
      bool operator == ( const tnlMeshSuperentityAccess< MeshConfig, MeshEntity>& a ) const { return true; } // TODO: fix
      
      void print( ostream& str ) const{};

};

template< typename MeshConfig,
          typename MeshEntity,
          typename Dimensions >
class tnlMeshSuperentityAccessLayer< MeshConfig,
                                     MeshEntity,
                                     Dimensions,
                                     tnlStorageTraits< true > > :
   public tnlMeshSuperentityAccessLayer< MeshConfig, MeshEntity, typename Dimensions::Decrement >
{
	typedef tnlMeshSuperentityAccessLayer< MeshConfig, MeshEntity, typename Dimensions::Decrement > BaseType;

   public:
	   typedef typename tnlMeshConfigTraits< MeshConfig >::IdArrayAccessorType    IdArrayAccessorType;

	   using BaseType::superentityIds;
	   IdArrayAccessorType superentityIds( Dimensions ) const { return m_superentityIndices; }

	   using BaseType::superentityIdsArray;
	   IdArrayAccessorType &superentityIdsArray( Dimensions ) { return m_superentityIndices; }
      
      //bool operator == ( const tnlMeshSuperentityAccessLayer< MeshConfig, MeshEntity, Dimensions, tnlStorageTraits< true > >& l ) { return true; } // TODO: fix

   private:
	   IdArrayAccessorType m_superentityIndices;
};

template< typename MeshConfig,
          typename MeshEntity,
          typename Dimensions >
class tnlMeshSuperentityAccessLayer< MeshConfig, MeshEntity, Dimensions, tnlStorageTraits< false > > :
   public tnlMeshSuperentityAccessLayer< MeshConfig, MeshEntity, typename Dimensions::Decrement >
{
};

template< typename MeshConfig,
          typename MeshEntity >
class tnlMeshSuperentityAccessLayer< MeshConfig, MeshEntity, tnlDimensionsTag< MeshEntity::dimensions >, tnlStorageTraits< false > >
{
   protected:
	   /***
       * Necessary because of 'using TBase::...;' in the derived classes
       */
	   void superentityIds()      {}
	   void superentityIdsArray() {}
};

template< typename MeshConfig,
          typename MeshEntity >
class tnlMeshSuperentityAccessLayer< MeshConfig, MeshEntity, tnlDimensionsTag< MeshEntity::dimensions >, tnlStorageTraits< true > >
{
   protected:
	   /***
       * Necessary because of 'using TBase::...;' in the derived classes
       */
	   void superentityIds()      {}
	   void superentityIdsArray() {}
};


#endif	/* TNLSUPERENTITYACCESS_H */
+26 −2
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include <mesh/tnlDimensionsTag.h>
#include <mesh/traits/tnlStorageTraits.h>
#include <mesh/traits/tnlMeshTraits.h>
#include <mesh/traits/tnlMeshConfigTraits.h>
#include <mesh/traits/tnlMeshSuperentitiesTraits.h>

template< typename ConfigTag,
@@ -178,6 +179,15 @@ class tnlMeshSuperentityStorageLayer< ConfigTag,
    ContainerType superentitiesIndices;

    SharedContainerType sharedSuperentitiesIndices;
    
   // TODO: this is only for the mesh initializer - fix it
   public:
              
      using BaseType::superentityIdsArray;               
      typename tnlMeshConfigTraits< ConfigTag >::GlobalIdArrayType& superentityIdsArray( DimensionsTag )
      {
         return this->superentitiesIndices;
      }
};

template< typename ConfigTag,
@@ -252,6 +262,12 @@ class tnlMeshSuperentityStorageLayer< ConfigTag,
      return true;
   }
   
   template< typename SuperDimensionsTag >
   typename tnlMeshConfigTraits< ConfigTag >::GlobalIdArrayType& superentityIdsArray( DimensionsTag )
   {
      tnlAssert( false, );
      //return this->superentitiesIndices;
   }
};

template< typename ConfigTag,
@@ -309,6 +325,14 @@ class tnlMeshSuperentityStorageLayer< ConfigTag,
   {
      return true;
   }
   
   template< typename SuperDimensionsTag >
   typename tnlMeshConfigTraits< ConfigTag >::GlobalIdArrayType& superentityIdsArray( DimensionsTag )
   {
      tnlAssert( false, );
      //return this->superentitiesIndices;
   }

};

#endif /* TNLMESHSUPERENTITYSTORAGELAYER_H_ */
Loading